[ACPI] ACPICA 20050930
Bob Moore [Fri, 30 Sep 2005 23:03:00 +0000 (19:03 -0400)]
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)

All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".

The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available.  Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)

Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.

acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>

58 files changed:
arch/ia64/kernel/acpi-ext.c
arch/ia64/pci/pci.c
arch/x86_64/kernel/io_apic.c
arch/x86_64/kernel/mpparse.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/dispatcher/dsutils.c
drivers/acpi/ec.c
drivers/acpi/events/evgpe.c
drivers/acpi/events/evsci.c
drivers/acpi/executer/exdump.c
drivers/acpi/executer/exnames.c
drivers/acpi/executer/exprep.c
drivers/acpi/executer/exresop.c
drivers/acpi/executer/exutils.c
drivers/acpi/glue.c
drivers/acpi/hardware/hwacpi.c
drivers/acpi/motherboard.c
drivers/acpi/namespace/nsaccess.c
drivers/acpi/namespace/nsnames.c
drivers/acpi/namespace/nsutils.c
drivers/acpi/parser/psargs.c
drivers/acpi/parser/psxface.c
drivers/acpi/pci_irq.c
drivers/acpi/pci_link.c
drivers/acpi/pci_root.c
drivers/acpi/resources/Makefile
drivers/acpi/resources/rsaddr.c
drivers/acpi/resources/rscalc.c
drivers/acpi/resources/rscreate.c
drivers/acpi/resources/rsdump.c
drivers/acpi/resources/rsinfo.c
drivers/acpi/resources/rsio.c
drivers/acpi/resources/rsirq.c
drivers/acpi/resources/rslist.c
drivers/acpi/resources/rsmemory.c
drivers/acpi/resources/rsmisc.c
drivers/acpi/resources/rsutils.c
drivers/acpi/resources/rsxface.c
drivers/acpi/tables/tbrsdt.c
drivers/acpi/tables/tbxfroot.c
drivers/acpi/utilities/utalloc.c
drivers/acpi/utilities/utglobal.c
drivers/acpi/utilities/utmisc.c
drivers/char/hpet.c
drivers/pnp/pnpacpi/rsparser.c
drivers/serial/8250_acpi.c
include/acpi/acconfig.h
include/acpi/acdisasm.h
include/acpi/acglobal.h
include/acpi/aclocal.h
include/acpi/acmacros.h
include/acpi/acpi_drivers.h
include/acpi/acpixf.h
include/acpi/acresrc.h
include/acpi/actypes.h
include/acpi/amlresrc.h
include/asm-x86_64/mpspec.h
include/linux/acpi.h

index a146016..4a5574f 100644 (file)
@@ -33,33 +33,33 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
        struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
        struct acpi_resource_vendor *vendor;
        struct acpi_vendor_descriptor *descriptor;
-       u32 length;
+       u32 byte_length;
 
-       if (resource->type != ACPI_RSTYPE_VENDOR)
+       if (resource->type != ACPI_RESOURCE_TYPE_VENDOR)
                return AE_OK;
 
        vendor = (struct acpi_resource_vendor *)&resource->data;
-       descriptor = (struct acpi_vendor_descriptor *)vendor->reserved;
-       if (vendor->length <= sizeof(*info->descriptor) ||
+       descriptor = (struct acpi_vendor_descriptor *)vendor->byte_data;
+       if (vendor->byte_length <= sizeof(*info->descriptor) ||
            descriptor->guid_id != info->descriptor->guid_id ||
            efi_guidcmp(descriptor->guid, info->descriptor->guid))
                return AE_OK;
 
-       length = vendor->length - sizeof(struct acpi_vendor_descriptor);
-       info->data = acpi_os_allocate(length);
+       byte_length = vendor->byte_length - sizeof(struct acpi_vendor_descriptor);
+       info->data = acpi_os_allocate(byte_length);
        if (!info->data)
                return AE_NO_MEMORY;
 
        memcpy(info->data,
-              vendor->reserved + sizeof(struct acpi_vendor_descriptor),
-              length);
-       info->length = length;
+              vendor->byte_data + sizeof(struct acpi_vendor_descriptor),
+              byte_length);
+       info->length = byte_length;
        return AE_CTRL_TERMINATE;
 }
 
 acpi_status
 acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
-                         u8 ** data, u32 * length)
+                         u8 ** data, u32 * byte_length)
 {
        struct acpi_vendor_info info;
 
@@ -72,7 +72,7 @@ acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
                return AE_NOT_FOUND;
 
        *data = info.data;
-       *length = info.length;
+       *byte_length = info.length;
        return AE_OK;
 }
 
index 20d76fa..25f923d 100644 (file)
@@ -193,12 +193,12 @@ add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr)
                goto free_resource;
        }
 
-       min = addr->min_address_range;
+       min = addr->minimum;
        max = min + addr->address_length - 1;
        if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION)
                sparse = 1;
 
-       space_nr = new_space(addr->address_translation_offset, sparse);
+       space_nr = new_space(addr->translation_offset, sparse);
        if (space_nr == ~0)
                goto free_name;
 
@@ -285,7 +285,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
        if (addr.resource_type == ACPI_MEMORY_RANGE) {
                flags = IORESOURCE_MEM;
                root = &iomem_resource;
-               offset = addr.address_translation_offset;
+               offset = addr.translation_offset;
        } else if (addr.resource_type == ACPI_IO_RANGE) {
                flags = IORESOURCE_IO;
                root = &ioport_resource;
@@ -298,7 +298,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
        window = &info->controller->window[info->controller->windows++];
        window->resource.name = info->name;
        window->resource.flags = flags;
-       window->resource.start = addr.min_address_range + offset;
+       window->resource.start = addr.minimum + offset;
        window->resource.end = window->resource.start + addr.address_length - 1;
        window->resource.child = NULL;
        window->offset = offset;
index 97154ab..619767d 100644 (file)
@@ -1956,7 +1956,7 @@ int __init io_apic_get_redir_entries (int ioapic)
 }
 
 
-int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low)
+int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int polarity)
 {
        struct IO_APIC_route_entry entry;
        unsigned long flags;
@@ -1978,8 +1978,8 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
        entry.delivery_mode = INT_DELIVERY_MODE;
        entry.dest_mode = INT_DEST_MODE;
        entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
-       entry.trigger = edge_level;
-       entry.polarity = active_high_low;
+       entry.trigger = triggering;
+       entry.polarity = polarity;
        entry.mask = 1;                                  /* Disabled (masked) */
 
        irq = gsi_irq_sharing(irq);
@@ -1994,9 +1994,9 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
        apic_printk(APIC_VERBOSE,KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> "
                "IRQ %d Mode:%i Active:%i)\n", ioapic, 
               mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq,
-              edge_level, active_high_low);
+              triggering, polarity);
 
-       ioapic_register_intr(irq, entry.vector, edge_level);
+       ioapic_register_intr(irq, entry.vector, triggering);
 
        if (!ioapic && (irq < 16))
                disable_8259A_irq(irq);
index 1105250..ba817e7 100644 (file)
@@ -915,7 +915,7 @@ void __init mp_config_acpi_legacy_irqs (void)
 
 #define MAX_GSI_NUM    4096
 
-int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
+int mp_register_gsi(u32 gsi, int triggering, int polarity)
 {
        int                     ioapic = -1;
        int                     ioapic_pin = 0;
@@ -964,7 +964,7 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
 
        mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
 
-       if (edge_level) {
+       if (triggering) {
                /*
                 * For PCI devices assign IRQs in order, avoiding gaps
                 * due to unused I/O APIC pins.
@@ -986,8 +986,8 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
        }
 
        io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
-               edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1,
-               active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1);
+               triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
+               polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
        return gsi;
 }
 
index 2143609..b12946c 100644 (file)
@@ -101,8 +101,8 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
                            address64.attribute.memory.cache_attribute;
                        mem_device->read_write_attribute =
                            address64.attribute.memory.read_write_attribute;
-                       mem_device->start_addr = address64.min_address_range;
-                       mem_device->end_addr = address64.max_address_range;
+                       mem_device->start_addr = address64.minimum;
+                       mem_device->end_addr = address64.maximum;
                }
        }
 
index 83ae1c1..2cc53da 100644 (file)
@@ -177,7 +177,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
 
        if (!op) {
                ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n"));
-               return_VALUE(TRUE);
+               return_UINT8(TRUE);
        }
 
        /*
@@ -208,7 +208,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
                                  "At Method level, result of [%s] not used\n",
                                  acpi_ps_get_opcode_name(op->common.
                                                          aml_opcode)));
-               return_VALUE(FALSE);
+               return_UINT8(FALSE);
        }
 
        /* Get info on the parent. The root_op is AML_SCOPE */
@@ -218,7 +218,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
        if (parent_info->class == AML_CLASS_UNKNOWN) {
                ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                  "Unknown parent opcode. Op=%p\n", op));
-               return_VALUE(FALSE);
+               return_UINT8(FALSE);
        }
 
        /*
@@ -304,7 +304,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
                          acpi_ps_get_opcode_name(op->common.parent->common.
                                                  aml_opcode), op));
 
-       return_VALUE(TRUE);
+       return_UINT8(TRUE);
 
       result_not_used:
        ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -313,7 +313,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
                          acpi_ps_get_opcode_name(op->common.parent->common.
                                                  aml_opcode), op));
 
-       return_VALUE(FALSE);
+       return_UINT8(FALSE);
 }
 
 /*******************************************************************************
@@ -616,7 +616,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
 
                if (op_info->flags & AML_HAS_RETVAL) {
                        ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
-                                         "Argument previously created, already stacked \n"));
+                                         "Argument previously created, already stacked\n"));
 
                        ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
                                           (walk_state->
index c33bfba..0ecbfa5 100644 (file)
@@ -1151,7 +1151,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
        union acpi_ec *ec = (union acpi_ec *)context;
        struct acpi_generic_address *addr;
 
-       if (resource->type != ACPI_RSTYPE_IO) {
+       if (resource->type != ACPI_RESOURCE_TYPE_IO) {
                return AE_OK;
        }
 
@@ -1171,7 +1171,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
        addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
        addr->register_bit_width = 8;
        addr->register_bit_offset = 0;
-       addr->address = resource->data.io.min_base_address;
+       addr->address = resource->data.io.minimum;
 
        return AE_OK;
 }
index b2f232d..f51c3b1 100644 (file)
@@ -600,7 +600,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
                status = acpi_hw_clear_gpe(gpe_event_info);
                if (ACPI_FAILURE(status)) {
                        ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
-                       return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
+                       return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
                }
        }
 
@@ -638,7 +638,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
                        status = acpi_hw_clear_gpe(gpe_event_info);
                        if (ACPI_FAILURE(status)) {
                                ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number));
-                               return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
+                               return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
                        }
                }
                break;
@@ -652,7 +652,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
                status = acpi_ev_disable_gpe(gpe_event_info);
                if (ACPI_FAILURE(status)) {
                        ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
-                       return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
+                       return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
                }
 
                /*
@@ -680,12 +680,12 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
                status = acpi_ev_disable_gpe(gpe_event_info);
                if (ACPI_FAILURE(status)) {
                        ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number));
-                       return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
+                       return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
                }
                break;
        }
 
-       return_VALUE(ACPI_INTERRUPT_HANDLED);
+       return_UINT32(ACPI_INTERRUPT_HANDLED);
 }
 
 #ifdef ACPI_GPE_NOTIFY_CHECK
index 1418359..e2c0b48 100644 (file)
@@ -88,7 +88,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
         */
        interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
 
-       return_VALUE(interrupt_handled);
+       return_UINT32(interrupt_handled);
 }
 
 /*******************************************************************************
@@ -121,7 +121,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
         */
        interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
 
-       return_VALUE(interrupt_handled);
+       return_UINT32(interrupt_handled);
 }
 
 /******************************************************************************
index bc2fa99..4477a62 100644 (file)
@@ -214,7 +214,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
 
        case ACPI_TYPE_BUFFER:
 
-               acpi_os_printf("Buffer len %X @ %p \n",
+               acpi_os_printf("Buffer len %X @ %p\n",
                               obj_desc->buffer.length,
                               obj_desc->buffer.pointer);
 
@@ -320,17 +320,17 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
 
        case ACPI_TYPE_BUFFER_FIELD:
 
-               acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n",
+               acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n",
                               obj_desc->buffer_field.bit_length,
                               obj_desc->buffer_field.base_byte_offset,
                               obj_desc->buffer_field.start_field_bit_offset);
 
                if (!obj_desc->buffer_field.buffer_obj) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n"));
+                       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
                } else
                    if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
                        != ACPI_TYPE_BUFFER) {
-                       acpi_os_printf("*not a Buffer* \n");
+                       acpi_os_printf("*not a Buffer*\n");
                } else {
                        acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
                                             depth + 1);
@@ -618,7 +618,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
 
        case ACPI_TYPE_PACKAGE:
 
-               acpi_os_printf("[Package] Contains %d Elements: \n",
+               acpi_os_printf("[Package] Contains %d Elements:\n",
                               obj_desc->package.count);
 
                for (i = 0; i < obj_desc->package.count; i++) {
index 239d847..dff4112 100644 (file)
@@ -191,10 +191,10 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
                if (name_string) {
                        ACPI_STRCAT(name_string, char_buf);
                        ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
-                                         "Appended to - %s \n", name_string));
+                                         "Appended to - %s\n", name_string));
                } else {
                        ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
-                                         "No Name string - %s \n", char_buf));
+                                         "No Name string - %s\n", char_buf));
                }
        } else if (index == 0) {
                /*
index 7476c36..88ccbf3 100644 (file)
@@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
 
                ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                  "Unknown field access type %X\n", access));
-               return_VALUE(0);
+               return_UINT32(0);
        }
 
        if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
@@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
        }
 
        *return_byte_alignment = byte_alignment;
-       return_VALUE(bit_length);
+       return_UINT32(bit_length);
 }
 
 /*******************************************************************************
index ff064e7..b04e4a3 100644 (file)
@@ -157,7 +157,7 @@ acpi_ex_resolve_operands(u16 opcode,
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-                         "Opcode %X [%s] required_operand_types=%8.8X \n",
+                         "Opcode %X [%s] required_operand_types=%8.8X\n",
                          opcode, op_info->name, arg_types));
 
        /*
index 1ee79d8..9f4e547 100644 (file)
@@ -206,7 +206,7 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags)
                }
        }
 
-       return_VALUE(locked);
+       return_UINT8(locked);
 }
 
 /*******************************************************************************
@@ -268,7 +268,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
        /* acpi_integer is unsigned, so we don't worry about a '-' prefix */
 
        if (value == 0) {
-               return_VALUE(1);
+               return_UINT32(1);
        }
 
        current_value = value;
@@ -282,7 +282,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
                num_digits++;
        }
 
-       return_VALUE(num_digits);
+       return_UINT32(num_digits);
 }
 
 /*******************************************************************************
index fcb881d..8daef57 100644 (file)
@@ -99,15 +99,15 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
        unsigned long *busnr = (unsigned long *)data;
        struct acpi_resource_address64 address;
 
-       if (resource->type != ACPI_RSTYPE_ADDRESS16 &&
-           resource->type != ACPI_RSTYPE_ADDRESS32 &&
-           resource->type != ACPI_RSTYPE_ADDRESS64)
+       if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
+           resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
+           resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
                return AE_OK;
 
        acpi_resource_to_address64(resource, &address);
        if ((address.address_length > 0) &&
            (address.resource_type == ACPI_BUS_NUMBER_RANGE))
-               *busnr = address.min_address_range;
+               *busnr = address.minimum;
 
        return AE_OK;
 }
index 1bb3463..20a335c 100644 (file)
@@ -204,18 +204,18 @@ u32 acpi_hw_get_mode(void)
         * system does not support mode transition.
         */
        if (!acpi_gbl_FADT->smi_cmd) {
-               return_VALUE(ACPI_SYS_MODE_ACPI);
+               return_UINT32(ACPI_SYS_MODE_ACPI);
        }
 
        status =
            acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
        if (ACPI_FAILURE(status)) {
-               return_VALUE(ACPI_SYS_MODE_LEGACY);
+               return_UINT32(ACPI_SYS_MODE_LEGACY);
        }
 
        if (value) {
-               return_VALUE(ACPI_SYS_MODE_ACPI);
+               return_UINT32(ACPI_SYS_MODE_ACPI);
        } else {
-               return_VALUE(ACPI_SYS_MODE_LEGACY);
+               return_UINT32(ACPI_SYS_MODE_LEGACY);
        }
 }
index 85c1fb5..4682441 100644 (file)
@@ -54,36 +54,36 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
 
        ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
 
-       if (res->type == ACPI_RSTYPE_IO) {
+       if (res->type == ACPI_RESOURCE_TYPE_IO) {
                struct acpi_resource_io *io_res = &res->data.io;
 
-               if (io_res->min_base_address != io_res->max_base_address)
+               if (io_res->minimum != io_res->maximum)
                        return_VALUE(AE_OK);
                if (IS_RESERVED_ADDR
-                   (io_res->min_base_address, io_res->range_length)) {
+                   (io_res->minimum, io_res->address_length)) {
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "Motherboard resources 0x%08x - 0x%08x\n",
-                                         io_res->min_base_address,
-                                         io_res->min_base_address +
-                                         io_res->range_length));
+                                         io_res->minimum,
+                                         io_res->minimum +
+                                         io_res->address_length));
                        requested_res =
-                           request_region(io_res->min_base_address,
-                                          io_res->range_length, "motherboard");
+                           request_region(io_res->minimum,
+                                          io_res->address_length, "motherboard");
                }
-       } else if (res->type == ACPI_RSTYPE_FIXED_IO) {
+       } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) {
                struct acpi_resource_fixed_io *fixed_io_res =
                    &res->data.fixed_io;
 
                if (IS_RESERVED_ADDR
-                   (fixed_io_res->base_address, fixed_io_res->range_length)) {
+                   (fixed_io_res->address, fixed_io_res->address_length)) {
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                          "Motherboard resources 0x%08x - 0x%08x\n",
-                                         fixed_io_res->base_address,
-                                         fixed_io_res->base_address +
-                                         fixed_io_res->range_length));
+                                         fixed_io_res->address,
+                                         fixed_io_res->address +
+                                         fixed_io_res->address_length));
                        requested_res =
-                           request_region(fixed_io_res->base_address,
-                                          fixed_io_res->range_length,
+                           request_region(fixed_io_res->address,
+                                          fixed_io_res->address_length,
                                           "motherboard");
                }
        } else {
index edfbe34..6923059 100644 (file)
@@ -498,7 +498,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
                        path++;
 
                        ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
-                                         "Multi Pathname (%d Segments, Flags=%X) \n",
+                                         "Multi Pathname (%d Segments, Flags=%X)\n",
                                          num_segments, flags));
                        break;
 
index d5e8dea..5400728 100644 (file)
@@ -241,7 +241,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
 
        acpi_ns_build_external_path(node, required_size, buffer->pointer);
 
-       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n",
+       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n",
                          (char *)buffer->pointer, (u32) required_size));
        return_ACPI_STATUS(AE_OK);
 }
index ebec036..549075f 100644 (file)
@@ -249,10 +249,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
 
        if (!node) {
                ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n"));
-               return_VALUE(ACPI_TYPE_ANY);
+               return_UINT32(ACPI_TYPE_ANY);
        }
 
-       return_VALUE((acpi_object_type) node->type);
+       return_UINT32((acpi_object_type) node->type);
 }
 
 /*******************************************************************************
@@ -276,10 +276,10 @@ u32 acpi_ns_local(acpi_object_type type)
                /* Type code out of range  */
 
                ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n"));
-               return_VALUE(ACPI_NS_NORMAL);
+               return_UINT32(ACPI_NS_NORMAL);
        }
 
-       return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
+       return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
 }
 
 /*******************************************************************************
@@ -805,10 +805,10 @@ u32 acpi_ns_opens_scope(acpi_object_type type)
 
                ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n",
                                     type));
-               return_VALUE(ACPI_NS_NORMAL);
+               return_UINT32(ACPI_NS_NORMAL);
        }
 
-       return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
+       return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
 }
 
 /*******************************************************************************
index 5858188..562d0f8 100644 (file)
@@ -116,7 +116,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
                break;
        }
 
-       return_VALUE(length);
+       return_UINT32(length);
 }
 
 /*******************************************************************************
index 4dcbd44..4c426f4 100644 (file)
 ACPI_MODULE_NAME("psxface")
 
 /* Local Prototypes */
+static void acpi_ps_start_trace(struct acpi_parameter_info *info);
+
+static void acpi_ps_stop_trace(struct acpi_parameter_info *info);
+
 static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info);
 
 static void
@@ -57,6 +61,136 @@ acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action);
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_debug_trace
+ *
+ * PARAMETERS:  method_name     - Valid ACPI name string
+ *              debug_level     - Optional level mask. 0 to use default
+ *              debug_layer     - Optional layer mask. 0 to use default
+ *              Flags           - bit 1: one shot(1) or persistent(0)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: External interface to enable debug tracing during control
+ *              method execution
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
+{
+       acpi_status status;
+
+       status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE(status)) {
+               return (status);
+       }
+
+       /* TBDs: Validate name, allow full path or just nameseg */
+
+       acpi_gbl_trace_method_name = *(u32 *) name;
+       acpi_gbl_trace_flags = flags;
+
+       if (debug_level) {
+               acpi_gbl_trace_dbg_level = debug_level;
+       }
+       if (debug_layer) {
+               acpi_gbl_trace_dbg_layer = debug_layer;
+       }
+
+       (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+       return (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ps_start_trace
+ *
+ * PARAMETERS:  Info        - Method info struct
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Start control method execution trace
+ *
+ ******************************************************************************/
+
+static void acpi_ps_start_trace(struct acpi_parameter_info *info)
+{
+       acpi_status status;
+
+       ACPI_FUNCTION_ENTRY();
+
+       status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE(status)) {
+               return;
+       }
+
+       if ((!acpi_gbl_trace_method_name) ||
+           (acpi_gbl_trace_method_name != info->node->name.integer)) {
+               goto exit;
+       }
+
+       acpi_gbl_original_dbg_level = acpi_dbg_level;
+       acpi_gbl_original_dbg_layer = acpi_dbg_layer;
+
+       acpi_dbg_level = 0x00FFFFFF;
+       acpi_dbg_layer = ACPI_UINT32_MAX;
+
+       if (acpi_gbl_trace_dbg_level) {
+               acpi_dbg_level = acpi_gbl_trace_dbg_level;
+       }
+       if (acpi_gbl_trace_dbg_layer) {
+               acpi_dbg_layer = acpi_gbl_trace_dbg_layer;
+       }
+
+      exit:
+       (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ps_stop_trace
+ *
+ * PARAMETERS:  Info        - Method info struct
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Stop control method execution trace
+ *
+ ******************************************************************************/
+
+static void acpi_ps_stop_trace(struct acpi_parameter_info *info)
+{
+       acpi_status status;
+
+       ACPI_FUNCTION_ENTRY();
+
+       status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+       if (ACPI_FAILURE(status)) {
+               return;
+       }
+
+       if ((!acpi_gbl_trace_method_name) ||
+           (acpi_gbl_trace_method_name != info->node->name.integer)) {
+               goto exit;
+       }
+
+       /* Disable further tracing if type is one-shot */
+
+       if (acpi_gbl_trace_flags & 1) {
+               acpi_gbl_trace_method_name = 0;
+               acpi_gbl_trace_dbg_level = 0;
+               acpi_gbl_trace_dbg_layer = 0;
+       }
+
+       acpi_dbg_level = acpi_gbl_original_dbg_level;
+       acpi_dbg_layer = acpi_gbl_original_dbg_layer;
+
+      exit:
+       (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+}
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_ps_execute_method
  *
  * PARAMETERS:  Info            - Method info block, contains:
@@ -104,6 +238,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
         */
        acpi_ps_update_parameter_list(info, REF_INCREMENT);
 
+       /* Begin tracing if requested */
+
+       acpi_ps_start_trace(info);
+
        /*
         * 1) Perform the first pass parse of the method to enter any
         *    named objects that it creates into the namespace
@@ -129,6 +267,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
        status = acpi_ps_execute_pass(info);
 
       cleanup:
+       /* End optional tracing */
+
+       acpi_ps_stop_trace(info);
+
        /* Take away the extra reference that we gave the parameters above */
 
        acpi_ps_update_parameter_list(info, REF_DECREMENT);
index 09567c2..726dda1 100644 (file)
@@ -258,7 +258,7 @@ typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **);
 
 static int
 acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
-                     int *edge_level, int *active_high_low, char **link)
+                     int *triggering, int *polarity, char **link)
 {
        int irq;
 
@@ -266,8 +266,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
 
        if (entry->link.handle) {
                irq = acpi_pci_link_allocate_irq(entry->link.handle,
-                                                entry->link.index, edge_level,
-                                                active_high_low, link);
+                                                entry->link.index, triggering,
+                                                polarity, link);
                if (irq < 0) {
                        ACPI_DEBUG_PRINT((ACPI_DB_WARN,
                                          "Invalid IRQ link routing entry\n"));
@@ -275,8 +275,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
                }
        } else {
                irq = entry->link.index;
-               *edge_level = ACPI_LEVEL_SENSITIVE;
-               *active_high_low = ACPI_ACTIVE_LOW;
+               *triggering = ACPI_LEVEL_SENSITIVE;
+               *polarity = ACPI_ACTIVE_LOW;
        }
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
@@ -285,7 +285,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
 
 static int
 acpi_pci_free_irq(struct acpi_prt_entry *entry,
-                 int *edge_level, int *active_high_low, char **link)
+                 int *triggering, int *polarity, char **link)
 {
        int irq;
 
@@ -307,8 +307,8 @@ static int
 acpi_pci_irq_lookup(struct pci_bus *bus,
                    int device,
                    int pin,
-                   int *edge_level,
-                   int *active_high_low, char **link, irq_lookup_func func)
+                   int *triggering,
+                   int *polarity, char **link, irq_lookup_func func)
 {
        struct acpi_prt_entry *entry = NULL;
        int segment = pci_domain_nr(bus);
@@ -327,7 +327,7 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
                return_VALUE(-1);
        }
 
-       ret = func(entry, edge_level, active_high_low, link);
+       ret = func(entry, triggering, polarity, link);
        return_VALUE(ret);
 }
 
@@ -339,8 +339,8 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
 static int
 acpi_pci_irq_derive(struct pci_dev *dev,
                    int pin,
-                   int *edge_level,
-                   int *active_high_low, char **link, irq_lookup_func func)
+                   int *triggering,
+                   int *polarity, char **link, irq_lookup_func func)
 {
        struct pci_dev *bridge = dev;
        int irq = -1;
@@ -375,7 +375,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
                }
 
                irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
-                                         pin, edge_level, active_high_low,
+                                         pin, triggering, polarity,
                                          link, func);
        }
 
@@ -402,8 +402,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
 {
        int irq = 0;
        u8 pin = 0;
-       int edge_level = ACPI_LEVEL_SENSITIVE;
-       int active_high_low = ACPI_ACTIVE_LOW;
+       int triggering = ACPI_LEVEL_SENSITIVE;
+       int polarity = ACPI_ACTIVE_LOW;
        char *link = NULL;
        int rc;
 
@@ -432,7 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
         * values override any BIOS-assigned IRQs set during boot.
         */
        irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
-                                 &edge_level, &active_high_low, &link,
+                                 &triggering, &polarity, &link,
                                  acpi_pci_allocate_irq);
 
        /*
@@ -440,8 +440,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
         * device's parent bridge.
         */
        if (irq < 0)
-               irq = acpi_pci_irq_derive(dev, pin, &edge_level,
-                                         &active_high_low, &link,
+               irq = acpi_pci_irq_derive(dev, pin, &triggering,
+                                         &polarity, &link,
                                          acpi_pci_allocate_irq);
 
        /*
@@ -463,7 +463,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
                }
        }
 
-       rc = acpi_register_gsi(irq, edge_level, active_high_low);
+       rc = acpi_register_gsi(irq, triggering, polarity);
        if (rc < 0) {
                printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
                       "to register GSI\n", pci_name(dev), ('A' + pin));
@@ -478,8 +478,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
                printk("Link [%s] -> ", link);
 
        printk("GSI %u (%s, %s) -> IRQ %d\n", irq,
-              (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
-              (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
+              (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
+              (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
 
        return_VALUE(0);
 }
@@ -495,8 +495,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
 {
        int gsi = 0;
        u8 pin = 0;
-       int edge_level = ACPI_LEVEL_SENSITIVE;
-       int active_high_low = ACPI_ACTIVE_LOW;
+       int triggering = ACPI_LEVEL_SENSITIVE;
+       int polarity = ACPI_ACTIVE_LOW;
 
        ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
 
@@ -512,7 +512,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
         * First we check the PCI IRQ routing table (PRT) for an IRQ.
         */
        gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
-                                 &edge_level, &active_high_low, NULL,
+                                 &triggering, &polarity, NULL,
                                  acpi_pci_free_irq);
        /*
         * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -520,7 +520,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
         */
        if (gsi < 0)
                gsi = acpi_pci_irq_derive(dev, pin,
-                                         &edge_level, &active_high_low, NULL,
+                                         &triggering, &polarity, NULL,
                                          acpi_pci_free_irq);
        if (gsi < 0)
                return_VOID;
index d8956c0..4921703 100644 (file)
@@ -70,8 +70,8 @@ static struct acpi_driver acpi_pci_link_driver = {
  */
 struct acpi_pci_link_irq {
        u8 active;              /* Current IRQ */
-       u8 edge_level;          /* All IRQs */
-       u8 active_high_low;     /* All IRQs */
+       u8 triggering;          /* All IRQs */
+       u8 polarity;    /* All IRQs */
        u8 resource_type;
        u8 possible_count;
        u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
@@ -109,18 +109,18 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
        ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
 
        switch (resource->type) {
-       case ACPI_RSTYPE_START_DPF:
+       case ACPI_RESOURCE_TYPE_START_DEPENDENT:
                return_ACPI_STATUS(AE_OK);
-       case ACPI_RSTYPE_IRQ:
+       case ACPI_RESOURCE_TYPE_IRQ:
                {
                        struct acpi_resource_irq *p = &resource->data.irq;
-                       if (!p || !p->number_of_interrupts) {
+                       if (!p || !p->interrupt_count) {
                                ACPI_DEBUG_PRINT((ACPI_DB_WARN,
                                                  "Blank IRQ resource\n"));
                                return_ACPI_STATUS(AE_OK);
                        }
                        for (i = 0;
-                            (i < p->number_of_interrupts
+                            (i < p->interrupt_count
                              && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
                                if (!p->interrupts[i]) {
                                        ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -131,22 +131,22 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
                                link->irq.possible[i] = p->interrupts[i];
                                link->irq.possible_count++;
                        }
-                       link->irq.edge_level = p->edge_level;
-                       link->irq.active_high_low = p->active_high_low;
-                       link->irq.resource_type = ACPI_RSTYPE_IRQ;
+                       link->irq.triggering = p->triggering;
+                       link->irq.polarity = p->polarity;
+                       link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ;
                        break;
                }
-       case ACPI_RSTYPE_EXT_IRQ:
+       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
                {
-                       struct acpi_resource_ext_irq *p =
+                       struct acpi_resource_extended_irq *p =
                            &resource->data.extended_irq;
-                       if (!p || !p->number_of_interrupts) {
+                       if (!p || !p->interrupt_count) {
                                ACPI_DEBUG_PRINT((ACPI_DB_WARN,
                                                  "Blank EXT IRQ resource\n"));
                                return_ACPI_STATUS(AE_OK);
                        }
                        for (i = 0;
-                            (i < p->number_of_interrupts
+                            (i < p->interrupt_count
                              && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
                                if (!p->interrupts[i]) {
                                        ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -157,9 +157,9 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
                                link->irq.possible[i] = p->interrupts[i];
                                link->irq.possible_count++;
                        }
-                       link->irq.edge_level = p->edge_level;
-                       link->irq.active_high_low = p->active_high_low;
-                       link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ;
+                       link->irq.triggering = p->triggering;
+                       link->irq.polarity = p->polarity;
+                       link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
                        break;
                }
        default:
@@ -202,10 +202,10 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
        ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
 
        switch (resource->type) {
-       case ACPI_RSTYPE_IRQ:
+       case ACPI_RESOURCE_TYPE_IRQ:
                {
                        struct acpi_resource_irq *p = &resource->data.irq;
-                       if (!p || !p->number_of_interrupts) {
+                       if (!p || !p->interrupt_count) {
                                /*
                                 * IRQ descriptors may have no IRQ# bits set,
                                 * particularly those those w/ _STA disabled
@@ -217,11 +217,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
                        *irq = p->interrupts[0];
                        break;
                }
-       case ACPI_RSTYPE_EXT_IRQ:
+       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
                {
-                       struct acpi_resource_ext_irq *p =
+                       struct acpi_resource_extended_irq *p =
                            &resource->data.extended_irq;
-                       if (!p || !p->number_of_interrupts) {
+                       if (!p || !p->interrupt_count) {
                                /*
                                 * extended IRQ descriptors must
                                 * return at least 1 IRQ
@@ -325,36 +325,36 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
        buffer.pointer = resource;
 
        switch (link->irq.resource_type) {
-       case ACPI_RSTYPE_IRQ:
-               resource->res.type = ACPI_RSTYPE_IRQ;
+       case ACPI_RESOURCE_TYPE_IRQ:
+               resource->res.type = ACPI_RESOURCE_TYPE_IRQ;
                resource->res.length = sizeof(struct acpi_resource);
-               resource->res.data.irq.edge_level = link->irq.edge_level;
-               resource->res.data.irq.active_high_low =
-                   link->irq.active_high_low;
-               if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
-                       resource->res.data.irq.shared_exclusive =
+               resource->res.data.irq.triggering = link->irq.triggering;
+               resource->res.data.irq.polarity =
+                   link->irq.polarity;
+               if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
+                       resource->res.data.irq.sharable =
                            ACPI_EXCLUSIVE;
                else
-                       resource->res.data.irq.shared_exclusive = ACPI_SHARED;
-               resource->res.data.irq.number_of_interrupts = 1;
+                       resource->res.data.irq.sharable = ACPI_SHARED;
+               resource->res.data.irq.interrupt_count = 1;
                resource->res.data.irq.interrupts[0] = irq;
                break;
 
-       case ACPI_RSTYPE_EXT_IRQ:
-               resource->res.type = ACPI_RSTYPE_EXT_IRQ;
+       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+               resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
                resource->res.length = sizeof(struct acpi_resource);
                resource->res.data.extended_irq.producer_consumer =
                    ACPI_CONSUMER;
-               resource->res.data.extended_irq.edge_level =
-                   link->irq.edge_level;
-               resource->res.data.extended_irq.active_high_low =
-                   link->irq.active_high_low;
-               if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
-                       resource->res.data.irq.shared_exclusive =
+               resource->res.data.extended_irq.triggering =
+                   link->irq.triggering;
+               resource->res.data.extended_irq.polarity =
+                   link->irq.polarity;
+               if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
+                       resource->res.data.irq.sharable =
                            ACPI_EXCLUSIVE;
                else
-                       resource->res.data.irq.shared_exclusive = ACPI_SHARED;
-               resource->res.data.extended_irq.number_of_interrupts = 1;
+                       resource->res.data.irq.sharable = ACPI_SHARED;
+               resource->res.data.extended_irq.interrupt_count = 1;
                resource->res.data.extended_irq.interrupts[0] = irq;
                /* ignore resource_source, it's optional */
                break;
@@ -364,7 +364,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
                goto end;
 
        }
-       resource->end.type = ACPI_RSTYPE_END_TAG;
+       resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
 
        /* Attempt to set the resource */
        status = acpi_set_current_resources(link->handle, &buffer);
@@ -613,7 +613,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
 int
 acpi_pci_link_allocate_irq(acpi_handle handle,
                           int index,
-                          int *edge_level, int *active_high_low, char **name)
+                          int *triggering, int *polarity, char **name)
 {
        int result = 0;
        struct acpi_device *device = NULL;
@@ -653,10 +653,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
        link->refcnt++;
        up(&acpi_link_lock);
 
-       if (edge_level)
-               *edge_level = link->irq.edge_level;
-       if (active_high_low)
-               *active_high_low = link->irq.active_high_low;
+       if (triggering)
+               *triggering = link->irq.triggering;
+       if (polarity)
+               *polarity = link->irq.polarity;
        if (name)
                *name = acpi_device_bid(link->device);
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
index 5d6bc81..4c313ea 100644 (file)
@@ -122,15 +122,15 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
        int *busnr = (int *)data;
        struct acpi_resource_address64 address;
 
-       if (resource->type != ACPI_RSTYPE_ADDRESS16 &&
-           resource->type != ACPI_RSTYPE_ADDRESS32 &&
-           resource->type != ACPI_RSTYPE_ADDRESS64)
+       if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
+           resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
+           resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
                return AE_OK;
 
        acpi_resource_to_address64(resource, &address);
        if ((address.address_length > 0) &&
            (address.resource_type == ACPI_BUS_NUMBER_RANGE))
-               *busnr = address.min_address_range;
+               *busnr = address.minimum;
 
        return AE_OK;
 }
index 2130b74..8de4f69 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for all Linux ACPI interpreter subdirectories
 #
 
-obj-y := rsaddr.o  rscreate.o  rsio.o   rslist.o    rsmisc.o   rsxface.o \
+obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
         rscalc.o  rsirq.o  rsmemory.o  rsutils.o
 
 obj-$(ACPI_FUTURE_USAGE) += rsdump.o
index 7987782..6f48ebf 100644 (file)
@@ -58,12 +58,20 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
 
 static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
 
+static void
+acpi_rs_set_address_common(union aml_resource *aml,
+                          struct acpi_resource *resource);
+
+static u8
+acpi_rs_get_address_common(struct acpi_resource *resource,
+                          union aml_resource *aml);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_rs_decode_general_flags
  *
  * PARAMETERS:  Resource            - Address resource data struct
- *              Flags               - Actual flag byte
+ *              Flags               - Raw AML flag byte
  *
  * RETURN:      Decoded flag bits in resource struct
  *
@@ -107,27 +115,19 @@ acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags)
 
 static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
 {
-       u8 flags;
-
        ACPI_FUNCTION_ENTRY();
 
-       /* Producer / Consumer - flag bit[0] */
-
-       flags = (u8) (resource->address.producer_consumer & 0x01);
-
-       /* Decode (_DEC) - flag bit[1] */
-
-       flags |= (u8) ((resource->address.decode & 0x01) << 1);
-
-       /* Min Address Fixed (_MIF) - flag bit[2] */
-
-       flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2);
-
-       /* Max Address Fixed (_MAF) - flag bit[3] */
-
-       flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3);
-
-       return (flags);
+       return ((u8)
+
+               /* Producer / Consumer - flag bit[0] */
+               ((resource->address.producer_consumer & 0x01) |
+                /* Decode (_DEC) - flag bit[1] */
+                ((resource->address.decode & 0x01) << 1) |
+                /* Min Address Fixed (_MIF) - flag bit[2] */
+                ((resource->address.min_address_fixed & 0x01) << 2) |
+                /* Max Address Fixed (_MAF) - flag bit[3] */
+                ((resource->address.max_address_fixed & 0x01) << 3))
+           );
 }
 
 /*******************************************************************************
@@ -135,7 +135,7 @@ static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource)
  * FUNCTION:    acpi_rs_decode_specific_flags
  *
  * PARAMETERS:  Resource            - Address resource data struct
- *              Flags               - Actual flag byte
+ *              Flags               - Raw AML flag byte
  *
  * RETURN:      Decoded flag bits in attribute struct
  *
@@ -189,921 +189,541 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags)
 
 static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource)
 {
-       u8 flags = 0;
-
        ACPI_FUNCTION_ENTRY();
 
        if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
-               /* Write Status (_RW) - flag bit[0] */
-
-               flags = (u8)
-                   (resource->address.attribute.memory.
-                    read_write_attribute & 0x01);
-
-               /* Memory Attributes (_MEM) - flag bits[2:1] */
-
-               flags |= (u8)
-                   ((resource->address.attribute.memory.
-                     cache_attribute & 0x03) << 1);
+               return ((u8)
+
+                       /* Write Status (_RW) - flag bit[0] */
+                       ((resource->address.attribute.memory.
+                         read_write_attribute & 0x01) |
+                        /* Memory Attributes (_MEM) - flag bits[2:1] */
+                        ((resource->address.attribute.memory.
+                          cache_attribute & 0x03) << 1)));
        } else if (resource->address.resource_type == ACPI_IO_RANGE) {
-               /* Ranges (_RNG) - flag bits[1:0] */
-
-               flags = (u8)
-                   (resource->address.attribute.io.range_attribute & 0x03);
-
-               /* Translations (_TTP and _TRS) - flag bits[5:4] */
-
-               flags |= (u8)
-                   ((resource->address.attribute.io.
-                     translation_attribute & 0x03) << 4);
+               return ((u8)
+
+                       /* Ranges (_RNG) - flag bits[1:0] */
+                       ((resource->address.attribute.io.
+                         range_attribute & 0x03) |
+                        /* Translations (_TTP and _TRS) - flag bits[5:4] */
+                        ((resource->address.attribute.io.
+                          translation_attribute & 0x03) << 4)));
        }
 
-       return (flags);
+       return (0);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_address16_resource
+ * FUNCTION:    acpi_rs_set_address_common
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              Resource            - Pointer to the internal resource struct
  *
- * RETURN:      Status
+ * RETURN:      None
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert common flag fields from a resource descriptor to an
+ *              AML descriptor
  *
  ******************************************************************************/
 
-acpi_status
-acpi_rs_address16_resource(u8 * byte_stream_buffer,
-                          acpi_size * bytes_consumed,
-                          u8 ** output_buffer, acpi_size * structure_size)
+static void
+acpi_rs_set_address_common(union aml_resource *aml,
+                          struct acpi_resource *resource)
 {
-       u32 index;
-       u16 temp16;
-       u8 temp8;
-       u8 *temp_ptr;
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16);
+       ACPI_FUNCTION_ENTRY();
 
-       ACPI_FUNCTION_TRACE("rs_address16_resource");
+       /* Set the Resource Type (Memory, Io, bus_number, etc.) */
 
-       /* Get the Descriptor Length field */
+       aml->address.resource_type = (u8) resource->data.address.resource_type;
 
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
+       /* Set the general flags */
 
-       /* Validate minimum descriptor length */
+       aml->address.flags = acpi_rs_encode_general_flags(&resource->data);
 
-       if (temp16 < 13) {
-               return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
-       }
+       /* Set the type-specific flags */
 
-       *bytes_consumed = temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_ADDRESS16;
+       aml->address.specific_flags =
+           acpi_rs_encode_specific_flags(&resource->data);
+}
 
-       /* Get the Resource Type (Byte3) */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_get_address_common
+ *
+ * PARAMETERS:  Resource            - Pointer to the internal resource struct
+ *              Aml                 - Pointer to the AML resource descriptor
+ *
+ * RETURN:      TRUE if the resource_type field is OK, FALSE otherwise
+ *
+ * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
+ *              to an internal resource descriptor
+ *
+ ******************************************************************************/
 
-       buffer += 2;
-       temp8 = *buffer;
+static u8
+acpi_rs_get_address_common(struct acpi_resource *resource,
+                          union aml_resource *aml)
+{
+       ACPI_FUNCTION_ENTRY();
 
-       /* Values 0-2 and 0xC0-0xFF are valid */
+       /* Validate resource type */
 
-       if ((temp8 > 2) && (temp8 < 0xC0)) {
-               return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
+       if ((aml->address.resource_type > 2)
+           && (aml->address.resource_type < 0xC0)) {
+               return (FALSE);
        }
 
-       output_struct->data.address16.resource_type = temp8;
-
-       /* Get the General Flags (Byte4) */
-
-       buffer += 1;
-       acpi_rs_decode_general_flags(&output_struct->data, *buffer);
-
-       /* Get the Type Specific Flags (Byte5) */
-
-       buffer += 1;
-       acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
-
-       /* Get Granularity (Bytes 6-7) */
-
-       buffer += 1;
-       ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer);
+       /* Get the Resource Type (Memory, Io, bus_number, etc.) */
 
-       /* Get min_address_range (Bytes 8-9) */
+       resource->data.address.resource_type = aml->address.resource_type;
 
-       buffer += 2;
-       ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range,
-                          buffer);
+       /* Get the General Flags */
 
-       /* Get max_address_range (Bytes 10-11) */
+       acpi_rs_decode_general_flags(&resource->data, aml->address.flags);
 
-       buffer += 2;
-       ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range,
-                          buffer);
+       /* Get the Type-Specific Flags */
 
-       /* Get address_translation_offset (Bytes 12-13) */
-
-       buffer += 2;
-       ACPI_MOVE_16_TO_32(&output_struct->data.address16.
-                          address_translation_offset, buffer);
+       acpi_rs_decode_specific_flags(&resource->data,
+                                     aml->address.specific_flags);
+       return (TRUE);
+}
 
-       /* Get address_length (Bytes 14-15) */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_get_address16
+ *
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
+ *
+ ******************************************************************************/
 
-       buffer += 2;
-       ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length,
-                          buffer);
+acpi_status
+acpi_rs_get_address16(union aml_resource * aml,
+                     u16 aml_resource_length, struct acpi_resource * resource)
+{
+       ACPI_FUNCTION_TRACE("rs_get_address16");
 
-       /* Resource Source Index (if present) */
+       /* Get the Resource Type, general flags, and type-specific flags */
 
-       buffer += 2;
+       if (!acpi_rs_get_address_common(resource, aml)) {
+               return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
+       }
 
        /*
-        * This will leave us pointing to the Resource Source Index
-        * If it is present, then save it off and calculate the
-        * pointer to where the null terminated string goes:
-        * Each Interrupt takes 32-bits + the 5 bytes of the
-        * stream that are default.
-        *
-        * Note: Some resource descriptors will have an additional null, so
-        * we add 1 to the length.
+        * Get the following contiguous fields from the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
         */
-       if (*bytes_consumed > (16 + 1)) {
-               /* Dereference the Index */
-
-               output_struct->data.address16.resource_source.index =
-                   (u32) * buffer;
-
-               /* Point to the String */
+       acpi_rs_move_data(&resource->data.address16.granularity,
+                         &aml->address16.granularity, 5,
+                         ACPI_MOVE_TYPE_16_TO_32);
 
-               buffer += 1;
+       /* Get the optional resource_source (index and string) */
 
-               /* Point the String pointer to the end of this structure */
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) +
+           acpi_rs_get_resource_source(aml_resource_length,
+                                       sizeof(struct aml_resource_address16),
+                                       &resource->data.address16.
+                                       resource_source, aml, NULL);
 
-               output_struct->data.address16.resource_source.string_ptr =
-                   (char *)((u8 *) output_struct + struct_size);
+       /* Complete the resource header */
 
-               temp_ptr = (u8 *)
-                   output_struct->data.address16.resource_source.string_ptr;
-
-               /* Copy the resource_source string into the buffer */
-
-               index = 0;
-               while (*buffer) {
-                       *temp_ptr = *buffer;
-
-                       temp_ptr++;
-                       buffer++;
-                       index++;
-               }
-
-               /* Add the terminating null and set the string length */
-
-               *temp_ptr = 0;
-               output_struct->data.address16.resource_source.string_length =
-                   index + 1;
-
-               /*
-                * In order for the struct_size to fall on a 32-bit boundary,
-                * calculate the length of the string and expand the
-                * struct_size to the next 32-bit boundary.
-                */
-               temp8 = (u8) (index + 1);
-               struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
-       } else {
-               output_struct->data.address16.resource_source.index = 0;
-               output_struct->data.address16.resource_source.string_length = 0;
-               output_struct->data.address16.resource_source.string_ptr = NULL;
-       }
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_ADDRESS16;
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_address16_stream
+ * FUNCTION:    acpi_rs_set_address16
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_address16_stream(struct acpi_resource *resource,
-                        u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u8 *length_field;
-       acpi_size actual_bytes;
-
-       ACPI_FUNCTION_TRACE("rs_address16_stream");
-
-       /* Set the Descriptor Type field */
+       acpi_size descriptor_length;
 
-       *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE;
-       buffer += 1;
+       ACPI_FUNCTION_TRACE("rs_set_address16");
 
-       /* Save a pointer to the Length field - to be filled in later */
+       /* Set the Resource Type, General Flags, and Type-Specific Flags */
 
-       length_field = buffer;
-       buffer += 2;
-
-       /* Set the Resource Type (Memory, Io, bus_number) */
-
-       *buffer = (u8) (resource->data.address16.resource_type & 0x03);
-       buffer += 1;
-
-       /* Set the general flags */
+       acpi_rs_set_address_common(aml, resource);
 
-       *buffer = acpi_rs_encode_general_flags(&resource->data);
-       buffer += 1;
-
-       /* Set the type specific flags */
-
-       *buffer = acpi_rs_encode_specific_flags(&resource->data);
-       buffer += 1;
-
-       /* Set the address space granularity */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.granularity);
-       buffer += 2;
-
-       /* Set the address range minimum */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.min_address_range);
-       buffer += 2;
-
-       /* Set the address range maximum */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.max_address_range);
-       buffer += 2;
-
-       /* Set the address translation offset */
-
-       ACPI_MOVE_32_TO_16(buffer,
-                          &resource->data.address16.
-                          address_translation_offset);
-       buffer += 2;
-
-       /* Set the address length */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.address_length);
-       buffer += 2;
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
+        */
+       acpi_rs_move_data(&aml->address16.granularity,
+                         &resource->data.address16.granularity, 5,
+                         ACPI_MOVE_TYPE_32_TO_16);
 
        /* Resource Source Index and Resource Source are optional */
 
-       if (resource->data.address16.resource_source.string_length) {
-               *buffer = (u8) resource->data.address16.resource_source.index;
-               buffer += 1;
+       descriptor_length = acpi_rs_set_resource_source(aml,
+                                                       sizeof(struct
+                                                              aml_resource_address16),
+                                                       &resource->data.
+                                                       address16.
+                                                       resource_source);
 
-               /* Copy the resource_source string */
+       /* Complete the AML descriptor header */
 
-               ACPI_STRCPY((char *)buffer,
-                           resource->data.address16.resource_source.
-                           string_ptr);
-
-               /*
-                * Buffer needs to be set to the length of the string + one for the
-                * terminating null
-                */
-               buffer +=
-                   (acpi_size) (ACPI_STRLEN
-                                (resource->data.address16.resource_source.
-                                 string_ptr) + 1);
-       }
-
-       /* Return the number of bytes consumed in this operation */
-
-       actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer);
-       *bytes_consumed = actual_bytes;
-
-       /*
-        * Set the length field to the number of bytes consumed
-        * minus the header size (3 bytes)
-        */
-       actual_bytes -= 3;
-       ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16,
+                                   descriptor_length, aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_address32_resource
+ * FUNCTION:    acpi_rs_get_address32
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_address32_resource(u8 * byte_stream_buffer,
-                          acpi_size * bytes_consumed,
-                          u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_address32(union aml_resource *aml,
+                     u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u16 temp16;
-       u8 temp8;
-       u8 *temp_ptr;
-       u32 index;
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32);
-
-       ACPI_FUNCTION_TRACE("rs_address32_resource");
-
-       /* Get the Descriptor Length field */
-
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
 
-       /* Validate minimum descriptor length */
+       ACPI_FUNCTION_TRACE("rs_get_address32");
 
-       if (temp16 < 23) {
-               return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
-       }
-
-       *bytes_consumed = temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_ADDRESS32;
-
-       /* Get the Resource Type (Byte3) */
-
-       buffer += 2;
-       temp8 = *buffer;
+       /* Get the Resource Type, general flags, and type-specific flags */
 
-       /* Values 0-2 and 0xC0-0xFF are valid */
-
-       if ((temp8 > 2) && (temp8 < 0xC0)) {
+       if (!acpi_rs_get_address_common(resource, (void *)aml)) {
                return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
        }
 
-       output_struct->data.address32.resource_type = temp8;
-
-       /* Get the General Flags (Byte4) */
-
-       buffer += 1;
-       acpi_rs_decode_general_flags(&output_struct->data, *buffer);
-
-       /* Get the Type Specific Flags (Byte5) */
-
-       buffer += 1;
-       acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
-
-       /* Get Granularity (Bytes 6-9) */
-
-       buffer += 1;
-       ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer);
-
-       /* Get min_address_range (Bytes 10-13) */
-
-       buffer += 4;
-       ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range,
-                          buffer);
-
-       /* Get max_address_range (Bytes 14-17) */
-
-       buffer += 4;
-       ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range,
-                          buffer);
-
-       /* Get address_translation_offset (Bytes 18-21) */
-
-       buffer += 4;
-       ACPI_MOVE_32_TO_32(&output_struct->data.address32.
-                          address_translation_offset, buffer);
-
-       /* Get address_length (Bytes 22-25) */
-
-       buffer += 4;
-       ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length,
-                          buffer);
-
-       /* Resource Source Index (if present) */
-
-       buffer += 4;
-
        /*
-        * This will leave us pointing to the Resource Source Index
-        * If it is present, then save it off and calculate the
-        * pointer to where the null terminated string goes:
-        *
-        * Note: Some resource descriptors will have an additional null, so
-        * we add 1 to the length.
+        * Get the following contiguous fields from the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
         */
-       if (*bytes_consumed > (26 + 1)) {
-               /* Dereference the Index */
-
-               output_struct->data.address32.resource_source.index =
-                   (u32) * buffer;
-
-               /* Point to the String */
+       acpi_rs_move_data(&resource->data.address32.granularity,
+                         &aml->address32.granularity, 5,
+                         ACPI_MOVE_TYPE_32_TO_32);
 
-               buffer += 1;
+       /* Get the optional resource_source (index and string) */
 
-               /* Point the String pointer to the end of this structure */
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) +
+           acpi_rs_get_resource_source(aml_resource_length,
+                                       sizeof(struct aml_resource_address32),
+                                       &resource->data.address32.
+                                       resource_source, aml, NULL);
 
-               output_struct->data.address32.resource_source.string_ptr =
-                   (char *)((u8 *) output_struct + struct_size);
+       /* Complete the resource header */
 
-               temp_ptr = (u8 *)
-                   output_struct->data.address32.resource_source.string_ptr;
-
-               /* Copy the resource_source string into the buffer */
-
-               index = 0;
-               while (*buffer) {
-                       *temp_ptr = *buffer;
-
-                       temp_ptr++;
-                       buffer++;
-                       index++;
-               }
-
-               /* Add the terminating null and set the string length */
-
-               *temp_ptr = 0;
-               output_struct->data.address32.resource_source.string_length =
-                   index + 1;
-
-               /*
-                * In order for the struct_size to fall on a 32-bit boundary,
-                * calculate the length of the string and expand the
-                * struct_size to the next 32-bit boundary.
-                */
-               temp8 = (u8) (index + 1);
-               struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
-       } else {
-               output_struct->data.address32.resource_source.index = 0;
-               output_struct->data.address32.resource_source.string_length = 0;
-               output_struct->data.address32.resource_source.string_ptr = NULL;
-       }
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_ADDRESS32;
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_address32_stream
+ * FUNCTION:    acpi_rs_set_address32
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_address32_stream(struct acpi_resource *resource,
-                        u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer;
-       u16 *length_field;
-
-       ACPI_FUNCTION_TRACE("rs_address32_stream");
-
-       buffer = *output_buffer;
+       acpi_size descriptor_length;
 
-       /* Set the Descriptor Type field */
+       ACPI_FUNCTION_TRACE("rs_set_address32");
 
-       *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE;
-       buffer += 1;
+       /* Set the Resource Type, General Flags, and Type-Specific Flags */
 
-       /* Save a pointer to the Length field - to be filled in later */
+       acpi_rs_set_address_common(aml, resource);
 
-       length_field = ACPI_CAST_PTR(u16, buffer);
-       buffer += 2;
-
-       /* Set the Resource Type (Memory, Io, bus_number) */
-
-       *buffer = (u8) (resource->data.address32.resource_type & 0x03);
-       buffer += 1;
-
-       /* Set the general flags */
-
-       *buffer = acpi_rs_encode_general_flags(&resource->data);
-       buffer += 1;
-
-       /* Set the type specific flags */
-
-       *buffer = acpi_rs_encode_specific_flags(&resource->data);
-       buffer += 1;
-
-       /* Set the address space granularity */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.granularity);
-       buffer += 4;
-
-       /* Set the address range minimum */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.min_address_range);
-       buffer += 4;
-
-       /* Set the address range maximum */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.max_address_range);
-       buffer += 4;
-
-       /* Set the address translation offset */
-
-       ACPI_MOVE_32_TO_32(buffer,
-                          &resource->data.address32.
-                          address_translation_offset);
-       buffer += 4;
-
-       /* Set the address length */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.address_length);
-       buffer += 4;
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
+        */
+       acpi_rs_move_data(&aml->address32.granularity,
+                         &resource->data.address32.granularity, 5,
+                         ACPI_MOVE_TYPE_32_TO_32);
 
        /* Resource Source Index and Resource Source are optional */
 
-       if (resource->data.address32.resource_source.string_length) {
-               *buffer = (u8) resource->data.address32.resource_source.index;
-               buffer += 1;
-
-               /* Copy the resource_source string */
+       descriptor_length = acpi_rs_set_resource_source(aml,
+                                                       sizeof(struct
+                                                              aml_resource_address32),
+                                                       &resource->data.
+                                                       address32.
+                                                       resource_source);
 
-               ACPI_STRCPY((char *)buffer,
-                           resource->data.address32.resource_source.
-                           string_ptr);
+       /* Complete the AML descriptor header */
 
-               /*
-                * Buffer needs to be set to the length of the string + one for the
-                *  terminating null
-                */
-               buffer +=
-                   (acpi_size) (ACPI_STRLEN
-                                (resource->data.address32.resource_source.
-                                 string_ptr) + 1);
-       }
-
-       /* Return the number of bytes consumed in this operation */
-
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
-
-       /*
-        * Set the length field to the number of bytes consumed
-        * minus the header size (3 bytes)
-        */
-       *length_field = (u16) (*bytes_consumed - 3);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32,
+                                   descriptor_length, aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_address64_resource
+ * FUNCTION:    acpi_rs_get_address64
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_address64_resource(u8 * byte_stream_buffer,
-                          acpi_size * bytes_consumed,
-                          u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_address64(union aml_resource *aml,
+                     u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u16 temp16;
-       u8 temp8;
-       u8 resource_type;
-       u8 *temp_ptr;
-       u32 index;
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64);
-
-       ACPI_FUNCTION_TRACE("rs_address64_resource");
-
-       /* Get the Descriptor Type */
-
-       resource_type = *buffer;
-
-       /* Get the Descriptor Length field */
-
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       /* Validate minimum descriptor length */
-
-       if (temp16 < 43) {
-               return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
-       }
-
-       *bytes_consumed = temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_ADDRESS64;
-
-       /* Get the Resource Type (Byte3) */
+       ACPI_FUNCTION_TRACE("rs_get_address64");
 
-       buffer += 2;
-       temp8 = *buffer;
+       /* Get the Resource Type, general Flags, and type-specific Flags */
 
-       /* Values 0-2 and 0xC0-0xFF are valid */
-
-       if ((temp8 > 2) && (temp8 < 0xC0)) {
+       if (!acpi_rs_get_address_common(resource, aml)) {
                return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
        }
 
-       output_struct->data.address64.resource_type = temp8;
-
-       /* Get the General Flags (Byte4) */
-
-       buffer += 1;
-       acpi_rs_decode_general_flags(&output_struct->data, *buffer);
-
-       /* Get the Type Specific Flags (Byte5) */
-
-       buffer += 1;
-       acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
-
-       if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) {
-               /* Move past revision_id and Reserved byte */
-
-               buffer += 2;
-       }
-
-       /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
-
-       buffer += 1;
-       ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer);
-
-       /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
-
-       buffer += 8;
-       ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range,
-                          buffer);
-
-       /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
-
-       buffer += 8;
-       ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range,
-                          buffer);
-
-       /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
-
-       buffer += 8;
-       ACPI_MOVE_64_TO_64(&output_struct->data.address64.
-                          address_translation_offset, buffer);
+       /*
+        * Get the following contiguous fields from the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
+        */
+       acpi_rs_move_data(&resource->data.address64.granularity,
+                         &aml->address64.granularity, 5,
+                         ACPI_MOVE_TYPE_64_TO_64);
 
-       /* Get address_length (Bytes 38-45) or (Bytes 40-47) */
+       /* Get the optional resource_source (index and string) */
 
-       buffer += 8;
-       ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length,
-                          buffer);
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) +
+           acpi_rs_get_resource_source(aml_resource_length,
+                                       sizeof(struct aml_resource_address64),
+                                       &resource->data.address64.
+                                       resource_source, aml, NULL);
 
-       output_struct->data.address64.resource_source.index = 0;
-       output_struct->data.address64.resource_source.string_length = 0;
-       output_struct->data.address64.resource_source.string_ptr = NULL;
+       /* Complete the resource header */
 
-       if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) {
-               /* Get type_specific_attribute (Bytes 48-55) */
+       resource->type = ACPI_RESOURCE_TYPE_ADDRESS64;
+       return_ACPI_STATUS(AE_OK);
+}
 
-               buffer += 8;
-               ACPI_MOVE_64_TO_64(&output_struct->data.address64.
-                                  type_specific_attributes, buffer);
-       } else {
-               output_struct->data.address64.type_specific_attributes = 0;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_set_address64
+ *
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
+ *
+ ******************************************************************************/
 
-               /* Resource Source Index (if present) */
+acpi_status
+acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml)
+{
+       acpi_size descriptor_length;
 
-               buffer += 8;
+       ACPI_FUNCTION_TRACE("rs_set_address64");
 
-               /*
-                * This will leave us pointing to the Resource Source Index
-                * If it is present, then save it off and calculate the
-                * pointer to where the null terminated string goes:
-                * Each Interrupt takes 32-bits + the 5 bytes of the
-                * stream that are default.
-                *
-                * Note: Some resource descriptors will have an additional null, so
-                * we add 1 to the length.
-                */
-               if (*bytes_consumed > (46 + 1)) {
-                       /* Dereference the Index */
+       /* Set the Resource Type, General Flags, and Type-Specific Flags */
 
-                       output_struct->data.address64.resource_source.index =
-                           (u32) * buffer;
+       acpi_rs_set_address_common(aml, resource);
 
-                       /* Point to the String */
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
+        */
+       acpi_rs_move_data(&aml->address64.granularity,
+                         &resource->data.address64.granularity, 5,
+                         ACPI_MOVE_TYPE_64_TO_64);
 
-                       buffer += 1;
+       /* Resource Source Index and Resource Source are optional */
 
-                       /* Point the String pointer to the end of this structure */
+       descriptor_length = acpi_rs_set_resource_source(aml,
+                                                       sizeof(struct
+                                                              aml_resource_address64),
+                                                       &resource->data.
+                                                       address64.
+                                                       resource_source);
 
-                       output_struct->data.address64.resource_source.
-                           string_ptr =
-                           (char *)((u8 *) output_struct + struct_size);
+       /* Complete the AML descriptor header */
 
-                       temp_ptr = (u8 *)
-                           output_struct->data.address64.resource_source.
-                           string_ptr;
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64,
+                                   descriptor_length, aml);
+       return_ACPI_STATUS(AE_OK);
+}
 
-                       /* Copy the resource_source string into the buffer */
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_get_ext_address64
+ *
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
+ *
+ ******************************************************************************/
 
-                       index = 0;
-                       while (*buffer) {
-                               *temp_ptr = *buffer;
+acpi_status
+acpi_rs_get_ext_address64(union aml_resource *aml,
+                         u16 aml_resource_length,
+                         struct acpi_resource *resource)
+{
 
-                               temp_ptr++;
-                               buffer++;
-                               index++;
-                       }
+       ACPI_FUNCTION_TRACE("rs_get_ext_address64");
 
-                       /*
-                        * Add the terminating null and set the string length
-                        */
-                       *temp_ptr = 0;
-                       output_struct->data.address64.resource_source.
-                           string_length = index + 1;
+       /* Get the Resource Type, general flags, and type-specific flags */
 
-                       /*
-                        * In order for the struct_size to fall on a 32-bit boundary,
-                        * calculate the length of the string and expand the
-                        * struct_size to the next 32-bit boundary.
-                        */
-                       temp8 = (u8) (index + 1);
-                       struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
-               }
+       if (!acpi_rs_get_address_common(resource, aml)) {
+               return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
        }
 
-       /* Set the Length parameter */
+       /*
+        * Get and validate the Revision ID
+        * Note: Only one revision ID is currently supported
+        */
+       resource->data.ext_address64.revision_iD =
+           aml->ext_address64.revision_iD;
+       if (aml->ext_address64.revision_iD !=
+           AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
+               return_ACPI_STATUS(AE_SUPPORT);
+       }
 
-       output_struct->length = (u32) struct_size;
+       /*
+        * Get the following contiguous fields from the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
+        * Type-Specific Attribute
+        */
+       acpi_rs_move_data(&resource->data.ext_address64.granularity,
+                         &aml->ext_address64.granularity, 6,
+                         ACPI_MOVE_TYPE_64_TO_64);
 
-       /* Return the final size of the structure */
+       /* Complete the resource header */
 
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64;
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_address64_stream
+ * FUNCTION:    acpi_rs_set_ext_address64
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_address64_stream(struct acpi_resource *resource,
-                        u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_ext_address64(struct acpi_resource *resource,
+                         union aml_resource *aml)
 {
-       u8 *buffer;
-       u16 *length_field;
-
-       ACPI_FUNCTION_TRACE("rs_address64_stream");
-
-       buffer = *output_buffer;
-
-       /* Set the Descriptor Type field */
-
-       *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
-       buffer += 1;
-
-       /* Save a pointer to the Length field - to be filled in later */
-
-       length_field = ACPI_CAST_PTR(u16, buffer);
-       buffer += 2;
-
-       /* Set the Resource Type (Memory, Io, bus_number) */
-
-       *buffer = (u8) (resource->data.address64.resource_type & 0x03);
-       buffer += 1;
-
-       /* Set the general flags */
-
-       *buffer = acpi_rs_encode_general_flags(&resource->data);
-       buffer += 1;
-
-       /* Set the type specific flags */
-
-       *buffer = acpi_rs_encode_specific_flags(&resource->data);
-       buffer += 1;
-
-       /* Set the address space granularity */
+       ACPI_FUNCTION_TRACE("rs_set_ext_address64");
 
-       ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.granularity);
-       buffer += 8;
+       /* Set the Resource Type, General Flags, and Type-Specific Flags */
 
-       /* Set the address range minimum */
+       acpi_rs_set_address_common(aml, resource);
 
-       ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.min_address_range);
-       buffer += 8;
+       /* Only one Revision ID is currently supported */
 
-       /* Set the address range maximum */
-
-       ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.max_address_range);
-       buffer += 8;
-
-       /* Set the address translation offset */
-
-       ACPI_MOVE_64_TO_64(buffer,
-                          &resource->data.address64.
-                          address_translation_offset);
-       buffer += 8;
-
-       /* Set the address length */
-
-       ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.address_length);
-       buffer += 8;
-
-       /* Resource Source Index and Resource Source are optional */
-
-       if (resource->data.address64.resource_source.string_length) {
-               *buffer = (u8) resource->data.address64.resource_source.index;
-               buffer += 1;
-
-               /* Copy the resource_source string */
-
-               ACPI_STRCPY((char *)buffer,
-                           resource->data.address64.resource_source.
-                           string_ptr);
-
-               /*
-                * Buffer needs to be set to the length of the string + one for the
-                * terminating null
-                */
-               buffer +=
-                   (acpi_size) (ACPI_STRLEN
-                                (resource->data.address64.resource_source.
-                                 string_ptr) + 1);
-       }
-
-       /* Return the number of bytes consumed in this operation */
-
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
+       aml->ext_address64.reserved = 0;
 
        /*
-        * Set the length field to the number of bytes consumed
-        * minus the header size (3 bytes)
+        * Set the following contiguous fields in the AML descriptor:
+        * Address Granularity
+        * Address Range Minimum
+        * Address Range Maximum
+        * Address Translation Offset
+        * Address Length
+        * Type-Specific Attribute
         */
-       *length_field = (u16) (*bytes_consumed - 3);
+       acpi_rs_move_data(&aml->ext_address64.granularity,
+                         &resource->data.address64.granularity, 6,
+                         ACPI_MOVE_TYPE_64_TO_64);
+
+       /* Complete the AML descriptor header */
+
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
+                                   sizeof(struct
+                                          aml_resource_extended_address64),
+                                   aml);
        return_ACPI_STATUS(AE_OK);
 }
index 2da7c6a..d170dee 100644 (file)
 #include <acpi/acpi.h>
 #include <acpi/acresrc.h>
 #include <acpi/amlcode.h>
-#include <acpi/amlresrc.h>
 #include <acpi/acnamesp.h>
 
 #define _COMPONENT          ACPI_RESOURCES
 ACPI_MODULE_NAME("rscalc")
 
-/*
- * Base sizes for external resource descriptors, indexed by internal type.
- * Includes size of the descriptor header (1 byte for small descriptors,
- * 3 bytes for large descriptors)
- */
-static u8 acpi_gbl_stream_sizes[] = {
-       4,                      /* ACPI_RSTYPE_IRQ (Byte 3 is optional, but always created) */
-       3,                      /* ACPI_RSTYPE_DMA */
-       2,                      /* ACPI_RSTYPE_START_DPF (Byte 1 is optional, but always created) */
-       1,                      /* ACPI_RSTYPE_END_DPF */
-       8,                      /* ACPI_RSTYPE_IO */
-       4,                      /* ACPI_RSTYPE_FIXED_IO */
-       1,                      /* ACPI_RSTYPE_VENDOR */
-       2,                      /* ACPI_RSTYPE_END_TAG */
-       12,                     /* ACPI_RSTYPE_MEM24 */
-       20,                     /* ACPI_RSTYPE_MEM32 */
-       12,                     /* ACPI_RSTYPE_FIXED_MEM32 */
-       16,                     /* ACPI_RSTYPE_ADDRESS16 */
-       26,                     /* ACPI_RSTYPE_ADDRESS32 */
-       46,                     /* ACPI_RSTYPE_ADDRESS64 */
-       9,                      /* ACPI_RSTYPE_EXT_IRQ */
-       15                      /* ACPI_RSTYPE_GENERIC_REG */
-};
-
-/*
- * Base sizes of resource descriptors, both the actual AML stream length and
- * size of the internal struct representation.
- */
-struct acpi_resource_sizes {
-       u8 minimum_stream_size;
-       u8 minimum_struct_size;
-};
-
-static struct acpi_resource_sizes acpi_gbl_sm_resource_sizes[] = {
-       {0, 0},                 /* 0x00, Reserved */
-       {0, 0},                 /* 0x01, Reserved */
-       {0, 0},                 /* 0x02, Reserved */
-       {0, 0},                 /* 0x03, Reserved */
-       {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)},    /* ACPI_RDESC_TYPE_IRQ_FORMAT */
-       {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)},    /* ACPI_RDESC_TYPE_DMA_FORMAT */
-       {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf)},      /* ACPI_RDESC_TYPE_START_DEPENDENT */
-       {1, ACPI_RESOURCE_LENGTH},      /* ACPI_RDESC_TYPE_END_DEPENDENT */
-       {8, ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)},     /* ACPI_RDESC_TYPE_IO_PORT */
-       {4, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)},       /* ACPI_RDESC_TYPE_FIXED_IO_PORT */
-       {0, 0},                 /* 0x0A, Reserved */
-       {0, 0},                 /* 0x0B, Reserved */
-       {0, 0},                 /* 0x0C, Reserved */
-       {0, 0},                 /* 0x0D, Reserved */
-       {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_SMALL_VENDOR */
-       {2, ACPI_RESOURCE_LENGTH},      /* ACPI_RDESC_TYPE_END_TAG */
-};
-
-static struct acpi_resource_sizes acpi_gbl_lg_resource_sizes[] = {
-       {0, 0},                 /* 0x00, Reserved */
-       {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24)}, /* ACPI_RDESC_TYPE_MEMORY_24 */
-       {15, ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg)},   /* ACPI_RDESC_TYPE_GENERIC_REGISTER */
-       {0, 0},                 /* 0x03, Reserved */
-       {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_LARGE_VENDOR */
-       {20, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32)}, /* ACPI_RDESC_TYPE_MEMORY_32 */
-       {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32)},   /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */
-       {26, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)},     /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */
-       {16, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)},     /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */
-       {9, ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq)},        /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */
-       {46, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)},     /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */
-       {56, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)},     /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */
-};
-
 /* Local prototypes */
-
 static u8 acpi_rs_count_set_bits(u16 bit_field);
 
-static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type);
-
-static u16 acpi_rs_get_resource_length(u8 * resource);
-
 static acpi_size
 acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
 
@@ -161,90 +88,6 @@ static u8 acpi_rs_count_set_bits(u16 bit_field)
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_get_resource_sizes
- *
- * PARAMETERS:  resource_type       - Byte 0 of a resource descriptor
- *
- * RETURN:      Pointer to the resource conversion handler
- *
- * DESCRIPTION: Extract the Resource Type/Name from the first byte of
- *              a resource descriptor.
- *
- ******************************************************************************/
-
-static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type)
-{
-       struct acpi_resource_sizes *size_info;
-
-       ACPI_FUNCTION_ENTRY();
-
-       /* Determine if this is a small or large resource */
-
-       if (resource_type & ACPI_RDESC_TYPE_LARGE) {
-               /* Large Resource Type -- bits 6:0 contain the name */
-
-               if (resource_type > ACPI_RDESC_LARGE_MAX) {
-                       return (NULL);
-               }
-
-               size_info = &acpi_gbl_lg_resource_sizes[(resource_type &
-                                                        ACPI_RDESC_LARGE_MASK)];
-       } else {
-               /* Small Resource Type -- bits 6:3 contain the name */
-
-               size_info = &acpi_gbl_sm_resource_sizes[((resource_type &
-                                                         ACPI_RDESC_SMALL_MASK)
-                                                        >> 3)];
-       }
-
-       /* Zero entry indicates an invalid resource type */
-
-       if (!size_info->minimum_stream_size) {
-               return (NULL);
-       }
-
-       return (size_info);
-}
-
-/*******************************************************************************
- *
- * FUNCTION:    acpi_rs_get_resource_length
- *
- * PARAMETERS:  Resource            - Pointer to the resource descriptor
- *
- * RETURN:      Byte length of the (AML byte stream) descriptor. By definition,
- *              this does not include the size of the descriptor header and the
- *              length field itself.
- *
- * DESCRIPTION: Extract the length of a resource descriptor.
- *
- ******************************************************************************/
-
-static u16 acpi_rs_get_resource_length(u8 * resource)
-{
-       u16 resource_length;
-
-       ACPI_FUNCTION_ENTRY();
-
-       /* Determine if this is a small or large resource */
-
-       if (*resource & ACPI_RDESC_TYPE_LARGE) {
-               /* Large Resource type -- length is in bytes 1-2 */
-
-               ACPI_MOVE_16_TO_16(&resource_length, (resource + 1));
-
-       } else {
-               /* Small Resource Type -- bits 2:0 of byte 0 contain the length */
-
-               resource_length =
-                   (u16) (*resource & ACPI_RDESC_SMALL_LENGTH_MASK);
-       }
-
-       return (resource_length);
-}
-
-/*******************************************************************************
- *
  * FUNCTION:    acpi_rs_struct_option_length
  *
  * PARAMETERS:  resource_source     - Pointer to optional descriptor field
@@ -291,10 +134,10 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
  ******************************************************************************/
 
 static u32
-acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
+acpi_rs_stream_option_length(u32 resource_length,
+                            u32 minimum_aml_resource_length)
 {
        u32 string_length = 0;
-       u32 minimum_resource_length;
 
        ACPI_FUNCTION_ENTRY();
 
@@ -303,11 +146,6 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
         * Large-type resource descriptors.
         */
 
-       /* Compute minimum size of the data part of the resource descriptor */
-
-       minimum_resource_length =
-           minimum_total_length - sizeof(struct asl_large_header);
-
        /*
         * If the length of the actual resource descriptor is greater than the ACPI
         * spec-defined minimum length, it means that a resource_source_index exists
@@ -315,10 +153,11 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
         * (including the null terminator) is the resource length minus the minimum
         * length, minus one byte for the resource_source_index itself.
         */
-       if (resource_length > minimum_resource_length) {
+       if (resource_length > minimum_aml_resource_length) {
                /* Compute the length of the optional string */
 
-               string_length = resource_length - minimum_resource_length - 1;
+               string_length =
+                   resource_length - minimum_aml_resource_length - 1;
        }
 
        /* Round up length to 32 bits for internal structure alignment */
@@ -328,7 +167,7 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_get_byte_stream_length
+ * FUNCTION:    acpi_rs_get_aml_length
  *
  * PARAMETERS:  Resource            - Pointer to the resource linked list
  *              size_needed         - Where the required size is returned
@@ -342,62 +181,62 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length)
  ******************************************************************************/
 
 acpi_status
-acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
-                              acpi_size * size_needed)
+acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
 {
-       acpi_size byte_stream_size_needed = 0;
+       acpi_size aml_size_needed = 0;
        acpi_size segment_size;
 
-       ACPI_FUNCTION_TRACE("rs_get_byte_stream_length");
+       ACPI_FUNCTION_TRACE("rs_get_aml_length");
 
        /* Traverse entire list of internal resource descriptors */
 
        while (resource) {
                /* Validate the descriptor type */
 
-               if (resource->type > ACPI_RSTYPE_MAX) {
+               if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
                        return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
                }
 
                /* Get the base size of the (external stream) resource descriptor */
 
-               segment_size = acpi_gbl_stream_sizes[resource->type];
+               segment_size = acpi_gbl_aml_resource_sizes[resource->type];
 
                /*
                 * Augment the base size for descriptors with optional and/or
                 * variable-length fields
                 */
                switch (resource->type) {
-               case ACPI_RSTYPE_VENDOR:
+               case ACPI_RESOURCE_TYPE_VENDOR:
                        /*
                         * Vendor Defined Resource:
                         * For a Vendor Specific resource, if the Length is between 1 and 7
                         * it will be created as a Small Resource data type, otherwise it
                         * is a Large Resource data type.
                         */
-                       if (resource->data.vendor_specific.length > 7) {
+                       if (resource->data.vendor.byte_length > 7) {
                                /* Base size of a Large resource descriptor */
 
-                               segment_size = 3;
+                               segment_size =
+                                   sizeof(struct aml_resource_large_header);
                        }
 
                        /* Add the size of the vendor-specific data */
 
-                       segment_size += resource->data.vendor_specific.length;
+                       segment_size += resource->data.vendor.byte_length;
                        break;
 
-               case ACPI_RSTYPE_END_TAG:
+               case ACPI_RESOURCE_TYPE_END_TAG:
                        /*
                         * End Tag:
                         * We are done -- return the accumulated total size.
                         */
-                       *size_needed = byte_stream_size_needed + segment_size;
+                       *size_needed = aml_size_needed + segment_size;
 
                        /* Normal exit */
 
                        return_ACPI_STATUS(AE_OK);
 
-               case ACPI_RSTYPE_ADDRESS16:
+               case ACPI_RESOURCE_TYPE_ADDRESS16:
                        /*
                         * 16-Bit Address Resource:
                         * Add the size of the optional resource_source info
@@ -408,7 +247,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
                                                         resource_source);
                        break;
 
-               case ACPI_RSTYPE_ADDRESS32:
+               case ACPI_RESOURCE_TYPE_ADDRESS32:
                        /*
                         * 32-Bit Address Resource:
                         * Add the size of the optional resource_source info
@@ -419,7 +258,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
                                                         resource_source);
                        break;
 
-               case ACPI_RSTYPE_ADDRESS64:
+               case ACPI_RESOURCE_TYPE_ADDRESS64:
                        /*
                         * 64-Bit Address Resource:
                         * Add the size of the optional resource_source info
@@ -430,7 +269,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
                                                         resource_source);
                        break;
 
-               case ACPI_RSTYPE_EXT_IRQ:
+               case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
                        /*
                         * Extended IRQ Resource:
                         * Add the size of each additional optional interrupt beyond the
@@ -438,7 +277,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
                         */
                        segment_size += (((acpi_size)
                                          resource->data.extended_irq.
-                                         number_of_interrupts - 1) * 4);
+                                         interrupt_count - 1) * 4);
 
                        /* Add the size of the optional resource_source info */
 
@@ -454,7 +293,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
 
                /* Update the total */
 
-               byte_stream_size_needed += segment_size;
+               aml_size_needed += segment_size;
 
                /* Point to the next object */
 
@@ -471,9 +310,9 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
  *
  * FUNCTION:    acpi_rs_get_list_length
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource byte stream
- *              byte_stream_buffer_length - Size of byte_stream_buffer
- *              size_needed             - Where the size needed is returned
+ * PARAMETERS:  aml_buffer          - Pointer to the resource byte stream
+ *              aml_buffer_length   - Size of aml_buffer
+ *              size_needed         - Where the size needed is returned
  *
  * RETURN:      Status
  *
@@ -484,11 +323,11 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource,
  ******************************************************************************/
 
 acpi_status
-acpi_rs_get_list_length(u8 * byte_stream_buffer,
-                       u32 byte_stream_buffer_length, acpi_size * size_needed)
+acpi_rs_get_list_length(u8 * aml_buffer,
+                       u32 aml_buffer_length, acpi_size * size_needed)
 {
        u8 *buffer;
-       struct acpi_resource_sizes *resource_info;
+       struct acpi_resource_info *resource_info;
        u32 buffer_size = 0;
        u32 bytes_parsed = 0;
        u8 resource_type;
@@ -499,14 +338,14 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
 
        ACPI_FUNCTION_TRACE("rs_get_list_length");
 
-       while (bytes_parsed < byte_stream_buffer_length) {
+       while (bytes_parsed < aml_buffer_length) {
                /* The next byte in the stream is the resource descriptor type */
 
-               resource_type = acpi_rs_get_resource_type(*byte_stream_buffer);
+               resource_type = acpi_rs_get_resource_type(*aml_buffer);
 
                /* Get the base stream size and structure sizes for the descriptor */
 
-               resource_info = acpi_rs_get_resource_sizes(resource_type);
+               resource_info = acpi_rs_get_resource_info(resource_type);
                if (!resource_info) {
                        return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
                }
@@ -514,43 +353,46 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                /* Get the Length field from the input resource descriptor */
 
                resource_length =
-                   acpi_rs_get_resource_length(byte_stream_buffer);
+                   acpi_rs_get_resource_length(ACPI_CAST_PTR
+                                               (union aml_resource,
+                                                aml_buffer));
 
                /* Augment the size for descriptors with optional fields */
 
                extra_struct_bytes = 0;
 
-               if (!(resource_type & ACPI_RDESC_TYPE_LARGE)) {
+               if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) {
                        /*
                         * Small resource descriptors
                         */
-                       header_length = 1;
-                       buffer = byte_stream_buffer + header_length;
+                       header_length =
+                           sizeof(struct aml_resource_small_header);
+                       buffer = aml_buffer + header_length;
 
                        switch (resource_type) {
-                       case ACPI_RDESC_TYPE_IRQ_FORMAT:
+                       case ACPI_RESOURCE_NAME_IRQ:
                                /*
                                 * IRQ Resource:
                                 * Get the number of bits set in the IRQ word
                                 */
                                ACPI_MOVE_16_TO_16(&temp16, buffer);
-
                                extra_struct_bytes =
                                    (acpi_rs_count_set_bits(temp16) *
                                     sizeof(u32));
                                break;
 
-                       case ACPI_RDESC_TYPE_DMA_FORMAT:
+                       case ACPI_RESOURCE_NAME_DMA:
                                /*
                                 * DMA Resource:
                                 * Get the number of bits set in the DMA channels byte
                                 */
+                               ACPI_MOVE_16_TO_16(&temp16, buffer);
                                extra_struct_bytes =
-                                   (acpi_rs_count_set_bits((u16) * buffer) *
+                                   (acpi_rs_count_set_bits(temp16) *
                                     sizeof(u32));
                                break;
 
-                       case ACPI_RDESC_TYPE_SMALL_VENDOR:
+                       case ACPI_RESOURCE_NAME_VENDOR_SMALL:
                                /*
                                 * Vendor Specific Resource:
                                 * Ensure a 32-bit boundary for the structure
@@ -559,12 +401,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                                    ACPI_ROUND_UP_to_32_bITS(resource_length);
                                break;
 
-                       case ACPI_RDESC_TYPE_END_TAG:
+                       case ACPI_RESOURCE_NAME_END_TAG:
                                /*
                                 * End Tag:
                                 * Terminate the loop now
                                 */
-                               byte_stream_buffer_length = bytes_parsed;
+                               aml_buffer_length = bytes_parsed;
                                break;
 
                        default:
@@ -574,11 +416,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                        /*
                         * Large resource descriptors
                         */
-                       header_length = sizeof(struct asl_large_header);
-                       buffer = byte_stream_buffer + header_length;
+                       header_length =
+                           sizeof(struct aml_resource_large_header);
+                       buffer = aml_buffer + header_length;
 
                        switch (resource_type) {
-                       case ACPI_RDESC_TYPE_LARGE_VENDOR:
+                       case ACPI_RESOURCE_NAME_VENDOR_LARGE:
                                /*
                                 * Vendor Defined Resource:
                                 * Add vendor data and ensure a 32-bit boundary for the structure
@@ -587,8 +430,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                                    ACPI_ROUND_UP_to_32_bITS(resource_length);
                                break;
 
-                       case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
-                       case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
+                       case ACPI_RESOURCE_NAME_ADDRESS32:
+                       case ACPI_RESOURCE_NAME_ADDRESS16:
                                /*
                                 * 32-Bit or 16-bit Address Resource:
                                 * Add the size of any optional data (resource_source)
@@ -596,10 +439,11 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                                extra_struct_bytes =
                                    acpi_rs_stream_option_length
                                    (resource_length,
-                                    resource_info->minimum_stream_size);
+                                    resource_info->
+                                    minimum_aml_resource_length);
                                break;
 
-                       case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
+                       case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
                                /*
                                 * Extended IRQ:
                                 * Point past the interrupt_vector_flags to get the
@@ -622,10 +466,10 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                                                                 -
                                                                 extra_struct_bytes,
                                                                 resource_info->
-                                                                minimum_stream_size);
+                                                                minimum_aml_resource_length);
                                break;
 
-                       case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
+                       case ACPI_RESOURCE_NAME_ADDRESS64:
                                /*
                                 * 64-Bit Address Resource:
                                 * Add the size of any optional data (resource_source)
@@ -635,7 +479,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                                    ACPI_ROUND_UP_to_64_bITS
                                    (acpi_rs_stream_option_length
                                     (resource_length,
-                                     resource_info->minimum_stream_size));
+                                     resource_info->
+                                     minimum_aml_resource_length));
                                break;
 
                        default:
@@ -646,7 +491,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                /* Update the required buffer size for the internal descriptor structs */
 
                temp16 =
-                   (u16) (resource_info->minimum_struct_size +
+                   (u16) (resource_info->minimum_internal_struct_length +
                           extra_struct_bytes);
                buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16);
 
@@ -656,7 +501,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer,
                 */
                temp16 = (u16) (header_length + resource_length);
                bytes_parsed += temp16;
-               byte_stream_buffer += temp16;
+               aml_buffer += temp16;
        }
 
        /* This is the data the caller needs */
@@ -758,8 +603,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
                                                     (*sub_object_list)->string.
                                                     length + 1);
                        } else {
-                               temp_size_needed +=
-                                   acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
+                               temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
                        }
                } else {
                        /*
index 0911526..6c7c6c5 100644 (file)
@@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate")
  *
  * FUNCTION:    acpi_rs_create_resource_list
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource byte stream
- *              output_buffer           - Pointer to the user's buffer
+ * PARAMETERS:  aml_buffer          - Pointer to the resource byte stream
+ *              output_buffer       - Pointer to the user's buffer
  *
- * RETURN:      Status  - AE_OK if okay, else a valid acpi_status code
+ * RETURN:      Status: AE_OK if okay, else a valid acpi_status code
  *              If output_buffer is not large enough, output_buffer_length
  *              indicates how large output_buffer should be, else it
  *              indicates how may u8 elements of output_buffer are valid.
@@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate")
  *
  ******************************************************************************/
 acpi_status
-acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
+acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
                             struct acpi_buffer *output_buffer)
 {
 
        acpi_status status;
-       u8 *byte_stream_start;
+       u8 *aml_start;
        acpi_size list_size_needed = 0;
-       u32 byte_stream_buffer_length;
+       u32 aml_buffer_length;
 
        ACPI_FUNCTION_TRACE("rs_create_resource_list");
 
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n",
-                         byte_stream_buffer));
+       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer));
 
        /* Params already validated, so we don't re-validate here */
 
-       byte_stream_buffer_length = byte_stream_buffer->buffer.length;
-       byte_stream_start = byte_stream_buffer->buffer.pointer;
+       aml_buffer_length = aml_buffer->buffer.length;
+       aml_start = aml_buffer->buffer.pointer;
 
        /*
-        * Pass the byte_stream_buffer into a module that can calculate
+        * Pass the aml_buffer into a module that can calculate
         * the buffer size needed for the linked list
         */
-       status =
-           acpi_rs_get_list_length(byte_stream_start,
-                                   byte_stream_buffer_length,
-                                   &list_size_needed);
+       status = acpi_rs_get_list_length(aml_start, aml_buffer_length,
+                                        &list_size_needed);
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
                          status, (u32) list_size_needed));
@@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
 
        /* Do the conversion */
 
-       status =
-           acpi_rs_byte_stream_to_list(byte_stream_start,
-                                       byte_stream_buffer_length,
-                                       output_buffer->pointer);
+       status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length,
+                                                 output_buffer->pointer);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
@@ -360,7 +355,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_create_byte_stream
+ * FUNCTION:    acpi_rs_create_aml_resources
  *
  * PARAMETERS:  linked_list_buffer      - Pointer to the resource linked list
  *              output_buffer           - Pointer to the user's buffer
@@ -377,13 +372,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
  ******************************************************************************/
 
 acpi_status
-acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
-                          struct acpi_buffer *output_buffer)
+acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
+                            struct acpi_buffer *output_buffer)
 {
        acpi_status status;
-       acpi_size byte_stream_size_needed = 0;
+       acpi_size aml_size_needed = 0;
 
-       ACPI_FUNCTION_TRACE("rs_create_byte_stream");
+       ACPI_FUNCTION_TRACE("rs_create_aml_resources");
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n",
                          linked_list_buffer));
@@ -394,11 +389,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
         * Pass the linked_list_buffer into a module that calculates
         * the buffer size needed for the byte stream.
         */
-       status = acpi_rs_get_byte_stream_length(linked_list_buffer,
-                                               &byte_stream_size_needed);
+       status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed);
 
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n",
-                         (u32) byte_stream_size_needed,
+       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n",
+                         (u32) aml_size_needed,
                          acpi_format_exception(status)));
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
@@ -406,8 +400,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
 
        /* Validate/Allocate/Clear caller buffer */
 
-       status =
-           acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed);
+       status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
@@ -415,9 +408,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
        /* Do the conversion */
 
        status =
-           acpi_rs_list_to_byte_stream(linked_list_buffer,
-                                       byte_stream_size_needed,
-                                       output_buffer->pointer);
+           acpi_rs_convert_resources_to_aml(linked_list_buffer,
+                                            aml_size_needed,
+                                            output_buffer->pointer);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
index 9d93ee5..2f89908 100644 (file)
@@ -49,38 +49,6 @@ ACPI_MODULE_NAME("rsdump")
 
 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 /* Local prototypes */
-static void acpi_rs_dump_irq(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_address16(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_address32(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_address64(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_dma(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_io(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_memory24(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_memory32(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource);
-
-static void acpi_rs_dump_end_tag(union acpi_resource_data *resource);
-
 static void acpi_rs_out_string(char *title, char *value);
 
 static void acpi_rs_out_integer8(char *title, u8 value);
@@ -104,30 +72,6 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
 
 static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
 
-/* Dispatch table for resource dump functions */
-
-typedef
-void (*ACPI_DUMP_RESOURCE) (union acpi_resource_data * data);
-
-static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = {
-       acpi_rs_dump_irq,       /* ACPI_RSTYPE_IRQ */
-       acpi_rs_dump_dma,       /* ACPI_RSTYPE_DMA */
-       acpi_rs_dump_start_depend_fns,  /* ACPI_RSTYPE_START_DPF */
-       acpi_rs_dump_end_depend_fns,    /* ACPI_RSTYPE_END_DPF */
-       acpi_rs_dump_io,        /* ACPI_RSTYPE_IO */
-       acpi_rs_dump_fixed_io,  /* ACPI_RSTYPE_FIXED_IO */
-       acpi_rs_dump_vendor_specific,   /* ACPI_RSTYPE_VENDOR */
-       acpi_rs_dump_end_tag,   /* ACPI_RSTYPE_END_TAG */
-       acpi_rs_dump_memory24,  /* ACPI_RSTYPE_MEM24 */
-       acpi_rs_dump_memory32,  /* ACPI_RSTYPE_MEM32 */
-       acpi_rs_dump_fixed_memory32,    /* ACPI_RSTYPE_FIXED_MEM32 */
-       acpi_rs_dump_address16, /* ACPI_RSTYPE_ADDRESS16 */
-       acpi_rs_dump_address32, /* ACPI_RSTYPE_ADDRESS32 */
-       acpi_rs_dump_address64, /* ACPI_RSTYPE_ADDRESS64 */
-       acpi_rs_dump_extended_irq,      /* ACPI_RSTYPE_EXT_IRQ */
-       acpi_rs_dump_generic_reg        /* ACPI_RSTYPE_GENERIC_REG */
-};
-
 /*******************************************************************************
  *
  * FUNCTION:    acpi_rs_out*
@@ -144,32 +88,32 @@ static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = {
 
 static void acpi_rs_out_string(char *title, char *value)
 {
-       acpi_os_printf("%30s : %s\n", title, value);
+       acpi_os_printf("%27s : %s\n", title, value);
 }
 
 static void acpi_rs_out_integer8(char *title, u8 value)
 {
-       acpi_os_printf("%30s : %2.2X\n", title, value);
+       acpi_os_printf("%27s : %2.2X\n", title, value);
 }
 
 static void acpi_rs_out_integer16(char *title, u16 value)
 {
-       acpi_os_printf("%30s : %4.4X\n", title, value);
+       acpi_os_printf("%27s : %4.4X\n", title, value);
 }
 
 static void acpi_rs_out_integer32(char *title, u32 value)
 {
-       acpi_os_printf("%30s : %8.8X\n", title, value);
+       acpi_os_printf("%27s : %8.8X\n", title, value);
 }
 
 static void acpi_rs_out_integer64(char *title, u64 value)
 {
-       acpi_os_printf("%30s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
+       acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
 }
 
 static void acpi_rs_out_title(char *title)
 {
-       acpi_os_printf("%30s : ", title);
+       acpi_os_printf("%27s : ", title);
 }
 
 /*******************************************************************************
@@ -190,7 +134,7 @@ static void acpi_rs_dump_byte_list(u32 length, u8 * data)
        u32 i;
 
        for (i = 0; i < length; i++) {
-               acpi_os_printf("%28s%2.2X : %2.2X\n", "Byte", i, data[i]);
+               acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
        }
 }
 
@@ -199,7 +143,7 @@ static void acpi_rs_dump_dword_list(u32 length, u32 * data)
        u32 i;
 
        for (i = 0; i < length; i++) {
-               acpi_os_printf("%28s%2.2X : %8.8X\n", "Dword", i, data[i]);
+               acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
        }
 }
 
@@ -213,6 +157,14 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data)
        acpi_os_printf("\n");
 }
 
+static void acpi_rs_dump_memory_attribute(u32 read_write_attribute)
+{
+
+       acpi_rs_out_string("Read/Write Attribute",
+                          ACPI_READ_WRITE_MEMORY == read_write_attribute ?
+                          "Read/Write" : "Read-Only");
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_rs_dump_resource_source
@@ -229,6 +181,7 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data)
 static void
 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
 {
+       ACPI_FUNCTION_ENTRY();
 
        if (resource_source->index == 0xFF) {
                return;
@@ -290,11 +243,8 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
                        break;
                }
 
-               acpi_rs_out_string("Read/Write Attribute",
-                                  ACPI_READ_WRITE_MEMORY ==
-                                  resource->address.attribute.memory.
-                                  read_write_attribute ? "Read/Write" :
-                                  "Read Only");
+               acpi_rs_dump_memory_attribute(resource->address.attribute.
+                                             memory.read_write_attribute);
                break;
 
        case ACPI_IO_RANGE:
@@ -392,7 +342,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
 
                /* Validate Type before dispatch */
 
-               if (resource_list->type > ACPI_RSTYPE_MAX) {
+               if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) {
                        acpi_os_printf
                            ("Invalid descriptor type (%X) in resource list\n",
                             resource_list->type);
@@ -406,7 +356,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
 
                /* Exit on end tag */
 
-               if (resource_list->type == ACPI_RSTYPE_END_TAG) {
+               if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) {
                        return;
                }
 
@@ -431,7 +381,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_irq(union acpi_resource_data *resource)
+void acpi_rs_dump_irq(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
@@ -439,22 +389,21 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource)
 
        acpi_rs_out_string("Triggering",
                           ACPI_LEVEL_SENSITIVE ==
-                          resource->irq.edge_level ? "Level" : "Edge");
+                          resource->irq.triggering ? "Level" : "Edge");
 
        acpi_rs_out_string("Active",
                           ACPI_ACTIVE_LOW ==
-                          resource->irq.active_high_low ? "Low" : "High");
+                          resource->irq.polarity ? "Low" : "High");
 
        acpi_rs_out_string("Sharing",
                           ACPI_SHARED ==
-                          resource->irq.
-                          shared_exclusive ? "Shared" : "Exclusive");
+                          resource->irq.sharable ? "Shared" : "Exclusive");
 
        acpi_rs_out_integer8("Interrupt Count",
-                            (u8) resource->irq.number_of_interrupts);
+                            (u8) resource->irq.interrupt_count);
 
        acpi_rs_out_title("Interrupt List");
-       acpi_rs_dump_short_byte_list(resource->irq.number_of_interrupts,
+       acpi_rs_dump_short_byte_list(resource->irq.interrupt_count,
                                     resource->irq.interrupts);
 }
 
@@ -470,7 +419,7 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_dma(union acpi_resource_data *resource)
+void acpi_rs_dump_dma(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
@@ -523,16 +472,16 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource)
        }
 
        acpi_rs_out_integer8("DMA Channel Count",
-                            (u8) resource->dma.number_of_channels);
+                            (u8) resource->dma.channel_count);
 
        acpi_rs_out_title("Channel List");
-       acpi_rs_dump_short_byte_list(resource->dma.number_of_channels,
+       acpi_rs_dump_short_byte_list(resource->dma.channel_count,
                                     resource->dma.channels);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_dump_start_depend_fns
+ * FUNCTION:    acpi_rs_dump_start_dpf
  *
  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
  *
@@ -542,7 +491,7 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource)
+void acpi_rs_dump_start_dpf(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
@@ -600,7 +549,7 @@ static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_io(union acpi_resource_data *resource)
+void acpi_rs_dump_io(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
@@ -610,15 +559,13 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource)
                           ACPI_DECODE_16 ==
                           resource->io.io_decode ? "16-bit" : "10-bit");
 
-       acpi_rs_out_integer32("Range Minimum Base",
-                             resource->io.min_base_address);
+       acpi_rs_out_integer32("Address Minimum", resource->io.minimum);
 
-       acpi_rs_out_integer32("Range Maximum Base",
-                             resource->io.max_base_address);
+       acpi_rs_out_integer32("Address Maximum", resource->io.maximum);
 
        acpi_rs_out_integer32("Alignment", resource->io.alignment);
 
-       acpi_rs_out_integer32("Range Length", resource->io.range_length);
+       acpi_rs_out_integer32("Address Length", resource->io.address_length);
 }
 
 /*******************************************************************************
@@ -633,21 +580,21 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource)
+void acpi_rs_dump_fixed_io(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
        acpi_os_printf("Fixed I/O Resource\n");
 
-       acpi_rs_out_integer32("Range Base Address",
-                             resource->fixed_io.base_address);
+       acpi_rs_out_integer32("Address", resource->fixed_io.address);
 
-       acpi_rs_out_integer32("Range Length", resource->fixed_io.range_length);
+       acpi_rs_out_integer32("Address Length",
+                             resource->fixed_io.address_length);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_dump_vendor_specific
+ * FUNCTION:    acpi_rs_dump_vendor
  *
  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
  *
@@ -657,16 +604,16 @@ static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource)
+void acpi_rs_dump_vendor(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
        acpi_os_printf("Vendor Specific Resource\n");
 
-       acpi_rs_out_integer16("Length", (u16) resource->vendor_specific.length);
+       acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length);
 
-       acpi_rs_dump_byte_list(resource->vendor_specific.length,
-                              resource->vendor_specific.reserved);
+       acpi_rs_dump_byte_list(resource->vendor.byte_length,
+                              resource->vendor.byte_data);
 }
 
 /*******************************************************************************
@@ -681,27 +628,24 @@ static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_memory24(union acpi_resource_data *resource)
+void acpi_rs_dump_memory24(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
        acpi_os_printf("24-Bit Memory Range Resource\n");
 
-       acpi_rs_out_string("Attribute",
-                          ACPI_READ_WRITE_MEMORY ==
-                          resource->memory24.read_write_attribute ?
-                          "Read/Write" : "Read Only");
+       acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute);
 
-       acpi_rs_out_integer16("Range Minimum Base",
-                             (u16) resource->memory24.min_base_address);
+       acpi_rs_out_integer16("Address Minimum",
+                             (u16) resource->memory24.minimum);
 
-       acpi_rs_out_integer16("Range Maximum Base",
-                             (u16) resource->memory24.max_base_address);
+       acpi_rs_out_integer16("Address Maximum",
+                             (u16) resource->memory24.maximum);
 
        acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment);
 
-       acpi_rs_out_integer16("Range Length",
-                             (u16) resource->memory24.range_length);
+       acpi_rs_out_integer16("Address Length",
+                             (u16) resource->memory24.address_length);
 }
 
 /*******************************************************************************
@@ -716,26 +660,22 @@ static void acpi_rs_dump_memory24(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_memory32(union acpi_resource_data *resource)
+void acpi_rs_dump_memory32(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
        acpi_os_printf("32-Bit Memory Range Resource\n");
 
-       acpi_rs_out_string("Attribute",
-                          ACPI_READ_WRITE_MEMORY ==
-                          resource->memory32.read_write_attribute ?
-                          "Read/Write" : "Read Only");
+       acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute);
 
-       acpi_rs_out_integer32("Range Minimum Base",
-                             resource->memory32.min_base_address);
+       acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum);
 
-       acpi_rs_out_integer32("Range Maximum Base",
-                             resource->memory32.max_base_address);
+       acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum);
 
        acpi_rs_out_integer32("Alignment", resource->memory32.alignment);
 
-       acpi_rs_out_integer32("Range Length", resource->memory32.range_length);
+       acpi_rs_out_integer32("Address Length",
+                             resource->memory32.address_length);
 }
 
 /*******************************************************************************
@@ -750,22 +690,19 @@ static void acpi_rs_dump_memory32(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource)
+void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
        acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
 
-       acpi_rs_out_string("Attribute",
-                          ACPI_READ_WRITE_MEMORY ==
-                          resource->fixed_memory32.read_write_attribute ?
-                          "Read/Write" : "Read Only");
+       acpi_rs_dump_memory_attribute(resource->fixed_memory32.
+                                     read_write_attribute);
 
-       acpi_rs_out_integer32("Range Base Address",
-                             resource->fixed_memory32.range_base_address);
+       acpi_rs_out_integer32("Address", resource->fixed_memory32.address);
 
-       acpi_rs_out_integer32("Range Length",
-                             resource->fixed_memory32.range_length);
+       acpi_rs_out_integer32("Address Length",
+                             resource->fixed_memory32.address_length);
 }
 
 /*******************************************************************************
@@ -780,26 +717,25 @@ static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_address16(union acpi_resource_data *resource)
+void acpi_rs_dump_address16(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
-       acpi_os_printf("16-Bit Address Space Resource\n");
+       acpi_os_printf("16-Bit WORD Address Space Resource\n");
 
        acpi_rs_dump_address_common(resource);
 
        acpi_rs_out_integer16("Granularity",
                              (u16) resource->address16.granularity);
 
-       acpi_rs_out_integer16("Address Range Min",
-                             (u16) resource->address16.min_address_range);
+       acpi_rs_out_integer16("Address Minimum",
+                             (u16) resource->address16.minimum);
 
-       acpi_rs_out_integer16("Address Range Max",
-                             (u16) resource->address16.max_address_range);
+       acpi_rs_out_integer16("Address Maximum",
+                             (u16) resource->address16.maximum);
 
-       acpi_rs_out_integer16("Address Translation Offset",
-                             (u16) resource->address16.
-                             address_translation_offset);
+       acpi_rs_out_integer16("Translation Offset",
+                             (u16) resource->address16.translation_offset);
 
        acpi_rs_out_integer16("Address Length",
                              (u16) resource->address16.address_length);
@@ -819,24 +755,22 @@ static void acpi_rs_dump_address16(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_address32(union acpi_resource_data *resource)
+void acpi_rs_dump_address32(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
-       acpi_os_printf("32-Bit Address Space Resource\n");
+       acpi_os_printf("32-Bit DWORD Address Space Resource\n");
 
        acpi_rs_dump_address_common(resource);
 
        acpi_rs_out_integer32("Granularity", resource->address32.granularity);
 
-       acpi_rs_out_integer32("Address Range Min",
-                             resource->address32.min_address_range);
+       acpi_rs_out_integer32("Address Minimum", resource->address32.minimum);
 
-       acpi_rs_out_integer32("Address Range Max",
-                             resource->address32.max_address_range);
+       acpi_rs_out_integer32("Address Maximum", resource->address32.maximum);
 
-       acpi_rs_out_integer32("Address Translation Offset",
-                             resource->address32.address_translation_offset);
+       acpi_rs_out_integer32("Translation Offset",
+                             resource->address32.translation_offset);
 
        acpi_rs_out_integer32("Address Length",
                              resource->address32.address_length);
@@ -856,37 +790,32 @@ static void acpi_rs_dump_address32(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_address64(union acpi_resource_data *resource)
+void acpi_rs_dump_address64(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
-       acpi_os_printf("64-Bit Address Space Resource\n");
+       acpi_os_printf("64-Bit QWORD Address Space Resource\n");
 
        acpi_rs_dump_address_common(resource);
 
        acpi_rs_out_integer64("Granularity", resource->address64.granularity);
 
-       acpi_rs_out_integer64("Address Range Min",
-                             resource->address64.min_address_range);
+       acpi_rs_out_integer64("Address Minimum", resource->address64.minimum);
 
-       acpi_rs_out_integer64("Address Range Max",
-                             resource->address64.max_address_range);
+       acpi_rs_out_integer64("Address Maximum", resource->address64.maximum);
 
-       acpi_rs_out_integer64("Address Translation Offset",
-                             resource->address64.address_translation_offset);
+       acpi_rs_out_integer64("Translation Offset",
+                             resource->address64.translation_offset);
 
        acpi_rs_out_integer64("Address Length",
                              resource->address64.address_length);
 
-       acpi_rs_out_integer64("Type Specific Attributes",
-                             resource->address64.type_specific_attributes);
-
        acpi_rs_dump_resource_source(&resource->address64.resource_source);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_dump_extended_irq
+ * FUNCTION:    acpi_rs_dump_ext_address64
  *
  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
  *
@@ -896,7 +825,46 @@ static void acpi_rs_dump_address64(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource)
+void acpi_rs_dump_ext_address64(union acpi_resource_data *resource)
+{
+       ACPI_FUNCTION_ENTRY();
+
+       acpi_os_printf("64-Bit Extended Address Space Resource\n");
+
+       acpi_rs_dump_address_common(resource);
+
+       acpi_rs_out_integer64("Granularity",
+                             resource->ext_address64.granularity);
+
+       acpi_rs_out_integer64("Address Minimum",
+                             resource->ext_address64.minimum);
+
+       acpi_rs_out_integer64("Address Maximum",
+                             resource->ext_address64.maximum);
+
+       acpi_rs_out_integer64("Translation Offset",
+                             resource->ext_address64.translation_offset);
+
+       acpi_rs_out_integer64("Address Length",
+                             resource->ext_address64.address_length);
+
+       acpi_rs_out_integer64("Type-Specific Attribute",
+                             resource->ext_address64.type_specific_attributes);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_dump_ext_irq
+ *
+ * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump the field names and values of the resource descriptor
+ *
+ ******************************************************************************/
+
+void acpi_rs_dump_ext_irq(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
@@ -910,24 +878,22 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource)
        acpi_rs_out_string("Triggering",
                           ACPI_LEVEL_SENSITIVE ==
                           resource->extended_irq.
-                          edge_level ? "Level" : "Edge");
+                          triggering ? "Level" : "Edge");
 
        acpi_rs_out_string("Active",
-                          ACPI_ACTIVE_LOW ==
-                          resource->extended_irq.
-                          active_high_low ? "Low" : "High");
+                          ACPI_ACTIVE_LOW == resource->extended_irq.polarity ?
+                          "Low" : "High");
 
        acpi_rs_out_string("Sharing",
-                          ACPI_SHARED ==
-                          resource->extended_irq.
-                          shared_exclusive ? "Shared" : "Exclusive");
+                          ACPI_SHARED == resource->extended_irq.sharable ?
+                          "Shared" : "Exclusive");
 
        acpi_rs_dump_resource_source(&resource->extended_irq.resource_source);
 
        acpi_rs_out_integer8("Interrupts",
-                            (u8) resource->extended_irq.number_of_interrupts);
+                            (u8) resource->extended_irq.interrupt_count);
 
-       acpi_rs_dump_dword_list(resource->extended_irq.number_of_interrupts,
+       acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count,
                                resource->extended_irq.interrupts);
 }
 
@@ -943,9 +909,8 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
+void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
 {
-
        ACPI_FUNCTION_ENTRY();
 
        acpi_os_printf("Generic Register Resource\n");
@@ -957,15 +922,15 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
        acpi_rs_out_integer8("Bit Offset",
                             (u8) resource->generic_reg.bit_offset);
 
-       acpi_rs_out_integer8("Address Size",
-                            (u8) resource->generic_reg.address_size);
+       acpi_rs_out_integer8("Access Size",
+                            (u8) resource->generic_reg.access_size);
 
        acpi_rs_out_integer64("Address", resource->generic_reg.address);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_dump_end_depend_fns
+ * FUNCTION:    acpi_rs_dump_end_dpf
  *
  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
  *
@@ -975,7 +940,7 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource)
+void acpi_rs_dump_end_dpf(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
@@ -994,7 +959,7 @@ static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource)
  *
  ******************************************************************************/
 
-static void acpi_rs_dump_end_tag(union acpi_resource_data *resource)
+void acpi_rs_dump_end_tag(union acpi_resource_data *resource)
 {
        ACPI_FUNCTION_ENTRY();
 
index 49a5f81..b31cb33 100644 (file)
@@ -207,7 +207,7 @@ struct acpi_resource_info acpi_gbl_lg_resource_info[] = {
        {0, ACPI_RLARGE(struct aml_resource_memory24),
         ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)},
        {0, ACPI_RLARGE(struct aml_resource_generic_register),
-        ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)},
+        ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)},
        {0, 0, 0},
        {1, ACPI_RLARGE(struct aml_resource_vendor_large),
         ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
index 6574e2a..0dab8cd 100644 (file)
@@ -49,426 +49,269 @@ ACPI_MODULE_NAME("rsio")
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_io_resource
+ * FUNCTION:    acpi_rs_get_io
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 acpi_status
-acpi_rs_io_resource(u8 * byte_stream_buffer,
-                   acpi_size * bytes_consumed,
-                   u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_io(union aml_resource *aml,
+              u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
+       ACPI_FUNCTION_TRACE("rs_get_io");
 
-       ACPI_FUNCTION_TRACE("rs_io_resource");
+       /* Get the Decode flag */
 
-       /* The number of bytes consumed are Constant */
+       resource->data.io.io_decode = aml->io.information & 0x01;
 
-       *bytes_consumed = 8;
+       /*
+        * Get the following contiguous fields from the AML descriptor:
+        * Minimum Base Address
+        * Maximum Base Address
+        * Address Alignment
+        * Length
+        */
+       ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum);
+       ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum);
+       resource->data.io.alignment = aml->io.alignment;
+       resource->data.io.address_length = aml->io.address_length;
 
-       output_struct->type = ACPI_RSTYPE_IO;
+       /* Complete the resource header */
 
-       /* Check Decode */
-
-       buffer += 1;
-       temp8 = *buffer;
-
-       output_struct->data.io.io_decode = temp8 & 0x01;
-
-       /* Check min_base Address */
-
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       output_struct->data.io.min_base_address = temp16;
-
-       /* Check max_base Address */
-
-       buffer += 2;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       output_struct->data.io.max_base_address = temp16;
-
-       /* Check Base alignment */
-
-       buffer += 2;
-       temp8 = *buffer;
-
-       output_struct->data.io.alignment = temp8;
-
-       /* Check range_length */
-
-       buffer += 1;
-       temp8 = *buffer;
-
-       output_struct->data.io.range_length = temp8;
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_IO;
+       resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_fixed_io_resource
+ * FUNCTION:    acpi_rs_set_io
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_fixed_io_resource(u8 * byte_stream_buffer,
-                         acpi_size * bytes_consumed,
-                         u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
-
-       ACPI_FUNCTION_TRACE("rs_fixed_io_resource");
+       ACPI_FUNCTION_TRACE("rs_set_io");
 
-       /* The number of bytes consumed are Constant */
+       /* I/O Information Byte */
 
-       *bytes_consumed = 4;
+       aml->io.information = (u8) (resource->data.io.io_decode & 0x01);
 
-       output_struct->type = ACPI_RSTYPE_FIXED_IO;
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Minimum Base Address
+        * Maximum Base Address
+        * Address Alignment
+        * Length
+        */
+       ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum);
+       ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum);
+       aml->io.alignment = (u8) resource->data.io.alignment;
+       aml->io.address_length = (u8) resource->data.io.address_length;
 
-       /* Check Range Base Address */
+       /* Complete the AML descriptor header */
 
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       output_struct->data.fixed_io.base_address = temp16;
-
-       /* Check range_length */
-
-       buffer += 2;
-       temp8 = *buffer;
-
-       output_struct->data.fixed_io.range_length = temp8;
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO,
+                                   sizeof(struct aml_resource_io), aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_io_stream
+ * FUNCTION:    acpi_rs_get_fixed_io
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_io_stream(struct acpi_resource *resource,
-                 u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_get_fixed_io(union aml_resource *aml,
+                    u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-
-       ACPI_FUNCTION_TRACE("rs_io_stream");
-
-       /* The Descriptor Type field is static */
-
-       *buffer = ACPI_RDESC_TYPE_IO_PORT | 0x07;
-       buffer += 1;
-
-       /* Io Information Byte */
-
-       temp8 = (u8) (resource->data.io.io_decode & 0x01);
-
-       *buffer = temp8;
-       buffer += 1;
-
-       /* Set the Range minimum base address */
-
-       temp16 = (u16) resource->data.io.min_base_address;
-
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
-
-       /* Set the Range maximum base address */
+       ACPI_FUNCTION_TRACE("rs_get_fixed_io");
 
-       temp16 = (u16) resource->data.io.max_base_address;
+       /*
+        * Get the following contiguous fields from the AML descriptor:
+        * Base Address
+        * Length
+        */
+       ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address,
+                          &aml->fixed_io.address);
+       resource->data.fixed_io.address_length = aml->fixed_io.address_length;
 
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
+       /* Complete the resource header */
 
-       /* Set the base alignment */
-
-       temp8 = (u8) resource->data.io.alignment;
-
-       *buffer = temp8;
-       buffer += 1;
-
-       /* Set the range length */
-
-       temp8 = (u8) resource->data.io.range_length;
-
-       *buffer = temp8;
-       buffer += 1;
-
-       /* Return the number of bytes consumed in this operation */
-
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       resource->type = ACPI_RESOURCE_TYPE_FIXED_IO;
+       resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_fixed_io_stream
+ * FUNCTION:    acpi_rs_set_fixed_io
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_fixed_io_stream(struct acpi_resource *resource,
-                       u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-
-       ACPI_FUNCTION_TRACE("rs_fixed_io_stream");
-
-       /* The Descriptor Type field is static */
-
-       *buffer = ACPI_RDESC_TYPE_FIXED_IO_PORT | 0x03;
-       buffer += 1;
-
-       /* Set the Range base address */
-
-       temp16 = (u16) resource->data.fixed_io.base_address;
-
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
-
-       /* Set the range length */
-
-       temp8 = (u8) resource->data.fixed_io.range_length;
-
-       *buffer = temp8;
-       buffer += 1;
-
-       /* Return the number of bytes consumed in this operation */
-
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       ACPI_FUNCTION_TRACE("rs_set_fixed_io");
+
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Base Address
+        * Length
+        */
+       ACPI_MOVE_32_TO_16(&aml->fixed_io.address,
+                          &resource->data.fixed_io.address);
+       aml->fixed_io.address_length =
+           (u8) resource->data.fixed_io.address_length;
+
+       /* Complete the AML descriptor header */
+
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO,
+                                   sizeof(struct aml_resource_fixed_io), aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_dma_resource
+ * FUNCTION:    acpi_rs_get_dma
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_dma_resource(u8 * byte_stream_buffer,
-                    acpi_size * bytes_consumed,
-                    u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_dma(union aml_resource *aml,
+               u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u8 temp8 = 0;
-       u8 index;
-       u8 i;
-       acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
+       u32 channel_count = 0;
+       u32 i;
+       u8 temp8;
 
-       ACPI_FUNCTION_TRACE("rs_dma_resource");
-
-       /* The number of bytes consumed are Constant */
-
-       *bytes_consumed = 3;
-       output_struct->type = ACPI_RSTYPE_DMA;
-
-       /* Point to the 8-bits of Byte 1 */
-
-       buffer += 1;
-       temp8 = *buffer;
+       ACPI_FUNCTION_TRACE("rs_get_dma");
 
        /* Decode the DMA channel bits */
 
-       for (i = 0, index = 0; index < 8; index++) {
-               if ((temp8 >> index) & 0x01) {
-                       output_struct->data.dma.channels[i] = index;
-                       i++;
+       for (i = 0; i < 8; i++) {
+               if ((aml->dma.dma_channel_mask >> i) & 0x01) {
+                       resource->data.dma.channels[channel_count] = i;
+                       channel_count++;
                }
        }
 
-       /* Zero DMA channels is valid */
-
-       output_struct->data.dma.number_of_channels = i;
-       if (i > 0) {
-               /* Calculate the structure size based upon the number of interrupts */
+       resource->length = 0;
+       resource->data.dma.channel_count = channel_count;
 
-               struct_size += ((acpi_size) i - 1) * 4;
+       /*
+        * Calculate the structure size based upon the number of channels
+        * Note: Zero DMA channels is valid
+        */
+       if (channel_count > 0) {
+               resource->length = (u32) (channel_count - 1) * 4;
        }
 
-       /* Point to Byte 2 */
+       /* Get the flags: transfer preference, bus mastering, channel speed */
 
-       buffer += 1;
-       temp8 = *buffer;
+       temp8 = aml->dma.flags;
+       resource->data.dma.transfer = temp8 & 0x03;
+       resource->data.dma.bus_master = (temp8 >> 2) & 0x01;
+       resource->data.dma.type = (temp8 >> 5) & 0x03;
 
-       /* Check for transfer preference (Bits[1:0]) */
-
-       output_struct->data.dma.transfer = temp8 & 0x03;
-
-       if (0x03 == output_struct->data.dma.transfer) {
+       if (resource->data.dma.transfer == 0x03) {
                ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                  "Invalid DMA.Transfer preference (3)\n"));
                return_ACPI_STATUS(AE_BAD_DATA);
        }
 
-       /* Get bus master preference (Bit[2]) */
-
-       output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
-
-       /* Get channel speed support (Bits[6:5]) */
+       /* Complete the resource header */
 
-       output_struct->data.dma.type = (temp8 >> 5) & 0x03;
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_DMA;
+       resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_dma_stream
+ * FUNCTION:    acpi_rs_set_dma
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_dma_stream(struct acpi_resource *resource,
-                  u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       u8 index;
-
-       ACPI_FUNCTION_TRACE("rs_dma_stream");
-
-       /* The Descriptor Type field is static */
+       u8 i;
 
-       *buffer = ACPI_RDESC_TYPE_DMA_FORMAT | 0x02;
-       buffer += 1;
-       temp8 = 0;
+       ACPI_FUNCTION_TRACE("rs_set_dma");
 
-       /* Loop through all of the Channels and set the mask bits */
+       /* Convert channel list to 8-bit DMA channel bitmask */
 
-       for (index = 0; index < resource->data.dma.number_of_channels; index++) {
-               temp16 = (u16) resource->data.dma.channels[index];
-               temp8 |= 0x1 << temp16;
+       aml->dma.dma_channel_mask = 0;
+       for (i = 0; i < resource->data.dma.channel_count; i++) {
+               aml->dma.dma_channel_mask |=
+                   (1 << resource->data.dma.channels[i]);
        }
 
-       *buffer = temp8;
-       buffer += 1;
-
-       /* Set the DMA Info */
-
-       temp8 = (u8) ((resource->data.dma.type & 0x03) << 5);
-       temp8 |= ((resource->data.dma.bus_master & 0x01) << 2);
-       temp8 |= (resource->data.dma.transfer & 0x03);
+       /* Set the DMA Flag bits */
 
-       *buffer = temp8;
-       buffer += 1;
+       aml->dma.flags = (u8)
+           (((resource->data.dma.type & 0x03) << 5) |
+            ((resource->data.dma.bus_master & 0x01) << 2) |
+            (resource->data.dma.transfer & 0x03));
 
-       /* Return the number of bytes consumed in this operation */
+       /* Complete the AML descriptor header */
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA,
+                                   sizeof(struct aml_resource_dma), aml);
        return_ACPI_STATUS(AE_OK);
 }
index 75df962..4e854ba 100644 (file)
@@ -49,93 +49,67 @@ ACPI_MODULE_NAME("rsirq")
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_irq_resource
+ * FUNCTION:    acpi_rs_get_irq
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 acpi_status
-acpi_rs_irq_resource(u8 * byte_stream_buffer,
-                    acpi_size * bytes_consumed,
-                    u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_irq(union aml_resource *aml,
+               u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
        u16 temp16 = 0;
-       u8 temp8 = 0;
-       u8 index;
-       u8 i;
-       acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
-
-       ACPI_FUNCTION_TRACE("rs_irq_resource");
-
-       /*
-        * The number of bytes consumed are contained in the descriptor
-        * (Bits:0-1)
-        */
-       temp8 = *buffer;
-       *bytes_consumed = (temp8 & 0x03) + 1;
-       output_struct->type = ACPI_RSTYPE_IRQ;
+       u32 interrupt_count = 0;
+       u32 i;
+       u32 resource_length;
 
-       /* Point to the 16-bits of Bytes 1 and 2 */
+       ACPI_FUNCTION_TRACE("rs_get_irq");
 
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
+       /* Get the IRQ mask (bytes 1:2) */
 
-       output_struct->data.irq.number_of_interrupts = 0;
+       ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask);
 
-       /* Decode the IRQ bits */
+       /* Decode the IRQ bits (up to 16 possible) */
 
-       for (i = 0, index = 0; index < 16; index++) {
-               if ((temp16 >> index) & 0x01) {
-                       output_struct->data.irq.interrupts[i] = index;
-                       i++;
+       for (i = 0; i < 16; i++) {
+               if ((temp16 >> i) & 0x01) {
+                       resource->data.irq.interrupts[interrupt_count] = i;
+                       interrupt_count++;
                }
        }
 
        /* Zero interrupts is valid */
 
-       output_struct->data.irq.number_of_interrupts = i;
-       if (i > 0) {
+       resource_length = 0;
+       resource->data.irq.interrupt_count = interrupt_count;
+       if (interrupt_count > 0) {
                /* Calculate the structure size based upon the number of interrupts */
 
-               struct_size += ((acpi_size) i - 1) * 4;
+               resource_length = (u32) (interrupt_count - 1) * 4;
        }
 
-       /* Point to Byte 3 if it is used */
-
-       if (4 == *bytes_consumed) {
-               buffer += 2;
-               temp8 = *buffer;
+       /* Get Flags (Byte 3) if it is used */
 
+       if (aml_resource_length == 3) {
                /* Check for HE, LL interrupts */
 
-               switch (temp8 & 0x09) {
+               switch (aml->irq.flags & 0x09) {
                case 0x01:      /* HE */
-                       output_struct->data.irq.edge_level =
-                           ACPI_EDGE_SENSITIVE;
-                       output_struct->data.irq.active_high_low =
-                           ACPI_ACTIVE_HIGH;
+                       resource->data.irq.triggering = ACPI_EDGE_SENSITIVE;
+                       resource->data.irq.polarity = ACPI_ACTIVE_HIGH;
                        break;
 
                case 0x08:      /* LL */
-                       output_struct->data.irq.edge_level =
-                           ACPI_LEVEL_SENSITIVE;
-                       output_struct->data.irq.active_high_low =
-                           ACPI_ACTIVE_LOW;
+                       resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE;
+                       resource->data.irq.polarity = ACPI_ACTIVE_LOW;
                        break;
 
                default:
@@ -146,170 +120,131 @@ acpi_rs_irq_resource(u8 * byte_stream_buffer,
                         */
                        ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                          "Invalid interrupt polarity/trigger in resource list, %X\n",
-                                         temp8));
+                                         aml->irq.flags));
                        return_ACPI_STATUS(AE_BAD_DATA);
                }
 
-               /* Check for sharable */
+               /* Get Sharing flag */
 
-               output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
+               resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01;
        } else {
                /*
-                * Assume Edge Sensitive, Active High, Non-Sharable
-                * per ACPI Specification
+                * Default configuration: assume Edge Sensitive, Active High,
+                * Non-Sharable as per the ACPI Specification
                 */
-               output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
-               output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
-               output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
+               resource->data.irq.triggering = ACPI_EDGE_SENSITIVE;
+               resource->data.irq.polarity = ACPI_ACTIVE_HIGH;
+               resource->data.irq.sharable = ACPI_EXCLUSIVE;
        }
 
-       /* Set the Length parameter */
+       /* Complete the resource header */
 
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_IRQ;
+       resource->length =
+           resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_irq_stream
+ * FUNCTION:    acpi_rs_set_irq
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_irq_stream(struct acpi_resource *resource,
-                  u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       u8 index;
-       u8 IRqinfo_byte_needed;
+       acpi_size descriptor_length;
+       u16 irq_mask;
+       u8 i;
+
+       ACPI_FUNCTION_TRACE("rs_set_irq");
 
-       ACPI_FUNCTION_TRACE("rs_irq_stream");
+       /* Convert interrupt list to 16-bit IRQ bitmask */
+
+       irq_mask = 0;
+       for (i = 0; i < resource->data.irq.interrupt_count; i++) {
+               irq_mask |= (1 << resource->data.irq.interrupts[i]);
+       }
+
+       /* Set the interrupt mask */
+
+       ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask);
 
        /*
         * The descriptor field is set based upon whether a third byte is
         * needed to contain the IRQ Information.
         */
-       if (ACPI_EDGE_SENSITIVE == resource->data.irq.edge_level &&
-           ACPI_ACTIVE_HIGH == resource->data.irq.active_high_low &&
-           ACPI_EXCLUSIVE == resource->data.irq.shared_exclusive) {
-               *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x02;
-               IRqinfo_byte_needed = FALSE;
-       } else {
-               *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x03;
-               IRqinfo_byte_needed = TRUE;
-       }
-
-       buffer += 1;
-       temp16 = 0;
-
-       /* Loop through all of the interrupts and set the mask bits */
+       if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) &&
+           (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) &&
+           (resource->data.irq.sharable == ACPI_EXCLUSIVE)) {
+               /* irq_no_flags() descriptor can be used */
 
-       for (index = 0;
-            index < resource->data.irq.number_of_interrupts; index++) {
-               temp8 = (u8) resource->data.irq.interrupts[index];
-               temp16 |= 0x1 << temp8;
-       }
+               descriptor_length = sizeof(struct aml_resource_irq_noflags);
+       } else {
+               /* Irq() descriptor must be used */
 
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
+               descriptor_length = sizeof(struct aml_resource_irq);
 
-       /* Set the IRQ Info byte if needed. */
+               /* Set the IRQ Info byte */
 
-       if (IRqinfo_byte_needed) {
-               temp8 = 0;
-               temp8 = (u8) ((resource->data.irq.shared_exclusive &
-                              0x01) << 4);
+               aml->irq.flags = (u8)
+                   ((resource->data.irq.sharable & 0x01) << 4);
 
-               if (ACPI_LEVEL_SENSITIVE == resource->data.irq.edge_level &&
-                   ACPI_ACTIVE_LOW == resource->data.irq.active_high_low) {
-                       temp8 |= 0x08;
+               if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering &&
+                   ACPI_ACTIVE_LOW == resource->data.irq.polarity) {
+                       aml->irq.flags |= 0x08;
                } else {
-                       temp8 |= 0x01;
+                       aml->irq.flags |= 0x01;
                }
-
-               *buffer = temp8;
-               buffer += 1;
        }
 
-       /* Return the number of bytes consumed in this operation */
+       /* Complete the AML descriptor header */
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length,
+                                   aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_extended_irq_resource
+ * FUNCTION:    acpi_rs_get_ext_irq
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
-                             acpi_size * bytes_consumed,
-                             u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_ext_irq(union aml_resource *aml,
+                   u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       u8 *temp_ptr;
-       u8 index;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq);
-
-       ACPI_FUNCTION_TRACE("rs_extended_irq_resource");
+       char *out_resource_string;
+       u8 temp8;
 
-       /* Get the Descriptor Length field */
+       ACPI_FUNCTION_TRACE("rs_get_ext_irq");
 
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
+       /* Get the flag bits */
 
-       /* Validate minimum descriptor length */
-
-       if (temp16 < 6) {
-               return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
-       }
-
-       *bytes_consumed = temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_EXT_IRQ;
-
-       /* Point to the Byte3 */
-
-       buffer += 2;
-       temp8 = *buffer;
-
-       output_struct->data.extended_irq.producer_consumer = temp8 & 0x01;
+       temp8 = aml->extended_irq.flags;
+       resource->data.extended_irq.producer_consumer = temp8 & 0x01;
+       resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01;
+       resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01;
 
        /*
         * Check for Interrupt Mode
@@ -319,165 +254,80 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
         *
         * - Edge/Level are defined opposite in the table vs the headers
         */
-       output_struct->data.extended_irq.edge_level =
+       resource->data.extended_irq.triggering =
            (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
 
-       /* Check Interrupt Polarity */
-
-       output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
-
-       /* Check for sharable */
-
-       output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
-
-       /* Point to Byte4 (IRQ Table length) */
-
-       buffer += 1;
-       temp8 = *buffer;
-
-       /* Must have at least one IRQ */
+       /* Get the IRQ Table length (Byte4) */
 
+       temp8 = aml->extended_irq.table_length;
+       resource->data.extended_irq.interrupt_count = temp8;
        if (temp8 < 1) {
+               /* Must have at least one IRQ */
+
                return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
        }
 
-       output_struct->data.extended_irq.number_of_interrupts = temp8;
-
        /*
         * Add any additional structure size to properly calculate
         * the next pointer at the end of this function
         */
-       struct_size += (temp8 - 1) * 4;
+       resource->length = (temp8 - 1) * 4;
+       out_resource_string = ACPI_CAST_PTR(char,
+                                           (&resource->data.extended_irq.
+                                            interrupts[0] + temp8));
 
-       /* Point to Byte5 (First IRQ Number) */
+       /* Get every IRQ in the table, each is 32 bits */
 
-       buffer += 1;
+       acpi_rs_move_data(resource->data.extended_irq.interrupts,
+                         aml->extended_irq.interrupt_number,
+                         (u16) temp8, ACPI_MOVE_TYPE_32_TO_32);
 
-       /* Cycle through every IRQ in the table */
+       /* Get the optional resource_source (index and string) */
 
-       for (index = 0; index < temp8; index++) {
-               ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq.
-                                  interrupts[index], buffer);
+       resource->length +=
+           acpi_rs_get_resource_source(aml_resource_length,
+                                       (acpi_size) resource->length +
+                                       sizeof(struct
+                                              aml_resource_extended_irq),
+                                       &resource->data.extended_irq.
+                                       resource_source, aml,
+                                       out_resource_string);
 
-               /* Point to the next IRQ */
+       /* Complete the resource header */
 
-               buffer += 4;
-       }
-
-       /*
-        * This will leave us pointing to the Resource Source Index
-        * If it is present, then save it off and calculate the
-        * pointer to where the null terminated string goes:
-        * Each Interrupt takes 32-bits + the 5 bytes of the
-        * stream that are default.
-        *
-        * Note: Some resource descriptors will have an additional null, so
-        * we add 1 to the length.
-        */
-       if (*bytes_consumed >
-           ((acpi_size) output_struct->data.extended_irq.number_of_interrupts *
-            4) + (5 + 1)) {
-               /* Dereference the Index */
-
-               temp8 = *buffer;
-               output_struct->data.extended_irq.resource_source.index =
-                   (u32) temp8;
-
-               /* Point to the String */
-
-               buffer += 1;
-
-               /* Point the String pointer to the end of this structure. */
-
-               output_struct->data.extended_irq.resource_source.string_ptr =
-                   (char *)((char *)output_struct + struct_size);
-
-               temp_ptr = (u8 *)
-                   output_struct->data.extended_irq.resource_source.string_ptr;
-
-               /* Copy the string into the buffer */
-
-               index = 0;
-               while (*buffer) {
-                       *temp_ptr = *buffer;
-
-                       temp_ptr += 1;
-                       buffer += 1;
-                       index += 1;
-               }
-
-               /* Add the terminating null */
-
-               *temp_ptr = 0;
-               output_struct->data.extended_irq.resource_source.string_length =
-                   index + 1;
-
-               /*
-                * In order for the struct_size to fall on a 32-bit boundary,
-                * calculate the length of the string and expand the
-                * struct_size to the next 32-bit boundary.
-                */
-               temp8 = (u8) (index + 1);
-               struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
-       } else {
-               output_struct->data.extended_irq.resource_source.index = 0;
-               output_struct->data.extended_irq.resource_source.string_length =
-                   0;
-               output_struct->data.extended_irq.resource_source.string_ptr =
-                   NULL;
-       }
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
+       resource->length +=
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_extended_irq_stream
+ * FUNCTION:    acpi_rs_set_ext_irq
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_extended_irq_stream(struct acpi_resource *resource,
-                           u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 *length_field;
-       u8 temp8 = 0;
-       u8 index;
-
-       ACPI_FUNCTION_TRACE("rs_extended_irq_stream");
-
-       /* Set the Descriptor Type field */
-
-       *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT;
-       buffer += 1;
+       acpi_size descriptor_length;
 
-       /* Save a pointer to the Length field - to be filled in later */
-
-       length_field = ACPI_CAST_PTR(u16, buffer);
-       buffer += 2;
+       ACPI_FUNCTION_TRACE("rs_set_ext_irq");
 
        /* Set the Interrupt vector flags */
 
-       temp8 = (u8) (resource->data.extended_irq.producer_consumer & 0x01);
-       temp8 |= ((resource->data.extended_irq.shared_exclusive & 0x01) << 3);
+       aml->extended_irq.flags = (u8)
+           ((resource->data.extended_irq.producer_consumer & 0x01) |
+            ((resource->data.extended_irq.sharable & 0x01) << 3) |
+            ((resource->data.extended_irq.polarity & 0x1) << 2));
 
        /*
         * Set the Interrupt Mode
@@ -488,64 +338,36 @@ acpi_rs_extended_irq_stream(struct acpi_resource *resource,
         *
         * - Edge/Level are defined opposite in the table vs the headers
         */
-       if (ACPI_EDGE_SENSITIVE == resource->data.extended_irq.edge_level) {
-               temp8 |= 0x2;
+       if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) {
+               aml->extended_irq.flags |= 0x02;
        }
 
-       /* Set the Interrupt Polarity */
-
-       temp8 |= ((resource->data.extended_irq.active_high_low & 0x1) << 2);
-
-       *buffer = temp8;
-       buffer += 1;
-
        /* Set the Interrupt table length */
 
-       temp8 = (u8) resource->data.extended_irq.number_of_interrupts;
-
-       *buffer = temp8;
-       buffer += 1;
+       aml->extended_irq.table_length = (u8)
+           resource->data.extended_irq.interrupt_count;
 
-       for (index = 0;
-            index < resource->data.extended_irq.number_of_interrupts;
-            index++) {
-               ACPI_MOVE_32_TO_32(buffer,
-                                  &resource->data.extended_irq.
-                                  interrupts[index]);
-               buffer += 4;
-       }
-
-       /* Resource Source Index and Resource Source are optional */
+       descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) +
+           ((acpi_size) resource->data.extended_irq.interrupt_count *
+            sizeof(u32));
 
-       if (0 != resource->data.extended_irq.resource_source.string_length) {
-               *buffer =
-                   (u8) resource->data.extended_irq.resource_source.index;
-               buffer += 1;
+       /* Set each interrupt value */
 
-               /* Copy the string */
+       acpi_rs_move_data(aml->extended_irq.interrupt_number,
+                         resource->data.extended_irq.interrupts,
+                         (u16) resource->data.extended_irq.interrupt_count,
+                         ACPI_MOVE_TYPE_32_TO_32);
 
-               ACPI_STRCPY((char *)buffer,
-                           resource->data.extended_irq.resource_source.
-                           string_ptr);
-
-               /*
-                * Buffer needs to be set to the length of the string + one for the
-                * terminating null
-                */
-               buffer +=
-                   (acpi_size) (ACPI_STRLEN
-                                (resource->data.extended_irq.resource_source.
-                                 string_ptr) + 1);
-       }
+       /* Resource Source Index and Resource Source are optional */
 
-       /* Return the number of bytes consumed in this operation */
+       descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length,
+                                                       &resource->data.
+                                                       extended_irq.
+                                                       resource_source);
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       /* Complete the AML descriptor header */
 
-       /*
-        * Set the length field to the number of bytes consumed
-        * minus the header size (3 bytes)
-        */
-       *length_field = (u16) (*bytes_consumed - 3);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ,
+                                   descriptor_length, aml);
        return_ACPI_STATUS(AE_OK);
 }
index 87e7534..f72d42e 100644 (file)
 #define _COMPONENT          ACPI_RESOURCES
 ACPI_MODULE_NAME("rslist")
 
-/* Dispatch table for convert-to-stream functions */
-typedef
-acpi_status(*ACPI_STREAM_HANDLER) (struct acpi_resource * resource,
-                                  u8 ** output_buffer,
-                                  acpi_size * bytes_consumed);
-
-static ACPI_STREAM_HANDLER acpi_gbl_stream_dispatch[] = {
-       acpi_rs_irq_stream,     /* ACPI_RSTYPE_IRQ */
-       acpi_rs_dma_stream,     /* ACPI_RSTYPE_DMA */
-       acpi_rs_start_depend_fns_stream,        /* ACPI_RSTYPE_START_DPF */
-       acpi_rs_end_depend_fns_stream,  /* ACPI_RSTYPE_END_DPF */
-       acpi_rs_io_stream,      /* ACPI_RSTYPE_IO */
-       acpi_rs_fixed_io_stream,        /* ACPI_RSTYPE_FIXED_IO */
-       acpi_rs_vendor_stream,  /* ACPI_RSTYPE_VENDOR */
-       acpi_rs_end_tag_stream, /* ACPI_RSTYPE_END_TAG */
-       acpi_rs_memory24_stream,        /* ACPI_RSTYPE_MEM24 */
-       acpi_rs_memory32_range_stream,  /* ACPI_RSTYPE_MEM32 */
-       acpi_rs_fixed_memory32_stream,  /* ACPI_RSTYPE_FIXED_MEM32 */
-       acpi_rs_address16_stream,       /* ACPI_RSTYPE_ADDRESS16 */
-       acpi_rs_address32_stream,       /* ACPI_RSTYPE_ADDRESS32 */
-       acpi_rs_address64_stream,       /* ACPI_RSTYPE_ADDRESS64 */
-       acpi_rs_extended_irq_stream,    /* ACPI_RSTYPE_EXT_IRQ */
-       acpi_rs_generic_register_stream /* ACPI_RSTYPE_GENERIC_REG */
-};
-
-/* Dispatch tables for convert-to-resource functions */
-
-typedef
-acpi_status(*ACPI_RESOURCE_HANDLER) (u8 * byte_stream_buffer,
-                                    acpi_size * bytes_consumed,
-                                    u8 ** output_buffer,
-                                    acpi_size * structure_size);
-
-static ACPI_RESOURCE_HANDLER acpi_gbl_sm_resource_dispatch[] = {
-       NULL,                   /* 0x00, Reserved */
-       NULL,                   /* 0x01, Reserved */
-       NULL,                   /* 0x02, Reserved */
-       NULL,                   /* 0x03, Reserved */
-       acpi_rs_irq_resource,   /* ACPI_RDESC_TYPE_IRQ_FORMAT */
-       acpi_rs_dma_resource,   /* ACPI_RDESC_TYPE_DMA_FORMAT */
-       acpi_rs_start_depend_fns_resource,      /* ACPI_RDESC_TYPE_START_DEPENDENT */
-       acpi_rs_end_depend_fns_resource,        /* ACPI_RDESC_TYPE_END_DEPENDENT */
-       acpi_rs_io_resource,    /* ACPI_RDESC_TYPE_IO_PORT */
-       acpi_rs_fixed_io_resource,      /* ACPI_RDESC_TYPE_FIXED_IO_PORT */
-       NULL,                   /* 0x0A, Reserved */
-       NULL,                   /* 0x0B, Reserved */
-       NULL,                   /* 0x0C, Reserved */
-       NULL,                   /* 0x0D, Reserved */
-       acpi_rs_vendor_resource,        /* ACPI_RDESC_TYPE_SMALL_VENDOR */
-       acpi_rs_end_tag_resource        /* ACPI_RDESC_TYPE_END_TAG */
-};
-
-static ACPI_RESOURCE_HANDLER acpi_gbl_lg_resource_dispatch[] = {
-       NULL,                   /* 0x00, Reserved */
-       acpi_rs_memory24_resource,      /* ACPI_RDESC_TYPE_MEMORY_24 */
-       acpi_rs_generic_register_resource,      /* ACPI_RDESC_TYPE_GENERIC_REGISTER */
-       NULL,                   /* 0x03, Reserved */
-       acpi_rs_vendor_resource,        /* ACPI_RDESC_TYPE_LARGE_VENDOR */
-       acpi_rs_memory32_range_resource,        /* ACPI_RDESC_TYPE_MEMORY_32 */
-       acpi_rs_fixed_memory32_resource,        /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */
-       acpi_rs_address32_resource,     /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */
-       acpi_rs_address16_resource,     /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */
-       acpi_rs_extended_irq_resource,  /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */
-       acpi_rs_address64_resource,     /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */
-       acpi_rs_address64_resource      /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */
-};
-
 /* Local prototypes */
+static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type);
 
-static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type);
+static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml);
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_get_resource_type
+ * FUNCTION:    acpi_rs_validate_resource_length
  *
- * PARAMETERS:  resource_type       - Byte 0 of a resource descriptor
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
  *
- * RETURN:      The Resource Type with no extraneous bits (except the large/
- *              small bit -- left alone)
+ * RETURN:      Status - AE_OK if the resource length appears valid
  *
- * DESCRIPTION: Extract the Resource Type/Name from the first byte of
- *              a resource descriptor.
+ * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must
+ *              have the exact length; variable-length descriptors must be
+ *              at least as long as the minimum. Certain Small descriptors
+ *              can vary in size by at most one byte.
  *
  ******************************************************************************/
 
-u8 acpi_rs_get_resource_type(u8 resource_type)
+static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml)
 {
+       struct acpi_resource_info *resource_info;
+       u16 minimum_aml_resource_length;
+       u16 resource_length;
+
        ACPI_FUNCTION_ENTRY();
 
-       /* Determine if this is a small or large resource */
+       /* Get the size and type info about this resource descriptor */
 
-       if (resource_type & ACPI_RDESC_TYPE_LARGE) {
-               /* Large Resource Type -- bits 6:0 contain the name */
+       resource_info =
+           acpi_rs_get_resource_info(aml->small_header.descriptor_type);
+       if (!resource_info) {
+               return (AE_AML_INVALID_RESOURCE_TYPE);
+       }
+
+       resource_length = acpi_rs_get_resource_length(aml);
+       minimum_aml_resource_length =
+           resource_info->minimum_aml_resource_length;
+
+       /* Validate based upon the type of resource, fixed length or variable */
+
+       if (resource_info->length_type == ACPI_FIXED_LENGTH) {
+               /* Fixed length resource, length must match exactly */
 
-               return (resource_type);
+               if (resource_length != minimum_aml_resource_length) {
+                       return (AE_AML_BAD_RESOURCE_LENGTH);
+               }
+       } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) {
+               /* Variable length resource, must be at least the minimum */
+
+               if (resource_length < minimum_aml_resource_length) {
+                       return (AE_AML_BAD_RESOURCE_LENGTH);
+               }
        } else {
-               /* Small Resource Type -- bits 6:3 contain the name */
+               /* Small variable length resource, allowed to be (Min) or (Min-1) */
 
-               return ((u8) (resource_type & ACPI_RDESC_SMALL_MASK));
+               if ((resource_length > minimum_aml_resource_length) ||
+                   (resource_length < (minimum_aml_resource_length - 1))) {
+                       return (AE_AML_BAD_RESOURCE_LENGTH);
+               }
        }
+
+       return (AE_OK);
 }
 
 /*******************************************************************************
@@ -162,38 +126,38 @@ u8 acpi_rs_get_resource_type(u8 resource_type)
  *
  ******************************************************************************/
 
-static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type)
+static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type)
 {
        ACPI_FUNCTION_ENTRY();
 
        /* Determine if this is a small or large resource */
 
-       if (resource_type & ACPI_RDESC_TYPE_LARGE) {
+       if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
                /* Large Resource Type -- bits 6:0 contain the name */
 
-               if (resource_type > ACPI_RDESC_LARGE_MAX) {
+               if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
                        return (NULL);
                }
 
-               return (acpi_gbl_lg_resource_dispatch[(resource_type &
-                                                      ACPI_RDESC_LARGE_MASK)]);
+               return (acpi_gbl_lg_get_resource_dispatch[(resource_type &
+                                                          ACPI_RESOURCE_NAME_LARGE_MASK)]);
        } else {
                /* Small Resource Type -- bits 6:3 contain the name */
 
-               return (acpi_gbl_sm_resource_dispatch[((resource_type &
-                                                       ACPI_RDESC_SMALL_MASK)
-                                                      >> 3)]);
+               return (acpi_gbl_sm_get_resource_dispatch[((resource_type &
+                                                           ACPI_RESOURCE_NAME_SMALL_MASK)
+                                                          >> 3)]);
        }
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_byte_stream_to_list
+ * FUNCTION:    acpi_rs_convert_aml_to_resources
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource byte stream
- *              byte_stream_buffer_length - Length of byte_stream_buffer
- *              output_buffer           - Pointer to the buffer that will
- *                                        contain the output structures
+ * PARAMETERS:  aml_buffer          - Pointer to the resource byte stream
+ *              aml_buffer_length   - Length of aml_buffer
+ *              output_buffer       - Pointer to the buffer that will
+ *                                    contain the output structures
  *
  * RETURN:      Status
  *
@@ -203,37 +167,60 @@ static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type)
  ******************************************************************************/
 
 acpi_status
-acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
-                           u32 byte_stream_buffer_length, u8 * output_buffer)
+acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
+                                u32 aml_buffer_length, u8 * output_buffer)
 {
        u8 *buffer = output_buffer;
        acpi_status status;
        acpi_size bytes_parsed = 0;
-       acpi_size bytes_consumed = 0;
-       acpi_size structure_size = 0;
        struct acpi_resource *resource;
-       ACPI_RESOURCE_HANDLER handler;
+       u16 resource_length;
+       u32 descriptor_length;
+       ACPI_GET_RESOURCE_HANDLER handler;
 
-       ACPI_FUNCTION_TRACE("rs_byte_stream_to_list");
+       ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
 
        /* Loop until end-of-buffer or an end_tag is found */
 
-       while (bytes_parsed < byte_stream_buffer_length) {
+       while (bytes_parsed < aml_buffer_length) {
                /* Get the handler associated with this Descriptor Type */
 
-               handler = acpi_rs_get_resource_handler(*byte_stream_buffer);
-               if (handler) {
-                       /* Convert a byte stream resource to local resource struct */
+               handler = acpi_rs_get_resource_handler(*aml_buffer);
+               if (!handler) {
+                       /* No handler indicates invalid resource type */
 
-                       status = handler(byte_stream_buffer, &bytes_consumed,
-                                        &buffer, &structure_size);
-               } else {
-                       /* Invalid resource type */
+                       return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
+               }
 
-                       status = AE_AML_INVALID_RESOURCE_TYPE;
+               resource_length =
+                   acpi_rs_get_resource_length(ACPI_CAST_PTR
+                                               (union aml_resource,
+                                                aml_buffer));
+
+               descriptor_length =
+                   acpi_rs_get_descriptor_length(ACPI_CAST_PTR
+                                                 (union aml_resource,
+                                                  aml_buffer));
+
+               /*
+                * Perform limited validation of the resource length, based upon
+                * what we know about the resource type
+                */
+               status =
+                   acpi_rs_validate_resource_length(ACPI_CAST_PTR
+                                                    (union aml_resource,
+                                                     aml_buffer));
+               if (ACPI_FAILURE(status)) {
+                       return_ACPI_STATUS(status);
                }
 
+               /* Convert a byte stream resource to local resource struct */
+
+               status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer),
+                                resource_length,
+                                ACPI_CAST_PTR(struct acpi_resource, buffer));
                if (ACPI_FAILURE(status)) {
+                       ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status)));
                        return_ACPI_STATUS(status);
                }
 
@@ -245,19 +232,19 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
 
                /* Normal exit on completion of an end_tag resource descriptor */
 
-               if (acpi_rs_get_resource_type(*byte_stream_buffer) ==
-                   ACPI_RDESC_TYPE_END_TAG) {
+               if (acpi_rs_get_resource_type(*aml_buffer) ==
+                   ACPI_RESOURCE_NAME_END_TAG) {
                        return_ACPI_STATUS(AE_OK);
                }
 
                /* Update counter and point to the next input resource */
 
-               bytes_parsed += bytes_consumed;
-               byte_stream_buffer += bytes_consumed;
+               bytes_parsed += descriptor_length;
+               aml_buffer += descriptor_length;
 
                /* Point to the next structure in the output buffer */
 
-               buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
+               buffer += resource->length;
        }
 
        /* Completed buffer, but did not find an end_tag resource descriptor */
@@ -267,17 +254,15 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_list_to_byte_stream
+ * FUNCTION:    acpi_rs_convert_resources_to_aml
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              byte_steam_size_needed  - Calculated size of the byte stream
- *                                        needed from calling
- *                                        acpi_rs_get_byte_stream_length()
- *                                        The size of the output_buffer is
- *                                        guaranteed to be >=
- *                                        byte_stream_size_needed
- *              output_buffer           - Pointer to the buffer that will
- *                                        contain the byte stream
+ * PARAMETERS:  Resource            - Pointer to the resource linked list
+ *              aml_size_needed     - Calculated size of the byte stream
+ *                                    needed from calling acpi_rs_get_aml_length()
+ *                                    The size of the output_buffer is
+ *                                    guaranteed to be >= aml_size_needed
+ *              output_buffer       - Pointer to the buffer that will
+ *                                    contain the byte stream
  *
  * RETURN:      Status
  *
@@ -287,52 +272,69 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
  ******************************************************************************/
 
 acpi_status
-acpi_rs_list_to_byte_stream(struct acpi_resource *resource,
-                           acpi_size byte_stream_size_needed,
-                           u8 * output_buffer)
+acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
+                                acpi_size aml_size_needed, u8 * output_buffer)
 {
-       u8 *buffer = output_buffer;
-       acpi_size bytes_consumed = 0;
+       u8 *aml_buffer = output_buffer;
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("rs_list_to_byte_stream");
+       ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
 
        /* Convert each resource descriptor in the list */
 
        while (1) {
-               /* Validate Type before dispatch */
+               /* Validate Resource Descriptor Type before dispatch */
 
-               if (resource->type > ACPI_RSTYPE_MAX) {
+               if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
                        ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                                          "Invalid descriptor type (%X) in resource list\n",
                                          resource->type));
                        return_ACPI_STATUS(AE_BAD_DATA);
                }
 
-               /* Perform the conversion, per resource type */
+               /* Perform the conversion per resource type */
+
+               status =
+                   acpi_gbl_set_resource_dispatch[resource->type] (resource,
+                                                                   ACPI_CAST_PTR
+                                                                   (union
+                                                                    aml_resource,
+                                                                    aml_buffer));
+               if (ACPI_FAILURE(status)) {
+                       ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status)));
+                       return_ACPI_STATUS(status);
+               }
+
+               /* Perform final sanity check on the new AML resource descriptor */
 
-               status = acpi_gbl_stream_dispatch[resource->type] (resource,
-                                                                  &buffer,
-                                                                  &bytes_consumed);
+               status =
+                   acpi_rs_validate_resource_length(ACPI_CAST_PTR
+                                                    (union aml_resource,
+                                                     aml_buffer));
                if (ACPI_FAILURE(status)) {
                        return_ACPI_STATUS(status);
                }
 
-               /* Check for end-of-list */
+               /* Check for end-of-list, normal exit */
 
-               if (resource->type == ACPI_RSTYPE_END_TAG) {
-                       /* An End Tag indicates the end of the Resource Template */
+               if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
+                       /* An End Tag indicates the end of the input Resource Template */
 
                        return_ACPI_STATUS(AE_OK);
                }
 
-               /* Set the Buffer to point to the next (output) resource descriptor */
+               /* Extract the total length of the new descriptor */
+               /* Set the aml_buffer to point to the next (output) resource descriptor */
 
-               buffer += bytes_consumed;
+               aml_buffer +=
+                   acpi_rs_get_descriptor_length(ACPI_CAST_PTR
+                                                 (union aml_resource,
+                                                  aml_buffer));
 
-               /* Point to the next input resource object */
+               /* Point to the next input resource descriptor */
 
-               resource = ACPI_PTR_ADD(struct acpi_resource,
-                                       resource, resource->length);
+               resource =
+                   ACPI_PTR_ADD(struct acpi_resource, resource,
+                                resource->length);
        }
 }
index 418f1af..47e979e 100644 (file)
@@ -49,446 +49,260 @@ ACPI_MODULE_NAME("rsmemory")
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_memory24_resource
+ * FUNCTION:    acpi_rs_get_memory24
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 acpi_status
-acpi_rs_memory24_resource(u8 * byte_stream_buffer,
-                         acpi_size * bytes_consumed,
-                         u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_memory24(union aml_resource * aml,
+                    u16 aml_resource_length, struct acpi_resource * resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
+       ACPI_FUNCTION_TRACE("rs_get_memory24");
 
-       ACPI_FUNCTION_TRACE("rs_memory24_resource");
+       /* Get the Read/Write bit */
 
-       /* Point past the Descriptor to get the number of bytes consumed */
+       resource->data.memory24.read_write_attribute =
+           (aml->memory24.information & 0x01);
 
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       buffer += 2;
-       *bytes_consumed = (acpi_size) temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_MEM24;
-
-       /* Check Byte 3 the Read/Write bit */
-
-       temp8 = *buffer;
-       buffer += 1;
-       output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
-
-       /* Get min_base_address (Bytes 4-5) */
-
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-       buffer += 2;
-       output_struct->data.memory24.min_base_address = temp16;
-
-       /* Get max_base_address (Bytes 6-7) */
-
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-       buffer += 2;
-       output_struct->data.memory24.max_base_address = temp16;
-
-       /* Get Alignment (Bytes 8-9) */
-
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-       buffer += 2;
-       output_struct->data.memory24.alignment = temp16;
-
-       /* Get range_length (Bytes 10-11) */
-
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-       output_struct->data.memory24.range_length = temp16;
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
+       /*
+        * Get the following contiguous fields from the AML descriptor:
+        * Minimum Base Address
+        * Maximum Base Address
+        * Address Base Alignment
+        * Range Length
+        */
+       acpi_rs_move_data(&resource->data.memory24.minimum,
+                         &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32);
 
-       /* Return the final size of the structure */
+       /* Complete the resource header */
 
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
+       resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_memory24_stream
+ * FUNCTION:    acpi_rs_set_memory24
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_memory24_stream(struct acpi_resource *resource,
-                       u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-
-       ACPI_FUNCTION_TRACE("rs_memory24_stream");
-
-       /* The Descriptor Type field is static */
-
-       *buffer = ACPI_RDESC_TYPE_MEMORY_24;
-       buffer += 1;
-
-       /* The length field is static */
-
-       temp16 = 0x09;
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
+       ACPI_FUNCTION_TRACE("rs_set_memory24");
 
        /* Set the Information Byte */
 
-       temp8 = (u8) (resource->data.memory24.read_write_attribute & 0x01);
-       *buffer = temp8;
-       buffer += 1;
-
-       /* Set the Range minimum base address */
+       aml->memory24.information = (u8)
+           (resource->data.memory24.read_write_attribute & 0x01);
 
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.min_base_address);
-       buffer += 2;
-
-       /* Set the Range maximum base address */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.max_base_address);
-       buffer += 2;
-
-       /* Set the base alignment */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.alignment);
-       buffer += 2;
-
-       /* Set the range length */
-
-       ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.range_length);
-       buffer += 2;
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Minimum Base Address
+        * Maximum Base Address
+        * Address Base Alignment
+        * Range Length
+        */
+       acpi_rs_move_data(&aml->memory24.minimum,
+                         &resource->data.memory24.minimum, 4,
+                         ACPI_MOVE_TYPE_32_TO_16);
 
-       /* Return the number of bytes consumed in this operation */
+       /* Complete the AML descriptor header */
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24,
+                                   sizeof(struct aml_resource_memory24), aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_memory32_range_resource
+ * FUNCTION:    acpi_rs_get_memory32
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_memory32_range_resource(u8 * byte_stream_buffer,
-                               acpi_size * bytes_consumed,
-                               u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_memory32(union aml_resource *aml,
+                    u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
-
-       ACPI_FUNCTION_TRACE("rs_memory32_range_resource");
+       ACPI_FUNCTION_TRACE("rs_get_memory32");
 
-       /* Point past the Descriptor to get the number of bytes consumed */
+       /* Get the Read/Write bit */
 
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       buffer += 2;
-       *bytes_consumed = (acpi_size) temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_MEM32;
+       resource->data.memory32.read_write_attribute =
+           (aml->memory32.information & 0x01);
 
        /*
-        *  Point to the place in the output buffer where the data portion will
-        *  begin.
-        *  1. Set the RESOURCE_DATA * Data to point to its own address, then
-        *  2. Set the pointer to the next address.
-        *
-        *  NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
-        *  4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
+        * Get the following contiguous fields from the AML descriptor:
+        * Minimum Base Address
+        * Maximum Base Address
+        * Address Base Alignment
+        * Range Length
         */
+       acpi_rs_move_data(&resource->data.memory32.minimum,
+                         &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32);
 
-       /* Check Byte 3 the Read/Write bit */
-
-       temp8 = *buffer;
-       buffer += 1;
-
-       output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
-
-       /* Get min_base_address (Bytes 4-7) */
-
-       ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address,
-                          buffer);
-       buffer += 4;
-
-       /* Get max_base_address (Bytes 8-11) */
-
-       ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address,
-                          buffer);
-       buffer += 4;
-
-       /* Get Alignment (Bytes 12-15) */
-
-       ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer);
-       buffer += 4;
-
-       /* Get range_length (Bytes 16-19) */
-
-       ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer);
-
-       /* Set the Length parameter */
+       /* Complete the resource header */
 
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
+       resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_fixed_memory32_resource
+ * FUNCTION:    acpi_rs_set_memory32
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer,
-                               acpi_size * bytes_consumed,
-                               u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32);
-
-       ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource");
-
-       /* Point past the Descriptor to get the number of bytes consumed */
-
-       buffer += 1;
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-       buffer += 2;
-       *bytes_consumed = (acpi_size) temp16 + 3;
-       output_struct->type = ACPI_RSTYPE_FIXED_MEM32;
-
-       /* Check Byte 3 the Read/Write bit */
-
-       temp8 = *buffer;
-       buffer += 1;
-       output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
-
-       /* Get range_base_address (Bytes 4-7) */
-
-       ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.
-                          range_base_address, buffer);
-       buffer += 4;
-
-       /* Get range_length (Bytes 8-11) */
+       ACPI_FUNCTION_TRACE("rs_set_memory32");
 
-       ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length,
-                          buffer);
+       /* Set the Information Byte */
 
-       /* Set the Length parameter */
+       aml->memory32.information = (u8)
+           (resource->data.memory32.read_write_attribute & 0x01);
 
-       output_struct->length = (u32) struct_size;
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Minimum Base Address
+        * Maximum Base Address
+        * Address Base Alignment
+        * Range Length
+        */
+       acpi_rs_move_data(&aml->memory32.minimum,
+                         &resource->data.memory32.minimum, 4,
+                         ACPI_MOVE_TYPE_32_TO_32);
 
-       /* Return the final size of the structure */
+       /* Complete the AML descriptor header */
 
-       *structure_size = struct_size;
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32,
+                                   sizeof(struct aml_resource_memory32), aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_memory32_range_stream
+ * FUNCTION:    acpi_rs_get_fixed_memory32
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_memory32_range_stream(struct acpi_resource *resource,
-                             u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_get_fixed_memory32(union aml_resource *aml,
+                          u16 aml_resource_length,
+                          struct acpi_resource *resource)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-
-       ACPI_FUNCTION_TRACE("rs_memory32_range_stream");
-
-       /* The Descriptor Type field is static */
+       ACPI_FUNCTION_TRACE("rs_get_fixed_memory32");
 
-       *buffer = ACPI_RDESC_TYPE_MEMORY_32;
-       buffer += 1;
-
-       /* The length field is static */
-
-       temp16 = 0x11;
-
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
-
-       /* Set the Information Byte */
+       /* Get the Read/Write bit */
 
-       temp8 = (u8) (resource->data.memory32.read_write_attribute & 0x01);
-       *buffer = temp8;
-       buffer += 1;
+       resource->data.fixed_memory32.read_write_attribute =
+           (aml->fixed_memory32.information & 0x01);
 
-       /* Set the Range minimum base address */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.min_base_address);
-       buffer += 4;
-
-       /* Set the Range maximum base address */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.max_base_address);
-       buffer += 4;
-
-       /* Set the base alignment */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.alignment);
-       buffer += 4;
-
-       /* Set the range length */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.range_length);
-       buffer += 4;
+       /*
+        * Get the following contiguous fields from the AML descriptor:
+        * Base Address
+        * Range Length
+        */
+       ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address,
+                          &aml->fixed_memory32.address);
+       ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length,
+                          &aml->fixed_memory32.address_length);
 
-       /* Return the number of bytes consumed in this operation */
+       /* Complete the resource header */
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_fixed_memory32_stream
+ * FUNCTION:    acpi_rs_set_fixed_memory32
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_fixed_memory32_stream(struct acpi_resource *resource,
-                             u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_fixed_memory32(struct acpi_resource *resource,
+                          union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-
-       ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream");
-
-       /* The Descriptor Type field is static */
-
-       *buffer = ACPI_RDESC_TYPE_FIXED_MEMORY_32;
-       buffer += 1;
-
-       /* The length field is static */
-
-       temp16 = 0x09;
-
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
+       ACPI_FUNCTION_TRACE("rs_set_fixed_memory32");
 
        /* Set the Information Byte */
 
-       temp8 =
-           (u8) (resource->data.fixed_memory32.read_write_attribute & 0x01);
-       *buffer = temp8;
-       buffer += 1;
+       aml->fixed_memory32.information = (u8)
+           (resource->data.fixed_memory32.read_write_attribute & 0x01);
 
-       /* Set the Range base address */
-
-       ACPI_MOVE_32_TO_32(buffer,
-                          &resource->data.fixed_memory32.range_base_address);
-       buffer += 4;
-
-       /* Set the range length */
-
-       ACPI_MOVE_32_TO_32(buffer, &resource->data.fixed_memory32.range_length);
-       buffer += 4;
+       /*
+        * Set the following contiguous fields in the AML descriptor:
+        * Base Address
+        * Range Length
+        */
+       ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address,
+                          &resource->data.fixed_memory32.address);
+       ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length,
+                          &resource->data.fixed_memory32.address_length);
 
-       /* Return the number of bytes consumed in this operation */
+       /* Complete the AML descriptor header */
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32,
+                                   sizeof(struct aml_resource_fixed_memory32),
+                                   aml);
        return_ACPI_STATUS(AE_OK);
 }
index fa7f5a8..337a0f0 100644 (file)
@@ -49,641 +49,432 @@ ACPI_MODULE_NAME("rsmisc")
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_generic_register_resource
+ * FUNCTION:    acpi_rs_get_generic_reg
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 acpi_status
-acpi_rs_generic_register_resource(u8 * byte_stream_buffer,
-                                 acpi_size * bytes_consumed,
-                                 u8 ** output_buffer,
-                                 acpi_size * structure_size)
+acpi_rs_get_generic_reg(union aml_resource *aml,
+                       u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16;
-       u8 temp8;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg);
+       ACPI_FUNCTION_TRACE("rs_get_generic_reg");
 
-       ACPI_FUNCTION_TRACE("rs_generic_register_resource");
-
-       /* Byte 0 is the Descriptor Type */
-
-       buffer += 1;
-
-       /* Get the Descriptor Length field (Bytes 1-2) */
-
-       ACPI_MOVE_16_TO_16(&temp16, buffer);
-       buffer += 2;
-
-       /* Validate the descriptor length */
-
-       if (temp16 != 12) {
-               return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
-       }
-
-       /* The number of bytes consumed is fixed (12 + 3) */
-
-       *bytes_consumed = 15;
-
-       /* Fill out the structure */
-
-       output_struct->type = ACPI_RSTYPE_GENERIC_REG;
-
-       /* Get space_id (Byte 3) */
-
-       temp8 = *buffer;
-       output_struct->data.generic_reg.space_id = temp8;
-       buffer += 1;
-
-       /* Get register_bit_width (Byte 4) */
-
-       temp8 = *buffer;
-       output_struct->data.generic_reg.bit_width = temp8;
-       buffer += 1;
-
-       /* Get register_bit_offset (Byte 5) */
-
-       temp8 = *buffer;
-       output_struct->data.generic_reg.bit_offset = temp8;
-       buffer += 1;
-
-       /* Get address_size (Byte 6) */
-
-       temp8 = *buffer;
-       output_struct->data.generic_reg.address_size = temp8;
-       buffer += 1;
-
-       /* Get register_address (Bytes 7-14) */
-
-       ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer);
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       /*
+        * Get the following fields from the AML descriptor:
+        * Address Space ID
+        * Register Bit Width
+        * Register Bit Offset
+        * Access Size
+        * Register Address
+        */
+       resource->data.generic_reg.space_id = aml->generic_reg.address_space_id;
+       resource->data.generic_reg.bit_width = aml->generic_reg.bit_width;
+       resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset;
+       resource->data.generic_reg.access_size = aml->generic_reg.access_size;
+       ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address,
+                          &aml->generic_reg.address);
+
+       /* Complete the resource header */
+
+       resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER;
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_generic_register_stream
+ * FUNCTION:    acpi_rs_set_generic_reg
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_generic_register_stream(struct acpi_resource *resource,
-                               u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16;
-
-       ACPI_FUNCTION_TRACE("rs_generic_register_stream");
-
-       /* Set the Descriptor Type (Byte 0) */
-
-       *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER;
-       buffer += 1;
-
-       /* Set the Descriptor Length (Bytes 1-2) */
-
-       temp16 = 12;
-       ACPI_MOVE_16_TO_16(buffer, &temp16);
-       buffer += 2;
-
-       /* Set space_id (Byte 3) */
-
-       *buffer = (u8) resource->data.generic_reg.space_id;
-       buffer += 1;
-
-       /* Set register_bit_width (Byte 4) */
-
-       *buffer = (u8) resource->data.generic_reg.bit_width;
-       buffer += 1;
-
-       /* Set register_bit_offset (Byte 5) */
-
-       *buffer = (u8) resource->data.generic_reg.bit_offset;
-       buffer += 1;
-
-       /* Set address_size (Byte 6) */
-
-       *buffer = (u8) resource->data.generic_reg.address_size;
-       buffer += 1;
-
-       /* Set register_address (Bytes 7-14) */
+       ACPI_FUNCTION_TRACE("rs_set_generic_reg");
 
-       ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address);
-       buffer += 8;
-
-       /* Return the number of bytes consumed in this operation */
-
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+       /*
+        * Set the following fields in the AML descriptor:
+        * Address Space ID
+        * Register Bit Width
+        * Register Bit Offset
+        * Access Size
+        * Register Address
+        */
+       aml->generic_reg.address_space_id =
+           (u8) resource->data.generic_reg.space_id;
+       aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width;
+       aml->generic_reg.bit_offset =
+           (u8) resource->data.generic_reg.bit_offset;
+       aml->generic_reg.access_size =
+           (u8) resource->data.generic_reg.access_size;
+       ACPI_MOVE_64_TO_64(&aml->generic_reg.address,
+                          &resource->data.generic_reg.address);
+
+       /* Complete the AML descriptor header */
+
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER,
+                                   sizeof(struct
+                                          aml_resource_generic_register), aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_end_tag_resource
+ * FUNCTION:    acpi_rs_get_vendor
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_tag_resource(u8 * byte_stream_buffer,
-                        acpi_size * bytes_consumed,
-                        u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_vendor(union aml_resource *aml,
+                  u16 aml_resource_length, struct acpi_resource *resource)
 {
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       acpi_size struct_size = ACPI_RESOURCE_LENGTH;
-
-       ACPI_FUNCTION_TRACE("rs_end_tag_resource");
+       u8 *aml_byte_data;
 
-       /* The number of bytes consumed is static */
+       ACPI_FUNCTION_TRACE("rs_get_vendor");
 
-       *bytes_consumed = 2;
+       /* Determine if this is a large or small vendor specific item */
 
-       /* Fill out the structure */
+       if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
+               /* Large item, Point to the first vendor byte */
 
-       output_struct->type = ACPI_RSTYPE_END_TAG;
+               aml_byte_data =
+                   ((u8 *) aml) + sizeof(struct aml_resource_large_header);
+       } else {
+               /* Small item, Point to the first vendor byte */
 
-       /* Set the Length parameter */
+               aml_byte_data =
+                   ((u8 *) aml) + sizeof(struct aml_resource_small_header);
+       }
 
-       output_struct->length = 0;
+       /* Copy the vendor-specific bytes */
 
-       /* Return the final size of the structure */
+       ACPI_MEMCPY(resource->data.vendor.byte_data,
+                   aml_byte_data, aml_resource_length);
+       resource->data.vendor.byte_length = aml_resource_length;
 
-       *structure_size = struct_size;
+       /*
+        * In order for the struct_size to fall on a 32-bit boundary,
+        * calculate the length of the vendor string and expand the
+        * struct_size to the next 32-bit boundary.
+        */
+       resource->type = ACPI_RESOURCE_TYPE_VENDOR;
+       resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
+           ACPI_ROUND_UP_to_32_bITS(aml_resource_length);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_end_tag_stream
+ * FUNCTION:    acpi_rs_set_vendor
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_tag_stream(struct acpi_resource *resource,
-                      u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u8 temp8 = 0;
+       u32 resource_length;
+       u8 *source;
+       u8 *destination;
 
-       ACPI_FUNCTION_TRACE("rs_end_tag_stream");
+       ACPI_FUNCTION_TRACE("rs_set_vendor");
 
-       /* The Descriptor Type field is static */
+       resource_length = resource->data.vendor.byte_length;
+       source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data);
 
-       *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01;
-       buffer += 1;
+       /* Length determines if this is a large or small resource */
 
-       /*
-        * Set the Checksum - zero means that the resource data is treated as if
-        * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
-        */
-       temp8 = 0;
+       if (resource_length > 7) {
+               /* Large item, get pointer to the data part of the descriptor */
+
+               destination =
+                   ((u8 *) aml) + sizeof(struct aml_resource_large_header);
+
+               /* Complete the AML descriptor header */
+
+               acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE,
+                                           (u32) (resource_length +
+                                                  sizeof(struct
+                                                         aml_resource_large_header)),
+                                           aml);
+       } else {
+               /* Small item, get pointer to the data part of the descriptor */
 
-       *buffer = temp8;
-       buffer += 1;
+               destination =
+                   ((u8 *) aml) + sizeof(struct aml_resource_small_header);
 
-       /* Return the number of bytes consumed in this operation */
+               /* Complete the AML descriptor header */
 
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
+               acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL,
+                                           (u32) (resource_length +
+                                                  sizeof(struct
+                                                         aml_resource_small_header)),
+                                           aml);
+       }
+
+       /* Copy the vendor-specific bytes */
+
+       ACPI_MEMCPY(destination, source, resource_length);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_vendor_resource
+ * FUNCTION:    acpi_rs_get_start_dpf
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_vendor_resource(u8 * byte_stream_buffer,
-                       acpi_size * bytes_consumed,
-                       u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_get_start_dpf(union aml_resource *aml,
+                     u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       u8 index;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor);
-
-       ACPI_FUNCTION_TRACE("rs_vendor_resource");
-
-       /* Dereference the Descriptor to find if this is a large or small item. */
+       ACPI_FUNCTION_TRACE("rs_get_start_dpf");
 
-       temp8 = *buffer;
+       /* Get the flags byte if present */
 
-       if (temp8 & ACPI_RDESC_TYPE_LARGE) {
-               /* Large Item, point to the length field */
+       if (aml_resource_length == 1) {
+               /* Get the Compatibility priority */
 
-               buffer += 1;
+               resource->data.start_dpf.compatibility_priority =
+                   (aml->start_dpf.flags & 0x03);
 
-               /* Dereference */
-
-               ACPI_MOVE_16_TO_16(&temp16, buffer);
-
-               /* Calculate bytes consumed */
+               if (resource->data.start_dpf.compatibility_priority >= 3) {
+                       return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
+               }
 
-               *bytes_consumed = (acpi_size) temp16 + 3;
+               /* Get the Performance/Robustness preference */
 
-               /* Point to the first vendor byte */
+               resource->data.start_dpf.performance_robustness =
+                   ((aml->start_dpf.flags >> 2) & 0x03);
 
-               buffer += 2;
+               if (resource->data.start_dpf.performance_robustness >= 3) {
+                       return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
+               }
        } else {
-               /* Small Item, dereference the size */
-
-               temp16 = (u8) (*buffer & 0x07);
-
-               /* Calculate bytes consumed */
+               /* start_dependent_no_pri(), no flags byte, set defaults */
 
-               *bytes_consumed = (acpi_size) temp16 + 1;
-
-               /* Point to the first vendor byte */
+               resource->data.start_dpf.compatibility_priority =
+                   ACPI_ACCEPTABLE_CONFIGURATION;
 
-               buffer += 1;
+               resource->data.start_dpf.performance_robustness =
+                   ACPI_ACCEPTABLE_CONFIGURATION;
        }
 
-       output_struct->type = ACPI_RSTYPE_VENDOR;
-       output_struct->data.vendor_specific.length = temp16;
-
-       for (index = 0; index < temp16; index++) {
-               output_struct->data.vendor_specific.reserved[index] = *buffer;
-               buffer += 1;
-       }
+       /* Complete the resource header */
 
-       /*
-        * In order for the struct_size to fall on a 32-bit boundary,
-        * calculate the length of the vendor string and expand the
-        * struct_size to the next 32-bit boundary.
-        */
-       struct_size += ACPI_ROUND_UP_to_32_bITS(temp16);
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT;
+       resource->length =
+           ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_vendor_stream
+ * FUNCTION:    acpi_rs_set_start_dpf
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        used in the output_buffer is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the
- *              the appropriate bytes in a byte stream
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_vendor_stream(struct acpi_resource *resource,
-                     u8 ** output_buffer, acpi_size * bytes_consumed)
+acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml)
 {
-       u8 *buffer = *output_buffer;
-       u16 temp16 = 0;
-       u8 temp8 = 0;
-       u8 index;
-
-       ACPI_FUNCTION_TRACE("rs_vendor_stream");
-
-       /* Dereference the length to find if this is a large or small item. */
-
-       if (resource->data.vendor_specific.length > 7) {
-               /* Large Item, Set the descriptor field and length bytes */
+       ACPI_FUNCTION_TRACE("rs_set_start_dpf");
 
-               *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR;
-               buffer += 1;
-
-               temp16 = (u16) resource->data.vendor_specific.length;
-
-               ACPI_MOVE_16_TO_16(buffer, &temp16);
-               buffer += 2;
+       /*
+        * The descriptor type field is set based upon whether a byte is needed
+        * to contain Priority data.
+        */
+       if (ACPI_ACCEPTABLE_CONFIGURATION ==
+           resource->data.start_dpf.compatibility_priority &&
+           ACPI_ACCEPTABLE_CONFIGURATION ==
+           resource->data.start_dpf.performance_robustness) {
+               acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
+                                           sizeof(struct
+                                                  aml_resource_start_dependent_noprio),
+                                           aml);
        } else {
-               /* Small Item, Set the descriptor field */
-
-               temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR;
-               temp8 |= (u8) resource->data.vendor_specific.length;
-
-               *buffer = temp8;
-               buffer += 1;
-       }
-
-       /* Loop through all of the Vendor Specific fields */
-
-       for (index = 0; index < resource->data.vendor_specific.length; index++) {
-               temp8 = resource->data.vendor_specific.reserved[index];
-
-               *buffer = temp8;
-               buffer += 1;
+               acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
+                                           sizeof(struct
+                                                  aml_resource_start_dependent),
+                                           aml);
+
+               /* Set the Flags byte */
+
+               aml->start_dpf.flags = (u8)
+                   (((resource->data.start_dpf.
+                      performance_robustness & 0x03) << 2) | (resource->data.
+                                                              start_dpf.
+                                                              compatibility_priority
+                                                              & 0x03));
        }
-
-       /* Return the number of bytes consumed in this operation */
-
-       *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_start_depend_fns_resource
+ * FUNCTION:    acpi_rs_get_end_dpf
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
+ *              internal resource descriptor, simplifying bitflags and handling
+ *              alignment and endian issues if necessary.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer,
-                                 acpi_size * bytes_consumed,
-                                 u8 ** output_buffer,
-                                 acpi_size * structure_size)
+acpi_rs_get_end_dpf(union aml_resource *aml,
+                   u16 aml_resource_length, struct acpi_resource *resource)
 {
-       u8 *buffer = byte_stream_buffer;
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       u8 temp8 = 0;
-       acpi_size struct_size =
-           ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf);
-
-       ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
-
-       /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
-
-       temp8 = *buffer;
-
-       *bytes_consumed = (temp8 & 0x01) + 1;
-
-       output_struct->type = ACPI_RSTYPE_START_DPF;
-
-       /* Point to Byte 1 if it is used */
-
-       if (2 == *bytes_consumed) {
-               buffer += 1;
-               temp8 = *buffer;
-
-               /* Check Compatibility priority */
-
-               output_struct->data.start_dpf.compatibility_priority =
-                   temp8 & 0x03;
-
-               if (3 == output_struct->data.start_dpf.compatibility_priority) {
-                       return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
-               }
+       ACPI_FUNCTION_TRACE("rs_get_end_dpf");
 
-               /* Check Performance/Robustness preference */
+       /* Complete the resource header */
 
-               output_struct->data.start_dpf.performance_robustness =
-                   (temp8 >> 2) & 0x03;
-
-               if (3 == output_struct->data.start_dpf.performance_robustness) {
-                       return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
-               }
-       } else {
-               output_struct->data.start_dpf.compatibility_priority =
-                   ACPI_ACCEPTABLE_CONFIGURATION;
-
-               output_struct->data.start_dpf.performance_robustness =
-                   ACPI_ACCEPTABLE_CONFIGURATION;
-       }
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT;
+       resource->length = (u32) ACPI_RESOURCE_LENGTH;
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_end_depend_fns_resource
+ * FUNCTION:    acpi_rs_set_end_dpf
  *
- * PARAMETERS:  byte_stream_buffer      - Pointer to the resource input byte
- *                                        stream
- *              bytes_consumed          - Pointer to where the number of bytes
- *                                        consumed the byte_stream_buffer is
- *                                        returned
- *              output_buffer           - Pointer to the return data buffer
- *              structure_size          - Pointer to where the number of bytes
- *                                        in the return data struct is returned
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Aml                 - Where the AML descriptor is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the resource byte stream and fill out the appropriate
- *              structure pointed to by the output_buffer. Return the
- *              number of bytes consumed from the byte stream.
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ *              external AML resource descriptor.
  *
  ******************************************************************************/
 
 acpi_status
-acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
-                               acpi_size * bytes_consumed,
-                               u8 ** output_buffer, acpi_size * structure_size)
+acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml)
 {
-       struct acpi_resource *output_struct = (void *)*output_buffer;
-       acpi_size struct_size = ACPI_RESOURCE_LENGTH;
-
-       ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
-
-       /* The number of bytes consumed is static */
-
-       *bytes_consumed = 1;
+       ACPI_FUNCTION_TRACE("rs_set_end_dpf");
 
-       /*  Fill out the structure */
+       /* Complete the AML descriptor header */
 
-       output_struct->type = ACPI_RSTYPE_END_DPF;
-
-       /* Set the Length parameter */
-
-       output_struct->length = (u32) struct_size;
-
-       /* Return the final size of the structure */
-
-       *structure_size = struct_size;
+       acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT,
+                                   sizeof(struct aml_resource_end_dependent),
+                                   aml);
        return_ACPI_STATUS(AE_OK);
 }
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_rs_start_depend_fns_stream
+ * FUNCTION:    acpi_rs_get_end_tag
  *
- * PARAMETERS:  Resource                - Pointer to the resource linked list
- *              output_buffer           - Pointer to the user's return buffer
- *              bytes_consumed          - u32 pointer that is filled with
- *                                        the number of bytes of the
- *                                        output_buffer used
+ * PARAMETERS:  Aml                 - Pointer to the AML resource descriptor
+ *              aml_resource_length - Length of the resource from the AML header
+ *              Resource            - Where the internal resource is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Take the linked list resource structure and fills in the