Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ACPI] ACPICA 20050930

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>

authored by

Bob Moore and committed by
Len Brown
50eca3eb 3d5271f9

+3096 -3656
+11 -11
arch/ia64/kernel/acpi-ext.c
··· 33 33 struct acpi_vendor_info *info = (struct acpi_vendor_info *)context; 34 34 struct acpi_resource_vendor *vendor; 35 35 struct acpi_vendor_descriptor *descriptor; 36 - u32 length; 36 + u32 byte_length; 37 37 38 - if (resource->type != ACPI_RSTYPE_VENDOR) 38 + if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) 39 39 return AE_OK; 40 40 41 41 vendor = (struct acpi_resource_vendor *)&resource->data; 42 - descriptor = (struct acpi_vendor_descriptor *)vendor->reserved; 43 - if (vendor->length <= sizeof(*info->descriptor) || 42 + descriptor = (struct acpi_vendor_descriptor *)vendor->byte_data; 43 + if (vendor->byte_length <= sizeof(*info->descriptor) || 44 44 descriptor->guid_id != info->descriptor->guid_id || 45 45 efi_guidcmp(descriptor->guid, info->descriptor->guid)) 46 46 return AE_OK; 47 47 48 - length = vendor->length - sizeof(struct acpi_vendor_descriptor); 49 - info->data = acpi_os_allocate(length); 48 + byte_length = vendor->byte_length - sizeof(struct acpi_vendor_descriptor); 49 + info->data = acpi_os_allocate(byte_length); 50 50 if (!info->data) 51 51 return AE_NO_MEMORY; 52 52 53 53 memcpy(info->data, 54 - vendor->reserved + sizeof(struct acpi_vendor_descriptor), 55 - length); 56 - info->length = length; 54 + vendor->byte_data + sizeof(struct acpi_vendor_descriptor), 55 + byte_length); 56 + info->length = byte_length; 57 57 return AE_CTRL_TERMINATE; 58 58 } 59 59 60 60 acpi_status 61 61 acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id, 62 - u8 ** data, u32 * length) 62 + u8 ** data, u32 * byte_length) 63 63 { 64 64 struct acpi_vendor_info info; 65 65 ··· 72 72 return AE_NOT_FOUND; 73 73 74 74 *data = info.data; 75 - *length = info.length; 75 + *byte_length = info.length; 76 76 return AE_OK; 77 77 } 78 78
+4 -4
arch/ia64/pci/pci.c
··· 193 193 goto free_resource; 194 194 } 195 195 196 - min = addr->min_address_range; 196 + min = addr->minimum; 197 197 max = min + addr->address_length - 1; 198 198 if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION) 199 199 sparse = 1; 200 200 201 - space_nr = new_space(addr->address_translation_offset, sparse); 201 + space_nr = new_space(addr->translation_offset, sparse); 202 202 if (space_nr == ~0) 203 203 goto free_name; 204 204 ··· 285 285 if (addr.resource_type == ACPI_MEMORY_RANGE) { 286 286 flags = IORESOURCE_MEM; 287 287 root = &iomem_resource; 288 - offset = addr.address_translation_offset; 288 + offset = addr.translation_offset; 289 289 } else if (addr.resource_type == ACPI_IO_RANGE) { 290 290 flags = IORESOURCE_IO; 291 291 root = &ioport_resource; ··· 298 298 window = &info->controller->window[info->controller->windows++]; 299 299 window->resource.name = info->name; 300 300 window->resource.flags = flags; 301 - window->resource.start = addr.min_address_range + offset; 301 + window->resource.start = addr.minimum + offset; 302 302 window->resource.end = window->resource.start + addr.address_length - 1; 303 303 window->resource.child = NULL; 304 304 window->offset = offset;
+5 -5
arch/x86_64/kernel/io_apic.c
··· 1956 1956 } 1957 1957 1958 1958 1959 - int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low) 1959 + int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int polarity) 1960 1960 { 1961 1961 struct IO_APIC_route_entry entry; 1962 1962 unsigned long flags; ··· 1978 1978 entry.delivery_mode = INT_DELIVERY_MODE; 1979 1979 entry.dest_mode = INT_DEST_MODE; 1980 1980 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS); 1981 - entry.trigger = edge_level; 1982 - entry.polarity = active_high_low; 1981 + entry.trigger = triggering; 1982 + entry.polarity = polarity; 1983 1983 entry.mask = 1; /* Disabled (masked) */ 1984 1984 1985 1985 irq = gsi_irq_sharing(irq); ··· 1994 1994 apic_printk(APIC_VERBOSE,KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> " 1995 1995 "IRQ %d Mode:%i Active:%i)\n", ioapic, 1996 1996 mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq, 1997 - edge_level, active_high_low); 1997 + triggering, polarity); 1998 1998 1999 - ioapic_register_intr(irq, entry.vector, edge_level); 1999 + ioapic_register_intr(irq, entry.vector, triggering); 2000 2000 2001 2001 if (!ioapic && (irq < 16)) 2002 2002 disable_8259A_irq(irq);
+4 -4
arch/x86_64/kernel/mpparse.c
··· 915 915 916 916 #define MAX_GSI_NUM 4096 917 917 918 - int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) 918 + int mp_register_gsi(u32 gsi, int triggering, int polarity) 919 919 { 920 920 int ioapic = -1; 921 921 int ioapic_pin = 0; ··· 964 964 965 965 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit); 966 966 967 - if (edge_level) { 967 + if (triggering) { 968 968 /* 969 969 * For PCI devices assign IRQs in order, avoiding gaps 970 970 * due to unused I/O APIC pins. ··· 986 986 } 987 987 988 988 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, 989 - edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1, 990 - active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1); 989 + triggering == ACPI_EDGE_SENSITIVE ? 0 : 1, 990 + polarity == ACPI_ACTIVE_HIGH ? 0 : 1); 991 991 return gsi; 992 992 } 993 993
+2 -2
drivers/acpi/acpi_memhotplug.c
··· 101 101 address64.attribute.memory.cache_attribute; 102 102 mem_device->read_write_attribute = 103 103 address64.attribute.memory.read_write_attribute; 104 - mem_device->start_addr = address64.min_address_range; 105 - mem_device->end_addr = address64.max_address_range; 104 + mem_device->start_addr = address64.minimum; 105 + mem_device->end_addr = address64.maximum; 106 106 } 107 107 } 108 108
+6 -6
drivers/acpi/dispatcher/dsutils.c
··· 177 177 178 178 if (!op) { 179 179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); 180 - return_VALUE(TRUE); 180 + return_UINT8(TRUE); 181 181 } 182 182 183 183 /* ··· 208 208 "At Method level, result of [%s] not used\n", 209 209 acpi_ps_get_opcode_name(op->common. 210 210 aml_opcode))); 211 - return_VALUE(FALSE); 211 + return_UINT8(FALSE); 212 212 } 213 213 214 214 /* Get info on the parent. The root_op is AML_SCOPE */ ··· 218 218 if (parent_info->class == AML_CLASS_UNKNOWN) { 219 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 220 220 "Unknown parent opcode. Op=%p\n", op)); 221 - return_VALUE(FALSE); 221 + return_UINT8(FALSE); 222 222 } 223 223 224 224 /* ··· 304 304 acpi_ps_get_opcode_name(op->common.parent->common. 305 305 aml_opcode), op)); 306 306 307 - return_VALUE(TRUE); 307 + return_UINT8(TRUE); 308 308 309 309 result_not_used: 310 310 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, ··· 313 313 acpi_ps_get_opcode_name(op->common.parent->common. 314 314 aml_opcode), op)); 315 315 316 - return_VALUE(FALSE); 316 + return_UINT8(FALSE); 317 317 } 318 318 319 319 /******************************************************************************* ··· 616 616 617 617 if (op_info->flags & AML_HAS_RETVAL) { 618 618 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 619 - "Argument previously created, already stacked \n")); 619 + "Argument previously created, already stacked\n")); 620 620 621 621 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object 622 622 (walk_state->
+2 -2
drivers/acpi/ec.c
··· 1151 1151 union acpi_ec *ec = (union acpi_ec *)context; 1152 1152 struct acpi_generic_address *addr; 1153 1153 1154 - if (resource->type != ACPI_RSTYPE_IO) { 1154 + if (resource->type != ACPI_RESOURCE_TYPE_IO) { 1155 1155 return AE_OK; 1156 1156 } 1157 1157 ··· 1171 1171 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 1172 1172 addr->register_bit_width = 8; 1173 1173 addr->register_bit_offset = 0; 1174 - addr->address = resource->data.io.min_base_address; 1174 + addr->address = resource->data.io.minimum; 1175 1175 1176 1176 return AE_OK; 1177 1177 }
+5 -5
drivers/acpi/events/evgpe.c
··· 600 600 status = acpi_hw_clear_gpe(gpe_event_info); 601 601 if (ACPI_FAILURE(status)) { 602 602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 603 - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 603 + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); 604 604 } 605 605 } 606 606 ··· 638 638 status = acpi_hw_clear_gpe(gpe_event_info); 639 639 if (ACPI_FAILURE(status)) { 640 640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 641 - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 641 + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); 642 642 } 643 643 } 644 644 break; ··· 652 652 status = acpi_ev_disable_gpe(gpe_event_info); 653 653 if (ACPI_FAILURE(status)) { 654 654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 655 - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 655 + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); 656 656 } 657 657 658 658 /* ··· 680 680 status = acpi_ev_disable_gpe(gpe_event_info); 681 681 if (ACPI_FAILURE(status)) { 682 682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 683 - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 683 + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); 684 684 } 685 685 break; 686 686 } 687 687 688 - return_VALUE(ACPI_INTERRUPT_HANDLED); 688 + return_UINT32(ACPI_INTERRUPT_HANDLED); 689 689 } 690 690 691 691 #ifdef ACPI_GPE_NOTIFY_CHECK
+2 -2
drivers/acpi/events/evsci.c
··· 88 88 */ 89 89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 90 90 91 - return_VALUE(interrupt_handled); 91 + return_UINT32(interrupt_handled); 92 92 } 93 93 94 94 /******************************************************************************* ··· 121 121 */ 122 122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 123 123 124 - return_VALUE(interrupt_handled); 124 + return_UINT32(interrupt_handled); 125 125 } 126 126 127 127 /******************************************************************************
+5 -5
drivers/acpi/executer/exdump.c
··· 214 214 215 215 case ACPI_TYPE_BUFFER: 216 216 217 - acpi_os_printf("Buffer len %X @ %p \n", 217 + acpi_os_printf("Buffer len %X @ %p\n", 218 218 obj_desc->buffer.length, 219 219 obj_desc->buffer.pointer); 220 220 ··· 320 320 321 321 case ACPI_TYPE_BUFFER_FIELD: 322 322 323 - acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n", 323 + acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n", 324 324 obj_desc->buffer_field.bit_length, 325 325 obj_desc->buffer_field.base_byte_offset, 326 326 obj_desc->buffer_field.start_field_bit_offset); 327 327 328 328 if (!obj_desc->buffer_field.buffer_obj) { 329 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n")); 329 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n")); 330 330 } else 331 331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) 332 332 != ACPI_TYPE_BUFFER) { 333 - acpi_os_printf("*not a Buffer* \n"); 333 + acpi_os_printf("*not a Buffer*\n"); 334 334 } else { 335 335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, 336 336 depth + 1); ··· 618 618 619 619 case ACPI_TYPE_PACKAGE: 620 620 621 - acpi_os_printf("[Package] Contains %d Elements: \n", 621 + acpi_os_printf("[Package] Contains %d Elements:\n", 622 622 obj_desc->package.count); 623 623 624 624 for (i = 0; i < obj_desc->package.count; i++) {
+2 -2
drivers/acpi/executer/exnames.c
··· 191 191 if (name_string) { 192 192 ACPI_STRCAT(name_string, char_buf); 193 193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 194 - "Appended to - %s \n", name_string)); 194 + "Appended to - %s\n", name_string)); 195 195 } else { 196 196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 197 - "No Name string - %s \n", char_buf)); 197 + "No Name string - %s\n", char_buf)); 198 198 } 199 199 } else if (index == 0) { 200 200 /*
+2 -2
drivers/acpi/executer/exprep.c
··· 276 276 277 277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 278 278 "Unknown field access type %X\n", access)); 279 - return_VALUE(0); 279 + return_UINT32(0); 280 280 } 281 281 282 282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { ··· 289 289 } 290 290 291 291 *return_byte_alignment = byte_alignment; 292 - return_VALUE(bit_length); 292 + return_UINT32(bit_length); 293 293 } 294 294 295 295 /*******************************************************************************
+1 -1
drivers/acpi/executer/exresop.c
··· 157 157 } 158 158 159 159 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 160 - "Opcode %X [%s] required_operand_types=%8.8X \n", 160 + "Opcode %X [%s] required_operand_types=%8.8X\n", 161 161 opcode, op_info->name, arg_types)); 162 162 163 163 /*
+3 -3
drivers/acpi/executer/exutils.c
··· 206 206 } 207 207 } 208 208 209 - return_VALUE(locked); 209 + return_UINT8(locked); 210 210 } 211 211 212 212 /******************************************************************************* ··· 268 268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 269 269 270 270 if (value == 0) { 271 - return_VALUE(1); 271 + return_UINT32(1); 272 272 } 273 273 274 274 current_value = value; ··· 282 282 num_digits++; 283 283 } 284 284 285 - return_VALUE(num_digits); 285 + return_UINT32(num_digits); 286 286 } 287 287 288 288 /*******************************************************************************
+4 -4
drivers/acpi/glue.c
··· 99 99 unsigned long *busnr = (unsigned long *)data; 100 100 struct acpi_resource_address64 address; 101 101 102 - if (resource->type != ACPI_RSTYPE_ADDRESS16 && 103 - resource->type != ACPI_RSTYPE_ADDRESS32 && 104 - resource->type != ACPI_RSTYPE_ADDRESS64) 102 + if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && 103 + resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && 104 + resource->type != ACPI_RESOURCE_TYPE_ADDRESS64) 105 105 return AE_OK; 106 106 107 107 acpi_resource_to_address64(resource, &address); 108 108 if ((address.address_length > 0) && 109 109 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 110 - *busnr = address.min_address_range; 110 + *busnr = address.minimum; 111 111 112 112 return AE_OK; 113 113 }
+4 -4
drivers/acpi/hardware/hwacpi.c
··· 204 204 * system does not support mode transition. 205 205 */ 206 206 if (!acpi_gbl_FADT->smi_cmd) { 207 - return_VALUE(ACPI_SYS_MODE_ACPI); 207 + return_UINT32(ACPI_SYS_MODE_ACPI); 208 208 } 209 209 210 210 status = 211 211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); 212 212 if (ACPI_FAILURE(status)) { 213 - return_VALUE(ACPI_SYS_MODE_LEGACY); 213 + return_UINT32(ACPI_SYS_MODE_LEGACY); 214 214 } 215 215 216 216 if (value) { 217 - return_VALUE(ACPI_SYS_MODE_ACPI); 217 + return_UINT32(ACPI_SYS_MODE_ACPI); 218 218 } else { 219 - return_VALUE(ACPI_SYS_MODE_LEGACY); 219 + return_UINT32(ACPI_SYS_MODE_LEGACY); 220 220 } 221 221 }
+15 -15
drivers/acpi/motherboard.c
··· 54 54 55 55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); 56 56 57 - if (res->type == ACPI_RSTYPE_IO) { 57 + if (res->type == ACPI_RESOURCE_TYPE_IO) { 58 58 struct acpi_resource_io *io_res = &res->data.io; 59 59 60 - if (io_res->min_base_address != io_res->max_base_address) 60 + if (io_res->minimum != io_res->maximum) 61 61 return_VALUE(AE_OK); 62 62 if (IS_RESERVED_ADDR 63 - (io_res->min_base_address, io_res->range_length)) { 63 + (io_res->minimum, io_res->address_length)) { 64 64 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 65 65 "Motherboard resources 0x%08x - 0x%08x\n", 66 - io_res->min_base_address, 67 - io_res->min_base_address + 68 - io_res->range_length)); 66 + io_res->minimum, 67 + io_res->minimum + 68 + io_res->address_length)); 69 69 requested_res = 70 - request_region(io_res->min_base_address, 71 - io_res->range_length, "motherboard"); 70 + request_region(io_res->minimum, 71 + io_res->address_length, "motherboard"); 72 72 } 73 - } else if (res->type == ACPI_RSTYPE_FIXED_IO) { 73 + } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) { 74 74 struct acpi_resource_fixed_io *fixed_io_res = 75 75 &res->data.fixed_io; 76 76 77 77 if (IS_RESERVED_ADDR 78 - (fixed_io_res->base_address, fixed_io_res->range_length)) { 78 + (fixed_io_res->address, fixed_io_res->address_length)) { 79 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 80 80 "Motherboard resources 0x%08x - 0x%08x\n", 81 - fixed_io_res->base_address, 82 - fixed_io_res->base_address + 83 - fixed_io_res->range_length)); 81 + fixed_io_res->address, 82 + fixed_io_res->address + 83 + fixed_io_res->address_length)); 84 84 requested_res = 85 - request_region(fixed_io_res->base_address, 86 - fixed_io_res->range_length, 85 + request_region(fixed_io_res->address, 86 + fixed_io_res->address_length, 87 87 "motherboard"); 88 88 } 89 89 } else {
+1 -1
drivers/acpi/namespace/nsaccess.c
··· 498 498 path++; 499 499 500 500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 501 - "Multi Pathname (%d Segments, Flags=%X) \n", 501 + "Multi Pathname (%d Segments, Flags=%X)\n", 502 502 num_segments, flags)); 503 503 break; 504 504
+1 -1
drivers/acpi/namespace/nsnames.c
··· 241 241 242 242 acpi_ns_build_external_path(node, required_size, buffer->pointer); 243 243 244 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n", 244 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n", 245 245 (char *)buffer->pointer, (u32) required_size)); 246 246 return_ACPI_STATUS(AE_OK); 247 247 }
+6 -6
drivers/acpi/namespace/nsutils.c
··· 249 249 250 250 if (!node) { 251 251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); 252 - return_VALUE(ACPI_TYPE_ANY); 252 + return_UINT32(ACPI_TYPE_ANY); 253 253 } 254 254 255 - return_VALUE((acpi_object_type) node->type); 255 + return_UINT32((acpi_object_type) node->type); 256 256 } 257 257 258 258 /******************************************************************************* ··· 276 276 /* Type code out of range */ 277 277 278 278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); 279 - return_VALUE(ACPI_NS_NORMAL); 279 + return_UINT32(ACPI_NS_NORMAL); 280 280 } 281 281 282 - return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 282 + return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 283 283 } 284 284 285 285 /******************************************************************************* ··· 805 805 806 806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", 807 807 type)); 808 - return_VALUE(ACPI_NS_NORMAL); 808 + return_UINT32(ACPI_NS_NORMAL); 809 809 } 810 810 811 - return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 811 + return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 812 812 } 813 813 814 814 /*******************************************************************************
+1 -1
drivers/acpi/parser/psargs.c
··· 116 116 break; 117 117 } 118 118 119 - return_VALUE(length); 119 + return_UINT32(length); 120 120 } 121 121 122 122 /*******************************************************************************
+142
drivers/acpi/parser/psxface.c
··· 50 50 ACPI_MODULE_NAME("psxface") 51 51 52 52 /* Local Prototypes */ 53 + static void acpi_ps_start_trace(struct acpi_parameter_info *info); 54 + 55 + static void acpi_ps_stop_trace(struct acpi_parameter_info *info); 56 + 53 57 static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info); 54 58 55 59 static void 56 60 acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action); 61 + 62 + /******************************************************************************* 63 + * 64 + * FUNCTION: acpi_debug_trace 65 + * 66 + * PARAMETERS: method_name - Valid ACPI name string 67 + * debug_level - Optional level mask. 0 to use default 68 + * debug_layer - Optional layer mask. 0 to use default 69 + * Flags - bit 1: one shot(1) or persistent(0) 70 + * 71 + * RETURN: Status 72 + * 73 + * DESCRIPTION: External interface to enable debug tracing during control 74 + * method execution 75 + * 76 + ******************************************************************************/ 77 + 78 + acpi_status 79 + acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags) 80 + { 81 + acpi_status status; 82 + 83 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 84 + if (ACPI_FAILURE(status)) { 85 + return (status); 86 + } 87 + 88 + /* TBDs: Validate name, allow full path or just nameseg */ 89 + 90 + acpi_gbl_trace_method_name = *(u32 *) name; 91 + acpi_gbl_trace_flags = flags; 92 + 93 + if (debug_level) { 94 + acpi_gbl_trace_dbg_level = debug_level; 95 + } 96 + if (debug_layer) { 97 + acpi_gbl_trace_dbg_layer = debug_layer; 98 + } 99 + 100 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 101 + return (AE_OK); 102 + } 103 + 104 + /******************************************************************************* 105 + * 106 + * FUNCTION: acpi_ps_start_trace 107 + * 108 + * PARAMETERS: Info - Method info struct 109 + * 110 + * RETURN: None 111 + * 112 + * DESCRIPTION: Start control method execution trace 113 + * 114 + ******************************************************************************/ 115 + 116 + static void acpi_ps_start_trace(struct acpi_parameter_info *info) 117 + { 118 + acpi_status status; 119 + 120 + ACPI_FUNCTION_ENTRY(); 121 + 122 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 123 + if (ACPI_FAILURE(status)) { 124 + return; 125 + } 126 + 127 + if ((!acpi_gbl_trace_method_name) || 128 + (acpi_gbl_trace_method_name != info->node->name.integer)) { 129 + goto exit; 130 + } 131 + 132 + acpi_gbl_original_dbg_level = acpi_dbg_level; 133 + acpi_gbl_original_dbg_layer = acpi_dbg_layer; 134 + 135 + acpi_dbg_level = 0x00FFFFFF; 136 + acpi_dbg_layer = ACPI_UINT32_MAX; 137 + 138 + if (acpi_gbl_trace_dbg_level) { 139 + acpi_dbg_level = acpi_gbl_trace_dbg_level; 140 + } 141 + if (acpi_gbl_trace_dbg_layer) { 142 + acpi_dbg_layer = acpi_gbl_trace_dbg_layer; 143 + } 144 + 145 + exit: 146 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 147 + } 148 + 149 + /******************************************************************************* 150 + * 151 + * FUNCTION: acpi_ps_stop_trace 152 + * 153 + * PARAMETERS: Info - Method info struct 154 + * 155 + * RETURN: None 156 + * 157 + * DESCRIPTION: Stop control method execution trace 158 + * 159 + ******************************************************************************/ 160 + 161 + static void acpi_ps_stop_trace(struct acpi_parameter_info *info) 162 + { 163 + acpi_status status; 164 + 165 + ACPI_FUNCTION_ENTRY(); 166 + 167 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 168 + if (ACPI_FAILURE(status)) { 169 + return; 170 + } 171 + 172 + if ((!acpi_gbl_trace_method_name) || 173 + (acpi_gbl_trace_method_name != info->node->name.integer)) { 174 + goto exit; 175 + } 176 + 177 + /* Disable further tracing if type is one-shot */ 178 + 179 + if (acpi_gbl_trace_flags & 1) { 180 + acpi_gbl_trace_method_name = 0; 181 + acpi_gbl_trace_dbg_level = 0; 182 + acpi_gbl_trace_dbg_layer = 0; 183 + } 184 + 185 + acpi_dbg_level = acpi_gbl_original_dbg_level; 186 + acpi_dbg_layer = acpi_gbl_original_dbg_layer; 187 + 188 + exit: 189 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 190 + } 57 191 58 192 /******************************************************************************* 59 193 * ··· 238 104 */ 239 105 acpi_ps_update_parameter_list(info, REF_INCREMENT); 240 106 107 + /* Begin tracing if requested */ 108 + 109 + acpi_ps_start_trace(info); 110 + 241 111 /* 242 112 * 1) Perform the first pass parse of the method to enter any 243 113 * named objects that it creates into the namespace ··· 267 129 status = acpi_ps_execute_pass(info); 268 130 269 131 cleanup: 132 + /* End optional tracing */ 133 + 134 + acpi_ps_stop_trace(info); 135 + 270 136 /* Take away the extra reference that we gave the parameters above */ 271 137 272 138 acpi_ps_update_parameter_list(info, REF_DECREMENT);
+24 -24
drivers/acpi/pci_irq.c
··· 258 258 259 259 static int 260 260 acpi_pci_allocate_irq(struct acpi_prt_entry *entry, 261 - int *edge_level, int *active_high_low, char **link) 261 + int *triggering, int *polarity, char **link) 262 262 { 263 263 int irq; 264 264 ··· 266 266 267 267 if (entry->link.handle) { 268 268 irq = acpi_pci_link_allocate_irq(entry->link.handle, 269 - entry->link.index, edge_level, 270 - active_high_low, link); 269 + entry->link.index, triggering, 270 + polarity, link); 271 271 if (irq < 0) { 272 272 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 273 273 "Invalid IRQ link routing entry\n")); ··· 275 275 } 276 276 } else { 277 277 irq = entry->link.index; 278 - *edge_level = ACPI_LEVEL_SENSITIVE; 279 - *active_high_low = ACPI_ACTIVE_LOW; 278 + *triggering = ACPI_LEVEL_SENSITIVE; 279 + *polarity = ACPI_ACTIVE_LOW; 280 280 } 281 281 282 282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); ··· 285 285 286 286 static int 287 287 acpi_pci_free_irq(struct acpi_prt_entry *entry, 288 - int *edge_level, int *active_high_low, char **link) 288 + int *triggering, int *polarity, char **link) 289 289 { 290 290 int irq; 291 291 ··· 307 307 acpi_pci_irq_lookup(struct pci_bus *bus, 308 308 int device, 309 309 int pin, 310 - int *edge_level, 311 - int *active_high_low, char **link, irq_lookup_func func) 310 + int *triggering, 311 + int *polarity, char **link, irq_lookup_func func) 312 312 { 313 313 struct acpi_prt_entry *entry = NULL; 314 314 int segment = pci_domain_nr(bus); ··· 327 327 return_VALUE(-1); 328 328 } 329 329 330 - ret = func(entry, edge_level, active_high_low, link); 330 + ret = func(entry, triggering, polarity, link); 331 331 return_VALUE(ret); 332 332 } 333 333 ··· 339 339 static int 340 340 acpi_pci_irq_derive(struct pci_dev *dev, 341 341 int pin, 342 - int *edge_level, 343 - int *active_high_low, char **link, irq_lookup_func func) 342 + int *triggering, 343 + int *polarity, char **link, irq_lookup_func func) 344 344 { 345 345 struct pci_dev *bridge = dev; 346 346 int irq = -1; ··· 375 375 } 376 376 377 377 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 378 - pin, edge_level, active_high_low, 378 + pin, triggering, polarity, 379 379 link, func); 380 380 } 381 381 ··· 402 402 { 403 403 int irq = 0; 404 404 u8 pin = 0; 405 - int edge_level = ACPI_LEVEL_SENSITIVE; 406 - int active_high_low = ACPI_ACTIVE_LOW; 405 + int triggering = ACPI_LEVEL_SENSITIVE; 406 + int polarity = ACPI_ACTIVE_LOW; 407 407 char *link = NULL; 408 408 int rc; 409 409 ··· 432 432 * values override any BIOS-assigned IRQs set during boot. 433 433 */ 434 434 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 435 - &edge_level, &active_high_low, &link, 435 + &triggering, &polarity, &link, 436 436 acpi_pci_allocate_irq); 437 437 438 438 /* ··· 440 440 * device's parent bridge. 441 441 */ 442 442 if (irq < 0) 443 - irq = acpi_pci_irq_derive(dev, pin, &edge_level, 444 - &active_high_low, &link, 443 + irq = acpi_pci_irq_derive(dev, pin, &triggering, 444 + &polarity, &link, 445 445 acpi_pci_allocate_irq); 446 446 447 447 /* ··· 463 463 } 464 464 } 465 465 466 - rc = acpi_register_gsi(irq, edge_level, active_high_low); 466 + rc = acpi_register_gsi(irq, triggering, polarity); 467 467 if (rc < 0) { 468 468 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " 469 469 "to register GSI\n", pci_name(dev), ('A' + pin)); ··· 478 478 printk("Link [%s] -> ", link); 479 479 480 480 printk("GSI %u (%s, %s) -> IRQ %d\n", irq, 481 - (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 482 - (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 481 + (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 482 + (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 483 483 484 484 return_VALUE(0); 485 485 } ··· 495 495 { 496 496 int gsi = 0; 497 497 u8 pin = 0; 498 - int edge_level = ACPI_LEVEL_SENSITIVE; 499 - int active_high_low = ACPI_ACTIVE_LOW; 498 + int triggering = ACPI_LEVEL_SENSITIVE; 499 + int polarity = ACPI_ACTIVE_LOW; 500 500 501 501 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); 502 502 ··· 512 512 * First we check the PCI IRQ routing table (PRT) for an IRQ. 513 513 */ 514 514 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 515 - &edge_level, &active_high_low, NULL, 515 + &triggering, &polarity, NULL, 516 516 acpi_pci_free_irq); 517 517 /* 518 518 * If no PRT entry was found, we'll try to derive an IRQ from the ··· 520 520 */ 521 521 if (gsi < 0) 522 522 gsi = acpi_pci_irq_derive(dev, pin, 523 - &edge_level, &active_high_low, NULL, 523 + &triggering, &polarity, NULL, 524 524 acpi_pci_free_irq); 525 525 if (gsi < 0) 526 526 return_VOID;
+46 -46
drivers/acpi/pci_link.c
··· 70 70 */ 71 71 struct acpi_pci_link_irq { 72 72 u8 active; /* Current IRQ */ 73 - u8 edge_level; /* All IRQs */ 74 - u8 active_high_low; /* All IRQs */ 73 + u8 triggering; /* All IRQs */ 74 + u8 polarity; /* All IRQs */ 75 75 u8 resource_type; 76 76 u8 possible_count; 77 77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; ··· 109 109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); 110 110 111 111 switch (resource->type) { 112 - case ACPI_RSTYPE_START_DPF: 112 + case ACPI_RESOURCE_TYPE_START_DEPENDENT: 113 113 return_ACPI_STATUS(AE_OK); 114 - case ACPI_RSTYPE_IRQ: 114 + case ACPI_RESOURCE_TYPE_IRQ: 115 115 { 116 116 struct acpi_resource_irq *p = &resource->data.irq; 117 - if (!p || !p->number_of_interrupts) { 117 + if (!p || !p->interrupt_count) { 118 118 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 119 119 "Blank IRQ resource\n")); 120 120 return_ACPI_STATUS(AE_OK); 121 121 } 122 122 for (i = 0; 123 - (i < p->number_of_interrupts 123 + (i < p->interrupt_count 124 124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 125 125 if (!p->interrupts[i]) { 126 126 ACPI_DEBUG_PRINT((ACPI_DB_WARN, ··· 131 131 link->irq.possible[i] = p->interrupts[i]; 132 132 link->irq.possible_count++; 133 133 } 134 - link->irq.edge_level = p->edge_level; 135 - link->irq.active_high_low = p->active_high_low; 136 - link->irq.resource_type = ACPI_RSTYPE_IRQ; 134 + link->irq.triggering = p->triggering; 135 + link->irq.polarity = p->polarity; 136 + link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ; 137 137 break; 138 138 } 139 - case ACPI_RSTYPE_EXT_IRQ: 139 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 140 140 { 141 - struct acpi_resource_ext_irq *p = 141 + struct acpi_resource_extended_irq *p = 142 142 &resource->data.extended_irq; 143 - if (!p || !p->number_of_interrupts) { 143 + if (!p || !p->interrupt_count) { 144 144 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 145 145 "Blank EXT IRQ resource\n")); 146 146 return_ACPI_STATUS(AE_OK); 147 147 } 148 148 for (i = 0; 149 - (i < p->number_of_interrupts 149 + (i < p->interrupt_count 150 150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 151 151 if (!p->interrupts[i]) { 152 152 ACPI_DEBUG_PRINT((ACPI_DB_WARN, ··· 157 157 link->irq.possible[i] = p->interrupts[i]; 158 158 link->irq.possible_count++; 159 159 } 160 - link->irq.edge_level = p->edge_level; 161 - link->irq.active_high_low = p->active_high_low; 162 - link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; 160 + link->irq.triggering = p->triggering; 161 + link->irq.polarity = p->polarity; 162 + link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; 163 163 break; 164 164 } 165 165 default: ··· 202 202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); 203 203 204 204 switch (resource->type) { 205 - case ACPI_RSTYPE_IRQ: 205 + case ACPI_RESOURCE_TYPE_IRQ: 206 206 { 207 207 struct acpi_resource_irq *p = &resource->data.irq; 208 - if (!p || !p->number_of_interrupts) { 208 + if (!p || !p->interrupt_count) { 209 209 /* 210 210 * IRQ descriptors may have no IRQ# bits set, 211 211 * particularly those those w/ _STA disabled ··· 217 217 *irq = p->interrupts[0]; 218 218 break; 219 219 } 220 - case ACPI_RSTYPE_EXT_IRQ: 220 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 221 221 { 222 - struct acpi_resource_ext_irq *p = 222 + struct acpi_resource_extended_irq *p = 223 223 &resource->data.extended_irq; 224 - if (!p || !p->number_of_interrupts) { 224 + if (!p || !p->interrupt_count) { 225 225 /* 226 226 * extended IRQ descriptors must 227 227 * return at least 1 IRQ ··· 325 325 buffer.pointer = resource; 326 326 327 327 switch (link->irq.resource_type) { 328 - case ACPI_RSTYPE_IRQ: 329 - resource->res.type = ACPI_RSTYPE_IRQ; 328 + case ACPI_RESOURCE_TYPE_IRQ: 329 + resource->res.type = ACPI_RESOURCE_TYPE_IRQ; 330 330 resource->res.length = sizeof(struct acpi_resource); 331 - resource->res.data.irq.edge_level = link->irq.edge_level; 332 - resource->res.data.irq.active_high_low = 333 - link->irq.active_high_low; 334 - if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 335 - resource->res.data.irq.shared_exclusive = 331 + resource->res.data.irq.triggering = link->irq.triggering; 332 + resource->res.data.irq.polarity = 333 + link->irq.polarity; 334 + if (link->irq.triggering == ACPI_EDGE_SENSITIVE) 335 + resource->res.data.irq.sharable = 336 336 ACPI_EXCLUSIVE; 337 337 else 338 - resource->res.data.irq.shared_exclusive = ACPI_SHARED; 339 - resource->res.data.irq.number_of_interrupts = 1; 338 + resource->res.data.irq.sharable = ACPI_SHARED; 339 + resource->res.data.irq.interrupt_count = 1; 340 340 resource->res.data.irq.interrupts[0] = irq; 341 341 break; 342 342 343 - case ACPI_RSTYPE_EXT_IRQ: 344 - resource->res.type = ACPI_RSTYPE_EXT_IRQ; 343 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 344 + resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; 345 345 resource->res.length = sizeof(struct acpi_resource); 346 346 resource->res.data.extended_irq.producer_consumer = 347 347 ACPI_CONSUMER; 348 - resource->res.data.extended_irq.edge_level = 349 - link->irq.edge_level; 350 - resource->res.data.extended_irq.active_high_low = 351 - link->irq.active_high_low; 352 - if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 353 - resource->res.data.irq.shared_exclusive = 348 + resource->res.data.extended_irq.triggering = 349 + link->irq.triggering; 350 + resource->res.data.extended_irq.polarity = 351 + link->irq.polarity; 352 + if (link->irq.triggering == ACPI_EDGE_SENSITIVE) 353 + resource->res.data.irq.sharable = 354 354 ACPI_EXCLUSIVE; 355 355 else 356 - resource->res.data.irq.shared_exclusive = ACPI_SHARED; 357 - resource->res.data.extended_irq.number_of_interrupts = 1; 356 + resource->res.data.irq.sharable = ACPI_SHARED; 357 + resource->res.data.extended_irq.interrupt_count = 1; 358 358 resource->res.data.extended_irq.interrupts[0] = irq; 359 359 /* ignore resource_source, it's optional */ 360 360 break; ··· 364 364 goto end; 365 365 366 366 } 367 - resource->end.type = ACPI_RSTYPE_END_TAG; 367 + resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; 368 368 369 369 /* Attempt to set the resource */ 370 370 status = acpi_set_current_resources(link->handle, &buffer); ··· 613 613 int 614 614 acpi_pci_link_allocate_irq(acpi_handle handle, 615 615 int index, 616 - int *edge_level, int *active_high_low, char **name) 616 + int *triggering, int *polarity, char **name) 617 617 { 618 618 int result = 0; 619 619 struct acpi_device *device = NULL; ··· 653 653 link->refcnt++; 654 654 up(&acpi_link_lock); 655 655 656 - if (edge_level) 657 - *edge_level = link->irq.edge_level; 658 - if (active_high_low) 659 - *active_high_low = link->irq.active_high_low; 656 + if (triggering) 657 + *triggering = link->irq.triggering; 658 + if (polarity) 659 + *polarity = link->irq.polarity; 660 660 if (name) 661 661 *name = acpi_device_bid(link->device); 662 662 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+4 -4
drivers/acpi/pci_root.c
··· 122 122 int *busnr = (int *)data; 123 123 struct acpi_resource_address64 address; 124 124 125 - if (resource->type != ACPI_RSTYPE_ADDRESS16 && 126 - resource->type != ACPI_RSTYPE_ADDRESS32 && 127 - resource->type != ACPI_RSTYPE_ADDRESS64) 125 + if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && 126 + resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && 127 + resource->type != ACPI_RESOURCE_TYPE_ADDRESS64) 128 128 return AE_OK; 129 129 130 130 acpi_resource_to_address64(resource, &address); 131 131 if ((address.address_length > 0) && 132 132 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 133 - *busnr = address.min_address_range; 133 + *busnr = address.minimum; 134 134 135 135 return AE_OK; 136 136 }
+1 -1
drivers/acpi/resources/Makefile
··· 2 2 # Makefile for all Linux ACPI interpreter subdirectories 3 3 # 4 4 5 - obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \ 5 + obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \ 6 6 rscalc.o rsirq.o rsmemory.o rsutils.o 7 7 8 8 obj-$(ACPI_FUTURE_USAGE) += rsdump.o
+429 -809
drivers/acpi/resources/rsaddr.c
··· 58 58 59 59 static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); 60 60 61 + static void 62 + acpi_rs_set_address_common(union aml_resource *aml, 63 + struct acpi_resource *resource); 64 + 65 + static u8 66 + acpi_rs_get_address_common(struct acpi_resource *resource, 67 + union aml_resource *aml); 68 + 61 69 /******************************************************************************* 62 70 * 63 71 * FUNCTION: acpi_rs_decode_general_flags 64 72 * 65 73 * PARAMETERS: Resource - Address resource data struct 66 - * Flags - Actual flag byte 74 + * Flags - Raw AML flag byte 67 75 * 68 76 * RETURN: Decoded flag bits in resource struct 69 77 * ··· 115 107 116 108 static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) 117 109 { 118 - u8 flags; 119 - 120 110 ACPI_FUNCTION_ENTRY(); 121 111 122 - /* Producer / Consumer - flag bit[0] */ 112 + return ((u8) 123 113 124 - flags = (u8) (resource->address.producer_consumer & 0x01); 125 - 126 - /* Decode (_DEC) - flag bit[1] */ 127 - 128 - flags |= (u8) ((resource->address.decode & 0x01) << 1); 129 - 130 - /* Min Address Fixed (_MIF) - flag bit[2] */ 131 - 132 - flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2); 133 - 134 - /* Max Address Fixed (_MAF) - flag bit[3] */ 135 - 136 - flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); 137 - 138 - return (flags); 114 + /* Producer / Consumer - flag bit[0] */ 115 + ((resource->address.producer_consumer & 0x01) | 116 + /* Decode (_DEC) - flag bit[1] */ 117 + ((resource->address.decode & 0x01) << 1) | 118 + /* Min Address Fixed (_MIF) - flag bit[2] */ 119 + ((resource->address.min_address_fixed & 0x01) << 2) | 120 + /* Max Address Fixed (_MAF) - flag bit[3] */ 121 + ((resource->address.max_address_fixed & 0x01) << 3)) 122 + ); 139 123 } 140 124 141 125 /******************************************************************************* ··· 135 135 * FUNCTION: acpi_rs_decode_specific_flags 136 136 * 137 137 * PARAMETERS: Resource - Address resource data struct 138 - * Flags - Actual flag byte 138 + * Flags - Raw AML flag byte 139 139 * 140 140 * RETURN: Decoded flag bits in attribute struct 141 141 * ··· 189 189 190 190 static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) 191 191 { 192 - u8 flags = 0; 193 - 194 192 ACPI_FUNCTION_ENTRY(); 195 193 196 194 if (resource->address.resource_type == ACPI_MEMORY_RANGE) { 197 - /* Write Status (_RW) - flag bit[0] */ 195 + return ((u8) 198 196 199 - flags = (u8) 200 - (resource->address.attribute.memory. 201 - read_write_attribute & 0x01); 202 - 203 - /* Memory Attributes (_MEM) - flag bits[2:1] */ 204 - 205 - flags |= (u8) 206 - ((resource->address.attribute.memory. 207 - cache_attribute & 0x03) << 1); 197 + /* Write Status (_RW) - flag bit[0] */ 198 + ((resource->address.attribute.memory. 199 + read_write_attribute & 0x01) | 200 + /* Memory Attributes (_MEM) - flag bits[2:1] */ 201 + ((resource->address.attribute.memory. 202 + cache_attribute & 0x03) << 1))); 208 203 } else if (resource->address.resource_type == ACPI_IO_RANGE) { 209 - /* Ranges (_RNG) - flag bits[1:0] */ 204 + return ((u8) 210 205 211 - flags = (u8) 212 - (resource->address.attribute.io.range_attribute & 0x03); 213 - 214 - /* Translations (_TTP and _TRS) - flag bits[5:4] */ 215 - 216 - flags |= (u8) 217 - ((resource->address.attribute.io. 218 - translation_attribute & 0x03) << 4); 206 + /* Ranges (_RNG) - flag bits[1:0] */ 207 + ((resource->address.attribute.io. 208 + range_attribute & 0x03) | 209 + /* Translations (_TTP and _TRS) - flag bits[5:4] */ 210 + ((resource->address.attribute.io. 211 + translation_attribute & 0x03) << 4))); 219 212 } 220 213 221 - return (flags); 214 + return (0); 222 215 } 223 216 224 217 /******************************************************************************* 225 218 * 226 - * FUNCTION: acpi_rs_address16_resource 219 + * FUNCTION: acpi_rs_set_address_common 227 220 * 228 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 229 - * stream 230 - * bytes_consumed - Pointer to where the number of bytes 231 - * consumed the byte_stream_buffer is 232 - * returned 233 - * output_buffer - Pointer to the return data buffer 234 - * structure_size - Pointer to where the number of bytes 235 - * in the return data struct is returned 221 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 222 + * Resource - Pointer to the internal resource struct 236 223 * 237 - * RETURN: Status 224 + * RETURN: None 238 225 * 239 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 240 - * structure pointed to by the output_buffer. Return the 241 - * number of bytes consumed from the byte stream. 226 + * DESCRIPTION: Convert common flag fields from a resource descriptor to an 227 + * AML descriptor 242 228 * 243 229 ******************************************************************************/ 244 230 245 - acpi_status 246 - acpi_rs_address16_resource(u8 * byte_stream_buffer, 247 - acpi_size * bytes_consumed, 248 - u8 ** output_buffer, acpi_size * structure_size) 231 + static void 232 + acpi_rs_set_address_common(union aml_resource *aml, 233 + struct acpi_resource *resource) 249 234 { 250 - u32 index; 251 - u16 temp16; 252 - u8 temp8; 253 - u8 *temp_ptr; 254 - u8 *buffer = byte_stream_buffer; 255 - struct acpi_resource *output_struct = (void *)*output_buffer; 256 - acpi_size struct_size = 257 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16); 235 + ACPI_FUNCTION_ENTRY(); 258 236 259 - ACPI_FUNCTION_TRACE("rs_address16_resource"); 237 + /* Set the Resource Type (Memory, Io, bus_number, etc.) */ 260 238 261 - /* Get the Descriptor Length field */ 262 - 263 - buffer += 1; 264 - ACPI_MOVE_16_TO_16(&temp16, buffer); 265 - 266 - /* Validate minimum descriptor length */ 267 - 268 - if (temp16 < 13) { 269 - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 270 - } 271 - 272 - *bytes_consumed = temp16 + 3; 273 - output_struct->type = ACPI_RSTYPE_ADDRESS16; 274 - 275 - /* Get the Resource Type (Byte3) */ 276 - 277 - buffer += 2; 278 - temp8 = *buffer; 279 - 280 - /* Values 0-2 and 0xC0-0xFF are valid */ 281 - 282 - if ((temp8 > 2) && (temp8 < 0xC0)) { 283 - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 284 - } 285 - 286 - output_struct->data.address16.resource_type = temp8; 287 - 288 - /* Get the General Flags (Byte4) */ 289 - 290 - buffer += 1; 291 - acpi_rs_decode_general_flags(&output_struct->data, *buffer); 292 - 293 - /* Get the Type Specific Flags (Byte5) */ 294 - 295 - buffer += 1; 296 - acpi_rs_decode_specific_flags(&output_struct->data, *buffer); 297 - 298 - /* Get Granularity (Bytes 6-7) */ 299 - 300 - buffer += 1; 301 - ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer); 302 - 303 - /* Get min_address_range (Bytes 8-9) */ 304 - 305 - buffer += 2; 306 - ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range, 307 - buffer); 308 - 309 - /* Get max_address_range (Bytes 10-11) */ 310 - 311 - buffer += 2; 312 - ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range, 313 - buffer); 314 - 315 - /* Get address_translation_offset (Bytes 12-13) */ 316 - 317 - buffer += 2; 318 - ACPI_MOVE_16_TO_32(&output_struct->data.address16. 319 - address_translation_offset, buffer); 320 - 321 - /* Get address_length (Bytes 14-15) */ 322 - 323 - buffer += 2; 324 - ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length, 325 - buffer); 326 - 327 - /* Resource Source Index (if present) */ 328 - 329 - buffer += 2; 330 - 331 - /* 332 - * This will leave us pointing to the Resource Source Index 333 - * If it is present, then save it off and calculate the 334 - * pointer to where the null terminated string goes: 335 - * Each Interrupt takes 32-bits + the 5 bytes of the 336 - * stream that are default. 337 - * 338 - * Note: Some resource descriptors will have an additional null, so 339 - * we add 1 to the length. 340 - */ 341 - if (*bytes_consumed > (16 + 1)) { 342 - /* Dereference the Index */ 343 - 344 - output_struct->data.address16.resource_source.index = 345 - (u32) * buffer; 346 - 347 - /* Point to the String */ 348 - 349 - buffer += 1; 350 - 351 - /* Point the String pointer to the end of this structure */ 352 - 353 - output_struct->data.address16.resource_source.string_ptr = 354 - (char *)((u8 *) output_struct + struct_size); 355 - 356 - temp_ptr = (u8 *) 357 - output_struct->data.address16.resource_source.string_ptr; 358 - 359 - /* Copy the resource_source string into the buffer */ 360 - 361 - index = 0; 362 - while (*buffer) { 363 - *temp_ptr = *buffer; 364 - 365 - temp_ptr++; 366 - buffer++; 367 - index++; 368 - } 369 - 370 - /* Add the terminating null and set the string length */ 371 - 372 - *temp_ptr = 0; 373 - output_struct->data.address16.resource_source.string_length = 374 - index + 1; 375 - 376 - /* 377 - * In order for the struct_size to fall on a 32-bit boundary, 378 - * calculate the length of the string and expand the 379 - * struct_size to the next 32-bit boundary. 380 - */ 381 - temp8 = (u8) (index + 1); 382 - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); 383 - } else { 384 - output_struct->data.address16.resource_source.index = 0; 385 - output_struct->data.address16.resource_source.string_length = 0; 386 - output_struct->data.address16.resource_source.string_ptr = NULL; 387 - } 388 - 389 - /* Set the Length parameter */ 390 - 391 - output_struct->length = (u32) struct_size; 392 - 393 - /* Return the final size of the structure */ 394 - 395 - *structure_size = struct_size; 396 - return_ACPI_STATUS(AE_OK); 397 - } 398 - 399 - /******************************************************************************* 400 - * 401 - * FUNCTION: acpi_rs_address16_stream 402 - * 403 - * PARAMETERS: Resource - Pointer to the resource linked list 404 - * output_buffer - Pointer to the user's return buffer 405 - * bytes_consumed - Pointer to where the number of bytes 406 - * used in the output_buffer is returned 407 - * 408 - * RETURN: Status 409 - * 410 - * DESCRIPTION: Take the linked list resource structure and fills in the 411 - * the appropriate bytes in a byte stream 412 - * 413 - ******************************************************************************/ 414 - 415 - acpi_status 416 - acpi_rs_address16_stream(struct acpi_resource *resource, 417 - u8 ** output_buffer, acpi_size * bytes_consumed) 418 - { 419 - u8 *buffer = *output_buffer; 420 - u8 *length_field; 421 - acpi_size actual_bytes; 422 - 423 - ACPI_FUNCTION_TRACE("rs_address16_stream"); 424 - 425 - /* Set the Descriptor Type field */ 426 - 427 - *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; 428 - buffer += 1; 429 - 430 - /* Save a pointer to the Length field - to be filled in later */ 431 - 432 - length_field = buffer; 433 - buffer += 2; 434 - 435 - /* Set the Resource Type (Memory, Io, bus_number) */ 436 - 437 - *buffer = (u8) (resource->data.address16.resource_type & 0x03); 438 - buffer += 1; 239 + aml->address.resource_type = (u8) resource->data.address.resource_type; 439 240 440 241 /* Set the general flags */ 441 242 442 - *buffer = acpi_rs_encode_general_flags(&resource->data); 443 - buffer += 1; 243 + aml->address.flags = acpi_rs_encode_general_flags(&resource->data); 444 244 445 - /* Set the type specific flags */ 245 + /* Set the type-specific flags */ 446 246 447 - *buffer = acpi_rs_encode_specific_flags(&resource->data); 448 - buffer += 1; 449 - 450 - /* Set the address space granularity */ 451 - 452 - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.granularity); 453 - buffer += 2; 454 - 455 - /* Set the address range minimum */ 456 - 457 - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.min_address_range); 458 - buffer += 2; 459 - 460 - /* Set the address range maximum */ 461 - 462 - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.max_address_range); 463 - buffer += 2; 464 - 465 - /* Set the address translation offset */ 466 - 467 - ACPI_MOVE_32_TO_16(buffer, 468 - &resource->data.address16. 469 - address_translation_offset); 470 - buffer += 2; 471 - 472 - /* Set the address length */ 473 - 474 - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.address_length); 475 - buffer += 2; 476 - 477 - /* Resource Source Index and Resource Source are optional */ 478 - 479 - if (resource->data.address16.resource_source.string_length) { 480 - *buffer = (u8) resource->data.address16.resource_source.index; 481 - buffer += 1; 482 - 483 - /* Copy the resource_source string */ 484 - 485 - ACPI_STRCPY((char *)buffer, 486 - resource->data.address16.resource_source. 487 - string_ptr); 488 - 489 - /* 490 - * Buffer needs to be set to the length of the string + one for the 491 - * terminating null 492 - */ 493 - buffer += 494 - (acpi_size) (ACPI_STRLEN 495 - (resource->data.address16.resource_source. 496 - string_ptr) + 1); 497 - } 498 - 499 - /* Return the number of bytes consumed in this operation */ 500 - 501 - actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer); 502 - *bytes_consumed = actual_bytes; 503 - 504 - /* 505 - * Set the length field to the number of bytes consumed 506 - * minus the header size (3 bytes) 507 - */ 508 - actual_bytes -= 3; 509 - ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes); 510 - return_ACPI_STATUS(AE_OK); 247 + aml->address.specific_flags = 248 + acpi_rs_encode_specific_flags(&resource->data); 511 249 } 512 250 513 251 /******************************************************************************* 514 252 * 515 - * FUNCTION: acpi_rs_address32_resource 253 + * FUNCTION: acpi_rs_get_address_common 516 254 * 517 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 518 - * stream 519 - * bytes_consumed - Pointer to where the number of bytes 520 - * consumed the byte_stream_buffer is 521 - * returned 522 - * output_buffer - Pointer to the return data buffer 523 - * structure_size - Pointer to where the number of bytes 524 - * in the return data struct is returned 255 + * PARAMETERS: Resource - Pointer to the internal resource struct 256 + * Aml - Pointer to the AML resource descriptor 257 + * 258 + * RETURN: TRUE if the resource_type field is OK, FALSE otherwise 259 + * 260 + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor 261 + * to an internal resource descriptor 262 + * 263 + ******************************************************************************/ 264 + 265 + static u8 266 + acpi_rs_get_address_common(struct acpi_resource *resource, 267 + union aml_resource *aml) 268 + { 269 + ACPI_FUNCTION_ENTRY(); 270 + 271 + /* Validate resource type */ 272 + 273 + if ((aml->address.resource_type > 2) 274 + && (aml->address.resource_type < 0xC0)) { 275 + return (FALSE); 276 + } 277 + 278 + /* Get the Resource Type (Memory, Io, bus_number, etc.) */ 279 + 280 + resource->data.address.resource_type = aml->address.resource_type; 281 + 282 + /* Get the General Flags */ 283 + 284 + acpi_rs_decode_general_flags(&resource->data, aml->address.flags); 285 + 286 + /* Get the Type-Specific Flags */ 287 + 288 + acpi_rs_decode_specific_flags(&resource->data, 289 + aml->address.specific_flags); 290 + return (TRUE); 291 + } 292 + 293 + /******************************************************************************* 294 + * 295 + * FUNCTION: acpi_rs_get_address16 296 + * 297 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 298 + * aml_resource_length - Length of the resource from the AML header 299 + * Resource - Where the internal resource is returned 525 300 * 526 301 * RETURN: Status 527 302 * 528 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 529 - * structure pointed to by the output_buffer. Return the 530 - * number of bytes consumed from the byte stream. 303 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 304 + * internal resource descriptor, simplifying bitflags and handling 305 + * alignment and endian issues if necessary. 531 306 * 532 307 ******************************************************************************/ 533 308 534 309 acpi_status 535 - acpi_rs_address32_resource(u8 * byte_stream_buffer, 536 - acpi_size * bytes_consumed, 537 - u8 ** output_buffer, acpi_size * structure_size) 310 + acpi_rs_get_address16(union aml_resource * aml, 311 + u16 aml_resource_length, struct acpi_resource * resource) 538 312 { 539 - u16 temp16; 540 - u8 temp8; 541 - u8 *temp_ptr; 542 - u32 index; 543 - u8 *buffer = byte_stream_buffer; 544 - struct acpi_resource *output_struct = (void *)*output_buffer; 545 - acpi_size struct_size = 546 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); 313 + ACPI_FUNCTION_TRACE("rs_get_address16"); 547 314 548 - ACPI_FUNCTION_TRACE("rs_address32_resource"); 315 + /* Get the Resource Type, general flags, and type-specific flags */ 549 316 550 - /* Get the Descriptor Length field */ 551 - 552 - buffer += 1; 553 - ACPI_MOVE_16_TO_16(&temp16, buffer); 554 - 555 - /* Validate minimum descriptor length */ 556 - 557 - if (temp16 < 23) { 558 - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 559 - } 560 - 561 - *bytes_consumed = temp16 + 3; 562 - output_struct->type = ACPI_RSTYPE_ADDRESS32; 563 - 564 - /* Get the Resource Type (Byte3) */ 565 - 566 - buffer += 2; 567 - temp8 = *buffer; 568 - 569 - /* Values 0-2 and 0xC0-0xFF are valid */ 570 - 571 - if ((temp8 > 2) && (temp8 < 0xC0)) { 317 + if (!acpi_rs_get_address_common(resource, aml)) { 572 318 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 573 319 } 574 320 575 - output_struct->data.address32.resource_type = temp8; 576 - 577 - /* Get the General Flags (Byte4) */ 578 - 579 - buffer += 1; 580 - acpi_rs_decode_general_flags(&output_struct->data, *buffer); 581 - 582 - /* Get the Type Specific Flags (Byte5) */ 583 - 584 - buffer += 1; 585 - acpi_rs_decode_specific_flags(&output_struct->data, *buffer); 586 - 587 - /* Get Granularity (Bytes 6-9) */ 588 - 589 - buffer += 1; 590 - ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer); 591 - 592 - /* Get min_address_range (Bytes 10-13) */ 593 - 594 - buffer += 4; 595 - ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range, 596 - buffer); 597 - 598 - /* Get max_address_range (Bytes 14-17) */ 599 - 600 - buffer += 4; 601 - ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range, 602 - buffer); 603 - 604 - /* Get address_translation_offset (Bytes 18-21) */ 605 - 606 - buffer += 4; 607 - ACPI_MOVE_32_TO_32(&output_struct->data.address32. 608 - address_translation_offset, buffer); 609 - 610 - /* Get address_length (Bytes 22-25) */ 611 - 612 - buffer += 4; 613 - ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length, 614 - buffer); 615 - 616 - /* Resource Source Index (if present) */ 617 - 618 - buffer += 4; 619 - 620 321 /* 621 - * This will leave us pointing to the Resource Source Index 622 - * If it is present, then save it off and calculate the 623 - * pointer to where the null terminated string goes: 624 - * 625 - * Note: Some resource descriptors will have an additional null, so 626 - * we add 1 to the length. 322 + * Get the following contiguous fields from the AML descriptor: 323 + * Address Granularity 324 + * Address Range Minimum 325 + * Address Range Maximum 326 + * Address Translation Offset 327 + * Address Length 627 328 */ 628 - if (*bytes_consumed > (26 + 1)) { 629 - /* Dereference the Index */ 329 + acpi_rs_move_data(&resource->data.address16.granularity, 330 + &aml->address16.granularity, 5, 331 + ACPI_MOVE_TYPE_16_TO_32); 630 332 631 - output_struct->data.address32.resource_source.index = 632 - (u32) * buffer; 333 + /* Get the optional resource_source (index and string) */ 633 334 634 - /* Point to the String */ 335 + resource->length = 336 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) + 337 + acpi_rs_get_resource_source(aml_resource_length, 338 + sizeof(struct aml_resource_address16), 339 + &resource->data.address16. 340 + resource_source, aml, NULL); 635 341 636 - buffer += 1; 342 + /* Complete the resource header */ 637 343 638 - /* Point the String pointer to the end of this structure */ 639 - 640 - output_struct->data.address32.resource_source.string_ptr = 641 - (char *)((u8 *) output_struct + struct_size); 642 - 643 - temp_ptr = (u8 *) 644 - output_struct->data.address32.resource_source.string_ptr; 645 - 646 - /* Copy the resource_source string into the buffer */ 647 - 648 - index = 0; 649 - while (*buffer) { 650 - *temp_ptr = *buffer; 651 - 652 - temp_ptr++; 653 - buffer++; 654 - index++; 655 - } 656 - 657 - /* Add the terminating null and set the string length */ 658 - 659 - *temp_ptr = 0; 660 - output_struct->data.address32.resource_source.string_length = 661 - index + 1; 662 - 663 - /* 664 - * In order for the struct_size to fall on a 32-bit boundary, 665 - * calculate the length of the string and expand the 666 - * struct_size to the next 32-bit boundary. 667 - */ 668 - temp8 = (u8) (index + 1); 669 - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); 670 - } else { 671 - output_struct->data.address32.resource_source.index = 0; 672 - output_struct->data.address32.resource_source.string_length = 0; 673 - output_struct->data.address32.resource_source.string_ptr = NULL; 674 - } 675 - 676 - /* Set the Length parameter */ 677 - 678 - output_struct->length = (u32) struct_size; 679 - 680 - /* Return the final size of the structure */ 681 - 682 - *structure_size = struct_size; 344 + resource->type = ACPI_RESOURCE_TYPE_ADDRESS16; 683 345 return_ACPI_STATUS(AE_OK); 684 346 } 685 347 686 348 /******************************************************************************* 687 349 * 688 - * FUNCTION: acpi_rs_address32_stream 350 + * FUNCTION: acpi_rs_set_address16 689 351 * 690 - * PARAMETERS: Resource - Pointer to the resource linked list 691 - * output_buffer - Pointer to the user's return buffer 692 - * bytes_consumed - Pointer to where the number of bytes 693 - * used in the output_buffer is returned 352 + * PARAMETERS: Resource - Pointer to the resource descriptor 353 + * Aml - Where the AML descriptor is returned 694 354 * 695 355 * RETURN: Status 696 356 * 697 - * DESCRIPTION: Take the linked list resource structure and fills in the 698 - * the appropriate bytes in a byte stream 357 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 358 + * external AML resource descriptor. 699 359 * 700 360 ******************************************************************************/ 701 361 702 362 acpi_status 703 - acpi_rs_address32_stream(struct acpi_resource *resource, 704 - u8 ** output_buffer, acpi_size * bytes_consumed) 363 + acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml) 705 364 { 706 - u8 *buffer; 707 - u16 *length_field; 365 + acpi_size descriptor_length; 708 366 709 - ACPI_FUNCTION_TRACE("rs_address32_stream"); 367 + ACPI_FUNCTION_TRACE("rs_set_address16"); 710 368 711 - buffer = *output_buffer; 369 + /* Set the Resource Type, General Flags, and Type-Specific Flags */ 712 370 713 - /* Set the Descriptor Type field */ 371 + acpi_rs_set_address_common(aml, resource); 714 372 715 - *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; 716 - buffer += 1; 717 - 718 - /* Save a pointer to the Length field - to be filled in later */ 719 - 720 - length_field = ACPI_CAST_PTR(u16, buffer); 721 - buffer += 2; 722 - 723 - /* Set the Resource Type (Memory, Io, bus_number) */ 724 - 725 - *buffer = (u8) (resource->data.address32.resource_type & 0x03); 726 - buffer += 1; 727 - 728 - /* Set the general flags */ 729 - 730 - *buffer = acpi_rs_encode_general_flags(&resource->data); 731 - buffer += 1; 732 - 733 - /* Set the type specific flags */ 734 - 735 - *buffer = acpi_rs_encode_specific_flags(&resource->data); 736 - buffer += 1; 737 - 738 - /* Set the address space granularity */ 739 - 740 - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.granularity); 741 - buffer += 4; 742 - 743 - /* Set the address range minimum */ 744 - 745 - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.min_address_range); 746 - buffer += 4; 747 - 748 - /* Set the address range maximum */ 749 - 750 - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.max_address_range); 751 - buffer += 4; 752 - 753 - /* Set the address translation offset */ 754 - 755 - ACPI_MOVE_32_TO_32(buffer, 756 - &resource->data.address32. 757 - address_translation_offset); 758 - buffer += 4; 759 - 760 - /* Set the address length */ 761 - 762 - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.address_length); 763 - buffer += 4; 373 + /* 374 + * Set the following contiguous fields in the AML descriptor: 375 + * Address Granularity 376 + * Address Range Minimum 377 + * Address Range Maximum 378 + * Address Translation Offset 379 + * Address Length 380 + */ 381 + acpi_rs_move_data(&aml->address16.granularity, 382 + &resource->data.address16.granularity, 5, 383 + ACPI_MOVE_TYPE_32_TO_16); 764 384 765 385 /* Resource Source Index and Resource Source are optional */ 766 386 767 - if (resource->data.address32.resource_source.string_length) { 768 - *buffer = (u8) resource->data.address32.resource_source.index; 769 - buffer += 1; 387 + descriptor_length = acpi_rs_set_resource_source(aml, 388 + sizeof(struct 389 + aml_resource_address16), 390 + &resource->data. 391 + address16. 392 + resource_source); 770 393 771 - /* Copy the resource_source string */ 394 + /* Complete the AML descriptor header */ 772 395 773 - ACPI_STRCPY((char *)buffer, 774 - resource->data.address32.resource_source. 775 - string_ptr); 776 - 777 - /* 778 - * Buffer needs to be set to the length of the string + one for the 779 - * terminating null 780 - */ 781 - buffer += 782 - (acpi_size) (ACPI_STRLEN 783 - (resource->data.address32.resource_source. 784 - string_ptr) + 1); 785 - } 786 - 787 - /* Return the number of bytes consumed in this operation */ 788 - 789 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 790 - 791 - /* 792 - * Set the length field to the number of bytes consumed 793 - * minus the header size (3 bytes) 794 - */ 795 - *length_field = (u16) (*bytes_consumed - 3); 396 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16, 397 + descriptor_length, aml); 796 398 return_ACPI_STATUS(AE_OK); 797 399 } 798 400 799 401 /******************************************************************************* 800 402 * 801 - * FUNCTION: acpi_rs_address64_resource 403 + * FUNCTION: acpi_rs_get_address32 802 404 * 803 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 804 - * stream 805 - * bytes_consumed - Pointer to where the number of bytes 806 - * consumed the byte_stream_buffer is 807 - * returned 808 - * output_buffer - Pointer to the return data buffer 809 - * structure_size - Pointer to where the number of bytes 810 - * in the return data struct is returned 405 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 406 + * aml_resource_length - Length of the resource from the AML header 407 + * Resource - Where the internal resource is returned 811 408 * 812 409 * RETURN: Status 813 410 * 814 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 815 - * structure pointed to by the output_buffer. Return the 816 - * number of bytes consumed from the byte stream. 411 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 412 + * internal resource descriptor, simplifying bitflags and handling 413 + * alignment and endian issues if necessary. 817 414 * 818 415 ******************************************************************************/ 819 416 820 417 acpi_status 821 - acpi_rs_address64_resource(u8 * byte_stream_buffer, 822 - acpi_size * bytes_consumed, 823 - u8 ** output_buffer, acpi_size * structure_size) 418 + acpi_rs_get_address32(union aml_resource *aml, 419 + u16 aml_resource_length, struct acpi_resource *resource) 824 420 { 825 - u16 temp16; 826 - u8 temp8; 827 - u8 resource_type; 828 - u8 *temp_ptr; 829 - u32 index; 830 - u8 *buffer = byte_stream_buffer; 831 - struct acpi_resource *output_struct = (void *)*output_buffer; 832 - acpi_size struct_size = 833 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); 834 421 835 - ACPI_FUNCTION_TRACE("rs_address64_resource"); 422 + ACPI_FUNCTION_TRACE("rs_get_address32"); 836 423 837 - /* Get the Descriptor Type */ 424 + /* Get the Resource Type, general flags, and type-specific flags */ 838 425 839 - resource_type = *buffer; 840 - 841 - /* Get the Descriptor Length field */ 842 - 843 - buffer += 1; 844 - ACPI_MOVE_16_TO_16(&temp16, buffer); 845 - 846 - /* Validate minimum descriptor length */ 847 - 848 - if (temp16 < 43) { 849 - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 850 - } 851 - 852 - *bytes_consumed = temp16 + 3; 853 - output_struct->type = ACPI_RSTYPE_ADDRESS64; 854 - 855 - /* Get the Resource Type (Byte3) */ 856 - 857 - buffer += 2; 858 - temp8 = *buffer; 859 - 860 - /* Values 0-2 and 0xC0-0xFF are valid */ 861 - 862 - if ((temp8 > 2) && (temp8 < 0xC0)) { 426 + if (!acpi_rs_get_address_common(resource, (void *)aml)) { 863 427 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 864 428 } 865 429 866 - output_struct->data.address64.resource_type = temp8; 430 + /* 431 + * Get the following contiguous fields from the AML descriptor: 432 + * Address Granularity 433 + * Address Range Minimum 434 + * Address Range Maximum 435 + * Address Translation Offset 436 + * Address Length 437 + */ 438 + acpi_rs_move_data(&resource->data.address32.granularity, 439 + &aml->address32.granularity, 5, 440 + ACPI_MOVE_TYPE_32_TO_32); 867 441 868 - /* Get the General Flags (Byte4) */ 442 + /* Get the optional resource_source (index and string) */ 869 443 870 - buffer += 1; 871 - acpi_rs_decode_general_flags(&output_struct->data, *buffer); 444 + resource->length = 445 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) + 446 + acpi_rs_get_resource_source(aml_resource_length, 447 + sizeof(struct aml_resource_address32), 448 + &resource->data.address32. 449 + resource_source, aml, NULL); 872 450 873 - /* Get the Type Specific Flags (Byte5) */ 451 + /* Complete the resource header */ 874 452 875 - buffer += 1; 876 - acpi_rs_decode_specific_flags(&output_struct->data, *buffer); 877 - 878 - if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 879 - /* Move past revision_id and Reserved byte */ 880 - 881 - buffer += 2; 882 - } 883 - 884 - /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ 885 - 886 - buffer += 1; 887 - ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer); 888 - 889 - /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ 890 - 891 - buffer += 8; 892 - ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range, 893 - buffer); 894 - 895 - /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ 896 - 897 - buffer += 8; 898 - ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range, 899 - buffer); 900 - 901 - /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ 902 - 903 - buffer += 8; 904 - ACPI_MOVE_64_TO_64(&output_struct->data.address64. 905 - address_translation_offset, buffer); 906 - 907 - /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ 908 - 909 - buffer += 8; 910 - ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, 911 - buffer); 912 - 913 - output_struct->data.address64.resource_source.index = 0; 914 - output_struct->data.address64.resource_source.string_length = 0; 915 - output_struct->data.address64.resource_source.string_ptr = NULL; 916 - 917 - if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 918 - /* Get type_specific_attribute (Bytes 48-55) */ 919 - 920 - buffer += 8; 921 - ACPI_MOVE_64_TO_64(&output_struct->data.address64. 922 - type_specific_attributes, buffer); 923 - } else { 924 - output_struct->data.address64.type_specific_attributes = 0; 925 - 926 - /* Resource Source Index (if present) */ 927 - 928 - buffer += 8; 929 - 930 - /* 931 - * This will leave us pointing to the Resource Source Index 932 - * If it is present, then save it off and calculate the 933 - * pointer to where the null terminated string goes: 934 - * Each Interrupt takes 32-bits + the 5 bytes of the 935 - * stream that are default. 936 - * 937 - * Note: Some resource descriptors will have an additional null, so 938 - * we add 1 to the length. 939 - */ 940 - if (*bytes_consumed > (46 + 1)) { 941 - /* Dereference the Index */ 942 - 943 - output_struct->data.address64.resource_source.index = 944 - (u32) * buffer; 945 - 946 - /* Point to the String */ 947 - 948 - buffer += 1; 949 - 950 - /* Point the String pointer to the end of this structure */ 951 - 952 - output_struct->data.address64.resource_source. 953 - string_ptr = 954 - (char *)((u8 *) output_struct + struct_size); 955 - 956 - temp_ptr = (u8 *) 957 - output_struct->data.address64.resource_source. 958 - string_ptr; 959 - 960 - /* Copy the resource_source string into the buffer */ 961 - 962 - index = 0; 963 - while (*buffer) { 964 - *temp_ptr = *buffer; 965 - 966 - temp_ptr++; 967 - buffer++; 968 - index++; 969 - } 970 - 971 - /* 972 - * Add the terminating null and set the string length 973 - */ 974 - *temp_ptr = 0; 975 - output_struct->data.address64.resource_source. 976 - string_length = index + 1; 977 - 978 - /* 979 - * In order for the struct_size to fall on a 32-bit boundary, 980 - * calculate the length of the string and expand the 981 - * struct_size to the next 32-bit boundary. 982 - */ 983 - temp8 = (u8) (index + 1); 984 - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); 985 - } 986 - } 987 - 988 - /* Set the Length parameter */ 989 - 990 - output_struct->length = (u32) struct_size; 991 - 992 - /* Return the final size of the structure */ 993 - 994 - *structure_size = struct_size; 453 + resource->type = ACPI_RESOURCE_TYPE_ADDRESS32; 995 454 return_ACPI_STATUS(AE_OK); 996 455 } 997 456 998 457 /******************************************************************************* 999 458 * 1000 - * FUNCTION: acpi_rs_address64_stream 459 + * FUNCTION: acpi_rs_set_address32 1001 460 * 1002 - * PARAMETERS: Resource - Pointer to the resource linked list 1003 - * output_buffer - Pointer to the user's return buffer 1004 - * bytes_consumed - Pointer to where the number of bytes 1005 - * used in the output_buffer is returned 461 + * PARAMETERS: Resource - Pointer to the resource descriptor 462 + * Aml - Where the AML descriptor is returned 1006 463 * 1007 464 * RETURN: Status 1008 465 * 1009 - * DESCRIPTION: Take the linked list resource structure and fills in the 1010 - * the appropriate bytes in a byte stream 466 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 467 + * external AML resource descriptor. 1011 468 * 1012 469 ******************************************************************************/ 1013 470 1014 471 acpi_status 1015 - acpi_rs_address64_stream(struct acpi_resource *resource, 1016 - u8 ** output_buffer, acpi_size * bytes_consumed) 472 + acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml) 1017 473 { 1018 - u8 *buffer; 1019 - u16 *length_field; 474 + acpi_size descriptor_length; 1020 475 1021 - ACPI_FUNCTION_TRACE("rs_address64_stream"); 476 + ACPI_FUNCTION_TRACE("rs_set_address32"); 1022 477 1023 - buffer = *output_buffer; 478 + /* Set the Resource Type, General Flags, and Type-Specific Flags */ 1024 479 1025 - /* Set the Descriptor Type field */ 480 + acpi_rs_set_address_common(aml, resource); 1026 481 1027 - *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; 1028 - buffer += 1; 1029 - 1030 - /* Save a pointer to the Length field - to be filled in later */ 1031 - 1032 - length_field = ACPI_CAST_PTR(u16, buffer); 1033 - buffer += 2; 1034 - 1035 - /* Set the Resource Type (Memory, Io, bus_number) */ 1036 - 1037 - *buffer = (u8) (resource->data.address64.resource_type & 0x03); 1038 - buffer += 1; 1039 - 1040 - /* Set the general flags */ 1041 - 1042 - *buffer = acpi_rs_encode_general_flags(&resource->data); 1043 - buffer += 1; 1044 - 1045 - /* Set the type specific flags */ 1046 - 1047 - *buffer = acpi_rs_encode_specific_flags(&resource->data); 1048 - buffer += 1; 1049 - 1050 - /* Set the address space granularity */ 1051 - 1052 - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.granularity); 1053 - buffer += 8; 1054 - 1055 - /* Set the address range minimum */ 1056 - 1057 - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.min_address_range); 1058 - buffer += 8; 1059 - 1060 - /* Set the address range maximum */ 1061 - 1062 - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.max_address_range); 1063 - buffer += 8; 1064 - 1065 - /* Set the address translation offset */ 1066 - 1067 - ACPI_MOVE_64_TO_64(buffer, 1068 - &resource->data.address64. 1069 - address_translation_offset); 1070 - buffer += 8; 1071 - 1072 - /* Set the address length */ 1073 - 1074 - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.address_length); 1075 - buffer += 8; 482 + /* 483 + * Set the following contiguous fields in the AML descriptor: 484 + * Address Granularity 485 + * Address Range Minimum 486 + * Address Range Maximum 487 + * Address Translation Offset 488 + * Address Length 489 + */ 490 + acpi_rs_move_data(&aml->address32.granularity, 491 + &resource->data.address32.granularity, 5, 492 + ACPI_MOVE_TYPE_32_TO_32); 1076 493 1077 494 /* Resource Source Index and Resource Source are optional */ 1078 495 1079 - if (resource->data.address64.resource_source.string_length) { 1080 - *buffer = (u8) resource->data.address64.resource_source.index; 1081 - buffer += 1; 496 + descriptor_length = acpi_rs_set_resource_source(aml, 497 + sizeof(struct 498 + aml_resource_address32), 499 + &resource->data. 500 + address32. 501 + resource_source); 1082 502 1083 - /* Copy the resource_source string */ 503 + /* Complete the AML descriptor header */ 1084 504 1085 - ACPI_STRCPY((char *)buffer, 1086 - resource->data.address64.resource_source. 1087 - string_ptr); 505 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32, 506 + descriptor_length, aml); 507 + return_ACPI_STATUS(AE_OK); 508 + } 1088 509 1089 - /* 1090 - * Buffer needs to be set to the length of the string + one for the 1091 - * terminating null 1092 - */ 1093 - buffer += 1094 - (acpi_size) (ACPI_STRLEN 1095 - (resource->data.address64.resource_source. 1096 - string_ptr) + 1); 510 + /******************************************************************************* 511 + * 512 + * FUNCTION: acpi_rs_get_address64 513 + * 514 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 515 + * aml_resource_length - Length of the resource from the AML header 516 + * Resource - Where the internal resource is returned 517 + * 518 + * RETURN: Status 519 + * 520 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 521 + * internal resource descriptor, simplifying bitflags and handling 522 + * alignment and endian issues if necessary. 523 + * 524 + ******************************************************************************/ 525 + 526 + acpi_status 527 + acpi_rs_get_address64(union aml_resource *aml, 528 + u16 aml_resource_length, struct acpi_resource *resource) 529 + { 530 + ACPI_FUNCTION_TRACE("rs_get_address64"); 531 + 532 + /* Get the Resource Type, general Flags, and type-specific Flags */ 533 + 534 + if (!acpi_rs_get_address_common(resource, aml)) { 535 + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 1097 536 } 1098 537 1099 - /* Return the number of bytes consumed in this operation */ 538 + /* 539 + * Get the following contiguous fields from the AML descriptor: 540 + * Address Granularity 541 + * Address Range Minimum 542 + * Address Range Maximum 543 + * Address Translation Offset 544 + * Address Length 545 + */ 546 + acpi_rs_move_data(&resource->data.address64.granularity, 547 + &aml->address64.granularity, 5, 548 + ACPI_MOVE_TYPE_64_TO_64); 1100 549 1101 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 550 + /* Get the optional resource_source (index and string) */ 551 + 552 + resource->length = 553 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) + 554 + acpi_rs_get_resource_source(aml_resource_length, 555 + sizeof(struct aml_resource_address64), 556 + &resource->data.address64. 557 + resource_source, aml, NULL); 558 + 559 + /* Complete the resource header */ 560 + 561 + resource->type = ACPI_RESOURCE_TYPE_ADDRESS64; 562 + return_ACPI_STATUS(AE_OK); 563 + } 564 + 565 + /******************************************************************************* 566 + * 567 + * FUNCTION: acpi_rs_set_address64 568 + * 569 + * PARAMETERS: Resource - Pointer to the resource descriptor 570 + * Aml - Where the AML descriptor is returned 571 + * 572 + * RETURN: Status 573 + * 574 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 575 + * external AML resource descriptor. 576 + * 577 + ******************************************************************************/ 578 + 579 + acpi_status 580 + acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml) 581 + { 582 + acpi_size descriptor_length; 583 + 584 + ACPI_FUNCTION_TRACE("rs_set_address64"); 585 + 586 + /* Set the Resource Type, General Flags, and Type-Specific Flags */ 587 + 588 + acpi_rs_set_address_common(aml, resource); 1102 589 1103 590 /* 1104 - * Set the length field to the number of bytes consumed 1105 - * minus the header size (3 bytes) 591 + * Set the following contiguous fields in the AML descriptor: 592 + * Address Granularity 593 + * Address Range Minimum 594 + * Address Range Maximum 595 + * Address Translation Offset 596 + * Address Length 1106 597 */ 1107 - *length_field = (u16) (*bytes_consumed - 3); 598 + acpi_rs_move_data(&aml->address64.granularity, 599 + &resource->data.address64.granularity, 5, 600 + ACPI_MOVE_TYPE_64_TO_64); 601 + 602 + /* Resource Source Index and Resource Source are optional */ 603 + 604 + descriptor_length = acpi_rs_set_resource_source(aml, 605 + sizeof(struct 606 + aml_resource_address64), 607 + &resource->data. 608 + address64. 609 + resource_source); 610 + 611 + /* Complete the AML descriptor header */ 612 + 613 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64, 614 + descriptor_length, aml); 615 + return_ACPI_STATUS(AE_OK); 616 + } 617 + 618 + /******************************************************************************* 619 + * 620 + * FUNCTION: acpi_rs_get_ext_address64 621 + * 622 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 623 + * aml_resource_length - Length of the resource from the AML header 624 + * Resource - Where the internal resource is returned 625 + * 626 + * RETURN: Status 627 + * 628 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 629 + * internal resource descriptor, simplifying bitflags and handling 630 + * alignment and endian issues if necessary. 631 + * 632 + ******************************************************************************/ 633 + 634 + acpi_status 635 + acpi_rs_get_ext_address64(union aml_resource *aml, 636 + u16 aml_resource_length, 637 + struct acpi_resource *resource) 638 + { 639 + 640 + ACPI_FUNCTION_TRACE("rs_get_ext_address64"); 641 + 642 + /* Get the Resource Type, general flags, and type-specific flags */ 643 + 644 + if (!acpi_rs_get_address_common(resource, aml)) { 645 + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 646 + } 647 + 648 + /* 649 + * Get and validate the Revision ID 650 + * Note: Only one revision ID is currently supported 651 + */ 652 + resource->data.ext_address64.revision_iD = 653 + aml->ext_address64.revision_iD; 654 + if (aml->ext_address64.revision_iD != 655 + AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { 656 + return_ACPI_STATUS(AE_SUPPORT); 657 + } 658 + 659 + /* 660 + * Get the following contiguous fields from the AML descriptor: 661 + * Address Granularity 662 + * Address Range Minimum 663 + * Address Range Maximum 664 + * Address Translation Offset 665 + * Address Length 666 + * Type-Specific Attribute 667 + */ 668 + acpi_rs_move_data(&resource->data.ext_address64.granularity, 669 + &aml->ext_address64.granularity, 6, 670 + ACPI_MOVE_TYPE_64_TO_64); 671 + 672 + /* Complete the resource header */ 673 + 674 + resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64; 675 + resource->length = 676 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64); 677 + return_ACPI_STATUS(AE_OK); 678 + } 679 + 680 + /******************************************************************************* 681 + * 682 + * FUNCTION: acpi_rs_set_ext_address64 683 + * 684 + * PARAMETERS: Resource - Pointer to the resource descriptor 685 + * Aml - Where the AML descriptor is returned 686 + * 687 + * RETURN: Status 688 + * 689 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 690 + * external AML resource descriptor. 691 + * 692 + ******************************************************************************/ 693 + 694 + acpi_status 695 + acpi_rs_set_ext_address64(struct acpi_resource *resource, 696 + union aml_resource *aml) 697 + { 698 + ACPI_FUNCTION_TRACE("rs_set_ext_address64"); 699 + 700 + /* Set the Resource Type, General Flags, and Type-Specific Flags */ 701 + 702 + acpi_rs_set_address_common(aml, resource); 703 + 704 + /* Only one Revision ID is currently supported */ 705 + 706 + aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; 707 + aml->ext_address64.reserved = 0; 708 + 709 + /* 710 + * Set the following contiguous fields in the AML descriptor: 711 + * Address Granularity 712 + * Address Range Minimum 713 + * Address Range Maximum 714 + * Address Translation Offset 715 + * Address Length 716 + * Type-Specific Attribute 717 + */ 718 + acpi_rs_move_data(&aml->ext_address64.granularity, 719 + &resource->data.address64.granularity, 6, 720 + ACPI_MOVE_TYPE_64_TO_64); 721 + 722 + /* Complete the AML descriptor header */ 723 + 724 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, 725 + sizeof(struct 726 + aml_resource_extended_address64), 727 + aml); 1108 728 return_ACPI_STATUS(AE_OK); 1109 729 }
+63 -219
drivers/acpi/resources/rscalc.c
··· 44 44 #include <acpi/acpi.h> 45 45 #include <acpi/acresrc.h> 46 46 #include <acpi/amlcode.h> 47 - #include <acpi/amlresrc.h> 48 47 #include <acpi/acnamesp.h> 49 48 50 49 #define _COMPONENT ACPI_RESOURCES 51 50 ACPI_MODULE_NAME("rscalc") 52 51 53 - /* 54 - * Base sizes for external resource descriptors, indexed by internal type. 55 - * Includes size of the descriptor header (1 byte for small descriptors, 56 - * 3 bytes for large descriptors) 57 - */ 58 - static u8 acpi_gbl_stream_sizes[] = { 59 - 4, /* ACPI_RSTYPE_IRQ (Byte 3 is optional, but always created) */ 60 - 3, /* ACPI_RSTYPE_DMA */ 61 - 2, /* ACPI_RSTYPE_START_DPF (Byte 1 is optional, but always created) */ 62 - 1, /* ACPI_RSTYPE_END_DPF */ 63 - 8, /* ACPI_RSTYPE_IO */ 64 - 4, /* ACPI_RSTYPE_FIXED_IO */ 65 - 1, /* ACPI_RSTYPE_VENDOR */ 66 - 2, /* ACPI_RSTYPE_END_TAG */ 67 - 12, /* ACPI_RSTYPE_MEM24 */ 68 - 20, /* ACPI_RSTYPE_MEM32 */ 69 - 12, /* ACPI_RSTYPE_FIXED_MEM32 */ 70 - 16, /* ACPI_RSTYPE_ADDRESS16 */ 71 - 26, /* ACPI_RSTYPE_ADDRESS32 */ 72 - 46, /* ACPI_RSTYPE_ADDRESS64 */ 73 - 9, /* ACPI_RSTYPE_EXT_IRQ */ 74 - 15 /* ACPI_RSTYPE_GENERIC_REG */ 75 - }; 76 - 77 - /* 78 - * Base sizes of resource descriptors, both the actual AML stream length and 79 - * size of the internal struct representation. 80 - */ 81 - struct acpi_resource_sizes { 82 - u8 minimum_stream_size; 83 - u8 minimum_struct_size; 84 - }; 85 - 86 - static struct acpi_resource_sizes acpi_gbl_sm_resource_sizes[] = { 87 - {0, 0}, /* 0x00, Reserved */ 88 - {0, 0}, /* 0x01, Reserved */ 89 - {0, 0}, /* 0x02, Reserved */ 90 - {0, 0}, /* 0x03, Reserved */ 91 - {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)}, /* ACPI_RDESC_TYPE_IRQ_FORMAT */ 92 - {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)}, /* ACPI_RDESC_TYPE_DMA_FORMAT */ 93 - {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf)}, /* ACPI_RDESC_TYPE_START_DEPENDENT */ 94 - {1, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_DEPENDENT */ 95 - {8, ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)}, /* ACPI_RDESC_TYPE_IO_PORT */ 96 - {4, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)}, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */ 97 - {0, 0}, /* 0x0A, Reserved */ 98 - {0, 0}, /* 0x0B, Reserved */ 99 - {0, 0}, /* 0x0C, Reserved */ 100 - {0, 0}, /* 0x0D, Reserved */ 101 - {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_SMALL_VENDOR */ 102 - {2, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_TAG */ 103 - }; 104 - 105 - static struct acpi_resource_sizes acpi_gbl_lg_resource_sizes[] = { 106 - {0, 0}, /* 0x00, Reserved */ 107 - {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24)}, /* ACPI_RDESC_TYPE_MEMORY_24 */ 108 - {15, ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg)}, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */ 109 - {0, 0}, /* 0x03, Reserved */ 110 - {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_LARGE_VENDOR */ 111 - {20, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32)}, /* ACPI_RDESC_TYPE_MEMORY_32 */ 112 - {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32)}, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */ 113 - {26, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)}, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */ 114 - {16, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)}, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */ 115 - {9, ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq)}, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */ 116 - {46, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */ 117 - {56, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */ 118 - }; 119 - 120 52 /* Local prototypes */ 121 - 122 53 static u8 acpi_rs_count_set_bits(u16 bit_field); 123 - 124 - static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type); 125 - 126 - static u16 acpi_rs_get_resource_length(u8 * resource); 127 54 128 55 static acpi_size 129 56 acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); ··· 84 157 } 85 158 86 159 return (bits_set); 87 - } 88 - 89 - /******************************************************************************* 90 - * 91 - * FUNCTION: acpi_rs_get_resource_sizes 92 - * 93 - * PARAMETERS: resource_type - Byte 0 of a resource descriptor 94 - * 95 - * RETURN: Pointer to the resource conversion handler 96 - * 97 - * DESCRIPTION: Extract the Resource Type/Name from the first byte of 98 - * a resource descriptor. 99 - * 100 - ******************************************************************************/ 101 - 102 - static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type) 103 - { 104 - struct acpi_resource_sizes *size_info; 105 - 106 - ACPI_FUNCTION_ENTRY(); 107 - 108 - /* Determine if this is a small or large resource */ 109 - 110 - if (resource_type & ACPI_RDESC_TYPE_LARGE) { 111 - /* Large Resource Type -- bits 6:0 contain the name */ 112 - 113 - if (resource_type > ACPI_RDESC_LARGE_MAX) { 114 - return (NULL); 115 - } 116 - 117 - size_info = &acpi_gbl_lg_resource_sizes[(resource_type & 118 - ACPI_RDESC_LARGE_MASK)]; 119 - } else { 120 - /* Small Resource Type -- bits 6:3 contain the name */ 121 - 122 - size_info = &acpi_gbl_sm_resource_sizes[((resource_type & 123 - ACPI_RDESC_SMALL_MASK) 124 - >> 3)]; 125 - } 126 - 127 - /* Zero entry indicates an invalid resource type */ 128 - 129 - if (!size_info->minimum_stream_size) { 130 - return (NULL); 131 - } 132 - 133 - return (size_info); 134 - } 135 - 136 - /******************************************************************************* 137 - * 138 - * FUNCTION: acpi_rs_get_resource_length 139 - * 140 - * PARAMETERS: Resource - Pointer to the resource descriptor 141 - * 142 - * RETURN: Byte length of the (AML byte stream) descriptor. By definition, 143 - * this does not include the size of the descriptor header and the 144 - * length field itself. 145 - * 146 - * DESCRIPTION: Extract the length of a resource descriptor. 147 - * 148 - ******************************************************************************/ 149 - 150 - static u16 acpi_rs_get_resource_length(u8 * resource) 151 - { 152 - u16 resource_length; 153 - 154 - ACPI_FUNCTION_ENTRY(); 155 - 156 - /* Determine if this is a small or large resource */ 157 - 158 - if (*resource & ACPI_RDESC_TYPE_LARGE) { 159 - /* Large Resource type -- length is in bytes 1-2 */ 160 - 161 - ACPI_MOVE_16_TO_16(&resource_length, (resource + 1)); 162 - 163 - } else { 164 - /* Small Resource Type -- bits 2:0 of byte 0 contain the length */ 165 - 166 - resource_length = 167 - (u16) (*resource & ACPI_RDESC_SMALL_LENGTH_MASK); 168 - } 169 - 170 - return (resource_length); 171 160 } 172 161 173 162 /******************************************************************************* ··· 134 291 ******************************************************************************/ 135 292 136 293 static u32 137 - acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) 294 + acpi_rs_stream_option_length(u32 resource_length, 295 + u32 minimum_aml_resource_length) 138 296 { 139 297 u32 string_length = 0; 140 - u32 minimum_resource_length; 141 298 142 299 ACPI_FUNCTION_ENTRY(); 143 300 ··· 146 303 * Large-type resource descriptors. 147 304 */ 148 305 149 - /* Compute minimum size of the data part of the resource descriptor */ 150 - 151 - minimum_resource_length = 152 - minimum_total_length - sizeof(struct asl_large_header); 153 - 154 306 /* 155 307 * If the length of the actual resource descriptor is greater than the ACPI 156 308 * spec-defined minimum length, it means that a resource_source_index exists ··· 153 315 * (including the null terminator) is the resource length minus the minimum 154 316 * length, minus one byte for the resource_source_index itself. 155 317 */ 156 - if (resource_length > minimum_resource_length) { 318 + if (resource_length > minimum_aml_resource_length) { 157 319 /* Compute the length of the optional string */ 158 320 159 - string_length = resource_length - minimum_resource_length - 1; 321 + string_length = 322 + resource_length - minimum_aml_resource_length - 1; 160 323 } 161 324 162 325 /* Round up length to 32 bits for internal structure alignment */ ··· 167 328 168 329 /******************************************************************************* 169 330 * 170 - * FUNCTION: acpi_rs_get_byte_stream_length 331 + * FUNCTION: acpi_rs_get_aml_length 171 332 * 172 333 * PARAMETERS: Resource - Pointer to the resource linked list 173 334 * size_needed - Where the required size is returned ··· 181 342 ******************************************************************************/ 182 343 183 344 acpi_status 184 - acpi_rs_get_byte_stream_length(struct acpi_resource * resource, 185 - acpi_size * size_needed) 345 + acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) 186 346 { 187 - acpi_size byte_stream_size_needed = 0; 347 + acpi_size aml_size_needed = 0; 188 348 acpi_size segment_size; 189 349 190 - ACPI_FUNCTION_TRACE("rs_get_byte_stream_length"); 350 + ACPI_FUNCTION_TRACE("rs_get_aml_length"); 191 351 192 352 /* Traverse entire list of internal resource descriptors */ 193 353 194 354 while (resource) { 195 355 /* Validate the descriptor type */ 196 356 197 - if (resource->type > ACPI_RSTYPE_MAX) { 357 + if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 198 358 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 199 359 } 200 360 201 361 /* Get the base size of the (external stream) resource descriptor */ 202 362 203 - segment_size = acpi_gbl_stream_sizes[resource->type]; 363 + segment_size = acpi_gbl_aml_resource_sizes[resource->type]; 204 364 205 365 /* 206 366 * Augment the base size for descriptors with optional and/or 207 367 * variable-length fields 208 368 */ 209 369 switch (resource->type) { 210 - case ACPI_RSTYPE_VENDOR: 370 + case ACPI_RESOURCE_TYPE_VENDOR: 211 371 /* 212 372 * Vendor Defined Resource: 213 373 * For a Vendor Specific resource, if the Length is between 1 and 7 214 374 * it will be created as a Small Resource data type, otherwise it 215 375 * is a Large Resource data type. 216 376 */ 217 - if (resource->data.vendor_specific.length > 7) { 377 + if (resource->data.vendor.byte_length > 7) { 218 378 /* Base size of a Large resource descriptor */ 219 379 220 - segment_size = 3; 380 + segment_size = 381 + sizeof(struct aml_resource_large_header); 221 382 } 222 383 223 384 /* Add the size of the vendor-specific data */ 224 385 225 - segment_size += resource->data.vendor_specific.length; 386 + segment_size += resource->data.vendor.byte_length; 226 387 break; 227 388 228 - case ACPI_RSTYPE_END_TAG: 389 + case ACPI_RESOURCE_TYPE_END_TAG: 229 390 /* 230 391 * End Tag: 231 392 * We are done -- return the accumulated total size. 232 393 */ 233 - *size_needed = byte_stream_size_needed + segment_size; 394 + *size_needed = aml_size_needed + segment_size; 234 395 235 396 /* Normal exit */ 236 397 237 398 return_ACPI_STATUS(AE_OK); 238 399 239 - case ACPI_RSTYPE_ADDRESS16: 400 + case ACPI_RESOURCE_TYPE_ADDRESS16: 240 401 /* 241 402 * 16-Bit Address Resource: 242 403 * Add the size of the optional resource_source info ··· 247 408 resource_source); 248 409 break; 249 410 250 - case ACPI_RSTYPE_ADDRESS32: 411 + case ACPI_RESOURCE_TYPE_ADDRESS32: 251 412 /* 252 413 * 32-Bit Address Resource: 253 414 * Add the size of the optional resource_source info ··· 258 419 resource_source); 259 420 break; 260 421 261 - case ACPI_RSTYPE_ADDRESS64: 422 + case ACPI_RESOURCE_TYPE_ADDRESS64: 262 423 /* 263 424 * 64-Bit Address Resource: 264 425 * Add the size of the optional resource_source info ··· 269 430 resource_source); 270 431 break; 271 432 272 - case ACPI_RSTYPE_EXT_IRQ: 433 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 273 434 /* 274 435 * Extended IRQ Resource: 275 436 * Add the size of each additional optional interrupt beyond the ··· 277 438 */ 278 439 segment_size += (((acpi_size) 279 440 resource->data.extended_irq. 280 - number_of_interrupts - 1) * 4); 441 + interrupt_count - 1) * 4); 281 442 282 443 /* Add the size of the optional resource_source info */ 283 444 ··· 293 454 294 455 /* Update the total */ 295 456 296 - byte_stream_size_needed += segment_size; 457 + aml_size_needed += segment_size; 297 458 298 459 /* Point to the next object */ 299 460 ··· 310 471 * 311 472 * FUNCTION: acpi_rs_get_list_length 312 473 * 313 - * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 314 - * byte_stream_buffer_length - Size of byte_stream_buffer 315 - * size_needed - Where the size needed is returned 474 + * PARAMETERS: aml_buffer - Pointer to the resource byte stream 475 + * aml_buffer_length - Size of aml_buffer 476 + * size_needed - Where the size needed is returned 316 477 * 317 478 * RETURN: Status 318 479 * ··· 323 484 ******************************************************************************/ 324 485 325 486 acpi_status 326 - acpi_rs_get_list_length(u8 * byte_stream_buffer, 327 - u32 byte_stream_buffer_length, acpi_size * size_needed) 487 + acpi_rs_get_list_length(u8 * aml_buffer, 488 + u32 aml_buffer_length, acpi_size * size_needed) 328 489 { 329 490 u8 *buffer; 330 - struct acpi_resource_sizes *resource_info; 491 + struct acpi_resource_info *resource_info; 331 492 u32 buffer_size = 0; 332 493 u32 bytes_parsed = 0; 333 494 u8 resource_type; ··· 338 499 339 500 ACPI_FUNCTION_TRACE("rs_get_list_length"); 340 501 341 - while (bytes_parsed < byte_stream_buffer_length) { 502 + while (bytes_parsed < aml_buffer_length) { 342 503 /* The next byte in the stream is the resource descriptor type */ 343 504 344 - resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); 505 + resource_type = acpi_rs_get_resource_type(*aml_buffer); 345 506 346 507 /* Get the base stream size and structure sizes for the descriptor */ 347 508 348 - resource_info = acpi_rs_get_resource_sizes(resource_type); 509 + resource_info = acpi_rs_get_resource_info(resource_type); 349 510 if (!resource_info) { 350 511 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 351 512 } ··· 353 514 /* Get the Length field from the input resource descriptor */ 354 515 355 516 resource_length = 356 - acpi_rs_get_resource_length(byte_stream_buffer); 517 + acpi_rs_get_resource_length(ACPI_CAST_PTR 518 + (union aml_resource, 519 + aml_buffer)); 357 520 358 521 /* Augment the size for descriptors with optional fields */ 359 522 360 523 extra_struct_bytes = 0; 361 524 362 - if (!(resource_type & ACPI_RDESC_TYPE_LARGE)) { 525 + if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { 363 526 /* 364 527 * Small resource descriptors 365 528 */ 366 - header_length = 1; 367 - buffer = byte_stream_buffer + header_length; 529 + header_length = 530 + sizeof(struct aml_resource_small_header); 531 + buffer = aml_buffer + header_length; 368 532 369 533 switch (resource_type) { 370 - case ACPI_RDESC_TYPE_IRQ_FORMAT: 534 + case ACPI_RESOURCE_NAME_IRQ: 371 535 /* 372 536 * IRQ Resource: 373 537 * Get the number of bits set in the IRQ word 374 538 */ 375 539 ACPI_MOVE_16_TO_16(&temp16, buffer); 376 - 377 540 extra_struct_bytes = 378 541 (acpi_rs_count_set_bits(temp16) * 379 542 sizeof(u32)); 380 543 break; 381 544 382 - case ACPI_RDESC_TYPE_DMA_FORMAT: 545 + case ACPI_RESOURCE_NAME_DMA: 383 546 /* 384 547 * DMA Resource: 385 548 * Get the number of bits set in the DMA channels byte 386 549 */ 550 + ACPI_MOVE_16_TO_16(&temp16, buffer); 387 551 extra_struct_bytes = 388 - (acpi_rs_count_set_bits((u16) * buffer) * 552 + (acpi_rs_count_set_bits(temp16) * 389 553 sizeof(u32)); 390 554 break; 391 555 392 - case ACPI_RDESC_TYPE_SMALL_VENDOR: 556 + case ACPI_RESOURCE_NAME_VENDOR_SMALL: 393 557 /* 394 558 * Vendor Specific Resource: 395 559 * Ensure a 32-bit boundary for the structure ··· 401 559 ACPI_ROUND_UP_to_32_bITS(resource_length); 402 560 break; 403 561 404 - case ACPI_RDESC_TYPE_END_TAG: 562 + case ACPI_RESOURCE_NAME_END_TAG: 405 563 /* 406 564 * End Tag: 407 565 * Terminate the loop now 408 566 */ 409 - byte_stream_buffer_length = bytes_parsed; 567 + aml_buffer_length = bytes_parsed; 410 568 break; 411 569 412 570 default: ··· 416 574 /* 417 575 * Large resource descriptors 418 576 */ 419 - header_length = sizeof(struct asl_large_header); 420 - buffer = byte_stream_buffer + header_length; 577 + header_length = 578 + sizeof(struct aml_resource_large_header); 579 + buffer = aml_buffer + header_length; 421 580 422 581 switch (resource_type) { 423 - case ACPI_RDESC_TYPE_LARGE_VENDOR: 582 + case ACPI_RESOURCE_NAME_VENDOR_LARGE: 424 583 /* 425 584 * Vendor Defined Resource: 426 585 * Add vendor data and ensure a 32-bit boundary for the structure ··· 430 587 ACPI_ROUND_UP_to_32_bITS(resource_length); 431 588 break; 432 589 433 - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 434 - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 590 + case ACPI_RESOURCE_NAME_ADDRESS32: 591 + case ACPI_RESOURCE_NAME_ADDRESS16: 435 592 /* 436 593 * 32-Bit or 16-bit Address Resource: 437 594 * Add the size of any optional data (resource_source) ··· 439 596 extra_struct_bytes = 440 597 acpi_rs_stream_option_length 441 598 (resource_length, 442 - resource_info->minimum_stream_size); 599 + resource_info-> 600 + minimum_aml_resource_length); 443 601 break; 444 602 445 - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 603 + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: 446 604 /* 447 605 * Extended IRQ: 448 606 * Point past the interrupt_vector_flags to get the ··· 466 622 - 467 623 extra_struct_bytes, 468 624 resource_info-> 469 - minimum_stream_size); 625 + minimum_aml_resource_length); 470 626 break; 471 627 472 - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 628 + case ACPI_RESOURCE_NAME_ADDRESS64: 473 629 /* 474 630 * 64-Bit Address Resource: 475 631 * Add the size of any optional data (resource_source) ··· 479 635 ACPI_ROUND_UP_to_64_bITS 480 636 (acpi_rs_stream_option_length 481 637 (resource_length, 482 - resource_info->minimum_stream_size)); 638 + resource_info-> 639 + minimum_aml_resource_length)); 483 640 break; 484 641 485 642 default: ··· 491 646 /* Update the required buffer size for the internal descriptor structs */ 492 647 493 648 temp16 = 494 - (u16) (resource_info->minimum_struct_size + 649 + (u16) (resource_info->minimum_internal_struct_length + 495 650 extra_struct_bytes); 496 651 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); 497 652 ··· 501 656 */ 502 657 temp16 = (u16) (header_length + resource_length); 503 658 bytes_parsed += temp16; 504 - byte_stream_buffer += temp16; 659 + aml_buffer += temp16; 505 660 } 506 661 507 662 /* This is the data the caller needs */ ··· 603 758 (*sub_object_list)->string. 604 759 length + 1); 605 760 } else { 606 - temp_size_needed += 607 - acpi_ns_get_pathname_length((*sub_object_list)->reference.node); 761 + temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); 608 762 } 609 763 } else { 610 764 /*
+26 -33
drivers/acpi/resources/rscreate.c
··· 53 53 * 54 54 * FUNCTION: acpi_rs_create_resource_list 55 55 * 56 - * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 57 - * output_buffer - Pointer to the user's buffer 56 + * PARAMETERS: aml_buffer - Pointer to the resource byte stream 57 + * output_buffer - Pointer to the user's buffer 58 58 * 59 - * RETURN: Status - AE_OK if okay, else a valid acpi_status code 59 + * RETURN: Status: AE_OK if okay, else a valid acpi_status code 60 60 * If output_buffer is not large enough, output_buffer_length 61 61 * indicates how large output_buffer should be, else it 62 62 * indicates how may u8 elements of output_buffer are valid. ··· 67 67 * 68 68 ******************************************************************************/ 69 69 acpi_status 70 - acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, 70 + acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, 71 71 struct acpi_buffer *output_buffer) 72 72 { 73 73 74 74 acpi_status status; 75 - u8 *byte_stream_start; 75 + u8 *aml_start; 76 76 acpi_size list_size_needed = 0; 77 - u32 byte_stream_buffer_length; 77 + u32 aml_buffer_length; 78 78 79 79 ACPI_FUNCTION_TRACE("rs_create_resource_list"); 80 80 81 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", 82 - byte_stream_buffer)); 81 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer)); 83 82 84 83 /* Params already validated, so we don't re-validate here */ 85 84 86 - byte_stream_buffer_length = byte_stream_buffer->buffer.length; 87 - byte_stream_start = byte_stream_buffer->buffer.pointer; 85 + aml_buffer_length = aml_buffer->buffer.length; 86 + aml_start = aml_buffer->buffer.pointer; 88 87 89 88 /* 90 - * Pass the byte_stream_buffer into a module that can calculate 89 + * Pass the aml_buffer into a module that can calculate 91 90 * the buffer size needed for the linked list 92 91 */ 93 - status = 94 - acpi_rs_get_list_length(byte_stream_start, 95 - byte_stream_buffer_length, 96 - &list_size_needed); 92 + status = acpi_rs_get_list_length(aml_start, aml_buffer_length, 93 + &list_size_needed); 97 94 98 95 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", 99 96 status, (u32) list_size_needed)); ··· 107 110 108 111 /* Do the conversion */ 109 112 110 - status = 111 - acpi_rs_byte_stream_to_list(byte_stream_start, 112 - byte_stream_buffer_length, 113 - output_buffer->pointer); 113 + status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length, 114 + output_buffer->pointer); 114 115 if (ACPI_FAILURE(status)) { 115 116 return_ACPI_STATUS(status); 116 117 } ··· 355 360 356 361 /******************************************************************************* 357 362 * 358 - * FUNCTION: acpi_rs_create_byte_stream 363 + * FUNCTION: acpi_rs_create_aml_resources 359 364 * 360 365 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list 361 366 * output_buffer - Pointer to the user's buffer ··· 372 377 ******************************************************************************/ 373 378 374 379 acpi_status 375 - acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, 376 - struct acpi_buffer *output_buffer) 380 + acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, 381 + struct acpi_buffer *output_buffer) 377 382 { 378 383 acpi_status status; 379 - acpi_size byte_stream_size_needed = 0; 384 + acpi_size aml_size_needed = 0; 380 385 381 - ACPI_FUNCTION_TRACE("rs_create_byte_stream"); 386 + ACPI_FUNCTION_TRACE("rs_create_aml_resources"); 382 387 383 388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", 384 389 linked_list_buffer)); ··· 389 394 * Pass the linked_list_buffer into a module that calculates 390 395 * the buffer size needed for the byte stream. 391 396 */ 392 - status = acpi_rs_get_byte_stream_length(linked_list_buffer, 393 - &byte_stream_size_needed); 397 + status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); 394 398 395 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", 396 - (u32) byte_stream_size_needed, 399 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n", 400 + (u32) aml_size_needed, 397 401 acpi_format_exception(status))); 398 402 if (ACPI_FAILURE(status)) { 399 403 return_ACPI_STATUS(status); ··· 400 406 401 407 /* Validate/Allocate/Clear caller buffer */ 402 408 403 - status = 404 - acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed); 409 + status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed); 405 410 if (ACPI_FAILURE(status)) { 406 411 return_ACPI_STATUS(status); 407 412 } ··· 408 415 /* Do the conversion */ 409 416 410 417 status = 411 - acpi_rs_list_to_byte_stream(linked_list_buffer, 412 - byte_stream_size_needed, 413 - output_buffer->pointer); 418 + acpi_rs_convert_resources_to_aml(linked_list_buffer, 419 + aml_size_needed, 420 + output_buffer->pointer); 414 421 if (ACPI_FAILURE(status)) { 415 422 return_ACPI_STATUS(status); 416 423 }
+139 -174
drivers/acpi/resources/rsdump.c
··· 49 49 50 50 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 51 51 /* Local prototypes */ 52 - static void acpi_rs_dump_irq(union acpi_resource_data *resource); 53 - 54 - static void acpi_rs_dump_address16(union acpi_resource_data *resource); 55 - 56 - static void acpi_rs_dump_address32(union acpi_resource_data *resource); 57 - 58 - static void acpi_rs_dump_address64(union acpi_resource_data *resource); 59 - 60 - static void acpi_rs_dump_dma(union acpi_resource_data *resource); 61 - 62 - static void acpi_rs_dump_io(union acpi_resource_data *resource); 63 - 64 - static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource); 65 - 66 - static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource); 67 - 68 - static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource); 69 - 70 - static void acpi_rs_dump_memory24(union acpi_resource_data *resource); 71 - 72 - static void acpi_rs_dump_memory32(union acpi_resource_data *resource); 73 - 74 - static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource); 75 - 76 - static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource); 77 - 78 - static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource); 79 - 80 - static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource); 81 - 82 - static void acpi_rs_dump_end_tag(union acpi_resource_data *resource); 83 - 84 52 static void acpi_rs_out_string(char *title, char *value); 85 53 86 54 static void acpi_rs_out_integer8(char *title, u8 value); ··· 72 104 73 105 static void acpi_rs_dump_address_common(union acpi_resource_data *resource); 74 106 75 - /* Dispatch table for resource dump functions */ 76 - 77 - typedef 78 - void (*ACPI_DUMP_RESOURCE) (union acpi_resource_data * data); 79 - 80 - static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = { 81 - acpi_rs_dump_irq, /* ACPI_RSTYPE_IRQ */ 82 - acpi_rs_dump_dma, /* ACPI_RSTYPE_DMA */ 83 - acpi_rs_dump_start_depend_fns, /* ACPI_RSTYPE_START_DPF */ 84 - acpi_rs_dump_end_depend_fns, /* ACPI_RSTYPE_END_DPF */ 85 - acpi_rs_dump_io, /* ACPI_RSTYPE_IO */ 86 - acpi_rs_dump_fixed_io, /* ACPI_RSTYPE_FIXED_IO */ 87 - acpi_rs_dump_vendor_specific, /* ACPI_RSTYPE_VENDOR */ 88 - acpi_rs_dump_end_tag, /* ACPI_RSTYPE_END_TAG */ 89 - acpi_rs_dump_memory24, /* ACPI_RSTYPE_MEM24 */ 90 - acpi_rs_dump_memory32, /* ACPI_RSTYPE_MEM32 */ 91 - acpi_rs_dump_fixed_memory32, /* ACPI_RSTYPE_FIXED_MEM32 */ 92 - acpi_rs_dump_address16, /* ACPI_RSTYPE_ADDRESS16 */ 93 - acpi_rs_dump_address32, /* ACPI_RSTYPE_ADDRESS32 */ 94 - acpi_rs_dump_address64, /* ACPI_RSTYPE_ADDRESS64 */ 95 - acpi_rs_dump_extended_irq, /* ACPI_RSTYPE_EXT_IRQ */ 96 - acpi_rs_dump_generic_reg /* ACPI_RSTYPE_GENERIC_REG */ 97 - }; 98 - 99 107 /******************************************************************************* 100 108 * 101 109 * FUNCTION: acpi_rs_out* ··· 88 144 89 145 static void acpi_rs_out_string(char *title, char *value) 90 146 { 91 - acpi_os_printf("%30s : %s\n", title, value); 147 + acpi_os_printf("%27s : %s\n", title, value); 92 148 } 93 149 94 150 static void acpi_rs_out_integer8(char *title, u8 value) 95 151 { 96 - acpi_os_printf("%30s : %2.2X\n", title, value); 152 + acpi_os_printf("%27s : %2.2X\n", title, value); 97 153 } 98 154 99 155 static void acpi_rs_out_integer16(char *title, u16 value) 100 156 { 101 - acpi_os_printf("%30s : %4.4X\n", title, value); 157 + acpi_os_printf("%27s : %4.4X\n", title, value); 102 158 } 103 159 104 160 static void acpi_rs_out_integer32(char *title, u32 value) 105 161 { 106 - acpi_os_printf("%30s : %8.8X\n", title, value); 162 + acpi_os_printf("%27s : %8.8X\n", title, value); 107 163 } 108 164 109 165 static void acpi_rs_out_integer64(char *title, u64 value) 110 166 { 111 - acpi_os_printf("%30s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); 167 + acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); 112 168 } 113 169 114 170 static void acpi_rs_out_title(char *title) 115 171 { 116 - acpi_os_printf("%30s : ", title); 172 + acpi_os_printf("%27s : ", title); 117 173 } 118 174 119 175 /******************************************************************************* ··· 134 190 u32 i; 135 191 136 192 for (i = 0; i < length; i++) { 137 - acpi_os_printf("%28s%2.2X : %2.2X\n", "Byte", i, data[i]); 193 + acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]); 138 194 } 139 195 } 140 196 ··· 143 199 u32 i; 144 200 145 201 for (i = 0; i < length; i++) { 146 - acpi_os_printf("%28s%2.2X : %8.8X\n", "Dword", i, data[i]); 202 + acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]); 147 203 } 148 204 } 149 205 ··· 155 211 acpi_os_printf("%X ", data[i]); 156 212 } 157 213 acpi_os_printf("\n"); 214 + } 215 + 216 + static void acpi_rs_dump_memory_attribute(u32 read_write_attribute) 217 + { 218 + 219 + acpi_rs_out_string("Read/Write Attribute", 220 + ACPI_READ_WRITE_MEMORY == read_write_attribute ? 221 + "Read/Write" : "Read-Only"); 158 222 } 159 223 160 224 /******************************************************************************* ··· 181 229 static void 182 230 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source) 183 231 { 232 + ACPI_FUNCTION_ENTRY(); 184 233 185 234 if (resource_source->index == 0xFF) { 186 235 return; ··· 243 290 break; 244 291 } 245 292 246 - acpi_rs_out_string("Read/Write Attribute", 247 - ACPI_READ_WRITE_MEMORY == 248 - resource->address.attribute.memory. 249 - read_write_attribute ? "Read/Write" : 250 - "Read Only"); 293 + acpi_rs_dump_memory_attribute(resource->address.attribute. 294 + memory.read_write_attribute); 251 295 break; 252 296 253 297 case ACPI_IO_RANGE: ··· 342 392 343 393 /* Validate Type before dispatch */ 344 394 345 - if (resource_list->type > ACPI_RSTYPE_MAX) { 395 + if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) { 346 396 acpi_os_printf 347 397 ("Invalid descriptor type (%X) in resource list\n", 348 398 resource_list->type); ··· 356 406 357 407 /* Exit on end tag */ 358 408 359 - if (resource_list->type == ACPI_RSTYPE_END_TAG) { 409 + if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) { 360 410 return; 361 411 } 362 412 ··· 381 431 * 382 432 ******************************************************************************/ 383 433 384 - static void acpi_rs_dump_irq(union acpi_resource_data *resource) 434 + void acpi_rs_dump_irq(union acpi_resource_data *resource) 385 435 { 386 436 ACPI_FUNCTION_ENTRY(); 387 437 ··· 389 439 390 440 acpi_rs_out_string("Triggering", 391 441 ACPI_LEVEL_SENSITIVE == 392 - resource->irq.edge_level ? "Level" : "Edge"); 442 + resource->irq.triggering ? "Level" : "Edge"); 393 443 394 444 acpi_rs_out_string("Active", 395 445 ACPI_ACTIVE_LOW == 396 - resource->irq.active_high_low ? "Low" : "High"); 446 + resource->irq.polarity ? "Low" : "High"); 397 447 398 448 acpi_rs_out_string("Sharing", 399 449 ACPI_SHARED == 400 - resource->irq. 401 - shared_exclusive ? "Shared" : "Exclusive"); 450 + resource->irq.sharable ? "Shared" : "Exclusive"); 402 451 403 452 acpi_rs_out_integer8("Interrupt Count", 404 - (u8) resource->irq.number_of_interrupts); 453 + (u8) resource->irq.interrupt_count); 405 454 406 455 acpi_rs_out_title("Interrupt List"); 407 - acpi_rs_dump_short_byte_list(resource->irq.number_of_interrupts, 456 + acpi_rs_dump_short_byte_list(resource->irq.interrupt_count, 408 457 resource->irq.interrupts); 409 458 } 410 459 ··· 419 470 * 420 471 ******************************************************************************/ 421 472 422 - static void acpi_rs_dump_dma(union acpi_resource_data *resource) 473 + void acpi_rs_dump_dma(union acpi_resource_data *resource) 423 474 { 424 475 ACPI_FUNCTION_ENTRY(); 425 476 ··· 472 523 } 473 524 474 525 acpi_rs_out_integer8("DMA Channel Count", 475 - (u8) resource->dma.number_of_channels); 526 + (u8) resource->dma.channel_count); 476 527 477 528 acpi_rs_out_title("Channel List"); 478 - acpi_rs_dump_short_byte_list(resource->dma.number_of_channels, 529 + acpi_rs_dump_short_byte_list(resource->dma.channel_count, 479 530 resource->dma.channels); 480 531 } 481 532 482 533 /******************************************************************************* 483 534 * 484 - * FUNCTION: acpi_rs_dump_start_depend_fns 535 + * FUNCTION: acpi_rs_dump_start_dpf 485 536 * 486 537 * PARAMETERS: Resource - Pointer to an internal resource descriptor 487 538 * ··· 491 542 * 492 543 ******************************************************************************/ 493 544 494 - static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource) 545 + void acpi_rs_dump_start_dpf(union acpi_resource_data *resource) 495 546 { 496 547 ACPI_FUNCTION_ENTRY(); 497 548 ··· 549 600 * 550 601 ******************************************************************************/ 551 602 552 - static void acpi_rs_dump_io(union acpi_resource_data *resource) 603 + void acpi_rs_dump_io(union acpi_resource_data *resource) 553 604 { 554 605 ACPI_FUNCTION_ENTRY(); 555 606 ··· 559 610 ACPI_DECODE_16 == 560 611 resource->io.io_decode ? "16-bit" : "10-bit"); 561 612 562 - acpi_rs_out_integer32("Range Minimum Base", 563 - resource->io.min_base_address); 613 + acpi_rs_out_integer32("Address Minimum", resource->io.minimum); 564 614 565 - acpi_rs_out_integer32("Range Maximum Base", 566 - resource->io.max_base_address); 615 + acpi_rs_out_integer32("Address Maximum", resource->io.maximum); 567 616 568 617 acpi_rs_out_integer32("Alignment", resource->io.alignment); 569 618 570 - acpi_rs_out_integer32("Range Length", resource->io.range_length); 619 + acpi_rs_out_integer32("Address Length", resource->io.address_length); 571 620 } 572 621 573 622 /******************************************************************************* ··· 580 633 * 581 634 ******************************************************************************/ 582 635 583 - static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) 636 + void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) 584 637 { 585 638 ACPI_FUNCTION_ENTRY(); 586 639 587 640 acpi_os_printf("Fixed I/O Resource\n"); 588 641 589 - acpi_rs_out_integer32("Range Base Address", 590 - resource->fixed_io.base_address); 642 + acpi_rs_out_integer32("Address", resource->fixed_io.address); 591 643 592 - acpi_rs_out_integer32("Range Length", resource->fixed_io.range_length); 644 + acpi_rs_out_integer32("Address Length", 645 + resource->fixed_io.address_length); 593 646 } 594 647 595 648 /******************************************************************************* 596 649 * 597 - * FUNCTION: acpi_rs_dump_vendor_specific 650 + * FUNCTION: acpi_rs_dump_vendor 598 651 * 599 652 * PARAMETERS: Resource - Pointer to an internal resource descriptor 600 653 * ··· 604 657 * 605 658 ******************************************************************************/ 606 659 607 - static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource) 660 + void acpi_rs_dump_vendor(union acpi_resource_data *resource) 608 661 { 609 662 ACPI_FUNCTION_ENTRY(); 610 663 611 664 acpi_os_printf("Vendor Specific Resource\n"); 612 665 613 - acpi_rs_out_integer16("Length", (u16) resource->vendor_specific.length); 666 + acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length); 614 667 615 - acpi_rs_dump_byte_list(resource->vendor_specific.length, 616 - resource->vendor_specific.reserved); 668 + acpi_rs_dump_byte_list(resource->vendor.byte_length, 669 + resource->vendor.byte_data); 617 670 } 618 671 619 672 /******************************************************************************* ··· 628 681 * 629 682 ******************************************************************************/ 630 683 631 - static void acpi_rs_dump_memory24(union acpi_resource_data *resource) 684 + void acpi_rs_dump_memory24(union acpi_resource_data *resource) 632 685 { 633 686 ACPI_FUNCTION_ENTRY(); 634 687 635 688 acpi_os_printf("24-Bit Memory Range Resource\n"); 636 689 637 - acpi_rs_out_string("Attribute", 638 - ACPI_READ_WRITE_MEMORY == 639 - resource->memory24.read_write_attribute ? 640 - "Read/Write" : "Read Only"); 690 + acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute); 641 691 642 - acpi_rs_out_integer16("Range Minimum Base", 643 - (u16) resource->memory24.min_base_address); 692 + acpi_rs_out_integer16("Address Minimum", 693 + (u16) resource->memory24.minimum); 644 694 645 - acpi_rs_out_integer16("Range Maximum Base", 646 - (u16) resource->memory24.max_base_address); 695 + acpi_rs_out_integer16("Address Maximum", 696 + (u16) resource->memory24.maximum); 647 697 648 698 acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment); 649 699 650 - acpi_rs_out_integer16("Range Length", 651 - (u16) resource->memory24.range_length); 700 + acpi_rs_out_integer16("Address Length", 701 + (u16) resource->memory24.address_length); 652 702 } 653 703 654 704 /******************************************************************************* ··· 660 716 * 661 717 ******************************************************************************/ 662 718 663 - static void acpi_rs_dump_memory32(union acpi_resource_data *resource) 719 + void acpi_rs_dump_memory32(union acpi_resource_data *resource) 664 720 { 665 721 ACPI_FUNCTION_ENTRY(); 666 722 667 723 acpi_os_printf("32-Bit Memory Range Resource\n"); 668 724 669 - acpi_rs_out_string("Attribute", 670 - ACPI_READ_WRITE_MEMORY == 671 - resource->memory32.read_write_attribute ? 672 - "Read/Write" : "Read Only"); 725 + acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute); 673 726 674 - acpi_rs_out_integer32("Range Minimum Base", 675 - resource->memory32.min_base_address); 727 + acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum); 676 728 677 - acpi_rs_out_integer32("Range Maximum Base", 678 - resource->memory32.max_base_address); 729 + acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum); 679 730 680 731 acpi_rs_out_integer32("Alignment", resource->memory32.alignment); 681 732 682 - acpi_rs_out_integer32("Range Length", resource->memory32.range_length); 733 + acpi_rs_out_integer32("Address Length", 734 + resource->memory32.address_length); 683 735 } 684 736 685 737 /******************************************************************************* ··· 690 750 * 691 751 ******************************************************************************/ 692 752 693 - static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) 753 + void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) 694 754 { 695 755 ACPI_FUNCTION_ENTRY(); 696 756 697 757 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); 698 758 699 - acpi_rs_out_string("Attribute", 700 - ACPI_READ_WRITE_MEMORY == 701 - resource->fixed_memory32.read_write_attribute ? 702 - "Read/Write" : "Read Only"); 759 + acpi_rs_dump_memory_attribute(resource->fixed_memory32. 760 + read_write_attribute); 703 761 704 - acpi_rs_out_integer32("Range Base Address", 705 - resource->fixed_memory32.range_base_address); 762 + acpi_rs_out_integer32("Address", resource->fixed_memory32.address); 706 763 707 - acpi_rs_out_integer32("Range Length", 708 - resource->fixed_memory32.range_length); 764 + acpi_rs_out_integer32("Address Length", 765 + resource->fixed_memory32.address_length); 709 766 } 710 767 711 768 /******************************************************************************* ··· 717 780 * 718 781 ******************************************************************************/ 719 782 720 - static void acpi_rs_dump_address16(union acpi_resource_data *resource) 783 + void acpi_rs_dump_address16(union acpi_resource_data *resource) 721 784 { 722 785 ACPI_FUNCTION_ENTRY(); 723 786 724 - acpi_os_printf("16-Bit Address Space Resource\n"); 787 + acpi_os_printf("16-Bit WORD Address Space Resource\n"); 725 788 726 789 acpi_rs_dump_address_common(resource); 727 790 728 791 acpi_rs_out_integer16("Granularity", 729 792 (u16) resource->address16.granularity); 730 793 731 - acpi_rs_out_integer16("Address Range Min", 732 - (u16) resource->address16.min_address_range); 794 + acpi_rs_out_integer16("Address Minimum", 795 + (u16) resource->address16.minimum); 733 796 734 - acpi_rs_out_integer16("Address Range Max", 735 - (u16) resource->address16.max_address_range); 797 + acpi_rs_out_integer16("Address Maximum", 798 + (u16) resource->address16.maximum); 736 799 737 - acpi_rs_out_integer16("Address Translation Offset", 738 - (u16) resource->address16. 739 - address_translation_offset); 800 + acpi_rs_out_integer16("Translation Offset", 801 + (u16) resource->address16.translation_offset); 740 802 741 803 acpi_rs_out_integer16("Address Length", 742 804 (u16) resource->address16.address_length); ··· 755 819 * 756 820 ******************************************************************************/ 757 821 758 - static void acpi_rs_dump_address32(union acpi_resource_data *resource) 822 + void acpi_rs_dump_address32(union acpi_resource_data *resource) 759 823 { 760 824 ACPI_FUNCTION_ENTRY(); 761 825 762 - acpi_os_printf("32-Bit Address Space Resource\n"); 826 + acpi_os_printf("32-Bit DWORD Address Space Resource\n"); 763 827 764 828 acpi_rs_dump_address_common(resource); 765 829 766 830 acpi_rs_out_integer32("Granularity", resource->address32.granularity); 767 831 768 - acpi_rs_out_integer32("Address Range Min", 769 - resource->address32.min_address_range); 832 + acpi_rs_out_integer32("Address Minimum", resource->address32.minimum); 770 833 771 - acpi_rs_out_integer32("Address Range Max", 772 - resource->address32.max_address_range); 834 + acpi_rs_out_integer32("Address Maximum", resource->address32.maximum); 773 835 774 - acpi_rs_out_integer32("Address Translation Offset", 775 - resource->address32.address_translation_offset); 836 + acpi_rs_out_integer32("Translation Offset", 837 + resource->address32.translation_offset); 776 838 777 839 acpi_rs_out_integer32("Address Length", 778 840 resource->address32.address_length); ··· 790 856 * 791 857 ******************************************************************************/ 792 858 793 - static void acpi_rs_dump_address64(union acpi_resource_data *resource) 859 + void acpi_rs_dump_address64(union acpi_resource_data *resource) 794 860 { 795 861 ACPI_FUNCTION_ENTRY(); 796 862 797 - acpi_os_printf("64-Bit Address Space Resource\n"); 863 + acpi_os_printf("64-Bit QWORD Address Space Resource\n"); 798 864 799 865 acpi_rs_dump_address_common(resource); 800 866 801 867 acpi_rs_out_integer64("Granularity", resource->address64.granularity); 802 868 803 - acpi_rs_out_integer64("Address Range Min", 804 - resource->address64.min_address_range); 869 + acpi_rs_out_integer64("Address Minimum", resource->address64.minimum); 805 870 806 - acpi_rs_out_integer64("Address Range Max", 807 - resource->address64.max_address_range); 871 + acpi_rs_out_integer64("Address Maximum", resource->address64.maximum); 808 872 809 - acpi_rs_out_integer64("Address Translation Offset", 810 - resource->address64.address_translation_offset); 873 + acpi_rs_out_integer64("Translation Offset", 874 + resource->address64.translation_offset); 811 875 812 876 acpi_rs_out_integer64("Address Length", 813 877 resource->address64.address_length); 814 - 815 - acpi_rs_out_integer64("Type Specific Attributes", 816 - resource->address64.type_specific_attributes); 817 878 818 879 acpi_rs_dump_resource_source(&resource->address64.resource_source); 819 880 } 820 881 821 882 /******************************************************************************* 822 883 * 823 - * FUNCTION: acpi_rs_dump_extended_irq 884 + * FUNCTION: acpi_rs_dump_ext_address64 824 885 * 825 886 * PARAMETERS: Resource - Pointer to an internal resource descriptor 826 887 * ··· 825 896 * 826 897 ******************************************************************************/ 827 898 828 - static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) 899 + void acpi_rs_dump_ext_address64(union acpi_resource_data *resource) 900 + { 901 + ACPI_FUNCTION_ENTRY(); 902 + 903 + acpi_os_printf("64-Bit Extended Address Space Resource\n"); 904 + 905 + acpi_rs_dump_address_common(resource); 906 + 907 + acpi_rs_out_integer64("Granularity", 908 + resource->ext_address64.granularity); 909 + 910 + acpi_rs_out_integer64("Address Minimum", 911 + resource->ext_address64.minimum); 912 + 913 + acpi_rs_out_integer64("Address Maximum", 914 + resource->ext_address64.maximum); 915 + 916 + acpi_rs_out_integer64("Translation Offset", 917 + resource->ext_address64.translation_offset); 918 + 919 + acpi_rs_out_integer64("Address Length", 920 + resource->ext_address64.address_length); 921 + 922 + acpi_rs_out_integer64("Type-Specific Attribute", 923 + resource->ext_address64.type_specific_attributes); 924 + } 925 + 926 + /******************************************************************************* 927 + * 928 + * FUNCTION: acpi_rs_dump_ext_irq 929 + * 930 + * PARAMETERS: Resource - Pointer to an internal resource descriptor 931 + * 932 + * RETURN: None 933 + * 934 + * DESCRIPTION: Dump the field names and values of the resource descriptor 935 + * 936 + ******************************************************************************/ 937 + 938 + void acpi_rs_dump_ext_irq(union acpi_resource_data *resource) 829 939 { 830 940 ACPI_FUNCTION_ENTRY(); 831 941 ··· 878 910 acpi_rs_out_string("Triggering", 879 911 ACPI_LEVEL_SENSITIVE == 880 912 resource->extended_irq. 881 - edge_level ? "Level" : "Edge"); 913 + triggering ? "Level" : "Edge"); 882 914 883 915 acpi_rs_out_string("Active", 884 - ACPI_ACTIVE_LOW == 885 - resource->extended_irq. 886 - active_high_low ? "Low" : "High"); 916 + ACPI_ACTIVE_LOW == resource->extended_irq.polarity ? 917 + "Low" : "High"); 887 918 888 919 acpi_rs_out_string("Sharing", 889 - ACPI_SHARED == 890 - resource->extended_irq. 891 - shared_exclusive ? "Shared" : "Exclusive"); 920 + ACPI_SHARED == resource->extended_irq.sharable ? 921 + "Shared" : "Exclusive"); 892 922 893 923 acpi_rs_dump_resource_source(&resource->extended_irq.resource_source); 894 924 895 925 acpi_rs_out_integer8("Interrupts", 896 - (u8) resource->extended_irq.number_of_interrupts); 926 + (u8) resource->extended_irq.interrupt_count); 897 927 898 - acpi_rs_dump_dword_list(resource->extended_irq.number_of_interrupts, 928 + acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count, 899 929 resource->extended_irq.interrupts); 900 930 } 901 931 ··· 909 943 * 910 944 ******************************************************************************/ 911 945 912 - static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) 946 + void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) 913 947 { 914 - 915 948 ACPI_FUNCTION_ENTRY(); 916 949 917 950 acpi_os_printf("Generic Register Resource\n"); ··· 922 957 acpi_rs_out_integer8("Bit Offset", 923 958 (u8) resource->generic_reg.bit_offset); 924 959 925 - acpi_rs_out_integer8("Address Size", 926 - (u8) resource->generic_reg.address_size); 960 + acpi_rs_out_integer8("Access Size", 961 + (u8) resource->generic_reg.access_size); 927 962 928 963 acpi_rs_out_integer64("Address", resource->generic_reg.address); 929 964 } 930 965 931 966 /******************************************************************************* 932 967 * 933 - * FUNCTION: acpi_rs_dump_end_depend_fns 968 + * FUNCTION: acpi_rs_dump_end_dpf 934 969 * 935 970 * PARAMETERS: Resource - Pointer to an internal resource descriptor 936 971 * ··· 940 975 * 941 976 ******************************************************************************/ 942 977 943 - static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource) 978 + void acpi_rs_dump_end_dpf(union acpi_resource_data *resource) 944 979 { 945 980 ACPI_FUNCTION_ENTRY(); 946 981 ··· 959 994 * 960 995 ******************************************************************************/ 961 996 962 - static void acpi_rs_dump_end_tag(union acpi_resource_data *resource) 997 + void acpi_rs_dump_end_tag(union acpi_resource_data *resource) 963 998 { 964 999 ACPI_FUNCTION_ENTRY(); 965 1000
+1 -1
drivers/acpi/resources/rsinfo.c
··· 207 207 {0, ACPI_RLARGE(struct aml_resource_memory24), 208 208 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, 209 209 {0, ACPI_RLARGE(struct aml_resource_generic_register), 210 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)}, 210 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)}, 211 211 {0, 0, 0}, 212 212 {1, ACPI_RLARGE(struct aml_resource_vendor_large), 213 213 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
+144 -301
drivers/acpi/resources/rsio.c
··· 49 49 50 50 /******************************************************************************* 51 51 * 52 - * FUNCTION: acpi_rs_io_resource 52 + * FUNCTION: acpi_rs_get_io 53 53 * 54 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 55 - * stream 56 - * bytes_consumed - Pointer to where the number of bytes 57 - * consumed the byte_stream_buffer is 58 - * returned 59 - * output_buffer - Pointer to the return data buffer 60 - * structure_size - Pointer to where the number of bytes 61 - * in the return data struct is returned 54 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 55 + * aml_resource_length - Length of the resource from the AML header 56 + * Resource - Where the internal resource is returned 62 57 * 63 58 * RETURN: Status 64 59 * 65 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 66 - * structure pointed to by the output_buffer. Return the 67 - * number of bytes consumed from the byte stream. 60 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 61 + * internal resource descriptor, simplifying bitflags and handling 62 + * alignment and endian issues if necessary. 68 63 * 69 64 ******************************************************************************/ 70 65 acpi_status 71 - acpi_rs_io_resource(u8 * byte_stream_buffer, 72 - acpi_size * bytes_consumed, 73 - u8 ** output_buffer, acpi_size * structure_size) 66 + acpi_rs_get_io(union aml_resource *aml, 67 + u16 aml_resource_length, struct acpi_resource *resource) 74 68 { 75 - u8 *buffer = byte_stream_buffer; 76 - struct acpi_resource *output_struct = (void *)*output_buffer; 77 - u16 temp16 = 0; 78 - u8 temp8 = 0; 79 - acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); 69 + ACPI_FUNCTION_TRACE("rs_get_io"); 80 70 81 - ACPI_FUNCTION_TRACE("rs_io_resource"); 71 + /* Get the Decode flag */ 82 72 83 - /* The number of bytes consumed are Constant */ 73 + resource->data.io.io_decode = aml->io.information & 0x01; 84 74 85 - *bytes_consumed = 8; 75 + /* 76 + * Get the following contiguous fields from the AML descriptor: 77 + * Minimum Base Address 78 + * Maximum Base Address 79 + * Address Alignment 80 + * Length 81 + */ 82 + ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum); 83 + ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum); 84 + resource->data.io.alignment = aml->io.alignment; 85 + resource->data.io.address_length = aml->io.address_length; 86 86 87 - output_struct->type = ACPI_RSTYPE_IO; 87 + /* Complete the resource header */ 88 88 89 - /* Check Decode */ 90 - 91 - buffer += 1; 92 - temp8 = *buffer; 93 - 94 - output_struct->data.io.io_decode = temp8 & 0x01; 95 - 96 - /* Check min_base Address */ 97 - 98 - buffer += 1; 99 - ACPI_MOVE_16_TO_16(&temp16, buffer); 100 - 101 - output_struct->data.io.min_base_address = temp16; 102 - 103 - /* Check max_base Address */ 104 - 105 - buffer += 2; 106 - ACPI_MOVE_16_TO_16(&temp16, buffer); 107 - 108 - output_struct->data.io.max_base_address = temp16; 109 - 110 - /* Check Base alignment */ 111 - 112 - buffer += 2; 113 - temp8 = *buffer; 114 - 115 - output_struct->data.io.alignment = temp8; 116 - 117 - /* Check range_length */ 118 - 119 - buffer += 1; 120 - temp8 = *buffer; 121 - 122 - output_struct->data.io.range_length = temp8; 123 - 124 - /* Set the Length parameter */ 125 - 126 - output_struct->length = (u32) struct_size; 127 - 128 - /* Return the final size of the structure */ 129 - 130 - *structure_size = struct_size; 89 + resource->type = ACPI_RESOURCE_TYPE_IO; 90 + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); 131 91 return_ACPI_STATUS(AE_OK); 132 92 } 133 93 134 94 /******************************************************************************* 135 95 * 136 - * FUNCTION: acpi_rs_fixed_io_resource 96 + * FUNCTION: acpi_rs_set_io 137 97 * 138 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 139 - * stream 140 - * bytes_consumed - Pointer to where the number of bytes 141 - * consumed the byte_stream_buffer is 142 - * returned 143 - * output_buffer - Pointer to the return data buffer 144 - * structure_size - Pointer to where the number of bytes 145 - * in the return data struct is returned 98 + * PARAMETERS: Resource - Pointer to the resource descriptor 99 + * Aml - Where the AML descriptor is returned 146 100 * 147 101 * RETURN: Status 148 102 * 149 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 150 - * structure pointed to by the output_buffer. Return the 151 - * number of bytes consumed from the byte stream. 103 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 104 + * external AML resource descriptor. 152 105 * 153 106 ******************************************************************************/ 154 107 155 108 acpi_status 156 - acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, 157 - acpi_size * bytes_consumed, 158 - u8 ** output_buffer, acpi_size * structure_size) 109 + acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml) 159 110 { 160 - u8 *buffer = byte_stream_buffer; 161 - struct acpi_resource *output_struct = (void *)*output_buffer; 162 - u16 temp16 = 0; 163 - u8 temp8 = 0; 164 - acpi_size struct_size = 165 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 111 + ACPI_FUNCTION_TRACE("rs_set_io"); 166 112 167 - ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); 113 + /* I/O Information Byte */ 168 114 169 - /* The number of bytes consumed are Constant */ 115 + aml->io.information = (u8) (resource->data.io.io_decode & 0x01); 170 116 171 - *bytes_consumed = 4; 117 + /* 118 + * Set the following contiguous fields in the AML descriptor: 119 + * Minimum Base Address 120 + * Maximum Base Address 121 + * Address Alignment 122 + * Length 123 + */ 124 + ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum); 125 + ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum); 126 + aml->io.alignment = (u8) resource->data.io.alignment; 127 + aml->io.address_length = (u8) resource->data.io.address_length; 172 128 173 - output_struct->type = ACPI_RSTYPE_FIXED_IO; 129 + /* Complete the AML descriptor header */ 174 130 175 - /* Check Range Base Address */ 176 - 177 - buffer += 1; 178 - ACPI_MOVE_16_TO_16(&temp16, buffer); 179 - 180 - output_struct->data.fixed_io.base_address = temp16; 181 - 182 - /* Check range_length */ 183 - 184 - buffer += 2; 185 - temp8 = *buffer; 186 - 187 - output_struct->data.fixed_io.range_length = temp8; 188 - 189 - /* Set the Length parameter */ 190 - 191 - output_struct->length = (u32) struct_size; 192 - 193 - /* Return the final size of the structure */ 194 - 195 - *structure_size = struct_size; 131 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO, 132 + sizeof(struct aml_resource_io), aml); 196 133 return_ACPI_STATUS(AE_OK); 197 134 } 198 135 199 136 /******************************************************************************* 200 137 * 201 - * FUNCTION: acpi_rs_io_stream 138 + * FUNCTION: acpi_rs_get_fixed_io 202 139 * 203 - * PARAMETERS: Resource - Pointer to the resource linked list 204 - * output_buffer - Pointer to the user's return buffer 205 - * bytes_consumed - Pointer to where the number of bytes 206 - * used in the output_buffer is returned 140 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 141 + * aml_resource_length - Length of the resource from the AML header 142 + * Resource - Where the internal resource is returned 207 143 * 208 144 * RETURN: Status 209 145 * 210 - * DESCRIPTION: Take the linked list resource structure and fills in the 211 - * the appropriate bytes in a byte stream 146 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 147 + * internal resource descriptor, simplifying bitflags and handling 148 + * alignment and endian issues if necessary. 212 149 * 213 150 ******************************************************************************/ 214 151 215 152 acpi_status 216 - acpi_rs_io_stream(struct acpi_resource *resource, 217 - u8 ** output_buffer, acpi_size * bytes_consumed) 153 + acpi_rs_get_fixed_io(union aml_resource *aml, 154 + u16 aml_resource_length, struct acpi_resource *resource) 218 155 { 219 - u8 *buffer = *output_buffer; 220 - u16 temp16 = 0; 221 - u8 temp8 = 0; 156 + ACPI_FUNCTION_TRACE("rs_get_fixed_io"); 222 157 223 - ACPI_FUNCTION_TRACE("rs_io_stream"); 158 + /* 159 + * Get the following contiguous fields from the AML descriptor: 160 + * Base Address 161 + * Length 162 + */ 163 + ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address, 164 + &aml->fixed_io.address); 165 + resource->data.fixed_io.address_length = aml->fixed_io.address_length; 224 166 225 - /* The Descriptor Type field is static */ 167 + /* Complete the resource header */ 226 168 227 - *buffer = ACPI_RDESC_TYPE_IO_PORT | 0x07; 228 - buffer += 1; 229 - 230 - /* Io Information Byte */ 231 - 232 - temp8 = (u8) (resource->data.io.io_decode & 0x01); 233 - 234 - *buffer = temp8; 235 - buffer += 1; 236 - 237 - /* Set the Range minimum base address */ 238 - 239 - temp16 = (u16) resource->data.io.min_base_address; 240 - 241 - ACPI_MOVE_16_TO_16(buffer, &temp16); 242 - buffer += 2; 243 - 244 - /* Set the Range maximum base address */ 245 - 246 - temp16 = (u16) resource->data.io.max_base_address; 247 - 248 - ACPI_MOVE_16_TO_16(buffer, &temp16); 249 - buffer += 2; 250 - 251 - /* Set the base alignment */ 252 - 253 - temp8 = (u8) resource->data.io.alignment; 254 - 255 - *buffer = temp8; 256 - buffer += 1; 257 - 258 - /* Set the range length */ 259 - 260 - temp8 = (u8) resource->data.io.range_length; 261 - 262 - *buffer = temp8; 263 - buffer += 1; 264 - 265 - /* Return the number of bytes consumed in this operation */ 266 - 267 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 169 + resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; 170 + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 268 171 return_ACPI_STATUS(AE_OK); 269 172 } 270 173 271 174 /******************************************************************************* 272 175 * 273 - * FUNCTION: acpi_rs_fixed_io_stream 176 + * FUNCTION: acpi_rs_set_fixed_io 274 177 * 275 - * PARAMETERS: Resource - Pointer to the resource linked list 276 - * output_buffer - Pointer to the user's return buffer 277 - * bytes_consumed - Pointer to where the number of bytes 278 - * used in the output_buffer is returned 178 + * PARAMETERS: Resource - Pointer to the resource descriptor 179 + * Aml - Where the AML descriptor is returned 279 180 * 280 181 * RETURN: Status 281 182 * 282 - * DESCRIPTION: Take the linked list resource structure and fills in the 283 - * the appropriate bytes in a byte stream 183 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 184 + * external AML resource descriptor. 284 185 * 285 186 ******************************************************************************/ 286 187 287 188 acpi_status 288 - acpi_rs_fixed_io_stream(struct acpi_resource *resource, 289 - u8 ** output_buffer, acpi_size * bytes_consumed) 189 + acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml) 290 190 { 291 - u8 *buffer = *output_buffer; 292 - u16 temp16 = 0; 293 - u8 temp8 = 0; 191 + ACPI_FUNCTION_TRACE("rs_set_fixed_io"); 294 192 295 - ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); 193 + /* 194 + * Set the following contiguous fields in the AML descriptor: 195 + * Base Address 196 + * Length 197 + */ 198 + ACPI_MOVE_32_TO_16(&aml->fixed_io.address, 199 + &resource->data.fixed_io.address); 200 + aml->fixed_io.address_length = 201 + (u8) resource->data.fixed_io.address_length; 296 202 297 - /* The Descriptor Type field is static */ 203 + /* Complete the AML descriptor header */ 298 204 299 - *buffer = ACPI_RDESC_TYPE_FIXED_IO_PORT | 0x03; 300 - buffer += 1; 301 - 302 - /* Set the Range base address */ 303 - 304 - temp16 = (u16) resource->data.fixed_io.base_address; 305 - 306 - ACPI_MOVE_16_TO_16(buffer, &temp16); 307 - buffer += 2; 308 - 309 - /* Set the range length */ 310 - 311 - temp8 = (u8) resource->data.fixed_io.range_length; 312 - 313 - *buffer = temp8; 314 - buffer += 1; 315 - 316 - /* Return the number of bytes consumed in this operation */ 317 - 318 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 205 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO, 206 + sizeof(struct aml_resource_fixed_io), aml); 319 207 return_ACPI_STATUS(AE_OK); 320 208 } 321 209 322 210 /******************************************************************************* 323 211 * 324 - * FUNCTION: acpi_rs_dma_resource 212 + * FUNCTION: acpi_rs_get_dma 325 213 * 326 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 327 - * stream 328 - * bytes_consumed - Pointer to where the number of bytes 329 - * consumed the byte_stream_buffer is 330 - * returned 331 - * output_buffer - Pointer to the return data buffer 332 - * structure_size - Pointer to where the number of bytes 333 - * in the return data struct is returned 214 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 215 + * aml_resource_length - Length of the resource from the AML header 216 + * Resource - Where the internal resource is returned 334 217 * 335 218 * RETURN: Status 336 219 * 337 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 338 - * structure pointed to by the output_buffer. Return the 339 - * number of bytes consumed from the byte stream. 220 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 221 + * internal resource descriptor, simplifying bitflags and handling 222 + * alignment and endian issues if necessary. 340 223 * 341 224 ******************************************************************************/ 342 225 343 226 acpi_status 344 - acpi_rs_dma_resource(u8 * byte_stream_buffer, 345 - acpi_size * bytes_consumed, 346 - u8 ** output_buffer, acpi_size * structure_size) 227 + acpi_rs_get_dma(union aml_resource *aml, 228 + u16 aml_resource_length, struct acpi_resource *resource) 347 229 { 348 - u8 *buffer = byte_stream_buffer; 349 - struct acpi_resource *output_struct = (void *)*output_buffer; 350 - u8 temp8 = 0; 351 - u8 index; 352 - u8 i; 353 - acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); 230 + u32 channel_count = 0; 231 + u32 i; 232 + u8 temp8; 354 233 355 - ACPI_FUNCTION_TRACE("rs_dma_resource"); 356 - 357 - /* The number of bytes consumed are Constant */ 358 - 359 - *bytes_consumed = 3; 360 - output_struct->type = ACPI_RSTYPE_DMA; 361 - 362 - /* Point to the 8-bits of Byte 1 */ 363 - 364 - buffer += 1; 365 - temp8 = *buffer; 234 + ACPI_FUNCTION_TRACE("rs_get_dma"); 366 235 367 236 /* Decode the DMA channel bits */ 368 237 369 - for (i = 0, index = 0; index < 8; index++) { 370 - if ((temp8 >> index) & 0x01) { 371 - output_struct->data.dma.channels[i] = index; 372 - i++; 238 + for (i = 0; i < 8; i++) { 239 + if ((aml->dma.dma_channel_mask >> i) & 0x01) { 240 + resource->data.dma.channels[channel_count] = i; 241 + channel_count++; 373 242 } 374 243 } 375 244 376 - /* Zero DMA channels is valid */ 245 + resource->length = 0; 246 + resource->data.dma.channel_count = channel_count; 377 247 378 - output_struct->data.dma.number_of_channels = i; 379 - if (i > 0) { 380 - /* Calculate the structure size based upon the number of interrupts */ 381 - 382 - struct_size += ((acpi_size) i - 1) * 4; 248 + /* 249 + * Calculate the structure size based upon the number of channels 250 + * Note: Zero DMA channels is valid 251 + */ 252 + if (channel_count > 0) { 253 + resource->length = (u32) (channel_count - 1) * 4; 383 254 } 384 255 385 - /* Point to Byte 2 */ 256 + /* Get the flags: transfer preference, bus mastering, channel speed */ 386 257 387 - buffer += 1; 388 - temp8 = *buffer; 258 + temp8 = aml->dma.flags; 259 + resource->data.dma.transfer = temp8 & 0x03; 260 + resource->data.dma.bus_master = (temp8 >> 2) & 0x01; 261 + resource->data.dma.type = (temp8 >> 5) & 0x03; 389 262 390 - /* Check for transfer preference (Bits[1:0]) */ 391 - 392 - output_struct->data.dma.transfer = temp8 & 0x03; 393 - 394 - if (0x03 == output_struct->data.dma.transfer) { 263 + if (resource->data.dma.transfer == 0x03) { 395 264 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 396 265 "Invalid DMA.Transfer preference (3)\n")); 397 266 return_ACPI_STATUS(AE_BAD_DATA); 398 267 } 399 268 400 - /* Get bus master preference (Bit[2]) */ 269 + /* Complete the resource header */ 401 270 402 - output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; 403 - 404 - /* Get channel speed support (Bits[6:5]) */ 405 - 406 - output_struct->data.dma.type = (temp8 >> 5) & 0x03; 407 - 408 - /* Set the Length parameter */ 409 - 410 - output_struct->length = (u32) struct_size; 411 - 412 - /* Return the final size of the structure */ 413 - 414 - *structure_size = struct_size; 271 + resource->type = ACPI_RESOURCE_TYPE_DMA; 272 + resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); 415 273 return_ACPI_STATUS(AE_OK); 416 274 } 417 275 418 276 /******************************************************************************* 419 277 * 420 - * FUNCTION: acpi_rs_dma_stream 278 + * FUNCTION: acpi_rs_set_dma 421 279 * 422 - * PARAMETERS: Resource - Pointer to the resource linked list 423 - * output_buffer - Pointer to the user's return buffer 424 - * bytes_consumed - Pointer to where the number of bytes 425 - * used in the output_buffer is returned 280 + * PARAMETERS: Resource - Pointer to the resource descriptor 281 + * Aml - Where the AML descriptor is returned 426 282 * 427 283 * RETURN: Status 428 284 * 429 - * DESCRIPTION: Take the linked list resource structure and fills in the 430 - * the appropriate bytes in a byte stream 285 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 286 + * external AML resource descriptor. 431 287 * 432 288 ******************************************************************************/ 433 289 434 290 acpi_status 435 - acpi_rs_dma_stream(struct acpi_resource *resource, 436 - u8 ** output_buffer, acpi_size * bytes_consumed) 291 + acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml) 437 292 { 438 - u8 *buffer = *output_buffer; 439 - u16 temp16 = 0; 440 - u8 temp8 = 0; 441 - u8 index; 293 + u8 i; 442 294 443 - ACPI_FUNCTION_TRACE("rs_dma_stream"); 295 + ACPI_FUNCTION_TRACE("rs_set_dma"); 444 296 445 - /* The Descriptor Type field is static */ 297 + /* Convert channel list to 8-bit DMA channel bitmask */ 446 298 447 - *buffer = ACPI_RDESC_TYPE_DMA_FORMAT | 0x02; 448 - buffer += 1; 449 - temp8 = 0; 450 - 451 - /* Loop through all of the Channels and set the mask bits */ 452 - 453 - for (index = 0; index < resource->data.dma.number_of_channels; index++) { 454 - temp16 = (u16) resource->data.dma.channels[index]; 455 - temp8 |= 0x1 << temp16; 299 + aml->dma.dma_channel_mask = 0; 300 + for (i = 0; i < resource->data.dma.channel_count; i++) { 301 + aml->dma.dma_channel_mask |= 302 + (1 << resource->data.dma.channels[i]); 456 303 } 457 304 458 - *buffer = temp8; 459 - buffer += 1; 305 + /* Set the DMA Flag bits */ 460 306 461 - /* Set the DMA Info */ 307 + aml->dma.flags = (u8) 308 + (((resource->data.dma.type & 0x03) << 5) | 309 + ((resource->data.dma.bus_master & 0x01) << 2) | 310 + (resource->data.dma.transfer & 0x03)); 462 311 463 - temp8 = (u8) ((resource->data.dma.type & 0x03) << 5); 464 - temp8 |= ((resource->data.dma.bus_master & 0x01) << 2); 465 - temp8 |= (resource->data.dma.transfer & 0x03); 312 + /* Complete the AML descriptor header */ 466 313 467 - *buffer = temp8; 468 - buffer += 1; 469 - 470 - /* Return the number of bytes consumed in this operation */ 471 - 472 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 314 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA, 315 + sizeof(struct aml_resource_dma), aml); 473 316 return_ACPI_STATUS(AE_OK); 474 317 }
+158 -336
drivers/acpi/resources/rsirq.c
··· 49 49 50 50 /******************************************************************************* 51 51 * 52 - * FUNCTION: acpi_rs_irq_resource 52 + * FUNCTION: acpi_rs_get_irq 53 53 * 54 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 55 - * stream 56 - * bytes_consumed - Pointer to where the number of bytes 57 - * consumed the byte_stream_buffer is 58 - * returned 59 - * output_buffer - Pointer to the return data buffer 60 - * structure_size - Pointer to where the number of bytes 61 - * in the return data struct is returned 54 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 55 + * aml_resource_length - Length of the resource from the AML header 56 + * Resource - Where the internal resource is returned 62 57 * 63 58 * RETURN: Status 64 59 * 65 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 66 - * structure pointed to by the output_buffer. Return the 67 - * number of bytes consumed from the byte stream. 60 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 61 + * internal resource descriptor, simplifying bitflags and handling 62 + * alignment and endian issues if necessary. 68 63 * 69 64 ******************************************************************************/ 70 65 acpi_status 71 - acpi_rs_irq_resource(u8 * byte_stream_buffer, 72 - acpi_size * bytes_consumed, 73 - u8 ** output_buffer, acpi_size * structure_size) 66 + acpi_rs_get_irq(union aml_resource *aml, 67 + u16 aml_resource_length, struct acpi_resource *resource) 74 68 { 75 - u8 *buffer = byte_stream_buffer; 76 - struct acpi_resource *output_struct = (void *)*output_buffer; 77 69 u16 temp16 = 0; 78 - u8 temp8 = 0; 79 - u8 index; 80 - u8 i; 81 - acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); 70 + u32 interrupt_count = 0; 71 + u32 i; 72 + u32 resource_length; 82 73 83 - ACPI_FUNCTION_TRACE("rs_irq_resource"); 74 + ACPI_FUNCTION_TRACE("rs_get_irq"); 84 75 85 - /* 86 - * The number of bytes consumed are contained in the descriptor 87 - * (Bits:0-1) 88 - */ 89 - temp8 = *buffer; 90 - *bytes_consumed = (temp8 & 0x03) + 1; 91 - output_struct->type = ACPI_RSTYPE_IRQ; 76 + /* Get the IRQ mask (bytes 1:2) */ 92 77 93 - /* Point to the 16-bits of Bytes 1 and 2 */ 78 + ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask); 94 79 95 - buffer += 1; 96 - ACPI_MOVE_16_TO_16(&temp16, buffer); 80 + /* Decode the IRQ bits (up to 16 possible) */ 97 81 98 - output_struct->data.irq.number_of_interrupts = 0; 99 - 100 - /* Decode the IRQ bits */ 101 - 102 - for (i = 0, index = 0; index < 16; index++) { 103 - if ((temp16 >> index) & 0x01) { 104 - output_struct->data.irq.interrupts[i] = index; 105 - i++; 82 + for (i = 0; i < 16; i++) { 83 + if ((temp16 >> i) & 0x01) { 84 + resource->data.irq.interrupts[interrupt_count] = i; 85 + interrupt_count++; 106 86 } 107 87 } 108 88 109 89 /* Zero interrupts is valid */ 110 90 111 - output_struct->data.irq.number_of_interrupts = i; 112 - if (i > 0) { 91 + resource_length = 0; 92 + resource->data.irq.interrupt_count = interrupt_count; 93 + if (interrupt_count > 0) { 113 94 /* Calculate the structure size based upon the number of interrupts */ 114 95 115 - struct_size += ((acpi_size) i - 1) * 4; 96 + resource_length = (u32) (interrupt_count - 1) * 4; 116 97 } 117 98 118 - /* Point to Byte 3 if it is used */ 99 + /* Get Flags (Byte 3) if it is used */ 119 100 120 - if (4 == *bytes_consumed) { 121 - buffer += 2; 122 - temp8 = *buffer; 123 - 101 + if (aml_resource_length == 3) { 124 102 /* Check for HE, LL interrupts */ 125 103 126 - switch (temp8 & 0x09) { 104 + switch (aml->irq.flags & 0x09) { 127 105 case 0x01: /* HE */ 128 - output_struct->data.irq.edge_level = 129 - ACPI_EDGE_SENSITIVE; 130 - output_struct->data.irq.active_high_low = 131 - ACPI_ACTIVE_HIGH; 106 + resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; 107 + resource->data.irq.polarity = ACPI_ACTIVE_HIGH; 132 108 break; 133 109 134 110 case 0x08: /* LL */ 135 - output_struct->data.irq.edge_level = 136 - ACPI_LEVEL_SENSITIVE; 137 - output_struct->data.irq.active_high_low = 138 - ACPI_ACTIVE_LOW; 111 + resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE; 112 + resource->data.irq.polarity = ACPI_ACTIVE_LOW; 139 113 break; 140 114 141 115 default: ··· 120 146 */ 121 147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 122 148 "Invalid interrupt polarity/trigger in resource list, %X\n", 123 - temp8)); 149 + aml->irq.flags)); 124 150 return_ACPI_STATUS(AE_BAD_DATA); 125 151 } 126 152 127 - /* Check for sharable */ 153 + /* Get Sharing flag */ 128 154 129 - output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 155 + resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01; 130 156 } else { 131 157 /* 132 - * Assume Edge Sensitive, Active High, Non-Sharable 133 - * per ACPI Specification 158 + * Default configuration: assume Edge Sensitive, Active High, 159 + * Non-Sharable as per the ACPI Specification 134 160 */ 135 - output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; 136 - output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; 137 - output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 161 + resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; 162 + resource->data.irq.polarity = ACPI_ACTIVE_HIGH; 163 + resource->data.irq.sharable = ACPI_EXCLUSIVE; 138 164 } 139 165 140 - /* Set the Length parameter */ 166 + /* Complete the resource header */ 141 167 142 - output_struct->length = (u32) struct_size; 143 - 144 - /* Return the final size of the structure */ 145 - 146 - *structure_size = struct_size; 168 + resource->type = ACPI_RESOURCE_TYPE_IRQ; 169 + resource->length = 170 + resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); 147 171 return_ACPI_STATUS(AE_OK); 148 172 } 149 173 150 174 /******************************************************************************* 151 175 * 152 - * FUNCTION: acpi_rs_irq_stream 176 + * FUNCTION: acpi_rs_set_irq 153 177 * 154 - * PARAMETERS: Resource - Pointer to the resource linked list 155 - * output_buffer - Pointer to the user's return buffer 156 - * bytes_consumed - Pointer to where the number of bytes 157 - * used in the output_buffer is returned 178 + * PARAMETERS: Resource - Pointer to the resource descriptor 179 + * Aml - Where the AML descriptor is returned 158 180 * 159 181 * RETURN: Status 160 182 * 161 - * DESCRIPTION: Take the linked list resource structure and fills in the 162 - * the appropriate bytes in a byte stream 183 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 184 + * external AML resource descriptor. 163 185 * 164 186 ******************************************************************************/ 165 187 166 188 acpi_status 167 - acpi_rs_irq_stream(struct acpi_resource *resource, 168 - u8 ** output_buffer, acpi_size * bytes_consumed) 189 + acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml) 169 190 { 170 - u8 *buffer = *output_buffer; 171 - u16 temp16 = 0; 172 - u8 temp8 = 0; 173 - u8 index; 174 - u8 IRqinfo_byte_needed; 191 + acpi_size descriptor_length; 192 + u16 irq_mask; 193 + u8 i; 175 194 176 - ACPI_FUNCTION_TRACE("rs_irq_stream"); 195 + ACPI_FUNCTION_TRACE("rs_set_irq"); 196 + 197 + /* Convert interrupt list to 16-bit IRQ bitmask */ 198 + 199 + irq_mask = 0; 200 + for (i = 0; i < resource->data.irq.interrupt_count; i++) { 201 + irq_mask |= (1 << resource->data.irq.interrupts[i]); 202 + } 203 + 204 + /* Set the interrupt mask */ 205 + 206 + ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask); 177 207 178 208 /* 179 209 * The descriptor field is set based upon whether a third byte is 180 210 * needed to contain the IRQ Information. 181 211 */ 182 - if (ACPI_EDGE_SENSITIVE == resource->data.irq.edge_level && 183 - ACPI_ACTIVE_HIGH == resource->data.irq.active_high_low && 184 - ACPI_EXCLUSIVE == resource->data.irq.shared_exclusive) { 185 - *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x02; 186 - IRqinfo_byte_needed = FALSE; 212 + if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) && 213 + (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) && 214 + (resource->data.irq.sharable == ACPI_EXCLUSIVE)) { 215 + /* irq_no_flags() descriptor can be used */ 216 + 217 + descriptor_length = sizeof(struct aml_resource_irq_noflags); 187 218 } else { 188 - *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x03; 189 - IRqinfo_byte_needed = TRUE; 190 - } 219 + /* Irq() descriptor must be used */ 191 220 192 - buffer += 1; 193 - temp16 = 0; 221 + descriptor_length = sizeof(struct aml_resource_irq); 194 222 195 - /* Loop through all of the interrupts and set the mask bits */ 223 + /* Set the IRQ Info byte */ 196 224 197 - for (index = 0; 198 - index < resource->data.irq.number_of_interrupts; index++) { 199 - temp8 = (u8) resource->data.irq.interrupts[index]; 200 - temp16 |= 0x1 << temp8; 201 - } 225 + aml->irq.flags = (u8) 226 + ((resource->data.irq.sharable & 0x01) << 4); 202 227 203 - ACPI_MOVE_16_TO_16(buffer, &temp16); 204 - buffer += 2; 205 - 206 - /* Set the IRQ Info byte if needed. */ 207 - 208 - if (IRqinfo_byte_needed) { 209 - temp8 = 0; 210 - temp8 = (u8) ((resource->data.irq.shared_exclusive & 211 - 0x01) << 4); 212 - 213 - if (ACPI_LEVEL_SENSITIVE == resource->data.irq.edge_level && 214 - ACPI_ACTIVE_LOW == resource->data.irq.active_high_low) { 215 - temp8 |= 0x08; 228 + if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering && 229 + ACPI_ACTIVE_LOW == resource->data.irq.polarity) { 230 + aml->irq.flags |= 0x08; 216 231 } else { 217 - temp8 |= 0x01; 232 + aml->irq.flags |= 0x01; 218 233 } 219 - 220 - *buffer = temp8; 221 - buffer += 1; 222 234 } 223 235 224 - /* Return the number of bytes consumed in this operation */ 236 + /* Complete the AML descriptor header */ 225 237 226 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 238 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length, 239 + aml); 227 240 return_ACPI_STATUS(AE_OK); 228 241 } 229 242 230 243 /******************************************************************************* 231 244 * 232 - * FUNCTION: acpi_rs_extended_irq_resource 245 + * FUNCTION: acpi_rs_get_ext_irq 233 246 * 234 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 235 - * stream 236 - * bytes_consumed - Pointer to where the number of bytes 237 - * consumed the byte_stream_buffer is 238 - * returned 239 - * output_buffer - Pointer to the return data buffer 240 - * structure_size - Pointer to where the number of bytes 241 - * in the return data struct is returned 247 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 248 + * aml_resource_length - Length of the resource from the AML header 249 + * Resource - Where the internal resource is returned 242 250 * 243 251 * RETURN: Status 244 252 * 245 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 246 - * structure pointed to by the output_buffer. Return the 247 - * number of bytes consumed from the byte stream. 253 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 254 + * internal resource descriptor, simplifying bitflags and handling 255 + * alignment and endian issues if necessary. 248 256 * 249 257 ******************************************************************************/ 250 258 251 259 acpi_status 252 - acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, 253 - acpi_size * bytes_consumed, 254 - u8 ** output_buffer, acpi_size * structure_size) 260 + acpi_rs_get_ext_irq(union aml_resource *aml, 261 + u16 aml_resource_length, struct acpi_resource *resource) 255 262 { 256 - u8 *buffer = byte_stream_buffer; 257 - struct acpi_resource *output_struct = (void *)*output_buffer; 258 - u16 temp16 = 0; 259 - u8 temp8 = 0; 260 - u8 *temp_ptr; 261 - u8 index; 262 - acpi_size struct_size = 263 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq); 263 + char *out_resource_string; 264 + u8 temp8; 264 265 265 - ACPI_FUNCTION_TRACE("rs_extended_irq_resource"); 266 + ACPI_FUNCTION_TRACE("rs_get_ext_irq"); 266 267 267 - /* Get the Descriptor Length field */ 268 + /* Get the flag bits */ 268 269 269 - buffer += 1; 270 - ACPI_MOVE_16_TO_16(&temp16, buffer); 271 - 272 - /* Validate minimum descriptor length */ 273 - 274 - if (temp16 < 6) { 275 - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 276 - } 277 - 278 - *bytes_consumed = temp16 + 3; 279 - output_struct->type = ACPI_RSTYPE_EXT_IRQ; 280 - 281 - /* Point to the Byte3 */ 282 - 283 - buffer += 2; 284 - temp8 = *buffer; 285 - 286 - output_struct->data.extended_irq.producer_consumer = temp8 & 0x01; 270 + temp8 = aml->extended_irq.flags; 271 + resource->data.extended_irq.producer_consumer = temp8 & 0x01; 272 + resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01; 273 + resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01; 287 274 288 275 /* 289 276 * Check for Interrupt Mode ··· 254 319 * 255 320 * - Edge/Level are defined opposite in the table vs the headers 256 321 */ 257 - output_struct->data.extended_irq.edge_level = 322 + resource->data.extended_irq.triggering = 258 323 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; 259 324 260 - /* Check Interrupt Polarity */ 325 + /* Get the IRQ Table length (Byte4) */ 261 326 262 - output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1; 263 - 264 - /* Check for sharable */ 265 - 266 - output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01; 267 - 268 - /* Point to Byte4 (IRQ Table length) */ 269 - 270 - buffer += 1; 271 - temp8 = *buffer; 272 - 273 - /* Must have at least one IRQ */ 274 - 327 + temp8 = aml->extended_irq.table_length; 328 + resource->data.extended_irq.interrupt_count = temp8; 275 329 if (temp8 < 1) { 330 + /* Must have at least one IRQ */ 331 + 276 332 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 277 333 } 278 - 279 - output_struct->data.extended_irq.number_of_interrupts = temp8; 280 334 281 335 /* 282 336 * Add any additional structure size to properly calculate 283 337 * the next pointer at the end of this function 284 338 */ 285 - struct_size += (temp8 - 1) * 4; 339 + resource->length = (temp8 - 1) * 4; 340 + out_resource_string = ACPI_CAST_PTR(char, 341 + (&resource->data.extended_irq. 342 + interrupts[0] + temp8)); 286 343 287 - /* Point to Byte5 (First IRQ Number) */ 344 + /* Get every IRQ in the table, each is 32 bits */ 288 345 289 - buffer += 1; 346 + acpi_rs_move_data(resource->data.extended_irq.interrupts, 347 + aml->extended_irq.interrupt_number, 348 + (u16) temp8, ACPI_MOVE_TYPE_32_TO_32); 290 349 291 - /* Cycle through every IRQ in the table */ 350 + /* Get the optional resource_source (index and string) */ 292 351 293 - for (index = 0; index < temp8; index++) { 294 - ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq. 295 - interrupts[index], buffer); 352 + resource->length += 353 + acpi_rs_get_resource_source(aml_resource_length, 354 + (acpi_size) resource->length + 355 + sizeof(struct 356 + aml_resource_extended_irq), 357 + &resource->data.extended_irq. 358 + resource_source, aml, 359 + out_resource_string); 296 360 297 - /* Point to the next IRQ */ 361 + /* Complete the resource header */ 298 362 299 - buffer += 4; 300 - } 301 - 302 - /* 303 - * This will leave us pointing to the Resource Source Index 304 - * If it is present, then save it off and calculate the 305 - * pointer to where the null terminated string goes: 306 - * Each Interrupt takes 32-bits + the 5 bytes of the 307 - * stream that are default. 308 - * 309 - * Note: Some resource descriptors will have an additional null, so 310 - * we add 1 to the length. 311 - */ 312 - if (*bytes_consumed > 313 - ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 314 - 4) + (5 + 1)) { 315 - /* Dereference the Index */ 316 - 317 - temp8 = *buffer; 318 - output_struct->data.extended_irq.resource_source.index = 319 - (u32) temp8; 320 - 321 - /* Point to the String */ 322 - 323 - buffer += 1; 324 - 325 - /* Point the String pointer to the end of this structure. */ 326 - 327 - output_struct->data.extended_irq.resource_source.string_ptr = 328 - (char *)((char *)output_struct + struct_size); 329 - 330 - temp_ptr = (u8 *) 331 - output_struct->data.extended_irq.resource_source.string_ptr; 332 - 333 - /* Copy the string into the buffer */ 334 - 335 - index = 0; 336 - while (*buffer) { 337 - *temp_ptr = *buffer; 338 - 339 - temp_ptr += 1; 340 - buffer += 1; 341 - index += 1; 342 - } 343 - 344 - /* Add the terminating null */ 345 - 346 - *temp_ptr = 0; 347 - output_struct->data.extended_irq.resource_source.string_length = 348 - index + 1; 349 - 350 - /* 351 - * In order for the struct_size to fall on a 32-bit boundary, 352 - * calculate the length of the string and expand the 353 - * struct_size to the next 32-bit boundary. 354 - */ 355 - temp8 = (u8) (index + 1); 356 - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); 357 - } else { 358 - output_struct->data.extended_irq.resource_source.index = 0; 359 - output_struct->data.extended_irq.resource_source.string_length = 360 - 0; 361 - output_struct->data.extended_irq.resource_source.string_ptr = 362 - NULL; 363 - } 364 - 365 - /* Set the Length parameter */ 366 - 367 - output_struct->length = (u32) struct_size; 368 - 369 - /* Return the final size of the structure */ 370 - 371 - *structure_size = struct_size; 363 + resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; 364 + resource->length += 365 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq); 372 366 return_ACPI_STATUS(AE_OK); 373 367 } 374 368 375 369 /******************************************************************************* 376 370 * 377 - * FUNCTION: acpi_rs_extended_irq_stream 371 + * FUNCTION: acpi_rs_set_ext_irq 378 372 * 379 - * PARAMETERS: Resource - Pointer to the resource linked list 380 - * output_buffer - Pointer to the user's return buffer 381 - * bytes_consumed - Pointer to where the number of bytes 382 - * used in the output_buffer is returned 373 + * PARAMETERS: Resource - Pointer to the resource descriptor 374 + * Aml - Where the AML descriptor is returned 383 375 * 384 376 * RETURN: Status 385 377 * 386 - * DESCRIPTION: Take the linked list resource structure and fills in the 387 - * the appropriate bytes in a byte stream 378 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 379 + * external AML resource descriptor. 388 380 * 389 381 ******************************************************************************/ 390 382 391 383 acpi_status 392 - acpi_rs_extended_irq_stream(struct acpi_resource *resource, 393 - u8 ** output_buffer, acpi_size * bytes_consumed) 384 + acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml) 394 385 { 395 - u8 *buffer = *output_buffer; 396 - u16 *length_field; 397 - u8 temp8 = 0; 398 - u8 index; 386 + acpi_size descriptor_length; 399 387 400 - ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); 401 - 402 - /* Set the Descriptor Type field */ 403 - 404 - *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT; 405 - buffer += 1; 406 - 407 - /* Save a pointer to the Length field - to be filled in later */ 408 - 409 - length_field = ACPI_CAST_PTR(u16, buffer); 410 - buffer += 2; 388 + ACPI_FUNCTION_TRACE("rs_set_ext_irq"); 411 389 412 390 /* Set the Interrupt vector flags */ 413 391 414 - temp8 = (u8) (resource->data.extended_irq.producer_consumer & 0x01); 415 - temp8 |= ((resource->data.extended_irq.shared_exclusive & 0x01) << 3); 392 + aml->extended_irq.flags = (u8) 393 + ((resource->data.extended_irq.producer_consumer & 0x01) | 394 + ((resource->data.extended_irq.sharable & 0x01) << 3) | 395 + ((resource->data.extended_irq.polarity & 0x1) << 2)); 416 396 417 397 /* 418 398 * Set the Interrupt Mode ··· 338 488 * 339 489 * - Edge/Level are defined opposite in the table vs the headers 340 490 */ 341 - if (ACPI_EDGE_SENSITIVE == resource->data.extended_irq.edge_level) { 342 - temp8 |= 0x2; 491 + if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) { 492 + aml->extended_irq.flags |= 0x02; 343 493 } 344 - 345 - /* Set the Interrupt Polarity */ 346 - 347 - temp8 |= ((resource->data.extended_irq.active_high_low & 0x1) << 2); 348 - 349 - *buffer = temp8; 350 - buffer += 1; 351 494 352 495 /* Set the Interrupt table length */ 353 496 354 - temp8 = (u8) resource->data.extended_irq.number_of_interrupts; 497 + aml->extended_irq.table_length = (u8) 498 + resource->data.extended_irq.interrupt_count; 355 499 356 - *buffer = temp8; 357 - buffer += 1; 500 + descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) + 501 + ((acpi_size) resource->data.extended_irq.interrupt_count * 502 + sizeof(u32)); 358 503 359 - for (index = 0; 360 - index < resource->data.extended_irq.number_of_interrupts; 361 - index++) { 362 - ACPI_MOVE_32_TO_32(buffer, 363 - &resource->data.extended_irq. 364 - interrupts[index]); 365 - buffer += 4; 366 - } 504 + /* Set each interrupt value */ 505 + 506 + acpi_rs_move_data(aml->extended_irq.interrupt_number, 507 + resource->data.extended_irq.interrupts, 508 + (u16) resource->data.extended_irq.interrupt_count, 509 + ACPI_MOVE_TYPE_32_TO_32); 367 510 368 511 /* Resource Source Index and Resource Source are optional */ 369 512 370 - if (0 != resource->data.extended_irq.resource_source.string_length) { 371 - *buffer = 372 - (u8) resource->data.extended_irq.resource_source.index; 373 - buffer += 1; 513 + descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length, 514 + &resource->data. 515 + extended_irq. 516 + resource_source); 374 517 375 - /* Copy the string */ 518 + /* Complete the AML descriptor header */ 376 519 377 - ACPI_STRCPY((char *)buffer, 378 - resource->data.extended_irq.resource_source. 379 - string_ptr); 380 - 381 - /* 382 - * Buffer needs to be set to the length of the string + one for the 383 - * terminating null 384 - */ 385 - buffer += 386 - (acpi_size) (ACPI_STRLEN 387 - (resource->data.extended_irq.resource_source. 388 - string_ptr) + 1); 389 - } 390 - 391 - /* Return the number of bytes consumed in this operation */ 392 - 393 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 394 - 395 - /* 396 - * Set the length field to the number of bytes consumed 397 - * minus the header size (3 bytes) 398 - */ 399 - *length_field = (u16) (*bytes_consumed - 3); 520 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ, 521 + descriptor_length, aml); 400 522 return_ACPI_STATUS(AE_OK); 401 523 }
+150 -148
drivers/acpi/resources/rslist.c
··· 47 47 #define _COMPONENT ACPI_RESOURCES 48 48 ACPI_MODULE_NAME("rslist") 49 49 50 - /* Dispatch table for convert-to-stream functions */ 51 - typedef 52 - acpi_status(*ACPI_STREAM_HANDLER) (struct acpi_resource * resource, 53 - u8 ** output_buffer, 54 - acpi_size * bytes_consumed); 55 - 56 - static ACPI_STREAM_HANDLER acpi_gbl_stream_dispatch[] = { 57 - acpi_rs_irq_stream, /* ACPI_RSTYPE_IRQ */ 58 - acpi_rs_dma_stream, /* ACPI_RSTYPE_DMA */ 59 - acpi_rs_start_depend_fns_stream, /* ACPI_RSTYPE_START_DPF */ 60 - acpi_rs_end_depend_fns_stream, /* ACPI_RSTYPE_END_DPF */ 61 - acpi_rs_io_stream, /* ACPI_RSTYPE_IO */ 62 - acpi_rs_fixed_io_stream, /* ACPI_RSTYPE_FIXED_IO */ 63 - acpi_rs_vendor_stream, /* ACPI_RSTYPE_VENDOR */ 64 - acpi_rs_end_tag_stream, /* ACPI_RSTYPE_END_TAG */ 65 - acpi_rs_memory24_stream, /* ACPI_RSTYPE_MEM24 */ 66 - acpi_rs_memory32_range_stream, /* ACPI_RSTYPE_MEM32 */ 67 - acpi_rs_fixed_memory32_stream, /* ACPI_RSTYPE_FIXED_MEM32 */ 68 - acpi_rs_address16_stream, /* ACPI_RSTYPE_ADDRESS16 */ 69 - acpi_rs_address32_stream, /* ACPI_RSTYPE_ADDRESS32 */ 70 - acpi_rs_address64_stream, /* ACPI_RSTYPE_ADDRESS64 */ 71 - acpi_rs_extended_irq_stream, /* ACPI_RSTYPE_EXT_IRQ */ 72 - acpi_rs_generic_register_stream /* ACPI_RSTYPE_GENERIC_REG */ 73 - }; 74 - 75 - /* Dispatch tables for convert-to-resource functions */ 76 - 77 - typedef 78 - acpi_status(*ACPI_RESOURCE_HANDLER) (u8 * byte_stream_buffer, 79 - acpi_size * bytes_consumed, 80 - u8 ** output_buffer, 81 - acpi_size * structure_size); 82 - 83 - static ACPI_RESOURCE_HANDLER acpi_gbl_sm_resource_dispatch[] = { 84 - NULL, /* 0x00, Reserved */ 85 - NULL, /* 0x01, Reserved */ 86 - NULL, /* 0x02, Reserved */ 87 - NULL, /* 0x03, Reserved */ 88 - acpi_rs_irq_resource, /* ACPI_RDESC_TYPE_IRQ_FORMAT */ 89 - acpi_rs_dma_resource, /* ACPI_RDESC_TYPE_DMA_FORMAT */ 90 - acpi_rs_start_depend_fns_resource, /* ACPI_RDESC_TYPE_START_DEPENDENT */ 91 - acpi_rs_end_depend_fns_resource, /* ACPI_RDESC_TYPE_END_DEPENDENT */ 92 - acpi_rs_io_resource, /* ACPI_RDESC_TYPE_IO_PORT */ 93 - acpi_rs_fixed_io_resource, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */ 94 - NULL, /* 0x0A, Reserved */ 95 - NULL, /* 0x0B, Reserved */ 96 - NULL, /* 0x0C, Reserved */ 97 - NULL, /* 0x0D, Reserved */ 98 - acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_SMALL_VENDOR */ 99 - acpi_rs_end_tag_resource /* ACPI_RDESC_TYPE_END_TAG */ 100 - }; 101 - 102 - static ACPI_RESOURCE_HANDLER acpi_gbl_lg_resource_dispatch[] = { 103 - NULL, /* 0x00, Reserved */ 104 - acpi_rs_memory24_resource, /* ACPI_RDESC_TYPE_MEMORY_24 */ 105 - acpi_rs_generic_register_resource, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */ 106 - NULL, /* 0x03, Reserved */ 107 - acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_LARGE_VENDOR */ 108 - acpi_rs_memory32_range_resource, /* ACPI_RDESC_TYPE_MEMORY_32 */ 109 - acpi_rs_fixed_memory32_resource, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */ 110 - acpi_rs_address32_resource, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */ 111 - acpi_rs_address16_resource, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */ 112 - acpi_rs_extended_irq_resource, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */ 113 - acpi_rs_address64_resource, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */ 114 - acpi_rs_address64_resource /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */ 115 - }; 116 - 117 50 /* Local prototypes */ 51 + static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); 118 52 119 - static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); 53 + static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); 120 54 121 55 /******************************************************************************* 122 56 * 123 - * FUNCTION: acpi_rs_get_resource_type 57 + * FUNCTION: acpi_rs_validate_resource_length 124 58 * 125 - * PARAMETERS: resource_type - Byte 0 of a resource descriptor 59 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 126 60 * 127 - * RETURN: The Resource Type with no extraneous bits (except the large/ 128 - * small bit -- left alone) 61 + * RETURN: Status - AE_OK if the resource length appears valid 129 62 * 130 - * DESCRIPTION: Extract the Resource Type/Name from the first byte of 131 - * a resource descriptor. 63 + * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must 64 + * have the exact length; variable-length descriptors must be 65 + * at least as long as the minimum. Certain Small descriptors 66 + * can vary in size by at most one byte. 132 67 * 133 68 ******************************************************************************/ 134 69 135 - u8 acpi_rs_get_resource_type(u8 resource_type) 70 + static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) 136 71 { 72 + struct acpi_resource_info *resource_info; 73 + u16 minimum_aml_resource_length; 74 + u16 resource_length; 75 + 137 76 ACPI_FUNCTION_ENTRY(); 138 77 139 - /* Determine if this is a small or large resource */ 78 + /* Get the size and type info about this resource descriptor */ 140 79 141 - if (resource_type & ACPI_RDESC_TYPE_LARGE) { 142 - /* Large Resource Type -- bits 6:0 contain the name */ 143 - 144 - return (resource_type); 145 - } else { 146 - /* Small Resource Type -- bits 6:3 contain the name */ 147 - 148 - return ((u8) (resource_type & ACPI_RDESC_SMALL_MASK)); 80 + resource_info = 81 + acpi_rs_get_resource_info(aml->small_header.descriptor_type); 82 + if (!resource_info) { 83 + return (AE_AML_INVALID_RESOURCE_TYPE); 149 84 } 85 + 86 + resource_length = acpi_rs_get_resource_length(aml); 87 + minimum_aml_resource_length = 88 + resource_info->minimum_aml_resource_length; 89 + 90 + /* Validate based upon the type of resource, fixed length or variable */ 91 + 92 + if (resource_info->length_type == ACPI_FIXED_LENGTH) { 93 + /* Fixed length resource, length must match exactly */ 94 + 95 + if (resource_length != minimum_aml_resource_length) { 96 + return (AE_AML_BAD_RESOURCE_LENGTH); 97 + } 98 + } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { 99 + /* Variable length resource, must be at least the minimum */ 100 + 101 + if (resource_length < minimum_aml_resource_length) { 102 + return (AE_AML_BAD_RESOURCE_LENGTH); 103 + } 104 + } else { 105 + /* Small variable length resource, allowed to be (Min) or (Min-1) */ 106 + 107 + if ((resource_length > minimum_aml_resource_length) || 108 + (resource_length < (minimum_aml_resource_length - 1))) { 109 + return (AE_AML_BAD_RESOURCE_LENGTH); 110 + } 111 + } 112 + 113 + return (AE_OK); 150 114 } 151 115 152 116 /******************************************************************************* ··· 126 162 * 127 163 ******************************************************************************/ 128 164 129 - static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) 165 + static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) 130 166 { 131 167 ACPI_FUNCTION_ENTRY(); 132 168 133 169 /* Determine if this is a small or large resource */ 134 170 135 - if (resource_type & ACPI_RDESC_TYPE_LARGE) { 171 + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 136 172 /* Large Resource Type -- bits 6:0 contain the name */ 137 173 138 - if (resource_type > ACPI_RDESC_LARGE_MAX) { 174 + if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 139 175 return (NULL); 140 176 } 141 177 142 - return (acpi_gbl_lg_resource_dispatch[(resource_type & 143 - ACPI_RDESC_LARGE_MASK)]); 178 + return (acpi_gbl_lg_get_resource_dispatch[(resource_type & 179 + ACPI_RESOURCE_NAME_LARGE_MASK)]); 144 180 } else { 145 181 /* Small Resource Type -- bits 6:3 contain the name */ 146 182 147 - return (acpi_gbl_sm_resource_dispatch[((resource_type & 148 - ACPI_RDESC_SMALL_MASK) 149 - >> 3)]); 183 + return (acpi_gbl_sm_get_resource_dispatch[((resource_type & 184 + ACPI_RESOURCE_NAME_SMALL_MASK) 185 + >> 3)]); 150 186 } 151 187 } 152 188 153 189 /******************************************************************************* 154 190 * 155 - * FUNCTION: acpi_rs_byte_stream_to_list 191 + * FUNCTION: acpi_rs_convert_aml_to_resources 156 192 * 157 - * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 158 - * byte_stream_buffer_length - Length of byte_stream_buffer 159 - * output_buffer - Pointer to the buffer that will 160 - * contain the output structures 193 + * PARAMETERS: aml_buffer - Pointer to the resource byte stream 194 + * aml_buffer_length - Length of aml_buffer 195 + * output_buffer - Pointer to the buffer that will 196 + * contain the output structures 161 197 * 162 198 * RETURN: Status 163 199 * ··· 167 203 ******************************************************************************/ 168 204 169 205 acpi_status 170 - acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, 171 - u32 byte_stream_buffer_length, u8 * output_buffer) 206 + acpi_rs_convert_aml_to_resources(u8 * aml_buffer, 207 + u32 aml_buffer_length, u8 * output_buffer) 172 208 { 173 209 u8 *buffer = output_buffer; 174 210 acpi_status status; 175 211 acpi_size bytes_parsed = 0; 176 - acpi_size bytes_consumed = 0; 177 - acpi_size structure_size = 0; 178 212 struct acpi_resource *resource; 179 - ACPI_RESOURCE_HANDLER handler; 213 + u16 resource_length; 214 + u32 descriptor_length; 215 + ACPI_GET_RESOURCE_HANDLER handler; 180 216 181 - ACPI_FUNCTION_TRACE("rs_byte_stream_to_list"); 217 + ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); 182 218 183 219 /* Loop until end-of-buffer or an end_tag is found */ 184 220 185 - while (bytes_parsed < byte_stream_buffer_length) { 221 + while (bytes_parsed < aml_buffer_length) { 186 222 /* Get the handler associated with this Descriptor Type */ 187 223 188 - handler = acpi_rs_get_resource_handler(*byte_stream_buffer); 189 - if (handler) { 190 - /* Convert a byte stream resource to local resource struct */ 224 + handler = acpi_rs_get_resource_handler(*aml_buffer); 225 + if (!handler) { 226 + /* No handler indicates invalid resource type */ 191 227 192 - status = handler(byte_stream_buffer, &bytes_consumed, 193 - &buffer, &structure_size); 194 - } else { 195 - /* Invalid resource type */ 196 - 197 - status = AE_AML_INVALID_RESOURCE_TYPE; 228 + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 198 229 } 199 230 231 + resource_length = 232 + acpi_rs_get_resource_length(ACPI_CAST_PTR 233 + (union aml_resource, 234 + aml_buffer)); 235 + 236 + descriptor_length = 237 + acpi_rs_get_descriptor_length(ACPI_CAST_PTR 238 + (union aml_resource, 239 + aml_buffer)); 240 + 241 + /* 242 + * Perform limited validation of the resource length, based upon 243 + * what we know about the resource type 244 + */ 245 + status = 246 + acpi_rs_validate_resource_length(ACPI_CAST_PTR 247 + (union aml_resource, 248 + aml_buffer)); 200 249 if (ACPI_FAILURE(status)) { 250 + return_ACPI_STATUS(status); 251 + } 252 + 253 + /* Convert a byte stream resource to local resource struct */ 254 + 255 + status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer), 256 + resource_length, 257 + ACPI_CAST_PTR(struct acpi_resource, buffer)); 258 + if (ACPI_FAILURE(status)) { 259 + ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); 201 260 return_ACPI_STATUS(status); 202 261 } 203 262 ··· 232 245 233 246 /* Normal exit on completion of an end_tag resource descriptor */ 234 247 235 - if (acpi_rs_get_resource_type(*byte_stream_buffer) == 236 - ACPI_RDESC_TYPE_END_TAG) { 248 + if (acpi_rs_get_resource_type(*aml_buffer) == 249 + ACPI_RESOURCE_NAME_END_TAG) { 237 250 return_ACPI_STATUS(AE_OK); 238 251 } 239 252 240 253 /* Update counter and point to the next input resource */ 241 254 242 - bytes_parsed += bytes_consumed; 243 - byte_stream_buffer += bytes_consumed; 255 + bytes_parsed += descriptor_length; 256 + aml_buffer += descriptor_length; 244 257 245 258 /* Point to the next structure in the output buffer */ 246 259 247 - buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size); 260 + buffer += resource->length; 248 261 } 249 262 250 263 /* Completed buffer, but did not find an end_tag resource descriptor */ ··· 254 267 255 268 /******************************************************************************* 256 269 * 257 - * FUNCTION: acpi_rs_list_to_byte_stream 270 + * FUNCTION: acpi_rs_convert_resources_to_aml 258 271 * 259 - * PARAMETERS: Resource - Pointer to the resource linked list 260 - * byte_steam_size_needed - Calculated size of the byte stream 261 - * needed from calling 262 - * acpi_rs_get_byte_stream_length() 263 - * The size of the output_buffer is 264 - * guaranteed to be >= 265 - * byte_stream_size_needed 266 - * output_buffer - Pointer to the buffer that will 267 - * contain the byte stream 272 + * PARAMETERS: Resource - Pointer to the resource linked list 273 + * aml_size_needed - Calculated size of the byte stream 274 + * needed from calling acpi_rs_get_aml_length() 275 + * The size of the output_buffer is 276 + * guaranteed to be >= aml_size_needed 277 + * output_buffer - Pointer to the buffer that will 278 + * contain the byte stream 268 279 * 269 280 * RETURN: Status 270 281 * ··· 272 287 ******************************************************************************/ 273 288 274 289 acpi_status 275 - acpi_rs_list_to_byte_stream(struct acpi_resource *resource, 276 - acpi_size byte_stream_size_needed, 277 - u8 * output_buffer) 290 + acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, 291 + acpi_size aml_size_needed, u8 * output_buffer) 278 292 { 279 - u8 *buffer = output_buffer; 280 - acpi_size bytes_consumed = 0; 293 + u8 *aml_buffer = output_buffer; 281 294 acpi_status status; 282 295 283 - ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); 296 + ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); 284 297 285 298 /* Convert each resource descriptor in the list */ 286 299 287 300 while (1) { 288 - /* Validate Type before dispatch */ 301 + /* Validate Resource Descriptor Type before dispatch */ 289 302 290 - if (resource->type > ACPI_RSTYPE_MAX) { 303 + if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 291 304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 292 305 "Invalid descriptor type (%X) in resource list\n", 293 306 resource->type)); 294 307 return_ACPI_STATUS(AE_BAD_DATA); 295 308 } 296 309 297 - /* Perform the conversion, per resource type */ 310 + /* Perform the conversion per resource type */ 298 311 299 - status = acpi_gbl_stream_dispatch[resource->type] (resource, 300 - &buffer, 301 - &bytes_consumed); 312 + status = 313 + acpi_gbl_set_resource_dispatch[resource->type] (resource, 314 + ACPI_CAST_PTR 315 + (union 316 + aml_resource, 317 + aml_buffer)); 318 + if (ACPI_FAILURE(status)) { 319 + ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status))); 320 + return_ACPI_STATUS(status); 321 + } 322 + 323 + /* Perform final sanity check on the new AML resource descriptor */ 324 + 325 + status = 326 + acpi_rs_validate_resource_length(ACPI_CAST_PTR 327 + (union aml_resource, 328 + aml_buffer)); 302 329 if (ACPI_FAILURE(status)) { 303 330 return_ACPI_STATUS(status); 304 331 } 305 332 306 - /* Check for end-of-list */ 333 + /* Check for end-of-list, normal exit */ 307 334 308 - if (resource->type == ACPI_RSTYPE_END_TAG) { 309 - /* An End Tag indicates the end of the Resource Template */ 335 + if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { 336 + /* An End Tag indicates the end of the input Resource Template */ 310 337 311 338 return_ACPI_STATUS(AE_OK); 312 339 } 313 340 314 - /* Set the Buffer to point to the next (output) resource descriptor */ 341 + /* Extract the total length of the new descriptor */ 342 + /* Set the aml_buffer to point to the next (output) resource descriptor */ 315 343 316 - buffer += bytes_consumed; 344 + aml_buffer += 345 + acpi_rs_get_descriptor_length(ACPI_CAST_PTR 346 + (union aml_resource, 347 + aml_buffer)); 317 348 318 - /* Point to the next input resource object */ 349 + /* Point to the next input resource descriptor */ 319 350 320 - resource = ACPI_PTR_ADD(struct acpi_resource, 321 - resource, resource->length); 351 + resource = 352 + ACPI_PTR_ADD(struct acpi_resource, resource, 353 + resource->length); 322 354 } 323 355 }
+191 -377
drivers/acpi/resources/rsmemory.c
··· 49 49 50 50 /******************************************************************************* 51 51 * 52 - * FUNCTION: acpi_rs_memory24_resource 52 + * FUNCTION: acpi_rs_get_memory24 53 53 * 54 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 55 - * stream 56 - * bytes_consumed - Pointer to where the number of bytes 57 - * consumed the byte_stream_buffer is 58 - * returned 59 - * output_buffer - Pointer to the return data buffer 60 - * structure_size - Pointer to where the number of bytes 61 - * in the return data struct is returned 54 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 55 + * aml_resource_length - Length of the resource from the AML header 56 + * Resource - Where the internal resource is returned 62 57 * 63 58 * RETURN: Status 64 59 * 65 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 66 - * structure pointed to by the output_buffer. Return the 67 - * number of bytes consumed from the byte stream. 60 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 61 + * internal resource descriptor, simplifying bitflags and handling 62 + * alignment and endian issues if necessary. 68 63 * 69 64 ******************************************************************************/ 70 65 acpi_status 71 - acpi_rs_memory24_resource(u8 * byte_stream_buffer, 72 - acpi_size * bytes_consumed, 73 - u8 ** output_buffer, acpi_size * structure_size) 66 + acpi_rs_get_memory24(union aml_resource * aml, 67 + u16 aml_resource_length, struct acpi_resource * resource) 74 68 { 75 - u8 *buffer = byte_stream_buffer; 76 - struct acpi_resource *output_struct = (void *)*output_buffer; 77 - u16 temp16 = 0; 78 - u8 temp8 = 0; 79 - acpi_size struct_size = 80 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24); 69 + ACPI_FUNCTION_TRACE("rs_get_memory24"); 81 70 82 - ACPI_FUNCTION_TRACE("rs_memory24_resource"); 71 + /* Get the Read/Write bit */ 83 72 84 - /* Point past the Descriptor to get the number of bytes consumed */ 85 - 86 - buffer += 1; 87 - ACPI_MOVE_16_TO_16(&temp16, buffer); 88 - 89 - buffer += 2; 90 - *bytes_consumed = (acpi_size) temp16 + 3; 91 - output_struct->type = ACPI_RSTYPE_MEM24; 92 - 93 - /* Check Byte 3 the Read/Write bit */ 94 - 95 - temp8 = *buffer; 96 - buffer += 1; 97 - output_struct->data.memory24.read_write_attribute = temp8 & 0x01; 98 - 99 - /* Get min_base_address (Bytes 4-5) */ 100 - 101 - ACPI_MOVE_16_TO_16(&temp16, buffer); 102 - buffer += 2; 103 - output_struct->data.memory24.min_base_address = temp16; 104 - 105 - /* Get max_base_address (Bytes 6-7) */ 106 - 107 - ACPI_MOVE_16_TO_16(&temp16, buffer); 108 - buffer += 2; 109 - output_struct->data.memory24.max_base_address = temp16; 110 - 111 - /* Get Alignment (Bytes 8-9) */ 112 - 113 - ACPI_MOVE_16_TO_16(&temp16, buffer); 114 - buffer += 2; 115 - output_struct->data.memory24.alignment = temp16; 116 - 117 - /* Get range_length (Bytes 10-11) */ 118 - 119 - ACPI_MOVE_16_TO_16(&temp16, buffer); 120 - output_struct->data.memory24.range_length = temp16; 121 - 122 - /* Set the Length parameter */ 123 - 124 - output_struct->length = (u32) struct_size; 125 - 126 - /* Return the final size of the structure */ 127 - 128 - *structure_size = struct_size; 129 - return_ACPI_STATUS(AE_OK); 130 - } 131 - 132 - /******************************************************************************* 133 - * 134 - * FUNCTION: acpi_rs_memory24_stream 135 - * 136 - * PARAMETERS: Resource - Pointer to the resource linked list 137 - * output_buffer - Pointer to the user's return buffer 138 - * bytes_consumed - Pointer to where the number of bytes 139 - * used in the output_buffer is returned 140 - * 141 - * RETURN: Status 142 - * 143 - * DESCRIPTION: Take the linked list resource structure and fills in the 144 - * the appropriate bytes in a byte stream 145 - * 146 - ******************************************************************************/ 147 - 148 - acpi_status 149 - acpi_rs_memory24_stream(struct acpi_resource *resource, 150 - u8 ** output_buffer, acpi_size * bytes_consumed) 151 - { 152 - u8 *buffer = *output_buffer; 153 - u16 temp16 = 0; 154 - u8 temp8 = 0; 155 - 156 - ACPI_FUNCTION_TRACE("rs_memory24_stream"); 157 - 158 - /* The Descriptor Type field is static */ 159 - 160 - *buffer = ACPI_RDESC_TYPE_MEMORY_24; 161 - buffer += 1; 162 - 163 - /* The length field is static */ 164 - 165 - temp16 = 0x09; 166 - ACPI_MOVE_16_TO_16(buffer, &temp16); 167 - buffer += 2; 168 - 169 - /* Set the Information Byte */ 170 - 171 - temp8 = (u8) (resource->data.memory24.read_write_attribute & 0x01); 172 - *buffer = temp8; 173 - buffer += 1; 174 - 175 - /* Set the Range minimum base address */ 176 - 177 - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.min_base_address); 178 - buffer += 2; 179 - 180 - /* Set the Range maximum base address */ 181 - 182 - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.max_base_address); 183 - buffer += 2; 184 - 185 - /* Set the base alignment */ 186 - 187 - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.alignment); 188 - buffer += 2; 189 - 190 - /* Set the range length */ 191 - 192 - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.range_length); 193 - buffer += 2; 194 - 195 - /* Return the number of bytes consumed in this operation */ 196 - 197 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 198 - return_ACPI_STATUS(AE_OK); 199 - } 200 - 201 - /******************************************************************************* 202 - * 203 - * FUNCTION: acpi_rs_memory32_range_resource 204 - * 205 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 206 - * stream 207 - * bytes_consumed - Pointer to where the number of bytes 208 - * consumed the byte_stream_buffer is 209 - * returned 210 - * output_buffer - Pointer to the return data buffer 211 - * structure_size - Pointer to where the number of bytes 212 - * in the return data struct is returned 213 - * 214 - * RETURN: Status 215 - * 216 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 217 - * structure pointed to by the output_buffer. Return the 218 - * number of bytes consumed from the byte stream. 219 - * 220 - ******************************************************************************/ 221 - 222 - acpi_status 223 - acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 224 - acpi_size * bytes_consumed, 225 - u8 ** output_buffer, acpi_size * structure_size) 226 - { 227 - u8 *buffer = byte_stream_buffer; 228 - struct acpi_resource *output_struct = (void *)*output_buffer; 229 - u16 temp16 = 0; 230 - u8 temp8 = 0; 231 - acpi_size struct_size = 232 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); 233 - 234 - ACPI_FUNCTION_TRACE("rs_memory32_range_resource"); 235 - 236 - /* Point past the Descriptor to get the number of bytes consumed */ 237 - 238 - buffer += 1; 239 - ACPI_MOVE_16_TO_16(&temp16, buffer); 240 - 241 - buffer += 2; 242 - *bytes_consumed = (acpi_size) temp16 + 3; 243 - output_struct->type = ACPI_RSTYPE_MEM32; 73 + resource->data.memory24.read_write_attribute = 74 + (aml->memory24.information & 0x01); 244 75 245 76 /* 246 - * Point to the place in the output buffer where the data portion will 247 - * begin. 248 - * 1. Set the RESOURCE_DATA * Data to point to its own address, then 249 - * 2. Set the pointer to the next address. 250 - * 251 - * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds 252 - * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) 77 + * Get the following contiguous fields from the AML descriptor: 78 + * Minimum Base Address 79 + * Maximum Base Address 80 + * Address Base Alignment 81 + * Range Length 253 82 */ 83 + acpi_rs_move_data(&resource->data.memory24.minimum, 84 + &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32); 254 85 255 - /* Check Byte 3 the Read/Write bit */ 86 + /* Complete the resource header */ 256 87 257 - temp8 = *buffer; 258 - buffer += 1; 259 - 260 - output_struct->data.memory32.read_write_attribute = temp8 & 0x01; 261 - 262 - /* Get min_base_address (Bytes 4-7) */ 263 - 264 - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address, 265 - buffer); 266 - buffer += 4; 267 - 268 - /* Get max_base_address (Bytes 8-11) */ 269 - 270 - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address, 271 - buffer); 272 - buffer += 4; 273 - 274 - /* Get Alignment (Bytes 12-15) */ 275 - 276 - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer); 277 - buffer += 4; 278 - 279 - /* Get range_length (Bytes 16-19) */ 280 - 281 - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer); 282 - 283 - /* Set the Length parameter */ 284 - 285 - output_struct->length = (u32) struct_size; 286 - 287 - /* Return the final size of the structure */ 288 - 289 - *structure_size = struct_size; 88 + resource->type = ACPI_RESOURCE_TYPE_MEMORY24; 89 + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24); 290 90 return_ACPI_STATUS(AE_OK); 291 91 } 292 92 293 93 /******************************************************************************* 294 94 * 295 - * FUNCTION: acpi_rs_fixed_memory32_resource 95 + * FUNCTION: acpi_rs_set_memory24 296 96 * 297 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 298 - * stream 299 - * bytes_consumed - Pointer to where the number of bytes 300 - * consumed the byte_stream_buffer is 301 - * returned 302 - * output_buffer - Pointer to the return data buffer 303 - * structure_size - Pointer to where the number of bytes 304 - * in the return data struct is returned 97 + * PARAMETERS: Resource - Pointer to the resource descriptor 98 + * Aml - Where the AML descriptor is returned 305 99 * 306 100 * RETURN: Status 307 101 * 308 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 309 - * structure pointed to by the output_buffer. Return the 310 - * number of bytes consumed from the byte stream. 102 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 103 + * external AML resource descriptor. 311 104 * 312 105 ******************************************************************************/ 313 106 314 107 acpi_status 315 - acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, 316 - acpi_size * bytes_consumed, 317 - u8 ** output_buffer, acpi_size * structure_size) 108 + acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml) 318 109 { 319 - u8 *buffer = byte_stream_buffer; 320 - struct acpi_resource *output_struct = (void *)*output_buffer; 321 - u16 temp16 = 0; 322 - u8 temp8 = 0; 323 - acpi_size struct_size = 324 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32); 325 - 326 - ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource"); 327 - 328 - /* Point past the Descriptor to get the number of bytes consumed */ 329 - 330 - buffer += 1; 331 - ACPI_MOVE_16_TO_16(&temp16, buffer); 332 - 333 - buffer += 2; 334 - *bytes_consumed = (acpi_size) temp16 + 3; 335 - output_struct->type = ACPI_RSTYPE_FIXED_MEM32; 336 - 337 - /* Check Byte 3 the Read/Write bit */ 338 - 339 - temp8 = *buffer; 340 - buffer += 1; 341 - output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; 342 - 343 - /* Get range_base_address (Bytes 4-7) */ 344 - 345 - ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32. 346 - range_base_address, buffer); 347 - buffer += 4; 348 - 349 - /* Get range_length (Bytes 8-11) */ 350 - 351 - ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length, 352 - buffer); 353 - 354 - /* Set the Length parameter */ 355 - 356 - output_struct->length = (u32) struct_size; 357 - 358 - /* Return the final size of the structure */ 359 - 360 - *structure_size = struct_size; 361 - return_ACPI_STATUS(AE_OK); 362 - } 363 - 364 - /******************************************************************************* 365 - * 366 - * FUNCTION: acpi_rs_memory32_range_stream 367 - * 368 - * PARAMETERS: Resource - Pointer to the resource linked list 369 - * output_buffer - Pointer to the user's return buffer 370 - * bytes_consumed - Pointer to where the number of bytes 371 - * used in the output_buffer is returned 372 - * 373 - * RETURN: Status 374 - * 375 - * DESCRIPTION: Take the linked list resource structure and fills in the 376 - * the appropriate bytes in a byte stream 377 - * 378 - ******************************************************************************/ 379 - 380 - acpi_status 381 - acpi_rs_memory32_range_stream(struct acpi_resource *resource, 382 - u8 ** output_buffer, acpi_size * bytes_consumed) 383 - { 384 - u8 *buffer = *output_buffer; 385 - u16 temp16 = 0; 386 - u8 temp8 = 0; 387 - 388 - ACPI_FUNCTION_TRACE("rs_memory32_range_stream"); 389 - 390 - /* The Descriptor Type field is static */ 391 - 392 - *buffer = ACPI_RDESC_TYPE_MEMORY_32; 393 - buffer += 1; 394 - 395 - /* The length field is static */ 396 - 397 - temp16 = 0x11; 398 - 399 - ACPI_MOVE_16_TO_16(buffer, &temp16); 400 - buffer += 2; 110 + ACPI_FUNCTION_TRACE("rs_set_memory24"); 401 111 402 112 /* Set the Information Byte */ 403 113 404 - temp8 = (u8) (resource->data.memory32.read_write_attribute & 0x01); 405 - *buffer = temp8; 406 - buffer += 1; 114 + aml->memory24.information = (u8) 115 + (resource->data.memory24.read_write_attribute & 0x01); 407 116 408 - /* Set the Range minimum base address */ 117 + /* 118 + * Set the following contiguous fields in the AML descriptor: 119 + * Minimum Base Address 120 + * Maximum Base Address 121 + * Address Base Alignment 122 + * Range Length 123 + */ 124 + acpi_rs_move_data(&aml->memory24.minimum, 125 + &resource->data.memory24.minimum, 4, 126 + ACPI_MOVE_TYPE_32_TO_16); 409 127 410 - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.min_base_address); 411 - buffer += 4; 128 + /* Complete the AML descriptor header */ 412 129 413 - /* Set the Range maximum base address */ 414 - 415 - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.max_base_address); 416 - buffer += 4; 417 - 418 - /* Set the base alignment */ 419 - 420 - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.alignment); 421 - buffer += 4; 422 - 423 - /* Set the range length */ 424 - 425 - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.range_length); 426 - buffer += 4; 427 - 428 - /* Return the number of bytes consumed in this operation */ 429 - 430 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 130 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24, 131 + sizeof(struct aml_resource_memory24), aml); 431 132 return_ACPI_STATUS(AE_OK); 432 133 } 433 134 434 135 /******************************************************************************* 435 136 * 436 - * FUNCTION: acpi_rs_fixed_memory32_stream 137 + * FUNCTION: acpi_rs_get_memory32 437 138 * 438 - * PARAMETERS: Resource - Pointer to the resource linked list 439 - * output_buffer - Pointer to the user's return buffer 440 - * bytes_consumed - Pointer to where the number of bytes 441 - * used in the output_buffer is returned 139 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 140 + * aml_resource_length - Length of the resource from the AML header 141 + * Resource - Where the internal resource is returned 442 142 * 443 143 * RETURN: Status 444 144 * 445 - * DESCRIPTION: Take the linked list resource structure and fills in the 446 - * the appropriate bytes in a byte stream 145 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 146 + * internal resource descriptor, simplifying bitflags and handling 147 + * alignment and endian issues if necessary. 447 148 * 448 149 ******************************************************************************/ 449 150 450 151 acpi_status 451 - acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, 452 - u8 ** output_buffer, acpi_size * bytes_consumed) 152 + acpi_rs_get_memory32(union aml_resource *aml, 153 + u16 aml_resource_length, struct acpi_resource *resource) 453 154 { 454 - u8 *buffer = *output_buffer; 455 - u16 temp16 = 0; 456 - u8 temp8 = 0; 155 + ACPI_FUNCTION_TRACE("rs_get_memory32"); 457 156 458 - ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream"); 157 + /* Get the Read/Write bit */ 459 158 460 - /* The Descriptor Type field is static */ 159 + resource->data.memory32.read_write_attribute = 160 + (aml->memory32.information & 0x01); 461 161 462 - *buffer = ACPI_RDESC_TYPE_FIXED_MEMORY_32; 463 - buffer += 1; 162 + /* 163 + * Get the following contiguous fields from the AML descriptor: 164 + * Minimum Base Address 165 + * Maximum Base Address 166 + * Address Base Alignment 167 + * Range Length 168 + */ 169 + acpi_rs_move_data(&resource->data.memory32.minimum, 170 + &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32); 464 171 465 - /* The length field is static */ 172 + /* Complete the resource header */ 466 173 467 - temp16 = 0x09; 174 + resource->type = ACPI_RESOURCE_TYPE_MEMORY32; 175 + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32); 176 + return_ACPI_STATUS(AE_OK); 177 + } 468 178 469 - ACPI_MOVE_16_TO_16(buffer, &temp16); 470 - buffer += 2; 179 + /******************************************************************************* 180 + * 181 + * FUNCTION: acpi_rs_set_memory32 182 + * 183 + * PARAMETERS: Resource - Pointer to the resource descriptor 184 + * Aml - Where the AML descriptor is returned 185 + * 186 + * RETURN: Status 187 + * 188 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 189 + * external AML resource descriptor. 190 + * 191 + ******************************************************************************/ 192 + 193 + acpi_status 194 + acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml) 195 + { 196 + ACPI_FUNCTION_TRACE("rs_set_memory32"); 471 197 472 198 /* Set the Information Byte */ 473 199 474 - temp8 = 475 - (u8) (resource->data.fixed_memory32.read_write_attribute & 0x01); 476 - *buffer = temp8; 477 - buffer += 1; 200 + aml->memory32.information = (u8) 201 + (resource->data.memory32.read_write_attribute & 0x01); 478 202 479 - /* Set the Range base address */ 203 + /* 204 + * Set the following contiguous fields in the AML descriptor: 205 + * Minimum Base Address 206 + * Maximum Base Address 207 + * Address Base Alignment 208 + * Range Length 209 + */ 210 + acpi_rs_move_data(&aml->memory32.minimum, 211 + &resource->data.memory32.minimum, 4, 212 + ACPI_MOVE_TYPE_32_TO_32); 480 213 481 - ACPI_MOVE_32_TO_32(buffer, 482 - &resource->data.fixed_memory32.range_base_address); 483 - buffer += 4; 214 + /* Complete the AML descriptor header */ 484 215 485 - /* Set the range length */ 216 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32, 217 + sizeof(struct aml_resource_memory32), aml); 218 + return_ACPI_STATUS(AE_OK); 219 + } 486 220 487 - ACPI_MOVE_32_TO_32(buffer, &resource->data.fixed_memory32.range_length); 488 - buffer += 4; 221 + /******************************************************************************* 222 + * 223 + * FUNCTION: acpi_rs_get_fixed_memory32 224 + * 225 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 226 + * aml_resource_length - Length of the resource from the AML header 227 + * Resource - Where the internal resource is returned 228 + * 229 + * RETURN: Status 230 + * 231 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 232 + * internal resource descriptor, simplifying bitflags and handling 233 + * alignment and endian issues if necessary. 234 + * 235 + ******************************************************************************/ 489 236 490 - /* Return the number of bytes consumed in this operation */ 237 + acpi_status 238 + acpi_rs_get_fixed_memory32(union aml_resource *aml, 239 + u16 aml_resource_length, 240 + struct acpi_resource *resource) 241 + { 242 + ACPI_FUNCTION_TRACE("rs_get_fixed_memory32"); 491 243 492 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 244 + /* Get the Read/Write bit */ 245 + 246 + resource->data.fixed_memory32.read_write_attribute = 247 + (aml->fixed_memory32.information & 0x01); 248 + 249 + /* 250 + * Get the following contiguous fields from the AML descriptor: 251 + * Base Address 252 + * Range Length 253 + */ 254 + ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address, 255 + &aml->fixed_memory32.address); 256 + ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length, 257 + &aml->fixed_memory32.address_length); 258 + 259 + /* Complete the resource header */ 260 + 261 + resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; 262 + resource->length = 263 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32); 264 + return_ACPI_STATUS(AE_OK); 265 + } 266 + 267 + /******************************************************************************* 268 + * 269 + * FUNCTION: acpi_rs_set_fixed_memory32 270 + * 271 + * PARAMETERS: Resource - Pointer to the resource descriptor 272 + * Aml - Where the AML descriptor is returned 273 + * 274 + * RETURN: Status 275 + * 276 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 277 + * external AML resource descriptor. 278 + * 279 + ******************************************************************************/ 280 + 281 + acpi_status 282 + acpi_rs_set_fixed_memory32(struct acpi_resource *resource, 283 + union aml_resource *aml) 284 + { 285 + ACPI_FUNCTION_TRACE("rs_set_fixed_memory32"); 286 + 287 + /* Set the Information Byte */ 288 + 289 + aml->fixed_memory32.information = (u8) 290 + (resource->data.fixed_memory32.read_write_attribute & 0x01); 291 + 292 + /* 293 + * Set the following contiguous fields in the AML descriptor: 294 + * Base Address 295 + * Range Length 296 + */ 297 + ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address, 298 + &resource->data.fixed_memory32.address); 299 + ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length, 300 + &resource->data.fixed_memory32.address_length); 301 + 302 + /* Complete the AML descriptor header */ 303 + 304 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32, 305 + sizeof(struct aml_resource_fixed_memory32), 306 + aml); 493 307 return_ACPI_STATUS(AE_OK); 494 308 }
+276 -485
drivers/acpi/resources/rsmisc.c
··· 49 49 50 50 /******************************************************************************* 51 51 * 52 - * FUNCTION: acpi_rs_generic_register_resource 52 + * FUNCTION: acpi_rs_get_generic_reg 53 53 * 54 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 55 - * stream 56 - * bytes_consumed - Pointer to where the number of bytes 57 - * consumed the byte_stream_buffer is 58 - * returned 59 - * output_buffer - Pointer to the return data buffer 60 - * structure_size - Pointer to where the number of bytes 61 - * in the return data struct is returned 54 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 55 + * aml_resource_length - Length of the resource from the AML header 56 + * Resource - Where the internal resource is returned 62 57 * 63 58 * RETURN: Status 64 59 * 65 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 66 - * structure pointed to by the output_buffer. Return the 67 - * number of bytes consumed from the byte stream. 60 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 61 + * internal resource descriptor, simplifying bitflags and handling 62 + * alignment and endian issues if necessary. 68 63 * 69 64 ******************************************************************************/ 70 65 acpi_status 71 - acpi_rs_generic_register_resource(u8 * byte_stream_buffer, 72 - acpi_size * bytes_consumed, 73 - u8 ** output_buffer, 74 - acpi_size * structure_size) 66 + acpi_rs_get_generic_reg(union aml_resource *aml, 67 + u16 aml_resource_length, struct acpi_resource *resource) 75 68 { 76 - u8 *buffer = byte_stream_buffer; 77 - struct acpi_resource *output_struct = (void *)*output_buffer; 78 - u16 temp16; 79 - u8 temp8; 80 - acpi_size struct_size = 81 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg); 82 - 83 - ACPI_FUNCTION_TRACE("rs_generic_register_resource"); 84 - 85 - /* Byte 0 is the Descriptor Type */ 86 - 87 - buffer += 1; 88 - 89 - /* Get the Descriptor Length field (Bytes 1-2) */ 90 - 91 - ACPI_MOVE_16_TO_16(&temp16, buffer); 92 - buffer += 2; 93 - 94 - /* Validate the descriptor length */ 95 - 96 - if (temp16 != 12) { 97 - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 98 - } 99 - 100 - /* The number of bytes consumed is fixed (12 + 3) */ 101 - 102 - *bytes_consumed = 15; 103 - 104 - /* Fill out the structure */ 105 - 106 - output_struct->type = ACPI_RSTYPE_GENERIC_REG; 107 - 108 - /* Get space_id (Byte 3) */ 109 - 110 - temp8 = *buffer; 111 - output_struct->data.generic_reg.space_id = temp8; 112 - buffer += 1; 113 - 114 - /* Get register_bit_width (Byte 4) */ 115 - 116 - temp8 = *buffer; 117 - output_struct->data.generic_reg.bit_width = temp8; 118 - buffer += 1; 119 - 120 - /* Get register_bit_offset (Byte 5) */ 121 - 122 - temp8 = *buffer; 123 - output_struct->data.generic_reg.bit_offset = temp8; 124 - buffer += 1; 125 - 126 - /* Get address_size (Byte 6) */ 127 - 128 - temp8 = *buffer; 129 - output_struct->data.generic_reg.address_size = temp8; 130 - buffer += 1; 131 - 132 - /* Get register_address (Bytes 7-14) */ 133 - 134 - ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer); 135 - 136 - /* Set the Length parameter */ 137 - 138 - output_struct->length = (u32) struct_size; 139 - 140 - /* Return the final size of the structure */ 141 - 142 - *structure_size = struct_size; 143 - return_ACPI_STATUS(AE_OK); 144 - } 145 - 146 - /******************************************************************************* 147 - * 148 - * FUNCTION: acpi_rs_generic_register_stream 149 - * 150 - * PARAMETERS: Resource - Pointer to the resource linked list 151 - * output_buffer - Pointer to the user's return buffer 152 - * bytes_consumed - Pointer to where the number of bytes 153 - * used in the output_buffer is returned 154 - * 155 - * RETURN: Status 156 - * 157 - * DESCRIPTION: Take the linked list resource structure and fills in the 158 - * the appropriate bytes in a byte stream 159 - * 160 - ******************************************************************************/ 161 - 162 - acpi_status 163 - acpi_rs_generic_register_stream(struct acpi_resource *resource, 164 - u8 ** output_buffer, acpi_size * bytes_consumed) 165 - { 166 - u8 *buffer = *output_buffer; 167 - u16 temp16; 168 - 169 - ACPI_FUNCTION_TRACE("rs_generic_register_stream"); 170 - 171 - /* Set the Descriptor Type (Byte 0) */ 172 - 173 - *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER; 174 - buffer += 1; 175 - 176 - /* Set the Descriptor Length (Bytes 1-2) */ 177 - 178 - temp16 = 12; 179 - ACPI_MOVE_16_TO_16(buffer, &temp16); 180 - buffer += 2; 181 - 182 - /* Set space_id (Byte 3) */ 183 - 184 - *buffer = (u8) resource->data.generic_reg.space_id; 185 - buffer += 1; 186 - 187 - /* Set register_bit_width (Byte 4) */ 188 - 189 - *buffer = (u8) resource->data.generic_reg.bit_width; 190 - buffer += 1; 191 - 192 - /* Set register_bit_offset (Byte 5) */ 193 - 194 - *buffer = (u8) resource->data.generic_reg.bit_offset; 195 - buffer += 1; 196 - 197 - /* Set address_size (Byte 6) */ 198 - 199 - *buffer = (u8) resource->data.generic_reg.address_size; 200 - buffer += 1; 201 - 202 - /* Set register_address (Bytes 7-14) */ 203 - 204 - ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address); 205 - buffer += 8; 206 - 207 - /* Return the number of bytes consumed in this operation */ 208 - 209 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 210 - return_ACPI_STATUS(AE_OK); 211 - } 212 - 213 - /******************************************************************************* 214 - * 215 - * FUNCTION: acpi_rs_end_tag_resource 216 - * 217 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 218 - * stream 219 - * bytes_consumed - Pointer to where the number of bytes 220 - * consumed the byte_stream_buffer is 221 - * returned 222 - * output_buffer - Pointer to the return data buffer 223 - * structure_size - Pointer to where the number of bytes 224 - * in the return data struct is returned 225 - * 226 - * RETURN: Status 227 - * 228 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 229 - * structure pointed to by the output_buffer. Return the 230 - * number of bytes consumed from the byte stream. 231 - * 232 - ******************************************************************************/ 233 - 234 - acpi_status 235 - acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 236 - acpi_size * bytes_consumed, 237 - u8 ** output_buffer, acpi_size * structure_size) 238 - { 239 - struct acpi_resource *output_struct = (void *)*output_buffer; 240 - acpi_size struct_size = ACPI_RESOURCE_LENGTH; 241 - 242 - ACPI_FUNCTION_TRACE("rs_end_tag_resource"); 243 - 244 - /* The number of bytes consumed is static */ 245 - 246 - *bytes_consumed = 2; 247 - 248 - /* Fill out the structure */ 249 - 250 - output_struct->type = ACPI_RSTYPE_END_TAG; 251 - 252 - /* Set the Length parameter */ 253 - 254 - output_struct->length = 0; 255 - 256 - /* Return the final size of the structure */ 257 - 258 - *structure_size = struct_size; 259 - return_ACPI_STATUS(AE_OK); 260 - } 261 - 262 - /******************************************************************************* 263 - * 264 - * FUNCTION: acpi_rs_end_tag_stream 265 - * 266 - * PARAMETERS: Resource - Pointer to the resource linked list 267 - * output_buffer - Pointer to the user's return buffer 268 - * bytes_consumed - Pointer to where the number of bytes 269 - * used in the output_buffer is returned 270 - * 271 - * RETURN: Status 272 - * 273 - * DESCRIPTION: Take the linked list resource structure and fills in the 274 - * the appropriate bytes in a byte stream 275 - * 276 - ******************************************************************************/ 277 - 278 - acpi_status 279 - acpi_rs_end_tag_stream(struct acpi_resource *resource, 280 - u8 ** output_buffer, acpi_size * bytes_consumed) 281 - { 282 - u8 *buffer = *output_buffer; 283 - u8 temp8 = 0; 284 - 285 - ACPI_FUNCTION_TRACE("rs_end_tag_stream"); 286 - 287 - /* The Descriptor Type field is static */ 288 - 289 - *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01; 290 - buffer += 1; 69 + ACPI_FUNCTION_TRACE("rs_get_generic_reg"); 291 70 292 71 /* 293 - * Set the Checksum - zero means that the resource data is treated as if 294 - * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) 72 + * Get the following fields from the AML descriptor: 73 + * Address Space ID 74 + * Register Bit Width 75 + * Register Bit Offset 76 + * Access Size 77 + * Register Address 295 78 */ 296 - temp8 = 0; 79 + resource->data.generic_reg.space_id = aml->generic_reg.address_space_id; 80 + resource->data.generic_reg.bit_width = aml->generic_reg.bit_width; 81 + resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset; 82 + resource->data.generic_reg.access_size = aml->generic_reg.access_size; 83 + ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address, 84 + &aml->generic_reg.address); 297 85 298 - *buffer = temp8; 299 - buffer += 1; 86 + /* Complete the resource header */ 300 87 301 - /* Return the number of bytes consumed in this operation */ 302 - 303 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 88 + resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER; 89 + resource->length = 90 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register); 304 91 return_ACPI_STATUS(AE_OK); 305 92 } 306 93 307 94 /******************************************************************************* 308 95 * 309 - * FUNCTION: acpi_rs_vendor_resource 96 + * FUNCTION: acpi_rs_set_generic_reg 310 97 * 311 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 312 - * stream 313 - * bytes_consumed - Pointer to where the number of bytes 314 - * consumed the byte_stream_buffer is 315 - * returned 316 - * output_buffer - Pointer to the return data buffer 317 - * structure_size - Pointer to where the number of bytes 318 - * in the return data struct is returned 98 + * PARAMETERS: Resource - Pointer to the resource descriptor 99 + * Aml - Where the AML descriptor is returned 319 100 * 320 101 * RETURN: Status 321 102 * 322 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 323 - * structure pointed to by the output_buffer. Return the 324 - * number of bytes consumed from the byte stream. 103 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 104 + * external AML resource descriptor. 325 105 * 326 106 ******************************************************************************/ 327 107 328 108 acpi_status 329 - acpi_rs_vendor_resource(u8 * byte_stream_buffer, 330 - acpi_size * bytes_consumed, 331 - u8 ** output_buffer, acpi_size * structure_size) 109 + acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml) 332 110 { 333 - u8 *buffer = byte_stream_buffer; 334 - struct acpi_resource *output_struct = (void *)*output_buffer; 335 - u16 temp16 = 0; 336 - u8 temp8 = 0; 337 - u8 index; 338 - acpi_size struct_size = 339 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor); 111 + ACPI_FUNCTION_TRACE("rs_set_generic_reg"); 340 112 341 - ACPI_FUNCTION_TRACE("rs_vendor_resource"); 113 + /* 114 + * Set the following fields in the AML descriptor: 115 + * Address Space ID 116 + * Register Bit Width 117 + * Register Bit Offset 118 + * Access Size 119 + * Register Address 120 + */ 121 + aml->generic_reg.address_space_id = 122 + (u8) resource->data.generic_reg.space_id; 123 + aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width; 124 + aml->generic_reg.bit_offset = 125 + (u8) resource->data.generic_reg.bit_offset; 126 + aml->generic_reg.access_size = 127 + (u8) resource->data.generic_reg.access_size; 128 + ACPI_MOVE_64_TO_64(&aml->generic_reg.address, 129 + &resource->data.generic_reg.address); 342 130 343 - /* Dereference the Descriptor to find if this is a large or small item. */ 131 + /* Complete the AML descriptor header */ 344 132 345 - temp8 = *buffer; 133 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER, 134 + sizeof(struct 135 + aml_resource_generic_register), aml); 136 + return_ACPI_STATUS(AE_OK); 137 + } 346 138 347 - if (temp8 & ACPI_RDESC_TYPE_LARGE) { 348 - /* Large Item, point to the length field */ 139 + /******************************************************************************* 140 + * 141 + * FUNCTION: acpi_rs_get_vendor 142 + * 143 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 144 + * aml_resource_length - Length of the resource from the AML header 145 + * Resource - Where the internal resource is returned 146 + * 147 + * RETURN: Status 148 + * 149 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 150 + * internal resource descriptor, simplifying bitflags and handling 151 + * alignment and endian issues if necessary. 152 + * 153 + ******************************************************************************/ 349 154 350 - buffer += 1; 155 + acpi_status 156 + acpi_rs_get_vendor(union aml_resource *aml, 157 + u16 aml_resource_length, struct acpi_resource *resource) 158 + { 159 + u8 *aml_byte_data; 351 160 352 - /* Dereference */ 161 + ACPI_FUNCTION_TRACE("rs_get_vendor"); 353 162 354 - ACPI_MOVE_16_TO_16(&temp16, buffer); 163 + /* Determine if this is a large or small vendor specific item */ 355 164 356 - /* Calculate bytes consumed */ 165 + if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 166 + /* Large item, Point to the first vendor byte */ 357 167 358 - *bytes_consumed = (acpi_size) temp16 + 3; 359 - 360 - /* Point to the first vendor byte */ 361 - 362 - buffer += 2; 168 + aml_byte_data = 169 + ((u8 *) aml) + sizeof(struct aml_resource_large_header); 363 170 } else { 364 - /* Small Item, dereference the size */ 171 + /* Small item, Point to the first vendor byte */ 365 172 366 - temp16 = (u8) (*buffer & 0x07); 367 - 368 - /* Calculate bytes consumed */ 369 - 370 - *bytes_consumed = (acpi_size) temp16 + 1; 371 - 372 - /* Point to the first vendor byte */ 373 - 374 - buffer += 1; 173 + aml_byte_data = 174 + ((u8 *) aml) + sizeof(struct aml_resource_small_header); 375 175 } 376 176 377 - output_struct->type = ACPI_RSTYPE_VENDOR; 378 - output_struct->data.vendor_specific.length = temp16; 177 + /* Copy the vendor-specific bytes */ 379 178 380 - for (index = 0; index < temp16; index++) { 381 - output_struct->data.vendor_specific.reserved[index] = *buffer; 382 - buffer += 1; 383 - } 179 + ACPI_MEMCPY(resource->data.vendor.byte_data, 180 + aml_byte_data, aml_resource_length); 181 + resource->data.vendor.byte_length = aml_resource_length; 384 182 385 183 /* 386 184 * In order for the struct_size to fall on a 32-bit boundary, 387 185 * calculate the length of the vendor string and expand the 388 186 * struct_size to the next 32-bit boundary. 389 187 */ 390 - struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); 391 - 392 - /* Set the Length parameter */ 393 - 394 - output_struct->length = (u32) struct_size; 395 - 396 - /* Return the final size of the structure */ 397 - 398 - *structure_size = struct_size; 188 + resource->type = ACPI_RESOURCE_TYPE_VENDOR; 189 + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + 190 + ACPI_ROUND_UP_to_32_bITS(aml_resource_length); 399 191 return_ACPI_STATUS(AE_OK); 400 192 } 401 193 402 194 /******************************************************************************* 403 195 * 404 - * FUNCTION: acpi_rs_vendor_stream 196 + * FUNCTION: acpi_rs_set_vendor 405 197 * 406 - * PARAMETERS: Resource - Pointer to the resource linked list 407 - * output_buffer - Pointer to the user's return buffer 408 - * bytes_consumed - Pointer to where the number of bytes 409 - * used in the output_buffer is returned 198 + * PARAMETERS: Resource - Pointer to the resource descriptor 199 + * Aml - Where the AML descriptor is returned 410 200 * 411 201 * RETURN: Status 412 202 * 413 - * DESCRIPTION: Take the linked list resource structure and fills in the 414 - * the appropriate bytes in a byte stream 203 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 204 + * external AML resource descriptor. 415 205 * 416 206 ******************************************************************************/ 417 207 418 208 acpi_status 419 - acpi_rs_vendor_stream(struct acpi_resource *resource, 420 - u8 ** output_buffer, acpi_size * bytes_consumed) 209 + acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) 421 210 { 422 - u8 *buffer = *output_buffer; 423 - u16 temp16 = 0; 424 - u8 temp8 = 0; 425 - u8 index; 211 + u32 resource_length; 212 + u8 *source; 213 + u8 *destination; 426 214 427 - ACPI_FUNCTION_TRACE("rs_vendor_stream"); 215 + ACPI_FUNCTION_TRACE("rs_set_vendor"); 428 216 429 - /* Dereference the length to find if this is a large or small item. */ 217 + resource_length = resource->data.vendor.byte_length; 218 + source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data); 430 219 431 - if (resource->data.vendor_specific.length > 7) { 432 - /* Large Item, Set the descriptor field and length bytes */ 220 + /* Length determines if this is a large or small resource */ 433 221 434 - *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR; 435 - buffer += 1; 222 + if (resource_length > 7) { 223 + /* Large item, get pointer to the data part of the descriptor */ 436 224 437 - temp16 = (u16) resource->data.vendor_specific.length; 225 + destination = 226 + ((u8 *) aml) + sizeof(struct aml_resource_large_header); 438 227 439 - ACPI_MOVE_16_TO_16(buffer, &temp16); 440 - buffer += 2; 228 + /* Complete the AML descriptor header */ 229 + 230 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, 231 + (u32) (resource_length + 232 + sizeof(struct 233 + aml_resource_large_header)), 234 + aml); 441 235 } else { 442 - /* Small Item, Set the descriptor field */ 236 + /* Small item, get pointer to the data part of the descriptor */ 443 237 444 - temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR; 445 - temp8 |= (u8) resource->data.vendor_specific.length; 238 + destination = 239 + ((u8 *) aml) + sizeof(struct aml_resource_small_header); 446 240 447 - *buffer = temp8; 448 - buffer += 1; 241 + /* Complete the AML descriptor header */ 242 + 243 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL, 244 + (u32) (resource_length + 245 + sizeof(struct 246 + aml_resource_small_header)), 247 + aml); 449 248 } 450 249 451 - /* Loop through all of the Vendor Specific fields */ 250 + /* Copy the vendor-specific bytes */ 452 251 453 - for (index = 0; index < resource->data.vendor_specific.length; index++) { 454 - temp8 = resource->data.vendor_specific.reserved[index]; 455 - 456 - *buffer = temp8; 457 - buffer += 1; 458 - } 459 - 460 - /* Return the number of bytes consumed in this operation */ 461 - 462 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 252 + ACPI_MEMCPY(destination, source, resource_length); 463 253 return_ACPI_STATUS(AE_OK); 464 254 } 465 255 466 256 /******************************************************************************* 467 257 * 468 - * FUNCTION: acpi_rs_start_depend_fns_resource 258 + * FUNCTION: acpi_rs_get_start_dpf 469 259 * 470 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 471 - * stream 472 - * bytes_consumed - Pointer to where the number of bytes 473 - * consumed the byte_stream_buffer is 474 - * returned 475 - * output_buffer - Pointer to the return data buffer 476 - * structure_size - Pointer to where the number of bytes 477 - * in the return data struct is returned 260 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 261 + * aml_resource_length - Length of the resource from the AML header 262 + * Resource - Where the internal resource is returned 478 263 * 479 264 * RETURN: Status 480 265 * 481 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 482 - * structure pointed to by the output_buffer. Return the 483 - * number of bytes consumed from the byte stream. 266 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 267 + * internal resource descriptor, simplifying bitflags and handling 268 + * alignment and endian issues if necessary. 484 269 * 485 270 ******************************************************************************/ 486 271 487 272 acpi_status 488 - acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, 489 - acpi_size * bytes_consumed, 490 - u8 ** output_buffer, 491 - acpi_size * structure_size) 273 + acpi_rs_get_start_dpf(union aml_resource *aml, 274 + u16 aml_resource_length, struct acpi_resource *resource) 492 275 { 493 - u8 *buffer = byte_stream_buffer; 494 - struct acpi_resource *output_struct = (void *)*output_buffer; 495 - u8 temp8 = 0; 496 - acpi_size struct_size = 497 - ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); 276 + ACPI_FUNCTION_TRACE("rs_get_start_dpf"); 498 277 499 - ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource"); 278 + /* Get the flags byte if present */ 500 279 501 - /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ 280 + if (aml_resource_length == 1) { 281 + /* Get the Compatibility priority */ 502 282 503 - temp8 = *buffer; 283 + resource->data.start_dpf.compatibility_priority = 284 + (aml->start_dpf.flags & 0x03); 504 285 505 - *bytes_consumed = (temp8 & 0x01) + 1; 506 - 507 - output_struct->type = ACPI_RSTYPE_START_DPF; 508 - 509 - /* Point to Byte 1 if it is used */ 510 - 511 - if (2 == *bytes_consumed) { 512 - buffer += 1; 513 - temp8 = *buffer; 514 - 515 - /* Check Compatibility priority */ 516 - 517 - output_struct->data.start_dpf.compatibility_priority = 518 - temp8 & 0x03; 519 - 520 - if (3 == output_struct->data.start_dpf.compatibility_priority) { 286 + if (resource->data.start_dpf.compatibility_priority >= 3) { 521 287 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); 522 288 } 523 289 524 - /* Check Performance/Robustness preference */ 290 + /* Get the Performance/Robustness preference */ 525 291 526 - output_struct->data.start_dpf.performance_robustness = 527 - (temp8 >> 2) & 0x03; 292 + resource->data.start_dpf.performance_robustness = 293 + ((aml->start_dpf.flags >> 2) & 0x03); 528 294 529 - if (3 == output_struct->data.start_dpf.performance_robustness) { 295 + if (resource->data.start_dpf.performance_robustness >= 3) { 530 296 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); 531 297 } 532 298 } else { 533 - output_struct->data.start_dpf.compatibility_priority = 299 + /* start_dependent_no_pri(), no flags byte, set defaults */ 300 + 301 + resource->data.start_dpf.compatibility_priority = 534 302 ACPI_ACCEPTABLE_CONFIGURATION; 535 303 536 - output_struct->data.start_dpf.performance_robustness = 304 + resource->data.start_dpf.performance_robustness = 537 305 ACPI_ACCEPTABLE_CONFIGURATION; 538 306 } 539 307 540 - /* Set the Length parameter */ 308 + /* Complete the resource header */ 541 309 542 - output_struct->length = (u32) struct_size; 543 - 544 - /* Return the final size of the structure */ 545 - 546 - *structure_size = struct_size; 310 + resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT; 311 + resource->length = 312 + ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent); 547 313 return_ACPI_STATUS(AE_OK); 548 314 } 549 315 550 316 /******************************************************************************* 551 317 * 552 - * FUNCTION: acpi_rs_end_depend_fns_resource 318 + * FUNCTION: acpi_rs_set_start_dpf 553 319 * 554 - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 555 - * stream 556 - * bytes_consumed - Pointer to where the number of bytes 557 - * consumed the byte_stream_buffer is 558 - * returned 559 - * output_buffer - Pointer to the return data buffer 560 - * structure_size - Pointer to where the number of bytes 561 - * in the return data struct is returned 320 + * PARAMETERS: Resource - Pointer to the resource descriptor 321 + * Aml - Where the AML descriptor is returned 562 322 * 563 323 * RETURN: Status 564 324 * 565 - * DESCRIPTION: Take the resource byte stream and fill out the appropriate 566 - * structure pointed to by the output_buffer. Return the 567 - * number of bytes consumed from the byte stream. 325 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 326 + * external AML resource descriptor. 568 327 * 569 328 ******************************************************************************/ 570 329 571 330 acpi_status 572 - acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, 573 - acpi_size * bytes_consumed, 574 - u8 ** output_buffer, acpi_size * structure_size) 331 + acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml) 575 332 { 576 - struct acpi_resource *output_struct = (void *)*output_buffer; 577 - acpi_size struct_size = ACPI_RESOURCE_LENGTH; 578 - 579 - ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource"); 580 - 581 - /* The number of bytes consumed is static */ 582 - 583 - *bytes_consumed = 1; 584 - 585 - /* Fill out the structure */ 586 - 587 - output_struct->type = ACPI_RSTYPE_END_DPF; 588 - 589 - /* Set the Length parameter */ 590 - 591 - output_struct->length = (u32) struct_size; 592 - 593 - /* Return the final size of the structure */ 594 - 595 - *structure_size = struct_size; 596 - return_ACPI_STATUS(AE_OK); 597 - } 598 - 599 - /******************************************************************************* 600 - * 601 - * FUNCTION: acpi_rs_start_depend_fns_stream 602 - * 603 - * PARAMETERS: Resource - Pointer to the resource linked list 604 - * output_buffer - Pointer to the user's return buffer 605 - * bytes_consumed - u32 pointer that is filled with 606 - * the number of bytes of the 607 - * output_buffer used 608 - * 609 - * RETURN: Status 610 - * 611 - * DESCRIPTION: Take the linked list resource structure and fills in the 612 - * the appropriate bytes in a byte stream 613 - * 614 - ******************************************************************************/ 615 - 616 - acpi_status 617 - acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, 618 - u8 ** output_buffer, acpi_size * bytes_consumed) 619 - { 620 - u8 *buffer = *output_buffer; 621 - u8 temp8 = 0; 622 - 623 - ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); 333 + ACPI_FUNCTION_TRACE("rs_set_start_dpf"); 624 334 625 335 /* 626 336 * The descriptor type field is set based upon whether a byte is needed ··· 340 630 resource->data.start_dpf.compatibility_priority && 341 631 ACPI_ACCEPTABLE_CONFIGURATION == 342 632 resource->data.start_dpf.performance_robustness) { 343 - *buffer = ACPI_RDESC_TYPE_START_DEPENDENT; 633 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, 634 + sizeof(struct 635 + aml_resource_start_dependent_noprio), 636 + aml); 344 637 } else { 345 - *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01; 346 - buffer += 1; 638 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, 639 + sizeof(struct 640 + aml_resource_start_dependent), 641 + aml); 347 642 348 - /* Set the Priority Byte Definition */ 643 + /* Set the Flags byte */ 349 644 350 - temp8 = 0; 351 - temp8 = (u8) ((resource->data.start_dpf.performance_robustness & 352 - 0x03) << 2); 353 - temp8 |= (resource->data.start_dpf.compatibility_priority & 354 - 0x03); 355 - *buffer = temp8; 645 + aml->start_dpf.flags = (u8) 646 + (((resource->data.start_dpf. 647 + performance_robustness & 0x03) << 2) | (resource->data. 648 + start_dpf. 649 + compatibility_priority 650 + & 0x03)); 356 651 } 357 - 358 - buffer += 1; 359 - 360 - /* Return the number of bytes consumed in this operation */ 361 - 362 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 363 652 return_ACPI_STATUS(AE_OK); 364 653 } 365 654 366 655 /******************************************************************************* 367 656 * 368 - * FUNCTION: acpi_rs_end_depend_fns_stream 657 + * FUNCTION: acpi_rs_get_end_dpf 369 658 * 370 - * PARAMETERS: Resource - Pointer to the resource linked list 371 - * output_buffer - Pointer to the user's return buffer 372 - * bytes_consumed - Pointer to where the number of bytes 373 - * used in the output_buffer is returned 659 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 660 + * aml_resource_length - Length of the resource from the AML header 661 + * Resource - Where the internal resource is returned 374 662 * 375 663 * RETURN: Status 376 664 * 377 - * DESCRIPTION: Take the linked list resource structure and fills in the 378 - * the appropriate bytes in a byte stream 665 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 666 + * internal resource descriptor, simplifying bitflags and handling 667 + * alignment and endian issues if necessary. 379 668 * 380 669 ******************************************************************************/ 381 670 382 671 acpi_status 383 - acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, 384 - u8 ** output_buffer, acpi_size * bytes_consumed) 672 + acpi_rs_get_end_dpf(union aml_resource *aml, 673 + u16 aml_resource_length, struct acpi_resource *resource) 385 674 { 386 - u8 *buffer = *output_buffer; 675 + ACPI_FUNCTION_TRACE("rs_get_end_dpf"); 387 676 388 - ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); 677 + /* Complete the resource header */ 389 678 390 - /* The Descriptor Type field is static */ 679 + resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT; 680 + resource->length = (u32) ACPI_RESOURCE_LENGTH; 681 + return_ACPI_STATUS(AE_OK); 682 + } 391 683 392 - *buffer = ACPI_RDESC_TYPE_END_DEPENDENT; 393 - buffer += 1; 684 + /******************************************************************************* 685 + * 686 + * FUNCTION: acpi_rs_set_end_dpf 687 + * 688 + * PARAMETERS: Resource - Pointer to the resource descriptor 689 + * Aml - Where the AML descriptor is returned 690 + * 691 + * RETURN: Status 692 + * 693 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 694 + * external AML resource descriptor. 695 + * 696 + ******************************************************************************/ 394 697 395 - /* Return the number of bytes consumed in this operation */ 698 + acpi_status 699 + acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml) 700 + { 701 + ACPI_FUNCTION_TRACE("rs_set_end_dpf"); 396 702 397 - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 703 + /* Complete the AML descriptor header */ 704 + 705 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT, 706 + sizeof(struct aml_resource_end_dependent), 707 + aml); 708 + return_ACPI_STATUS(AE_OK); 709 + } 710 + 711 + /******************************************************************************* 712 + * 713 + * FUNCTION: acpi_rs_get_end_tag 714 + * 715 + * PARAMETERS: Aml - Pointer to the AML resource descriptor 716 + * aml_resource_length - Length of the resource from the AML header 717 + * Resource - Where the internal resource is returned 718 + * 719 + * RETURN: Status 720 + * 721 + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding 722 + * internal resource descriptor, simplifying bitflags and handling 723 + * alignment and endian issues if necessary. 724 + * 725 + ******************************************************************************/ 726 + 727 + acpi_status 728 + acpi_rs_get_end_tag(union aml_resource *aml, 729 + u16 aml_resource_length, struct acpi_resource *resource) 730 + { 731 + ACPI_FUNCTION_TRACE("rs_get_end_tag"); 732 + 733 + /* Complete the resource header */ 734 + 735 + resource->type = ACPI_RESOURCE_TYPE_END_TAG; 736 + resource->length = ACPI_RESOURCE_LENGTH; 737 + return_ACPI_STATUS(AE_OK); 738 + } 739 + 740 + /******************************************************************************* 741 + * 742 + * FUNCTION: acpi_rs_set_end_tag 743 + * 744 + * PARAMETERS: Resource - Pointer to the resource descriptor 745 + * Aml - Where the AML descriptor is returned 746 + * 747 + * RETURN: Status 748 + * 749 + * DESCRIPTION: Convert an internal resource descriptor to the corresponding 750 + * external AML resource descriptor. 751 + * 752 + ******************************************************************************/ 753 + 754 + acpi_status 755 + acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml) 756 + { 757 + ACPI_FUNCTION_TRACE("rs_set_end_tag"); 758 + 759 + /* 760 + * Set the Checksum - zero means that the resource data is treated as if 761 + * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) 762 + */ 763 + aml->end_tag.checksum = 0; 764 + 765 + /* Complete the AML descriptor header */ 766 + 767 + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG, 768 + sizeof(struct aml_resource_end_tag), aml); 398 769 return_ACPI_STATUS(AE_OK); 399 770 }
+435 -2
drivers/acpi/resources/rsutils.c
··· 50 50 51 51 /******************************************************************************* 52 52 * 53 + * FUNCTION: acpi_rs_move_data 54 + * 55 + * PARAMETERS: Destination - Pointer to the destination descriptor 56 + * Source - Pointer to the source descriptor 57 + * item_count - How many items to move 58 + * move_type - Byte width 59 + * 60 + * RETURN: None 61 + * 62 + * DESCRIPTION: Move multiple data items from one descriptor to another. Handles 63 + * alignment issues and endian issues if necessary, as configured 64 + * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) 65 + * 66 + ******************************************************************************/ 67 + void 68 + acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) 69 + { 70 + acpi_native_uint i; 71 + 72 + /* One move per item */ 73 + 74 + for (i = 0; i < item_count; i++) { 75 + switch (move_type) { 76 + case ACPI_MOVE_TYPE_16_TO_32: 77 + ACPI_MOVE_16_TO_32(&((u32 *) destination)[i], 78 + &((u16 *) source)[i]); 79 + break; 80 + 81 + case ACPI_MOVE_TYPE_32_TO_16: 82 + ACPI_MOVE_32_TO_16(&((u16 *) destination)[i], 83 + &((u32 *) source)[i]); 84 + break; 85 + 86 + case ACPI_MOVE_TYPE_32_TO_32: 87 + ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], 88 + &((u32 *) source)[i]); 89 + break; 90 + 91 + case ACPI_MOVE_TYPE_64_TO_64: 92 + ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], 93 + &((u64 *) source)[i]); 94 + break; 95 + 96 + default: 97 + return; 98 + } 99 + } 100 + } 101 + 102 + /******************************************************************************* 103 + * 104 + * FUNCTION: acpi_rs_get_resource_info 105 + * 106 + * PARAMETERS: resource_type - Byte 0 of a resource descriptor 107 + * 108 + * RETURN: Pointer to the resource conversion handler 109 + * 110 + * DESCRIPTION: Extract the Resource Type/Name from the first byte of 111 + * a resource descriptor. 112 + * 113 + ******************************************************************************/ 114 + 115 + struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) 116 + { 117 + struct acpi_resource_info *size_info; 118 + 119 + ACPI_FUNCTION_ENTRY(); 120 + 121 + /* Determine if this is a small or large resource */ 122 + 123 + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 124 + /* Large Resource Type -- bits 6:0 contain the name */ 125 + 126 + if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 127 + return (NULL); 128 + } 129 + 130 + size_info = &acpi_gbl_lg_resource_info[(resource_type & 131 + ACPI_RESOURCE_NAME_LARGE_MASK)]; 132 + } else { 133 + /* Small Resource Type -- bits 6:3 contain the name */ 134 + 135 + size_info = &acpi_gbl_sm_resource_info[((resource_type & 136 + ACPI_RESOURCE_NAME_SMALL_MASK) 137 + >> 3)]; 138 + } 139 + 140 + /* Zero entry indicates an invalid resource type */ 141 + 142 + if (!size_info->minimum_internal_struct_length) { 143 + return (NULL); 144 + } 145 + 146 + return (size_info); 147 + } 148 + 149 + /******************************************************************************* 150 + * 151 + * FUNCTION: acpi_rs_get_resource_length 152 + * 153 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 154 + * 155 + * RETURN: Byte Length 156 + * 157 + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By 158 + * definition, this does not include the size of the descriptor 159 + * header or the length field itself. 160 + * 161 + ******************************************************************************/ 162 + 163 + u16 acpi_rs_get_resource_length(union aml_resource * aml) 164 + { 165 + u16 resource_length; 166 + 167 + ACPI_FUNCTION_ENTRY(); 168 + 169 + /* Determine if this is a small or large resource */ 170 + 171 + if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 172 + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 173 + 174 + ACPI_MOVE_16_TO_16(&resource_length, 175 + &aml->large_header.resource_length); 176 + 177 + } else { 178 + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 179 + 180 + resource_length = (u16) (aml->small_header.descriptor_type & 181 + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 182 + } 183 + 184 + return (resource_length); 185 + } 186 + 187 + /******************************************************************************* 188 + * 189 + * FUNCTION: acpi_rs_get_descriptor_length 190 + * 191 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 192 + * 193 + * RETURN: Byte length 194 + * 195 + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the 196 + * length of the descriptor header and the length field itself. 197 + * Used to walk descriptor lists. 198 + * 199 + ******************************************************************************/ 200 + 201 + u32 acpi_rs_get_descriptor_length(union aml_resource * aml) 202 + { 203 + u32 descriptor_length; 204 + 205 + ACPI_FUNCTION_ENTRY(); 206 + 207 + /* Determine if this is a small or large resource */ 208 + 209 + if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 210 + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 211 + 212 + ACPI_MOVE_16_TO_32(&descriptor_length, 213 + &aml->large_header.resource_length); 214 + descriptor_length += sizeof(struct aml_resource_large_header); 215 + 216 + } else { 217 + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 218 + 219 + descriptor_length = (u32) (aml->small_header.descriptor_type & 220 + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 221 + descriptor_length += sizeof(struct aml_resource_small_header); 222 + } 223 + 224 + return (descriptor_length); 225 + } 226 + 227 + /******************************************************************************* 228 + * 229 + * FUNCTION: acpi_rs_set_resource_header 230 + * 231 + * PARAMETERS: descriptor_type - Byte to be inserted as the type 232 + * total_length - Length of the AML descriptor, including 233 + * the header and length fields. 234 + * Aml - Pointer to the raw AML descriptor 235 + * 236 + * RETURN: None 237 + * 238 + * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML 239 + * resource descriptor, both Large and Small descriptors are 240 + * supported automatically 241 + * 242 + ******************************************************************************/ 243 + 244 + void 245 + acpi_rs_set_resource_header(u8 descriptor_type, 246 + acpi_size total_length, union aml_resource *aml) 247 + { 248 + u16 resource_length; 249 + 250 + ACPI_FUNCTION_ENTRY(); 251 + 252 + /* Set the descriptor type */ 253 + 254 + aml->small_header.descriptor_type = descriptor_type; 255 + 256 + /* Determine if this is a small or large resource */ 257 + 258 + if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 259 + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 260 + 261 + resource_length = 262 + (u16) (total_length - 263 + sizeof(struct aml_resource_large_header)); 264 + 265 + /* Insert length into the Large descriptor length field */ 266 + 267 + ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, 268 + &resource_length); 269 + } else { 270 + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 271 + 272 + resource_length = 273 + (u16) (total_length - 274 + sizeof(struct aml_resource_small_header)); 275 + 276 + /* Insert length into the descriptor type byte */ 277 + 278 + aml->small_header.descriptor_type |= (u8) resource_length; 279 + } 280 + } 281 + 282 + /******************************************************************************* 283 + * 284 + * FUNCTION: acpi_rs_get_resource_type 285 + * 286 + * PARAMETERS: resource_type - Byte 0 of a resource descriptor 287 + * 288 + * RETURN: The Resource Type with no extraneous bits (except the 289 + * Large/Small descriptor bit -- this is left alone) 290 + * 291 + * DESCRIPTION: Extract the Resource Type/Name from the first byte of 292 + * a resource descriptor. 293 + * 294 + ******************************************************************************/ 295 + 296 + u8 acpi_rs_get_resource_type(u8 resource_type) 297 + { 298 + ACPI_FUNCTION_ENTRY(); 299 + 300 + /* Determine if this is a small or large resource */ 301 + 302 + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 303 + /* Large Resource Type -- bits 6:0 contain the name */ 304 + 305 + return (resource_type); 306 + } else { 307 + /* Small Resource Type -- bits 6:3 contain the name */ 308 + 309 + return ((u8) (resource_type & ACPI_RESOURCE_NAME_SMALL_MASK)); 310 + } 311 + } 312 + 313 + /******************************************************************************* 314 + * 315 + * FUNCTION: acpi_rs_strcpy 316 + * 317 + * PARAMETERS: Destination - Pointer to the destination string 318 + * Source - Pointer to the source string 319 + * 320 + * RETURN: String length, including NULL terminator 321 + * 322 + * DESCRIPTION: Local string copy that returns the string length, saving a 323 + * strcpy followed by a strlen. 324 + * 325 + ******************************************************************************/ 326 + 327 + static u16 acpi_rs_strcpy(char *destination, char *source) 328 + { 329 + u16 i; 330 + 331 + ACPI_FUNCTION_ENTRY(); 332 + 333 + for (i = 0; source[i]; i++) { 334 + destination[i] = source[i]; 335 + } 336 + 337 + destination[i] = 0; 338 + 339 + /* Return string length including the NULL terminator */ 340 + 341 + return ((u16) (i + 1)); 342 + } 343 + 344 + /******************************************************************************* 345 + * 346 + * FUNCTION: acpi_rs_get_resource_source 347 + * 348 + * PARAMETERS: resource_length - Length field of the descriptor 349 + * minimum_length - Minimum length of the descriptor (minus 350 + * any optional fields) 351 + * resource_source - Where the resource_source is returned 352 + * Aml - Pointer to the raw AML descriptor 353 + * string_ptr - (optional) where to store the actual 354 + * resource_source string 355 + * 356 + * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit 357 + * 358 + * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor 359 + * to an internal resource descriptor 360 + * 361 + ******************************************************************************/ 362 + 363 + u16 364 + acpi_rs_get_resource_source(u16 resource_length, 365 + acpi_size minimum_length, 366 + struct acpi_resource_source * resource_source, 367 + union aml_resource * aml, char *string_ptr) 368 + { 369 + acpi_size total_length; 370 + u8 *aml_resource_source; 371 + 372 + ACPI_FUNCTION_ENTRY(); 373 + 374 + total_length = 375 + resource_length + sizeof(struct aml_resource_large_header); 376 + aml_resource_source = ((u8 *) aml) + minimum_length; 377 + 378 + /* 379 + * resource_source is present if the length of the descriptor is longer than 380 + * the minimum length. 381 + * 382 + * Note: Some resource descriptors will have an additional null, so 383 + * we add 1 to the minimum length. 384 + */ 385 + if (total_length > (minimum_length + 1)) { 386 + /* Get the resource_source_index */ 387 + 388 + resource_source->index = aml_resource_source[0]; 389 + 390 + resource_source->string_ptr = string_ptr; 391 + if (!string_ptr) { 392 + /* 393 + * String destination pointer is not specified; Set the String 394 + * pointer to the end of the current resource_source structure. 395 + */ 396 + resource_source->string_ptr = (char *) 397 + ((u8 *) resource_source) + 398 + sizeof(struct acpi_resource_source); 399 + } 400 + 401 + /* Copy the resource_source string to the destination */ 402 + 403 + resource_source->string_length = 404 + acpi_rs_strcpy(resource_source->string_ptr, 405 + (char *)&aml_resource_source[1]); 406 + 407 + /* 408 + * In order for the struct_size to fall on a 32-bit boundary, 409 + * calculate the length of the string and expand the 410 + * struct_size to the next 32-bit boundary. 411 + */ 412 + return ((u16) 413 + ACPI_ROUND_UP_to_32_bITS(resource_source-> 414 + string_length)); 415 + } else { 416 + /* resource_source is not present */ 417 + 418 + resource_source->index = 0; 419 + resource_source->string_length = 0; 420 + resource_source->string_ptr = NULL; 421 + return (0); 422 + } 423 + } 424 + 425 + /******************************************************************************* 426 + * 427 + * FUNCTION: acpi_rs_set_resource_source 428 + * 429 + * PARAMETERS: Aml - Pointer to the raw AML descriptor 430 + * minimum_length - Minimum length of the descriptor (minus 431 + * any optional fields) 432 + * resource_source - Internal resource_source 433 + 434 + * 435 + * RETURN: Total length of the AML descriptor 436 + * 437 + * DESCRIPTION: Convert an optoinal resource_source from internal format to a 438 + * raw AML resource descriptor 439 + * 440 + ******************************************************************************/ 441 + 442 + acpi_size 443 + acpi_rs_set_resource_source(union aml_resource * aml, 444 + acpi_size minimum_length, 445 + struct acpi_resource_source * resource_source) 446 + { 447 + u8 *aml_resource_source; 448 + acpi_size descriptor_length; 449 + 450 + ACPI_FUNCTION_ENTRY(); 451 + 452 + descriptor_length = minimum_length; 453 + 454 + /* Non-zero string length indicates presence of a resource_source */ 455 + 456 + if (resource_source->string_length) { 457 + /* Point to the end of the AML descriptor */ 458 + 459 + aml_resource_source = ((u8 *) aml) + minimum_length; 460 + 461 + /* Copy the resource_source_index */ 462 + 463 + aml_resource_source[0] = (u8) resource_source->index; 464 + 465 + /* Copy the resource_source string */ 466 + 467 + ACPI_STRCPY((char *)&aml_resource_source[1], 468 + resource_source->string_ptr); 469 + 470 + /* 471 + * Add the length of the string (+ 1 for null terminator) to the 472 + * final descriptor length 473 + */ 474 + descriptor_length += 475 + ((acpi_size) resource_source->string_length + 1); 476 + } 477 + 478 + /* Return the new total length of the AML descriptor */ 479 + 480 + return (descriptor_length); 481 + } 482 + 483 + /******************************************************************************* 484 + * 53 485 * FUNCTION: acpi_rs_get_prt_method_data 54 486 * 55 487 * PARAMETERS: Handle - a handle to the containing object ··· 497 65 * and the contents of the callers buffer is undefined. 498 66 * 499 67 ******************************************************************************/ 68 + 500 69 acpi_status 501 - acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) 70 + acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) 502 71 { 503 72 union acpi_operand_object *obj_desc; 504 73 acpi_status status; ··· 717 284 * Convert the linked list into a byte stream 718 285 */ 719 286 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 720 - status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); 287 + status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); 721 288 if (ACPI_FAILURE(status)) { 722 289 return_ACPI_STATUS(status); 723 290 }
+7 -7
drivers/acpi/resources/rsxface.c
··· 59 59 ACPI_COPY_FIELD(out, in, max_address_fixed); \ 60 60 ACPI_COPY_FIELD(out, in, attribute); \ 61 61 ACPI_COPY_FIELD(out, in, granularity); \ 62 - ACPI_COPY_FIELD(out, in, min_address_range); \ 63 - ACPI_COPY_FIELD(out, in, max_address_range); \ 64 - ACPI_COPY_FIELD(out, in, address_translation_offset); \ 62 + ACPI_COPY_FIELD(out, in, minimum); \ 63 + ACPI_COPY_FIELD(out, in, maximum); \ 64 + ACPI_COPY_FIELD(out, in, translation_offset); \ 65 65 ACPI_COPY_FIELD(out, in, address_length); \ 66 66 ACPI_COPY_FIELD(out, in, resource_source); 67 67 /******************************************************************************* ··· 269 269 /* Walk the resource list */ 270 270 271 271 for (;;) { 272 - if (!resource || resource->type == ACPI_RSTYPE_END_TAG) { 272 + if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) { 273 273 break; 274 274 } 275 275 ··· 382 382 struct acpi_resource_address32 *address32; 383 383 384 384 switch (resource->type) { 385 - case ACPI_RSTYPE_ADDRESS16: 385 + case ACPI_RESOURCE_TYPE_ADDRESS16: 386 386 387 387 address16 = (struct acpi_resource_address16 *)&resource->data; 388 388 ACPI_COPY_ADDRESS(out, address16); 389 389 break; 390 390 391 - case ACPI_RSTYPE_ADDRESS32: 391 + case ACPI_RESOURCE_TYPE_ADDRESS32: 392 392 393 393 address32 = (struct acpi_resource_address32 *)&resource->data; 394 394 ACPI_COPY_ADDRESS(out, address32); 395 395 break; 396 396 397 - case ACPI_RSTYPE_ADDRESS64: 397 + case ACPI_RESOURCE_TYPE_ADDRESS64: 398 398 399 399 /* Simple copy for 64 bit source */ 400 400
+1 -1
drivers/acpi/tables/tbrsdt.c
··· 251 251 } 252 252 253 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 254 - "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 254 + "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n", 255 255 acpi_gbl_RSDP, 256 256 ACPI_FORMAT_UINT64(address.pointer.value))); 257 257
+1 -1
drivers/acpi/tables/tbxfroot.c
··· 251 251 252 252 acpi_tb_get_rsdt_address(&address); 253 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 254 - "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 + "RSDP located at %p, RSDT physical=%8.8X%8.8X\n", 255 255 acpi_gbl_RSDP, 256 256 ACPI_FORMAT_UINT64(address.pointer.value))); 257 257
+3 -3
drivers/acpi/utilities/utalloc.c
··· 304 304 305 305 if (!size) { 306 306 _ACPI_REPORT_ERROR(module, line, component, 307 - ("ut_allocate: Attempt to allocate zero bytes\n")); 307 + ("ut_allocate: Attempt to allocate zero bytes, allocating 1 byte\n")); 308 308 size = 1; 309 309 } 310 310 ··· 347 347 348 348 if (!size) { 349 349 _ACPI_REPORT_ERROR(module, line, component, 350 - ("ut_callocate: Attempt to allocate zero bytes\n")); 351 - return_PTR(NULL); 350 + ("ut_callocate: Attempt to allocate zero bytes, allocating 1 byte\n")); 351 + size = 1; 352 352 } 353 353 354 354 allocation = acpi_os_allocate(size);
+3
drivers/acpi/utilities/utglobal.c
··· 825 825 acpi_gbl_ps_find_count = 0; 826 826 acpi_gbl_acpi_hardware_present = TRUE; 827 827 acpi_gbl_owner_id_mask = 0; 828 + acpi_gbl_trace_method_name = 0; 829 + acpi_gbl_trace_dbg_level = 0; 830 + acpi_gbl_trace_dbg_layer = 0; 828 831 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 829 832 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 830 833
+3 -3
drivers/acpi/utilities/utmisc.c
··· 811 811 812 812 while (buffer < end_buffer) { 813 813 buffer_byte = *buffer; 814 - if (buffer_byte & ACPI_RDESC_TYPE_LARGE) { 814 + if (buffer_byte & ACPI_RESOURCE_NAME_LARGE) { 815 815 /* Large Descriptor - Length is next 2 bytes */ 816 816 817 817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); 818 818 } else { 819 819 /* Small Descriptor. End Tag will be found here */ 820 820 821 - if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == 822 - ACPI_RDESC_TYPE_END_TAG) { 821 + if ((buffer_byte & ACPI_RESOURCE_NAME_SMALL_MASK) == 822 + ACPI_RESOURCE_NAME_END_TAG) { 823 823 /* Found the end tag descriptor, all done. */ 824 824 825 825 return (buffer);
+13 -13
drivers/char/hpet.c
··· 927 927 if (ACPI_SUCCESS(status)) { 928 928 unsigned long size; 929 929 930 - size = addr.max_address_range - addr.min_address_range + 1; 931 - hdp->hd_phys_address = addr.min_address_range; 932 - hdp->hd_address = ioremap(addr.min_address_range, size); 930 + size = addr.maximum - addr.minimum + 1; 931 + hdp->hd_phys_address = addr.minimum; 932 + hdp->hd_address = ioremap(addr.minimum, size); 933 933 934 934 if (hpet_is_known(hdp)) { 935 935 printk(KERN_DEBUG "%s: 0x%lx is busy\n", ··· 937 937 iounmap(hdp->hd_address); 938 938 return -EBUSY; 939 939 } 940 - } else if (res->type == ACPI_RSTYPE_FIXED_MEM32) { 941 - struct acpi_resource_fixed_mem32 *fixmem32; 940 + } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) { 941 + struct acpi_resource_fixed_memory32 *fixmem32; 942 942 943 943 fixmem32 = &res->data.fixed_memory32; 944 944 if (!fixmem32) 945 945 return -EINVAL; 946 946 947 - hdp->hd_phys_address = fixmem32->range_base_address; 948 - hdp->hd_address = ioremap(fixmem32->range_base_address, 947 + hdp->hd_phys_address = fixmem32->address; 948 + hdp->hd_address = ioremap(fixmem32->address, 949 949 HPET_RANGE_SIZE); 950 950 951 951 if (hpet_is_known(hdp)) { ··· 954 954 iounmap(hdp->hd_address); 955 955 return -EBUSY; 956 956 } 957 - } else if (res->type == ACPI_RSTYPE_EXT_IRQ) { 958 - struct acpi_resource_ext_irq *irqp; 957 + } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) { 958 + struct acpi_resource_extended_irq *irqp; 959 959 int i; 960 960 961 961 irqp = &res->data.extended_irq; 962 962 963 - if (irqp->number_of_interrupts > 0) { 964 - hdp->hd_nirqs = irqp->number_of_interrupts; 963 + if (irqp->interrupt_count > 0) { 964 + hdp->hd_nirqs = irqp->interrupt_count; 965 965 966 966 for (i = 0; i < hdp->hd_nirqs; i++) { 967 967 int rc = 968 968 acpi_register_gsi(irqp->interrupts[i], 969 - irqp->edge_level, 970 - irqp->active_high_low); 969 + irqp->triggering, 970 + irqp->polarity); 971 971 if (rc < 0) 972 972 return AE_ERROR; 973 973 hdp->hd_irq[i] = rc;
+182 -182
drivers/pnp/pnpacpi/rsparser.c
··· 3 3 * 4 4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr> 5 5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com> 6 - * 6 + * 7 7 * This program is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU General Public License as published by the 9 9 * Free Software Foundation; either version 2, or (at your option) any ··· 32 32 /* 33 33 * Allocated Resources 34 34 */ 35 - static int irq_flags(int edge_level, int active_high_low) 35 + static int irq_flags(int triggering, int polarity) 36 36 { 37 37 int flag; 38 - if (edge_level == ACPI_LEVEL_SENSITIVE) { 39 - if(active_high_low == ACPI_ACTIVE_LOW) 38 + if (triggering == ACPI_LEVEL_SENSITIVE) { 39 + if(polarity == ACPI_ACTIVE_LOW) 40 40 flag = IORESOURCE_IRQ_LOWLEVEL; 41 41 else 42 42 flag = IORESOURCE_IRQ_HIGHLEVEL; 43 43 } 44 44 else { 45 - if(active_high_low == ACPI_ACTIVE_LOW) 45 + if(polarity == ACPI_ACTIVE_LOW) 46 46 flag = IORESOURCE_IRQ_LOWEDGE; 47 47 else 48 48 flag = IORESOURCE_IRQ_HIGHEDGE; ··· 50 50 return flag; 51 51 } 52 52 53 - static void decode_irq_flags(int flag, int *edge_level, int *active_high_low) 53 + static void decode_irq_flags(int flag, int *triggering, int *polarity) 54 54 { 55 55 switch (flag) { 56 56 case IORESOURCE_IRQ_LOWLEVEL: 57 - *edge_level = ACPI_LEVEL_SENSITIVE; 58 - *active_high_low = ACPI_ACTIVE_LOW; 57 + *triggering = ACPI_LEVEL_SENSITIVE; 58 + *polarity = ACPI_ACTIVE_LOW; 59 59 break; 60 60 case IORESOURCE_IRQ_HIGHLEVEL: 61 - *edge_level = ACPI_LEVEL_SENSITIVE; 62 - *active_high_low = ACPI_ACTIVE_HIGH; 61 + *triggering = ACPI_LEVEL_SENSITIVE; 62 + *polarity = ACPI_ACTIVE_HIGH; 63 63 break; 64 64 case IORESOURCE_IRQ_LOWEDGE: 65 - *edge_level = ACPI_EDGE_SENSITIVE; 66 - *active_high_low = ACPI_ACTIVE_LOW; 65 + *triggering = ACPI_EDGE_SENSITIVE; 66 + *polarity = ACPI_ACTIVE_LOW; 67 67 break; 68 68 case IORESOURCE_IRQ_HIGHEDGE: 69 - *edge_level = ACPI_EDGE_SENSITIVE; 70 - *active_high_low = ACPI_ACTIVE_HIGH; 69 + *triggering = ACPI_EDGE_SENSITIVE; 70 + *polarity = ACPI_ACTIVE_HIGH; 71 71 break; 72 72 } 73 73 } 74 74 75 75 static void 76 76 pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, 77 - int edge_level, int active_high_low) 77 + int triggering, int polarity) 78 78 { 79 79 int i = 0; 80 80 int irq; ··· 89 89 return; 90 90 91 91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 92 - irq = acpi_register_gsi(gsi, edge_level, active_high_low); 92 + irq = acpi_register_gsi(gsi, triggering, polarity); 93 93 if (irq < 0) { 94 94 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 95 95 return; ··· 164 164 int i; 165 165 166 166 switch (res->type) { 167 - case ACPI_RSTYPE_IRQ: 167 + case ACPI_RESOURCE_TYPE_IRQ: 168 168 /* 169 169 * Per spec, only one interrupt per descriptor is allowed in 170 170 * _CRS, but some firmware violates this, so parse them all. 171 171 */ 172 - for (i = 0; i < res->data.irq.number_of_interrupts; i++) { 172 + for (i = 0; i < res->data.irq.interrupt_count; i++) { 173 173 pnpacpi_parse_allocated_irqresource(res_table, 174 174 res->data.irq.interrupts[i], 175 - res->data.irq.edge_level, 176 - res->data.irq.active_high_low); 175 + res->data.irq.triggering, 176 + res->data.irq.polarity); 177 177 } 178 178 break; 179 179 180 - case ACPI_RSTYPE_EXT_IRQ: 181 - for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) { 180 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 181 + for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { 182 182 pnpacpi_parse_allocated_irqresource(res_table, 183 183 res->data.extended_irq.interrupts[i], 184 - res->data.extended_irq.edge_level, 185 - res->data.extended_irq.active_high_low); 184 + res->data.extended_irq.triggering, 185 + res->data.extended_irq.polarity); 186 186 } 187 187 break; 188 - case ACPI_RSTYPE_DMA: 189 - if (res->data.dma.number_of_channels > 0) 190 - pnpacpi_parse_allocated_dmaresource(res_table, 188 + case ACPI_RESOURCE_TYPE_DMA: 189 + if (res->data.dma.channel_count > 0) 190 + pnpacpi_parse_allocated_dmaresource(res_table, 191 191 res->data.dma.channels[0]); 192 192 break; 193 - case ACPI_RSTYPE_IO: 194 - pnpacpi_parse_allocated_ioresource(res_table, 195 - res->data.io.min_base_address, 196 - res->data.io.range_length); 193 + case ACPI_RESOURCE_TYPE_IO: 194 + pnpacpi_parse_allocated_ioresource(res_table, 195 + res->data.io.minimum, 196 + res->data.io.address_length); 197 197 break; 198 - case ACPI_RSTYPE_FIXED_IO: 199 - pnpacpi_parse_allocated_ioresource(res_table, 200 - res->data.fixed_io.base_address, 201 - res->data.fixed_io.range_length); 198 + case ACPI_RESOURCE_TYPE_FIXED_IO: 199 + pnpacpi_parse_allocated_ioresource(res_table, 200 + res->data.fixed_io.address, 201 + res->data.fixed_io.address_length); 202 202 break; 203 - case ACPI_RSTYPE_MEM24: 204 - pnpacpi_parse_allocated_memresource(res_table, 205 - res->data.memory24.min_base_address, 206 - res->data.memory24.range_length); 203 + case ACPI_RESOURCE_TYPE_MEMORY24: 204 + pnpacpi_parse_allocated_memresource(res_table, 205 + res->data.memory24.minimum, 206 + res->data.memory24.address_length); 207 207 break; 208 - case ACPI_RSTYPE_MEM32: 209 - pnpacpi_parse_allocated_memresource(res_table, 210 - res->data.memory32.min_base_address, 211 - res->data.memory32.range_length); 208 + case ACPI_RESOURCE_TYPE_MEMORY32: 209 + pnpacpi_parse_allocated_memresource(res_table, 210 + res->data.memory32.minimum, 211 + res->data.memory32.address_length); 212 212 break; 213 - case ACPI_RSTYPE_FIXED_MEM32: 214 - pnpacpi_parse_allocated_memresource(res_table, 215 - res->data.fixed_memory32.range_base_address, 216 - res->data.fixed_memory32.range_length); 213 + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 214 + pnpacpi_parse_allocated_memresource(res_table, 215 + res->data.fixed_memory32.address, 216 + res->data.fixed_memory32.address_length); 217 217 break; 218 - case ACPI_RSTYPE_ADDRESS16: 219 - pnpacpi_parse_allocated_memresource(res_table, 220 - res->data.address16.min_address_range, 218 + case ACPI_RESOURCE_TYPE_ADDRESS16: 219 + pnpacpi_parse_allocated_memresource(res_table, 220 + res->data.address16.minimum, 221 221 res->data.address16.address_length); 222 222 break; 223 - case ACPI_RSTYPE_ADDRESS32: 224 - pnpacpi_parse_allocated_memresource(res_table, 225 - res->data.address32.min_address_range, 223 + case ACPI_RESOURCE_TYPE_ADDRESS32: 224 + pnpacpi_parse_allocated_memresource(res_table, 225 + res->data.address32.minimum, 226 226 res->data.address32.address_length); 227 227 break; 228 - case ACPI_RSTYPE_ADDRESS64: 229 - pnpacpi_parse_allocated_memresource(res_table, 230 - res->data.address64.min_address_range, 228 + case ACPI_RESOURCE_TYPE_ADDRESS64: 229 + pnpacpi_parse_allocated_memresource(res_table, 230 + res->data.address64.minimum, 231 231 res->data.address64.address_length); 232 232 break; 233 - case ACPI_RSTYPE_VENDOR: 233 + case ACPI_RESOURCE_TYPE_VENDOR: 234 234 break; 235 235 default: 236 236 pnp_warn("PnPACPI: unknown resource type %d", res->type); ··· 253 253 int i; 254 254 struct pnp_dma * dma; 255 255 256 - if (p->number_of_channels == 0) 256 + if (p->channel_count == 0) 257 257 return; 258 258 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 259 259 if (!dma) 260 260 return; 261 261 262 - for(i = 0; i < p->number_of_channels; i++) 262 + for(i = 0; i < p->channel_count; i++) 263 263 dma->map |= 1 << p->channels[i]; 264 264 dma->flags = 0; 265 265 if (p->bus_master) ··· 309 309 int i; 310 310 struct pnp_irq * irq; 311 311 312 - if (p->number_of_interrupts == 0) 312 + if (p->interrupt_count == 0) 313 313 return; 314 314 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 315 315 if (!irq) 316 316 return; 317 317 318 - for(i = 0; i < p->number_of_interrupts; i++) 318 + for(i = 0; i < p->interrupt_count; i++) 319 319 if (p->interrupts[i]) 320 320 __set_bit(p->interrupts[i], irq->map); 321 - irq->flags = irq_flags(p->edge_level, p->active_high_low); 321 + irq->flags = irq_flags(p->triggering, p->polarity); 322 322 323 323 pnp_register_irq_resource(option, irq); 324 324 return; 325 325 } 326 326 327 327 static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 328 - struct acpi_resource_ext_irq *p) 328 + struct acpi_resource_extended_irq *p) 329 329 { 330 330 int i; 331 331 struct pnp_irq * irq; 332 332 333 - if (p->number_of_interrupts == 0) 333 + if (p->interrupt_count == 0) 334 334 return; 335 335 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 336 336 if (!irq) 337 337 return; 338 338 339 - for(i = 0; i < p->number_of_interrupts; i++) 339 + for(i = 0; i < p->interrupt_count; i++) 340 340 if (p->interrupts[i]) 341 341 __set_bit(p->interrupts[i], irq->map); 342 - irq->flags = irq_flags(p->edge_level, p->active_high_low); 342 + irq->flags = irq_flags(p->triggering, p->polarity); 343 343 344 344 pnp_register_irq_resource(option, irq); 345 345 return; ··· 351 351 { 352 352 struct pnp_port * port; 353 353 354 - if (io->range_length == 0) 354 + if (io->address_length == 0) 355 355 return; 356 356 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 357 357 if (!port) 358 358 return; 359 - port->min = io->min_base_address; 360 - port->max = io->max_base_address; 359 + port->min = io->minimum; 360 + port->max = io->maximum; 361 361 port->align = io->alignment; 362 - port->size = io->range_length; 363 - port->flags = ACPI_DECODE_16 == io->io_decode ? 362 + port->size = io->address_length; 363 + port->flags = ACPI_DECODE_16 == io->io_decode ? 364 364 PNP_PORT_FLAG_16BITADDR : 0; 365 365 pnp_register_port_resource(option,port); 366 366 return; ··· 372 372 { 373 373 struct pnp_port * port; 374 374 375 - if (io->range_length == 0) 375 + if (io->address_length == 0) 376 376 return; 377 377 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 378 378 if (!port) 379 379 return; 380 - port->min = port->max = io->base_address; 381 - port->size = io->range_length; 380 + port->min = port->max = io->address; 381 + port->size = io->address_length; 382 382 port->align = 0; 383 383 port->flags = PNP_PORT_FLAG_FIXED; 384 384 pnp_register_port_resource(option,port); ··· 387 387 388 388 static void 389 389 pnpacpi_parse_mem24_option(struct pnp_option *option, 390 - struct acpi_resource_mem24 *p) 390 + struct acpi_resource_memory24 *p) 391 391 { 392 392 struct pnp_mem * mem; 393 393 394 - if (p->range_length == 0) 394 + if (p->address_length == 0) 395 395 return; 396 396 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 397 397 if (!mem) 398 398 return; 399 - mem->min = p->min_base_address; 400 - mem->max = p->max_base_address; 399 + mem->min = p->minimum; 400 + mem->max = p->maximum; 401 401 mem->align = p->alignment; 402 - mem->size = p->range_length; 402 + mem->size = p->address_length; 403 403 404 404 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 405 405 IORESOURCE_MEM_WRITEABLE : 0; ··· 410 410 411 411 static void 412 412 pnpacpi_parse_mem32_option(struct pnp_option *option, 413 - struct acpi_resource_mem32 *p) 413 + struct acpi_resource_memory32 *p) 414 414 { 415 415 struct pnp_mem * mem; 416 416 417 - if (p->range_length == 0) 417 + if (p->address_length == 0) 418 418 return; 419 419 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 420 420 if (!mem) 421 421 return; 422 - mem->min = p->min_base_address; 423 - mem->max = p->max_base_address; 422 + mem->min = p->minimum; 423 + mem->max = p->maximum; 424 424 mem->align = p->alignment; 425 - mem->size = p->range_length; 425 + mem->size = p->address_length; 426 426 427 427 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 428 428 IORESOURCE_MEM_WRITEABLE : 0; ··· 433 433 434 434 static void 435 435 pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 436 - struct acpi_resource_fixed_mem32 *p) 436 + struct acpi_resource_fixed_memory32 *p) 437 437 { 438 438 struct pnp_mem * mem; 439 439 440 - if (p->range_length == 0) 440 + if (p->address_length == 0) 441 441 return; 442 442 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 443 443 if (!mem) 444 444 return; 445 - mem->min = mem->max = p->range_base_address; 446 - mem->size = p->range_length; 445 + mem->min = mem->max = p->address; 446 + mem->size = p->address_length; 447 447 mem->align = 0; 448 448 449 449 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? ··· 459 459 struct pnp_dev *dev; 460 460 }; 461 461 462 - static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 462 + static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 463 463 void *data) 464 464 { 465 465 int priority = 0; ··· 468 468 struct pnp_option *option = parse_data->option; 469 469 470 470 switch (res->type) { 471 - case ACPI_RSTYPE_IRQ: 471 + case ACPI_RESOURCE_TYPE_IRQ: 472 472 pnpacpi_parse_irq_option(option, &res->data.irq); 473 473 break; 474 - case ACPI_RSTYPE_EXT_IRQ: 474 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 475 475 pnpacpi_parse_ext_irq_option(option, 476 476 &res->data.extended_irq); 477 477 break; 478 - case ACPI_RSTYPE_DMA: 478 + case ACPI_RESOURCE_TYPE_DMA: 479 479 pnpacpi_parse_dma_option(option, &res->data.dma); 480 480 break; 481 - case ACPI_RSTYPE_IO: 481 + case ACPI_RESOURCE_TYPE_IO: 482 482 pnpacpi_parse_port_option(option, &res->data.io); 483 483 break; 484 - case ACPI_RSTYPE_FIXED_IO: 484 + case ACPI_RESOURCE_TYPE_FIXED_IO: 485 485 pnpacpi_parse_fixed_port_option(option, 486 486 &res->data.fixed_io); 487 487 break; 488 - case ACPI_RSTYPE_MEM24: 488 + case ACPI_RESOURCE_TYPE_MEMORY24: 489 489 pnpacpi_parse_mem24_option(option, &res->data.memory24); 490 490 break; 491 - case ACPI_RSTYPE_MEM32: 491 + case ACPI_RESOURCE_TYPE_MEMORY32: 492 492 pnpacpi_parse_mem32_option(option, &res->data.memory32); 493 493 break; 494 - case ACPI_RSTYPE_FIXED_MEM32: 494 + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 495 495 pnpacpi_parse_fixed_mem32_option(option, 496 496 &res->data.fixed_memory32); 497 497 break; 498 - case ACPI_RSTYPE_START_DPF: 498 + case ACPI_RESOURCE_TYPE_START_DEPENDENT: 499 499 switch (res->data.start_dpf.compatibility_priority) { 500 500 case ACPI_GOOD_CONFIGURATION: 501 501 priority = PNP_RES_PRIORITY_PREFERRED; ··· 518 518 return AE_ERROR; 519 519 parse_data->option = option; 520 520 break; 521 - case ACPI_RSTYPE_END_DPF: 521 + case ACPI_RESOURCE_TYPE_END_DEPENDENT: 522 522 /*only one EndDependentFn is allowed*/ 523 523 if (!parse_data->option_independent) { 524 524 pnp_warn("PnPACPI: more than one EndDependentFn"); ··· 535 535 return AE_OK; 536 536 } 537 537 538 - acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 538 + acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 539 539 struct pnp_dev *dev) 540 540 { 541 541 acpi_status status; ··· 546 546 return AE_ERROR; 547 547 parse_data.option_independent = parse_data.option; 548 548 parse_data.dev = dev; 549 - status = acpi_walk_resources(handle, METHOD_NAME__PRS, 549 + status = acpi_walk_resources(handle, METHOD_NAME__PRS, 550 550 pnpacpi_option_resource, &parse_data); 551 551 552 552 return status; ··· 560 560 { 561 561 int *res_cnt = (int *)data; 562 562 switch (res->type) { 563 - case ACPI_RSTYPE_IRQ: 564 - case ACPI_RSTYPE_EXT_IRQ: 565 - case ACPI_RSTYPE_DMA: 566 - case ACPI_RSTYPE_IO: 567 - case ACPI_RSTYPE_FIXED_IO: 568 - case ACPI_RSTYPE_MEM24: 569 - case ACPI_RSTYPE_MEM32: 570 - case ACPI_RSTYPE_FIXED_MEM32: 563 + case ACPI_RESOURCE_TYPE_IRQ: 564 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 565 + case ACPI_RESOURCE_TYPE_DMA: 566 + case ACPI_RESOURCE_TYPE_IO: 567 + case ACPI_RESOURCE_TYPE_FIXED_IO: 568 + case ACPI_RESOURCE_TYPE_MEMORY24: 569 + case ACPI_RESOURCE_TYPE_MEMORY32: 570 + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 571 571 #if 0 572 - case ACPI_RSTYPE_ADDRESS16: 573 - case ACPI_RSTYPE_ADDRESS32: 574 - case ACPI_RSTYPE_ADDRESS64: 572 + case ACPI_RESOURCE_TYPE_ADDRESS16: 573 + case ACPI_RESOURCE_TYPE_ADDRESS32: 574 + case ACPI_RESOURCE_TYPE_ADDRESS64: 575 575 #endif 576 576 (*res_cnt) ++; 577 577 default: ··· 585 585 { 586 586 struct acpi_resource **resource = (struct acpi_resource **)data; 587 587 switch (res->type) { 588 - case ACPI_RSTYPE_IRQ: 589 - case ACPI_RSTYPE_EXT_IRQ: 590 - case ACPI_RSTYPE_DMA: 591 - case ACPI_RSTYPE_IO: 592 - case ACPI_RSTYPE_FIXED_IO: 593 - case ACPI_RSTYPE_MEM24: 594 - case ACPI_RSTYPE_MEM32: 595 - case ACPI_RSTYPE_FIXED_MEM32: 588 + case ACPI_RESOURCE_TYPE_IRQ: 589 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 590 + case ACPI_RESOURCE_TYPE_DMA: 591 + case ACPI_RESOURCE_TYPE_IO: 592 + case ACPI_RESOURCE_TYPE_FIXED_IO: 593 + case ACPI_RESOURCE_TYPE_MEMORY24: 594 + case ACPI_RESOURCE_TYPE_MEMORY32: 595 + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 596 596 #if 0 597 - case ACPI_RSTYPE_ADDRESS16: 598 - case ACPI_RSTYPE_ADDRESS32: 599 - case ACPI_RSTYPE_ADDRESS64: 597 + case ACPI_RESOURCE_TYPE_ADDRESS16: 598 + case ACPI_RESOURCE_TYPE_ADDRESS32: 599 + case ACPI_RESOURCE_TYPE_ADDRESS64: 600 600 #endif 601 601 (*resource)->type = res->type; 602 602 (*resource)++; ··· 607 607 return AE_OK; 608 608 } 609 609 610 - int pnpacpi_build_resource_template(acpi_handle handle, 610 + int pnpacpi_build_resource_template(acpi_handle handle, 611 611 struct acpi_buffer *buffer) 612 612 { 613 613 struct acpi_resource *resource; 614 614 int res_cnt = 0; 615 615 acpi_status status; 616 616 617 - status = acpi_walk_resources(handle, METHOD_NAME__CRS, 617 + status = acpi_walk_resources(handle, METHOD_NAME__CRS, 618 618 pnpacpi_count_resources, &res_cnt); 619 619 if (ACPI_FAILURE(status)) { 620 620 pnp_err("Evaluate _CRS failed"); ··· 628 628 return -ENOMEM; 629 629 pnp_dbg("Res cnt %d", res_cnt); 630 630 resource = (struct acpi_resource *)buffer->pointer; 631 - status = acpi_walk_resources(handle, METHOD_NAME__CRS, 631 + status = acpi_walk_resources(handle, METHOD_NAME__CRS, 632 632 pnpacpi_type_resources, &resource); 633 633 if (ACPI_FAILURE(status)) { 634 634 kfree(buffer->pointer); ··· 636 636 return -EINVAL; 637 637 } 638 638 /* resource will pointer the end resource now */ 639 - resource->type = ACPI_RSTYPE_END_TAG; 639 + resource->type = ACPI_RESOURCE_TYPE_END_TAG; 640 640 641 641 return 0; 642 642 } 643 643 644 - static void pnpacpi_encode_irq(struct acpi_resource *resource, 644 + static void pnpacpi_encode_irq(struct acpi_resource *resource, 645 645 struct resource *p) 646 646 { 647 - int edge_level, active_high_low; 647 + int triggering, polarity; 648 648 649 - decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 650 - &active_high_low); 651 - resource->type = ACPI_RSTYPE_IRQ; 649 + decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, 650 + &polarity); 651 + resource->type = ACPI_RESOURCE_TYPE_IRQ; 652 652 resource->length = sizeof(struct acpi_resource); 653 - resource->data.irq.edge_level = edge_level; 654 - resource->data.irq.active_high_low = active_high_low; 655 - if (edge_level == ACPI_EDGE_SENSITIVE) 656 - resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 653 + resource->data.irq.triggering = triggering; 654 + resource->data.irq.polarity = polarity; 655 + if (triggering == ACPI_EDGE_SENSITIVE) 656 + resource->data.irq.sharable = ACPI_EXCLUSIVE; 657 657 else 658 - resource->data.irq.shared_exclusive = ACPI_SHARED; 659 - resource->data.irq.number_of_interrupts = 1; 658 + resource->data.irq.sharable = ACPI_SHARED; 659 + resource->data.irq.interrupt_count = 1; 660 660 resource->data.irq.interrupts[0] = p->start; 661 661 } 662 662 663 663 static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 664 664 struct resource *p) 665 665 { 666 - int edge_level, active_high_low; 666 + int triggering, polarity; 667 667 668 - decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 669 - &active_high_low); 670 - resource->type = ACPI_RSTYPE_EXT_IRQ; 668 + decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, 669 + &polarity); 670 + resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; 671 671 resource->length = sizeof(struct acpi_resource); 672 672 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; 673 - resource->data.extended_irq.edge_level = edge_level; 674 - resource->data.extended_irq.active_high_low = active_high_low; 675 - if (edge_level == ACPI_EDGE_SENSITIVE) 676 - resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 673 + resource->data.extended_irq.triggering = triggering; 674 + resource->data.extended_irq.polarity = polarity; 675 + if (triggering == ACPI_EDGE_SENSITIVE) 676 + resource->data.irq.sharable = ACPI_EXCLUSIVE; 677 677 else 678 - resource->data.irq.shared_exclusive = ACPI_SHARED; 679 - resource->data.extended_irq.number_of_interrupts = 1; 678 + resource->data.irq.sharable = ACPI_SHARED; 679 + resource->data.extended_irq.interrupt_count = 1; 680 680 resource->data.extended_irq.interrupts[0] = p->start; 681 681 } 682 682 683 683 static void pnpacpi_encode_dma(struct acpi_resource *resource, 684 684 struct resource *p) 685 685 { 686 - resource->type = ACPI_RSTYPE_DMA; 686 + resource->type = ACPI_RESOURCE_TYPE_DMA; 687 687 resource->length = sizeof(struct acpi_resource); 688 688 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 689 689 if (p->flags & IORESOURCE_DMA_COMPATIBLE) ··· 701 701 else if (p->flags & IORESOURCE_DMA_16BIT) 702 702 resource->data.dma.transfer = ACPI_TRANSFER_16; 703 703 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; 704 - resource->data.dma.number_of_channels = 1; 704 + resource->data.dma.channel_count = 1; 705 705 resource->data.dma.channels[0] = p->start; 706 706 } 707 707 708 708 static void pnpacpi_encode_io(struct acpi_resource *resource, 709 709 struct resource *p) 710 710 { 711 - resource->type = ACPI_RSTYPE_IO; 711 + resource->type = ACPI_RESOURCE_TYPE_IO; 712 712 resource->length = sizeof(struct acpi_resource); 713 713 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 714 714 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? 715 - ACPI_DECODE_16 : ACPI_DECODE_10; 716 - resource->data.io.min_base_address = p->start; 717 - resource->data.io.max_base_address = p->end; 715 + ACPI_DECODE_16 : ACPI_DECODE_10; 716 + resource->data.io.minimum = p->start; 717 + resource->data.io.maximum = p->end; 718 718 resource->data.io.alignment = 0; /* Correct? */ 719 - resource->data.io.range_length = p->end - p->start + 1; 719 + resource->data.io.address_length = p->end - p->start + 1; 720 720 } 721 721 722 722 static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 723 723 struct resource *p) 724 724 { 725 - resource->type = ACPI_RSTYPE_FIXED_IO; 725 + resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; 726 726 resource->length = sizeof(struct acpi_resource); 727 - resource->data.fixed_io.base_address = p->start; 728 - resource->data.fixed_io.range_length = p->end - p->start + 1; 727 + resource->data.fixed_io.address = p->start; 728 + resource->data.fixed_io.address_length = p->end - p->start + 1; 729 729 } 730 730 731 731 static void pnpacpi_encode_mem24(struct acpi_resource *resource, 732 732 struct resource *p) 733 733 { 734 - resource->type = ACPI_RSTYPE_MEM24; 734 + resource->type = ACPI_RESOURCE_TYPE_MEMORY24; 735 735 resource->length = sizeof(struct acpi_resource); 736 736 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 737 737 resource->data.memory24.read_write_attribute = 738 738 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 739 739 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 740 - resource->data.memory24.min_base_address = p->start; 741 - resource->data.memory24.max_base_address = p->end; 740 + resource->data.memory24.minimum = p->start; 741 + resource->data.memory24.maximum = p->end; 742 742 resource->data.memory24.alignment = 0; 743 - resource->data.memory24.range_length = p->end - p->start + 1; 743 + resource->data.memory24.address_length = p->end - p->start + 1; 744 744 } 745 745 746 746 static void pnpacpi_encode_mem32(struct acpi_resource *resource, 747 747 struct resource *p) 748 748 { 749 - resource->type = ACPI_RSTYPE_MEM32; 749 + resource->type = ACPI_RESOURCE_TYPE_MEMORY32; 750 750 resource->length = sizeof(struct acpi_resource); 751 751 resource->data.memory32.read_write_attribute = 752 752 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 753 753 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 754 - resource->data.memory32.min_base_address = p->start; 755 - resource->data.memory32.max_base_address = p->end; 754 + resource->data.memory32.minimum = p->start; 755 + resource->data.memory32.maximum = p->end; 756 756 resource->data.memory32.alignment = 0; 757 - resource->data.memory32.range_length = p->end - p->start + 1; 757 + resource->data.memory32.address_length = p->end - p->start + 1; 758 758 } 759 759 760 760 static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 761 761 struct resource *p) 762 762 { 763 - resource->type = ACPI_RSTYPE_FIXED_MEM32; 763 + resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; 764 764 resource->length = sizeof(struct acpi_resource); 765 765 resource->data.fixed_memory32.read_write_attribute = 766 766 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 767 767 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 768 - resource->data.fixed_memory32.range_base_address = p->start; 769 - resource->data.fixed_memory32.range_length = p->end - p->start + 1; 768 + resource->data.fixed_memory32.address = p->start; 769 + resource->data.fixed_memory32.address_length = p->end - p->start + 1; 770 770 } 771 771 772 - int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 772 + int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 773 773 struct acpi_buffer *buffer) 774 774 { 775 775 int i = 0; ··· 781 781 pnp_dbg("res cnt %d", res_cnt); 782 782 while (i < res_cnt) { 783 783 switch(resource->type) { 784 - case ACPI_RSTYPE_IRQ: 784 + case ACPI_RESOURCE_TYPE_IRQ: 785 785 pnp_dbg("Encode irq"); 786 - pnpacpi_encode_irq(resource, 786 + pnpacpi_encode_irq(resource, 787 787 &res_table->irq_resource[irq]); 788 788 irq++; 789 789 break; 790 790 791 - case ACPI_RSTYPE_EXT_IRQ: 791 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 792 792 pnp_dbg("Encode ext irq"); 793 - pnpacpi_encode_ext_irq(resource, 793 + pnpacpi_encode_ext_irq(resource, 794 794 &res_table->irq_resource[irq]); 795 795 irq++; 796 796 break; 797 - case ACPI_RSTYPE_DMA: 797 + case ACPI_RESOURCE_TYPE_DMA: 798 798 pnp_dbg("Encode dma"); 799 - pnpacpi_encode_dma(resource, 799 + pnpacpi_encode_dma(resource, 800 800 &res_table->dma_resource[dma]); 801 801 dma ++; 802 802 break; 803 - case ACPI_RSTYPE_IO: 803 + case ACPI_RESOURCE_TYPE_IO: 804 804 pnp_dbg("Encode io"); 805 - pnpacpi_encode_io(resource, 805 + pnpacpi_encode_io(resource, 806 806 &res_table->port_resource[port]); 807 807 port ++; 808 808 break; 809 - case ACPI_RSTYPE_FIXED_IO: 809 + case ACPI_RESOURCE_TYPE_FIXED_IO: 810 810 pnp_dbg("Encode fixed io"); 811 811 pnpacpi_encode_fixed_io(resource, 812 812 &res_table->port_resource[port]); 813 813 port ++; 814 814 break; 815 - case ACPI_RSTYPE_MEM24: 815 + case ACPI_RESOURCE_TYPE_MEMORY24: 816 816 pnp_dbg("Encode mem24"); 817 817 pnpacpi_encode_mem24(resource, 818 818 &res_table->mem_resource[mem]); 819 819 mem ++; 820 820 break; 821 - case ACPI_RSTYPE_MEM32: 821 + case ACPI_RESOURCE_TYPE_MEMORY32: 822 822 pnp_dbg("Encode mem32"); 823 823 pnpacpi_encode_mem32(resource, 824 824 &res_table->mem_resource[mem]); 825 825 mem ++; 826 826 break; 827 - case ACPI_RSTYPE_FIXED_MEM32: 827 + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 828 828 pnp_dbg("Encode fixed mem32"); 829 829 pnpacpi_encode_fixed_mem32(resource, 830 830 &res_table->mem_resource[mem]);
+11 -11
drivers/serial/8250_acpi.c
··· 27 27 static acpi_status acpi_serial_mmio(struct uart_port *port, 28 28 struct acpi_resource_address64 *addr) 29 29 { 30 - port->mapbase = addr->min_address_range; 30 + port->mapbase = addr->minimum; 31 31 port->iotype = UPIO_MEM; 32 32 port->flags |= UPF_IOREMAP; 33 33 return AE_OK; ··· 36 36 static acpi_status acpi_serial_port(struct uart_port *port, 37 37 struct acpi_resource_io *io) 38 38 { 39 - if (io->range_length) { 40 - port->iobase = io->min_base_address; 39 + if (io->address_length) { 40 + port->iobase = io->minimum; 41 41 port->iotype = UPIO_PORT; 42 42 } else 43 43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); ··· 45 45 } 46 46 47 47 static acpi_status acpi_serial_ext_irq(struct uart_port *port, 48 - struct acpi_resource_ext_irq *ext_irq) 48 + struct acpi_resource_extended_irq *ext_irq) 49 49 { 50 50 int rc; 51 51 52 - if (ext_irq->number_of_interrupts > 0) { 52 + if (ext_irq->interrupt_count > 0) { 53 53 rc = acpi_register_gsi(ext_irq->interrupts[0], 54 - ext_irq->edge_level, ext_irq->active_high_low); 54 + ext_irq->triggering, ext_irq->polarity); 55 55 if (rc < 0) 56 56 return AE_ERROR; 57 57 port->irq = rc; ··· 64 64 { 65 65 int rc; 66 66 67 - if (irq->number_of_interrupts > 0) { 67 + if (irq->interrupt_count > 0) { 68 68 rc = acpi_register_gsi(irq->interrupts[0], 69 - irq->edge_level, irq->active_high_low); 69 + irq->triggering, irq->polarity); 70 70 if (rc < 0) 71 71 return AE_ERROR; 72 72 port->irq = rc; ··· 83 83 status = acpi_resource_to_address64(res, &addr); 84 84 if (ACPI_SUCCESS(status)) 85 85 return acpi_serial_mmio(port, &addr); 86 - else if (res->type == ACPI_RSTYPE_IO) 86 + else if (res->type == ACPI_RESOURCE_TYPE_IO) 87 87 return acpi_serial_port(port, &res->data.io); 88 - else if (res->type == ACPI_RSTYPE_EXT_IRQ) 88 + else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) 89 89 return acpi_serial_ext_irq(port, &res->data.extended_irq); 90 - else if (res->type == ACPI_RSTYPE_IRQ) 90 + else if (res->type == ACPI_RESOURCE_TYPE_IRQ) 91 91 return acpi_serial_irq(port, &res->data.irq); 92 92 return AE_OK; 93 93 }
+1 -1
include/acpi/acconfig.h
··· 63 63 64 64 /* Current ACPICA subsystem version in YYYYMMDD format */ 65 65 66 - #define ACPI_CA_VERSION 0x20050916 66 + #define ACPI_CA_VERSION 0x20050930 67 67 68 68 /* 69 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
+18 -24
include/acpi/acdisasm.h
··· 187 187 * dmresrcl 188 188 */ 189 189 void 190 - acpi_dm_word_descriptor(union asl_resource_desc *resource, 191 - u32 length, u32 level); 190 + acpi_dm_word_descriptor(union aml_resource *resource, u32 length, u32 level); 192 191 193 192 void 194 - acpi_dm_dword_descriptor(union asl_resource_desc *resource, 195 - u32 length, u32 level); 193 + acpi_dm_dword_descriptor(union aml_resource *resource, u32 length, u32 level); 196 194 197 195 void 198 - acpi_dm_extended_descriptor(union asl_resource_desc *resource, 196 + acpi_dm_extended_descriptor(union aml_resource *resource, 199 197 u32 length, u32 level); 200 198 201 199 void 202 - acpi_dm_qword_descriptor(union asl_resource_desc *resource, 203 - u32 length, u32 level); 200 + acpi_dm_qword_descriptor(union aml_resource *resource, u32 length, u32 level); 204 201 205 202 void 206 - acpi_dm_memory24_descriptor(union asl_resource_desc *resource, 203 + acpi_dm_memory24_descriptor(union aml_resource *resource, 207 204 u32 length, u32 level); 208 205 209 206 void 210 - acpi_dm_memory32_descriptor(union asl_resource_desc *resource, 207 + acpi_dm_memory32_descriptor(union aml_resource *resource, 211 208 u32 length, u32 level); 212 209 213 210 void 214 - acpi_dm_fixed_memory32_descriptor(union asl_resource_desc *resource, 211 + acpi_dm_fixed_memory32_descriptor(union aml_resource *resource, 215 212 u32 length, u32 level); 216 213 217 214 void 218 - acpi_dm_generic_register_descriptor(union asl_resource_desc *resource, 215 + acpi_dm_generic_register_descriptor(union aml_resource *resource, 219 216 u32 length, u32 level); 220 217 221 218 void 222 - acpi_dm_interrupt_descriptor(union asl_resource_desc *resource, 219 + acpi_dm_interrupt_descriptor(union aml_resource *resource, 223 220 u32 length, u32 level); 224 221 225 222 void 226 - acpi_dm_vendor_large_descriptor(union asl_resource_desc *resource, 223 + acpi_dm_vendor_large_descriptor(union aml_resource *resource, 227 224 u32 length, u32 level); 228 225 229 226 /* 230 227 * dmresrcs 231 228 */ 232 229 void 233 - acpi_dm_irq_descriptor(union asl_resource_desc *resource, 234 - u32 length, u32 level); 230 + acpi_dm_irq_descriptor(union aml_resource *resource, u32 length, u32 level); 235 231 236 232 void 237 - acpi_dm_dma_descriptor(union asl_resource_desc *resource, 238 - u32 length, u32 level); 233 + acpi_dm_dma_descriptor(union aml_resource *resource, u32 length, u32 level); 234 + 235 + void acpi_dm_io_descriptor(union aml_resource *resource, u32 length, u32 level); 239 236 240 237 void 241 - acpi_dm_io_descriptor(union asl_resource_desc *resource, u32 length, u32 level); 242 - 243 - void 244 - acpi_dm_fixed_io_descriptor(union asl_resource_desc *resource, 238 + acpi_dm_fixed_io_descriptor(union aml_resource *resource, 245 239 u32 length, u32 level); 246 240 247 241 void 248 - acpi_dm_start_dependent_descriptor(union asl_resource_desc *resource, 242 + acpi_dm_start_dependent_descriptor(union aml_resource *resource, 249 243 u32 length, u32 level); 250 244 251 245 void 252 - acpi_dm_end_dependent_descriptor(union asl_resource_desc *resource, 246 + acpi_dm_end_dependent_descriptor(union aml_resource *resource, 253 247 u32 length, u32 level); 254 248 255 249 void 256 - acpi_dm_vendor_small_descriptor(union asl_resource_desc *resource, 250 + acpi_dm_vendor_small_descriptor(union aml_resource *resource, 257 251 u32 length, u32 level); 258 252 259 253 /*
+9
include/acpi/acglobal.h
··· 80 80 81 81 extern u32 acpi_gbl_nesting_level; 82 82 83 + /* Support for dynamic control method tracing mechanism */ 84 + 85 + ACPI_EXTERN u32 acpi_gbl_original_dbg_level; 86 + ACPI_EXTERN u32 acpi_gbl_original_dbg_layer; 87 + ACPI_EXTERN acpi_name acpi_gbl_trace_method_name; 88 + ACPI_EXTERN u32 acpi_gbl_trace_dbg_level; 89 + ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer; 90 + ACPI_EXTERN u32 acpi_gbl_trace_flags; 91 + 83 92 /***************************************************************************** 84 93 * 85 94 * Runtime configuration (static defaults that can be overriden at runtime)
+36 -43
include/acpi/aclocal.h
··· 735 735 736 736 /* resource_type values */ 737 737 738 - #define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0 739 - #define ACPI_RESOURCE_TYPE_IO_RANGE 1 740 - #define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE 2 738 + #define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 739 + #define ACPI_ADDRESS_TYPE_IO_RANGE 1 740 + #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 741 741 742 742 /* Resource descriptor types and masks */ 743 743 744 - #define ACPI_RDESC_TYPE_LARGE 0x80 745 - #define ACPI_RDESC_TYPE_SMALL 0x00 744 + #define ACPI_RESOURCE_NAME_LARGE 0x80 745 + #define ACPI_RESOURCE_NAME_SMALL 0x00 746 746 747 - #define ACPI_RDESC_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ 748 - #define ACPI_RDESC_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ 749 - #define ACPI_RDESC_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ 747 + #define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ 748 + #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ 749 + #define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ 750 750 751 751 /* 752 - * Small resource descriptor types 752 + * Small resource descriptor "names" as defined by the ACPI specification. 753 753 * Note: Bits 2:0 are used for the descriptor length 754 754 */ 755 - #define ACPI_RDESC_TYPE_IRQ_FORMAT 0x20 756 - #define ACPI_RDESC_TYPE_DMA_FORMAT 0x28 757 - #define ACPI_RDESC_TYPE_START_DEPENDENT 0x30 758 - #define ACPI_RDESC_TYPE_END_DEPENDENT 0x38 759 - #define ACPI_RDESC_TYPE_IO_PORT 0x40 760 - #define ACPI_RDESC_TYPE_FIXED_IO_PORT 0x48 761 - #define ACPI_RDESC_TYPE_RESERVED_S1 0x50 762 - #define ACPI_RDESC_TYPE_RESERVED_S2 0x58 763 - #define ACPI_RDESC_TYPE_RESERVED_S3 0x60 764 - #define ACPI_RDESC_TYPE_RESERVED_S4 0x68 765 - #define ACPI_RDESC_TYPE_SMALL_VENDOR 0x70 766 - #define ACPI_RDESC_TYPE_END_TAG 0x78 755 + #define ACPI_RESOURCE_NAME_IRQ 0x20 756 + #define ACPI_RESOURCE_NAME_DMA 0x28 757 + #define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 758 + #define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 759 + #define ACPI_RESOURCE_NAME_IO 0x40 760 + #define ACPI_RESOURCE_NAME_FIXED_IO 0x48 761 + #define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 762 + #define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 763 + #define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 764 + #define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 765 + #define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 766 + #define ACPI_RESOURCE_NAME_END_TAG 0x78 767 767 768 768 /* 769 - * Large resource descriptor types 769 + * Large resource descriptor "names" as defined by the ACPI specification. 770 + * Note: includes the Large Descriptor bit in bit[7] 770 771 */ 771 - #define ACPI_RDESC_TYPE_MEMORY_24 0x81 772 - #define ACPI_RDESC_TYPE_GENERIC_REGISTER 0x82 773 - #define ACPI_RDESC_TYPE_RESERVED_L1 0x83 774 - #define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84 775 - #define ACPI_RDESC_TYPE_MEMORY_32 0x85 776 - #define ACPI_RDESC_TYPE_FIXED_MEMORY_32 0x86 777 - #define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE 0x87 778 - #define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE 0x88 779 - #define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89 780 - #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A 781 - #define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B 782 - #define ACPI_RDESC_LARGE_MAX 0x8B 783 - 784 - /* 785 - * Minimum lengths for descriptors with optional fields 786 - */ 787 - #define ACPI_RDESC_QWORD_MIN 43 788 - #define ACPI_RDESC_DWORD_MIN 23 789 - #define ACPI_RDESC_WORD_MIN 13 790 - #define ACPI_RDESC_EXT_XRUPT_MIN 6 772 + #define ACPI_RESOURCE_NAME_MEMORY24 0x81 773 + #define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 774 + #define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 775 + #define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 776 + #define ACPI_RESOURCE_NAME_MEMORY32 0x85 777 + #define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 778 + #define ACPI_RESOURCE_NAME_ADDRESS32 0x87 779 + #define ACPI_RESOURCE_NAME_ADDRESS16 0x88 780 + #define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 781 + #define ACPI_RESOURCE_NAME_ADDRESS64 0x8A 782 + #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B 783 + #define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B 791 784 792 785 /***************************************************************************** 793 786 * ··· 788 795 * 789 796 ****************************************************************************/ 790 797 791 - #define ACPI_ASCII_ZERO 0x30 798 + #define ACPI_ASCII_ZERO 0x30 792 799 793 800 /***************************************************************************** 794 801 *
+54 -4
include/acpi/acmacros.h
··· 525 525 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 526 526 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 527 527 * so that "_acpi_function_name" is defined. 528 + * 529 + * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining 530 + * about these constructs. 528 531 */ 529 532 #ifdef ACPI_USE_DO_WHILE_0 530 533 #define ACPI_DO_WHILE0(a) do a while(0) ··· 535 532 #define ACPI_DO_WHILE0(a) a 536 533 #endif 537 534 538 - #define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(ACPI_DEBUG_PARAMETERS);return;}) 539 - #define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(ACPI_DEBUG_PARAMETERS,(s));return((s));}) 540 - #define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(ACPI_DEBUG_PARAMETERS,(acpi_integer)(s));return((s));}) 541 - #define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(ACPI_DEBUG_PARAMETERS,(u8 *)(s));return((s));}) 535 + #define return_VOID ACPI_DO_WHILE0 ({ \ 536 + acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \ 537 + return;}) 538 + /* 539 + * There are two versions of most of the return macros. The default version is 540 + * safer, since it avoids side-effects by guaranteeing that the argument will 541 + * not be evaluated twice. 542 + * 543 + * A less-safe version of the macros is provided for optional use if the 544 + * compiler uses excessive CPU stack (for example, this may happen in the 545 + * debug case if code optimzation is disabled.) 546 + */ 547 + #ifndef ACPI_SIMPLE_RETURN_MACROS 548 + 549 + #define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ 550 + register acpi_status _s = (s); \ 551 + acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \ 552 + return (_s); }) 553 + #define return_PTR(s) ACPI_DO_WHILE0 ({ \ 554 + register void *_s = (void *) (s); \ 555 + acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \ 556 + return (_s); }) 557 + #define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 558 + register acpi_integer _s = (s); \ 559 + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ 560 + return (_s); }) 561 + #define return_UINT8(s) ACPI_DO_WHILE0 ({ \ 562 + register u8 _s = (u8) (s); \ 563 + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ 564 + return (_s); }) 565 + #define return_UINT32(s) ACPI_DO_WHILE0 ({ \ 566 + register u32 _s = (u32) (s); \ 567 + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ 568 + return (_s); }) 569 + #else /* Use original less-safe macros */ 570 + 571 + #define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ 572 + acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \ 573 + return((s)); }) 574 + #define return_PTR(s) ACPI_DO_WHILE0 ({ \ 575 + acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \ 576 + return((s)); }) 577 + #define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 578 + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \ 579 + return((s)); }) 580 + #define return_UINT8(s) return_VALUE(s) 581 + #define return_UINT32(s) return_VALUE(s) 582 + 583 + #endif /* ACPI_SIMPLE_RETURN_MACROS */ 542 584 543 585 /* Conditional execution */ 544 586 ··· 660 612 #define return_VOID return 661 613 #define return_ACPI_STATUS(s) return(s) 662 614 #define return_VALUE(s) return(s) 615 + #define return_UINT8(s) return(s) 616 + #define return_UINT32(s) return(s) 663 617 #define return_PTR(s) return(s) 664 618 665 619 #endif
+2 -2
include/acpi/acpi_drivers.h
··· 52 52 /* ACPI PCI Interrupt Link (pci_link.c) */ 53 53 54 54 int acpi_irq_penalty_init(void); 55 - int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *edge_level, 56 - int *active_high_low, char **name); 55 + int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering, 56 + int *polarity, char **name); 57 57 int acpi_pci_link_free_irq(acpi_handle handle); 58 58 59 59 /* ACPI PCI Interrupt Routing (pci_irq.c) */
+3
include/acpi/acpixf.h
··· 149 149 acpi_status 150 150 acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data); 151 151 152 + acpi_status 153 + acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags); 154 + 152 155 /* 153 156 * Object manipulation and enumeration 154 157 */
+226 -125
include/acpi/acresrc.h
··· 44 44 #ifndef __ACRESRC_H__ 45 45 #define __ACRESRC_H__ 46 46 47 + /* Need the AML resource descriptor structs */ 48 + 49 + #include "amlresrc.h" 50 + 51 + /* 52 + * Resource dispatch and info tables 53 + */ 54 + struct acpi_resource_info { 55 + u8 length_type; 56 + u8 minimum_aml_resource_length; 57 + u8 minimum_internal_struct_length; 58 + }; 59 + 60 + /* Types for length_type above */ 61 + 62 + #define ACPI_FIXED_LENGTH 0 63 + #define ACPI_VARIABLE_LENGTH 1 64 + #define ACPI_SMALL_VARIABLE_LENGTH 2 65 + 66 + /* Handlers */ 67 + 68 + typedef acpi_status(*ACPI_SET_RESOURCE_HANDLER) (struct acpi_resource * 69 + resource, 70 + union aml_resource * aml); 71 + 72 + typedef acpi_status(*ACPI_GET_RESOURCE_HANDLER) (union aml_resource * aml, 73 + u16 aml_resource_length, 74 + struct acpi_resource * 75 + resource); 76 + 77 + typedef void (*ACPI_DUMP_RESOURCE_HANDLER) (union acpi_resource_data * data); 78 + 79 + /* Tables indexed by internal resource type */ 80 + 81 + extern u8 acpi_gbl_aml_resource_sizes[]; 82 + extern ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[]; 83 + extern ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[]; 84 + 85 + /* Tables indexed by raw AML resource descriptor type */ 86 + 87 + extern struct acpi_resource_info acpi_gbl_sm_resource_info[]; 88 + extern struct acpi_resource_info acpi_gbl_lg_resource_info[]; 89 + extern ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[]; 90 + extern ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[]; 91 + 47 92 /* 48 93 * Function prototypes called from Acpi* APIs 49 94 */ ··· 111 66 acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); 112 67 113 68 acpi_status 114 - acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, 69 + acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, 115 70 struct acpi_buffer *output_buffer); 116 71 117 72 acpi_status 118 - acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, 119 - struct acpi_buffer *output_buffer); 73 + acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, 74 + struct acpi_buffer *output_buffer); 120 75 121 76 acpi_status 122 77 acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, ··· 135 90 * rscalc 136 91 */ 137 92 acpi_status 138 - acpi_rs_get_byte_stream_start(u8 * byte_stream_buffer, 139 - u8 ** byte_stream_start, u32 * size); 93 + acpi_rs_get_list_length(u8 * aml_buffer, 94 + u32 aml_buffer_length, acpi_size * size_needed); 140 95 141 96 acpi_status 142 - acpi_rs_get_list_length(u8 * byte_stream_buffer, 143 - u32 byte_stream_buffer_length, acpi_size * size_needed); 144 - 145 - acpi_status 146 - acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list_buffer, 147 - acpi_size * size_needed); 97 + acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer, 98 + acpi_size * size_needed); 148 99 149 100 acpi_status 150 101 acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, 151 102 acpi_size * buffer_size_needed); 152 103 153 104 acpi_status 154 - acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, 155 - u32 byte_stream_buffer_length, u8 * output_buffer); 105 + acpi_rs_convert_aml_to_resources(u8 * aml_buffer, 106 + u32 aml_buffer_length, u8 * output_buffer); 156 107 157 108 acpi_status 158 - acpi_rs_list_to_byte_stream(struct acpi_resource *resource, 159 - acpi_size byte_stream_size_needed, 160 - u8 * output_buffer); 109 + acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, 110 + acpi_size aml_size_needed, u8 * output_buffer); 111 + 112 + /* 113 + * rsio 114 + */ 115 + acpi_status 116 + acpi_rs_get_io(union aml_resource *aml, 117 + u16 aml_resource_length, struct acpi_resource *resource); 161 118 162 119 acpi_status 163 - acpi_rs_io_resource(u8 * byte_stream_buffer, 164 - acpi_size * bytes_consumed, 165 - u8 ** output_buffer, acpi_size * structure_size); 120 + acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml); 166 121 167 122 acpi_status 168 - acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, 169 - acpi_size * bytes_consumed, 170 - u8 ** output_buffer, acpi_size * structure_size); 123 + acpi_rs_get_fixed_io(union aml_resource *aml, 124 + u16 aml_resource_length, struct acpi_resource *resource); 171 125 172 126 acpi_status 173 - acpi_rs_io_stream(struct acpi_resource *resource, 174 - u8 ** output_buffer, acpi_size * bytes_consumed); 127 + acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml); 175 128 176 129 acpi_status 177 - acpi_rs_fixed_io_stream(struct acpi_resource *resource, 178 - u8 ** output_buffer, acpi_size * bytes_consumed); 130 + acpi_rs_get_dma(union aml_resource *aml, 131 + u16 aml_resource_length, struct acpi_resource *resource); 179 132 180 133 acpi_status 181 - acpi_rs_irq_resource(u8 * byte_stream_buffer, 182 - acpi_size * bytes_consumed, 183 - u8 ** output_buffer, acpi_size * structure_size); 134 + acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml); 135 + 136 + /* 137 + * rsirq 138 + */ 139 + acpi_status 140 + acpi_rs_get_irq(union aml_resource *aml, 141 + u16 aml_resource_length, struct acpi_resource *resource); 184 142 185 143 acpi_status 186 - acpi_rs_irq_stream(struct acpi_resource *resource, 187 - u8 ** output_buffer, acpi_size * bytes_consumed); 144 + acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml); 188 145 189 146 acpi_status 190 - acpi_rs_dma_resource(u8 * byte_stream_buffer, 191 - acpi_size * bytes_consumed, 192 - u8 ** output_buffer, acpi_size * structure_size); 147 + acpi_rs_get_ext_irq(union aml_resource *aml, 148 + u16 aml_resource_length, struct acpi_resource *resource); 193 149 194 150 acpi_status 195 - acpi_rs_dma_stream(struct acpi_resource *resource, 196 - u8 ** output_buffer, acpi_size * bytes_consumed); 151 + acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml); 152 + 153 + /* 154 + * rsaddr 155 + */ 156 + acpi_status 157 + acpi_rs_get_address16(union aml_resource *aml, 158 + u16 aml_resource_length, struct acpi_resource *resource); 197 159 198 160 acpi_status 199 - acpi_rs_address16_resource(u8 * byte_stream_buffer, 200 - acpi_size * bytes_consumed, 201 - u8 ** output_buffer, acpi_size * structure_size); 161 + acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml); 202 162 203 163 acpi_status 204 - acpi_rs_address16_stream(struct acpi_resource *resource, 205 - u8 ** output_buffer, acpi_size * bytes_consumed); 164 + acpi_rs_get_address32(union aml_resource *aml, 165 + u16 aml_resource_length, struct acpi_resource *resource); 206 166 207 167 acpi_status 208 - acpi_rs_address32_resource(u8 * byte_stream_buffer, 209 - acpi_size * bytes_consumed, 210 - u8 ** output_buffer, acpi_size * structure_size); 168 + acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml); 211 169 212 170 acpi_status 213 - acpi_rs_address32_stream(struct acpi_resource *resource, 214 - u8 ** output_buffer, acpi_size * bytes_consumed); 171 + acpi_rs_get_address64(union aml_resource *aml, 172 + u16 aml_resource_length, struct acpi_resource *resource); 215 173 216 174 acpi_status 217 - acpi_rs_address64_resource(u8 * byte_stream_buffer, 218 - acpi_size * bytes_consumed, 219 - u8 ** output_buffer, acpi_size * structure_size); 175 + acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml); 220 176 221 177 acpi_status 222 - acpi_rs_address64_stream(struct acpi_resource *resource, 223 - u8 ** output_buffer, acpi_size * bytes_consumed); 178 + acpi_rs_get_ext_address64(union aml_resource *aml, 179 + u16 aml_resource_length, 180 + struct acpi_resource *resource); 224 181 225 182 acpi_status 226 - acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, 227 - acpi_size * bytes_consumed, 228 - u8 ** output_buffer, 229 - acpi_size * structure_size); 183 + acpi_rs_set_ext_address64(struct acpi_resource *resource, 184 + union aml_resource *aml); 185 + 186 + /* 187 + * rsmemory 188 + */ 189 + acpi_status 190 + acpi_rs_get_memory24(union aml_resource *aml, 191 + u16 aml_resource_length, struct acpi_resource *resource); 230 192 231 193 acpi_status 232 - acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, 233 - acpi_size * bytes_consumed, 234 - u8 ** output_buffer, 235 - acpi_size * structure_size); 194 + acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml); 236 195 237 196 acpi_status 238 - acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, 239 - u8 ** output_buffer, 240 - acpi_size * bytes_consumed); 197 + acpi_rs_get_memory32(union aml_resource *aml, 198 + u16 aml_resource_length, struct acpi_resource *resource); 241 199 242 200 acpi_status 243 - acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, 244 - u8 ** output_buffer, acpi_size * bytes_consumed); 201 + acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml); 245 202 246 203 acpi_status 247 - acpi_rs_memory24_resource(u8 * byte_stream_buffer, 248 - acpi_size * bytes_consumed, 249 - u8 ** output_buffer, acpi_size * structure_size); 204 + acpi_rs_get_fixed_memory32(union aml_resource *aml, 205 + u16 aml_resource_length, 206 + struct acpi_resource *resource); 250 207 251 208 acpi_status 252 - acpi_rs_memory24_stream(struct acpi_resource *resource, 253 - u8 ** output_buffer, acpi_size * bytes_consumed); 254 - 255 - acpi_status 256 - acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 257 - acpi_size * bytes_consumed, 258 - u8 ** output_buffer, 259 - acpi_size * structure_size); 260 - 261 - acpi_status 262 - acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, 263 - acpi_size * bytes_consumed, 264 - u8 ** output_buffer, 265 - acpi_size * structure_size); 266 - 267 - acpi_status 268 - acpi_rs_memory32_range_stream(struct acpi_resource *resource, 269 - u8 ** output_buffer, acpi_size * bytes_consumed); 270 - 271 - acpi_status 272 - acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, 273 - u8 ** output_buffer, acpi_size * bytes_consumed); 274 - 275 - acpi_status 276 - acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, 277 - acpi_size * bytes_consumed, 278 - u8 ** output_buffer, acpi_size * structure_size); 279 - 280 - acpi_status 281 - acpi_rs_extended_irq_stream(struct acpi_resource *resource, 282 - u8 ** output_buffer, acpi_size * bytes_consumed); 283 - 284 - acpi_status 285 - acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 286 - acpi_size * bytes_consumed, 287 - u8 ** output_buffer, acpi_size * structure_size); 288 - 289 - acpi_status 290 - acpi_rs_end_tag_stream(struct acpi_resource *resource, 291 - u8 ** output_buffer, acpi_size * bytes_consumed); 292 - 293 - acpi_status 294 - acpi_rs_vendor_resource(u8 * byte_stream_buffer, 295 - acpi_size * bytes_consumed, 296 - u8 ** output_buffer, acpi_size * structure_size); 297 - 298 - acpi_status 299 - acpi_rs_vendor_stream(struct acpi_resource *resource, 300 - u8 ** output_buffer, acpi_size * bytes_consumed); 301 - 302 - u8 acpi_rs_get_resource_type(u8 resource_start_byte); 209 + acpi_rs_set_fixed_memory32(struct acpi_resource *resource, 210 + union aml_resource *aml); 303 211 304 212 /* 305 213 * rsmisc 306 214 */ 307 215 acpi_status 308 - acpi_rs_generic_register_resource(u8 * byte_stream_buffer, 309 - acpi_size * bytes_consumed, 310 - u8 ** output_buffer, 311 - acpi_size * structure_size); 216 + acpi_rs_get_generic_reg(union aml_resource *aml, 217 + u16 aml_resource_length, 218 + struct acpi_resource *resource); 312 219 313 220 acpi_status 314 - acpi_rs_generic_register_stream(struct acpi_resource *resource, 315 - u8 ** output_buffer, 316 - acpi_size * bytes_consumed); 221 + acpi_rs_set_generic_reg(struct acpi_resource *resource, 222 + union aml_resource *aml); 223 + 224 + acpi_status 225 + acpi_rs_get_vendor(union aml_resource *aml, 226 + u16 aml_resource_length, struct acpi_resource *resource); 227 + 228 + acpi_status 229 + acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml); 230 + 231 + acpi_status 232 + acpi_rs_get_start_dpf(union aml_resource *aml, 233 + u16 aml_resource_length, struct acpi_resource *resource); 234 + 235 + acpi_status 236 + acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml); 237 + 238 + acpi_status 239 + acpi_rs_get_end_dpf(union aml_resource *aml, 240 + u16 aml_resource_length, struct acpi_resource *resource); 241 + 242 + acpi_status 243 + acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml); 244 + 245 + acpi_status 246 + acpi_rs_get_end_tag(union aml_resource *aml, 247 + u16 aml_resource_length, struct acpi_resource *resource); 248 + 249 + acpi_status 250 + acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml); 251 + 252 + /* 253 + * rsutils 254 + */ 255 + void 256 + acpi_rs_move_data(void *destination, 257 + void *source, u16 item_count, u8 move_type); 258 + 259 + /* Types used in move_type above */ 260 + 261 + #define ACPI_MOVE_TYPE_16_TO_32 0 262 + #define ACPI_MOVE_TYPE_32_TO_16 1 263 + #define ACPI_MOVE_TYPE_32_TO_32 2 264 + #define ACPI_MOVE_TYPE_64_TO_64 3 265 + 266 + u16 267 + acpi_rs_get_resource_source(u16 resource_length, 268 + acpi_size minimum_length, 269 + struct acpi_resource_source *resource_source, 270 + union aml_resource *aml, char *string_ptr); 271 + 272 + acpi_size 273 + acpi_rs_set_resource_source(union aml_resource *aml, 274 + acpi_size minimum_length, 275 + struct acpi_resource_source *resource_source); 276 + 277 + u8 acpi_rs_get_resource_type(u8 resource_start_byte); 278 + 279 + u32 acpi_rs_get_descriptor_length(union aml_resource *aml); 280 + 281 + u16 acpi_rs_get_resource_length(union aml_resource *aml); 282 + 283 + void 284 + acpi_rs_set_resource_header(u8 descriptor_type, 285 + acpi_size total_length, union aml_resource *aml); 286 + 287 + struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type); 288 + 289 + #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 290 + /* 291 + * rsdump 292 + */ 293 + void acpi_rs_dump_irq(union acpi_resource_data *resource); 294 + 295 + void acpi_rs_dump_address16(union acpi_resource_data *resource); 296 + 297 + void acpi_rs_dump_address32(union acpi_resource_data *resource); 298 + 299 + void acpi_rs_dump_address64(union acpi_resource_data *resource); 300 + 301 + void acpi_rs_dump_ext_address64(union acpi_resource_data *resource); 302 + 303 + void acpi_rs_dump_dma(union acpi_resource_data *resource); 304 + 305 + void acpi_rs_dump_io(union acpi_resource_data *resource); 306 + 307 + void acpi_rs_dump_ext_irq(union acpi_resource_data *resource); 308 + 309 + void acpi_rs_dump_fixed_io(union acpi_resource_data *resource); 310 + 311 + void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource); 312 + 313 + void acpi_rs_dump_memory24(union acpi_resource_data *resource); 314 + 315 + void acpi_rs_dump_memory32(union acpi_resource_data *resource); 316 + 317 + void acpi_rs_dump_start_dpf(union acpi_resource_data *resource); 318 + 319 + void acpi_rs_dump_vendor(union acpi_resource_data *resource); 320 + 321 + void acpi_rs_dump_generic_reg(union acpi_resource_data *resource); 322 + 323 + void acpi_rs_dump_end_dpf(union acpi_resource_data *resource); 324 + 325 + void acpi_rs_dump_end_tag(union acpi_resource_data *resource); 326 + 327 + #endif 317 328 318 329 #endif /* __ACRESRC_H__ */
+82 -70
include/acpi/actypes.h
··· 978 978 * Structures used to describe device resources 979 979 */ 980 980 struct acpi_resource_irq { 981 - u32 edge_level; 982 - u32 active_high_low; 983 - u32 shared_exclusive; 984 - u32 number_of_interrupts; 981 + u32 triggering; 982 + u32 polarity; 983 + u32 sharable; 984 + u32 interrupt_count; 985 985 u32 interrupts[1]; 986 986 }; 987 987 ··· 989 989 u32 type; 990 990 u32 bus_master; 991 991 u32 transfer; 992 - u32 number_of_channels; 992 + u32 channel_count; 993 993 u32 channels[1]; 994 994 }; 995 995 996 - struct acpi_resource_start_dpf { 996 + struct acpi_resource_start_dependent { 997 997 u32 compatibility_priority; 998 998 u32 performance_robustness; 999 999 }; ··· 1005 1005 1006 1006 struct acpi_resource_io { 1007 1007 u32 io_decode; 1008 - u32 min_base_address; 1009 - u32 max_base_address; 1008 + u32 minimum; 1009 + u32 maximum; 1010 1010 u32 alignment; 1011 - u32 range_length; 1011 + u32 address_length; 1012 1012 }; 1013 1013 1014 1014 struct acpi_resource_fixed_io { 1015 - u32 base_address; 1016 - u32 range_length; 1015 + u32 address; 1016 + u32 address_length; 1017 1017 }; 1018 1018 1019 1019 struct acpi_resource_vendor { 1020 - u32 length; 1021 - u8 reserved[1]; 1020 + u32 byte_length; 1021 + u8 byte_data[1]; 1022 1022 }; 1023 1023 1024 1024 struct acpi_resource_end_tag { 1025 1025 u8 checksum; 1026 1026 }; 1027 1027 1028 - struct acpi_resource_mem24 { 1028 + struct acpi_resource_memory24 { 1029 1029 u32 read_write_attribute; 1030 - u32 min_base_address; 1031 - u32 max_base_address; 1030 + u32 minimum; 1031 + u32 maximum; 1032 1032 u32 alignment; 1033 - u32 range_length; 1033 + u32 address_length; 1034 1034 }; 1035 1035 1036 - struct acpi_resource_mem32 { 1036 + struct acpi_resource_memory32 { 1037 1037 u32 read_write_attribute; 1038 - u32 min_base_address; 1039 - u32 max_base_address; 1038 + u32 minimum; 1039 + u32 maximum; 1040 1040 u32 alignment; 1041 - u32 range_length; 1041 + u32 address_length; 1042 1042 }; 1043 1043 1044 - struct acpi_resource_fixed_mem32 { 1044 + struct acpi_resource_fixed_memory32 { 1045 1045 u32 read_write_attribute; 1046 - u32 range_base_address; 1047 - u32 range_length; 1046 + u32 address; 1047 + u32 address_length; 1048 1048 }; 1049 1049 1050 1050 struct acpi_memory_attribute { ··· 1089 1089 1090 1090 struct acpi_resource_address16 { 1091 1091 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; 1092 - u32 min_address_range; 1093 - u32 max_address_range; 1094 - u32 address_translation_offset; 1092 + u32 minimum; 1093 + u32 maximum; 1094 + u32 translation_offset; 1095 1095 u32 address_length; 1096 1096 struct acpi_resource_source resource_source; 1097 1097 }; 1098 1098 1099 1099 struct acpi_resource_address32 { 1100 1100 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; 1101 - u32 min_address_range; 1102 - u32 max_address_range; 1103 - u32 address_translation_offset; 1101 + u32 minimum; 1102 + u32 maximum; 1103 + u32 translation_offset; 1104 1104 u32 address_length; 1105 1105 struct acpi_resource_source resource_source; 1106 1106 }; 1107 1107 1108 1108 struct acpi_resource_address64 { 1109 1109 ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; 1110 - u64 min_address_range; 1111 - u64 max_address_range; 1112 - u64 address_translation_offset; 1110 + u64 minimum; 1111 + u64 maximum; 1112 + u64 translation_offset; 1113 1113 u64 address_length; 1114 - u64 type_specific_attributes; 1115 1114 struct acpi_resource_source resource_source; 1116 1115 }; 1117 1116 1118 - struct acpi_resource_ext_irq { 1117 + struct acpi_resource_extended_address64 { 1118 + ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; 1119 + u64 minimum; 1120 + u64 maximum; 1121 + u64 translation_offset; 1122 + u64 address_length; 1123 + u64 type_specific_attributes; 1124 + u8 revision_iD; 1125 + }; 1126 + 1127 + struct acpi_resource_extended_irq { 1119 1128 u32 producer_consumer; 1120 - u32 edge_level; 1121 - u32 active_high_low; 1122 - u32 shared_exclusive; 1123 - u32 number_of_interrupts; 1129 + u32 triggering; 1130 + u32 polarity; 1131 + u32 sharable; 1132 + u32 interrupt_count; 1124 1133 struct acpi_resource_source resource_source; 1125 1134 u32 interrupts[1]; 1126 1135 }; 1127 1136 1128 - struct acpi_resource_generic_reg { 1137 + struct acpi_resource_generic_register { 1129 1138 u32 space_id; 1130 1139 u32 bit_width; 1131 1140 u32 bit_offset; 1132 - u32 address_size; 1141 + u32 access_size; 1133 1142 u64 address; 1134 1143 }; 1135 1144 1136 1145 /* ACPI_RESOURCE_TYPEs */ 1137 1146 1138 - #define ACPI_RSTYPE_IRQ 0 1139 - #define ACPI_RSTYPE_DMA 1 1140 - #define ACPI_RSTYPE_START_DPF 2 1141 - #define ACPI_RSTYPE_END_DPF 3 1142 - #define ACPI_RSTYPE_IO 4 1143 - #define ACPI_RSTYPE_FIXED_IO 5 1144 - #define ACPI_RSTYPE_VENDOR 6 1145 - #define ACPI_RSTYPE_END_TAG 7 1146 - #define ACPI_RSTYPE_MEM24 8 1147 - #define ACPI_RSTYPE_MEM32 9 1148 - #define ACPI_RSTYPE_FIXED_MEM32 10 1149 - #define ACPI_RSTYPE_ADDRESS16 11 1150 - #define ACPI_RSTYPE_ADDRESS32 12 1151 - #define ACPI_RSTYPE_ADDRESS64 13 1152 - #define ACPI_RSTYPE_EXT_IRQ 14 1153 - #define ACPI_RSTYPE_GENERIC_REG 15 1154 - #define ACPI_RSTYPE_MAX 15 1155 - 1156 - typedef u32 acpi_resource_type; 1147 + #define ACPI_RESOURCE_TYPE_IRQ 0 1148 + #define ACPI_RESOURCE_TYPE_DMA 1 1149 + #define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 1150 + #define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 1151 + #define ACPI_RESOURCE_TYPE_IO 4 1152 + #define ACPI_RESOURCE_TYPE_FIXED_IO 5 1153 + #define ACPI_RESOURCE_TYPE_VENDOR 6 1154 + #define ACPI_RESOURCE_TYPE_END_TAG 7 1155 + #define ACPI_RESOURCE_TYPE_MEMORY24 8 1156 + #define ACPI_RESOURCE_TYPE_MEMORY32 9 1157 + #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 1158 + #define ACPI_RESOURCE_TYPE_ADDRESS16 11 1159 + #define ACPI_RESOURCE_TYPE_ADDRESS32 12 1160 + #define ACPI_RESOURCE_TYPE_ADDRESS64 13 1161 + #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ 1162 + #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 1163 + #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 1164 + #define ACPI_RESOURCE_TYPE_MAX 16 1157 1165 1158 1166 union acpi_resource_data { 1159 1167 struct acpi_resource_irq irq; 1160 1168 struct acpi_resource_dma dma; 1161 - struct acpi_resource_start_dpf start_dpf; 1169 + struct acpi_resource_start_dependent start_dpf; 1162 1170 struct acpi_resource_io io; 1163 1171 struct acpi_resource_fixed_io fixed_io; 1164 - struct acpi_resource_vendor vendor_specific; 1172 + struct acpi_resource_vendor vendor; 1165 1173 struct acpi_resource_end_tag end_tag; 1166 - struct acpi_resource_mem24 memory24; 1167 - struct acpi_resource_mem32 memory32; 1168 - struct acpi_resource_fixed_mem32 fixed_memory32; 1169 - struct acpi_resource_address address; /* Common 16/32/64 address fields */ 1174 + struct acpi_resource_memory24 memory24; 1175 + struct acpi_resource_memory32 memory32; 1176 + struct acpi_resource_fixed_memory32 fixed_memory32; 1170 1177 struct acpi_resource_address16 address16; 1171 1178 struct acpi_resource_address32 address32; 1172 1179 struct acpi_resource_address64 address64; 1173 - struct acpi_resource_ext_irq extended_irq; 1174 - struct acpi_resource_generic_reg generic_reg; 1180 + struct acpi_resource_extended_address64 ext_address64; 1181 + struct acpi_resource_extended_irq extended_irq; 1182 + struct acpi_resource_generic_register generic_reg; 1183 + 1184 + /* Common fields */ 1185 + 1186 + struct acpi_resource_address address; /* Common 16/32/64 address fields */ 1175 1187 }; 1176 1188 1177 1189 struct acpi_resource { 1178 - acpi_resource_type type; 1190 + u32 type; 1179 1191 u32 length; 1180 1192 union acpi_resource_data data; 1181 1193 }; ··· 1195 1183 #define ACPI_RESOURCE_LENGTH 12 1196 1184 #define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ 1197 1185 1198 - #define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) 1186 + #define ACPI_SIZEOF_RESOURCE(type) (u32) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) 1199 1187 1200 1188 #define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length) 1201 1189
+124 -118
include/acpi/amlresrc.h
··· 96 96 * Resource descriptors defined in the ACPI specification. 97 97 * 98 98 * Packing/alignment must be BYTE because these descriptors 99 - * are used to overlay the AML byte stream. 99 + * are used to overlay the raw AML byte stream. 100 100 */ 101 101 #pragma pack(1) 102 102 103 - struct asl_irq_format_desc { 104 - u8 descriptor_type; 105 - u16 irq_mask; 103 + /* 104 + * SMALL descriptors 105 + */ 106 + #define AML_RESOURCE_SMALL_HEADER_COMMON \ 107 + u8 descriptor_type; 108 + 109 + struct aml_resource_small_header { 110 + AML_RESOURCE_SMALL_HEADER_COMMON}; 111 + 112 + struct aml_resource_irq { 113 + AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask; 106 114 u8 flags; 107 115 }; 108 116 109 - struct asl_irq_noflags_desc { 110 - u8 descriptor_type; 111 - u16 irq_mask; 117 + struct aml_resource_irq_noflags { 118 + AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask; 112 119 }; 113 120 114 - struct asl_dma_format_desc { 115 - u8 descriptor_type; 116 - u8 dma_channel_mask; 121 + struct aml_resource_dma { 122 + AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask; 117 123 u8 flags; 118 124 }; 119 125 120 - struct asl_start_dependent_desc { 121 - u8 descriptor_type; 122 - u8 flags; 126 + struct aml_resource_start_dependent { 127 + AML_RESOURCE_SMALL_HEADER_COMMON u8 flags; 123 128 }; 124 129 125 - struct asl_start_dependent_noprio_desc { 126 - u8 descriptor_type; 127 - }; 130 + struct aml_resource_start_dependent_noprio { 131 + AML_RESOURCE_SMALL_HEADER_COMMON}; 128 132 129 - struct asl_end_dependent_desc { 130 - u8 descriptor_type; 131 - }; 133 + struct aml_resource_end_dependent { 134 + AML_RESOURCE_SMALL_HEADER_COMMON}; 132 135 133 - struct asl_io_port_desc { 134 - u8 descriptor_type; 135 - u8 information; 136 - u16 address_min; 137 - u16 address_max; 136 + struct aml_resource_io { 137 + AML_RESOURCE_SMALL_HEADER_COMMON u8 information; 138 + u16 minimum; 139 + u16 maximum; 138 140 u8 alignment; 139 - u8 length; 141 + u8 address_length; 140 142 }; 141 143 142 - struct asl_fixed_io_port_desc { 143 - u8 descriptor_type; 144 - u16 base_address; 145 - u8 length; 144 + struct aml_resource_fixed_io { 145 + AML_RESOURCE_SMALL_HEADER_COMMON u16 address; 146 + u8 address_length; 146 147 }; 147 148 148 - struct asl_small_vendor_desc { 149 - u8 descriptor_type; 150 - u8 vendor_defined[7]; 149 + struct aml_resource_vendor_small { 150 + AML_RESOURCE_SMALL_HEADER_COMMON}; 151 + 152 + struct aml_resource_end_tag { 153 + AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum; 151 154 }; 152 155 153 - struct asl_end_tag_desc { 154 - u8 descriptor_type; 155 - u8 checksum; 156 - }; 157 - 158 - /* LARGE descriptors */ 159 - 160 - #define ASL_LARGE_HEADER_COMMON \ 156 + /* 157 + * LARGE descriptors 158 + */ 159 + #define AML_RESOURCE_LARGE_HEADER_COMMON \ 161 160 u8 descriptor_type;\ 162 - u16 length; 161 + u16 resource_length; 163 162 164 - struct asl_large_header { 165 - ASL_LARGE_HEADER_COMMON}; 163 + struct aml_resource_large_header { 164 + AML_RESOURCE_LARGE_HEADER_COMMON}; 166 165 167 - struct asl_memory_24_desc { 168 - ASL_LARGE_HEADER_COMMON u8 information; 169 - u16 address_min; 170 - u16 address_max; 166 + struct aml_resource_memory24 { 167 + AML_RESOURCE_LARGE_HEADER_COMMON u8 information; 168 + u16 minimum; 169 + u16 maximum; 171 170 u16 alignment; 172 - u16 range_length; 171 + u16 address_length; 173 172 }; 174 173 175 - struct asl_large_vendor_desc { 176 - ASL_LARGE_HEADER_COMMON u8 vendor_defined[1]; 177 - }; 174 + struct aml_resource_vendor_large { 175 + AML_RESOURCE_LARGE_HEADER_COMMON}; 178 176 179 - struct asl_memory_32_desc { 180 - ASL_LARGE_HEADER_COMMON u8 information; 181 - u32 address_min; 182 - u32 address_max; 177 + struct aml_resource_memory32 { 178 + AML_RESOURCE_LARGE_HEADER_COMMON u8 information; 179 + u32 minimum; 180 + u32 maximum; 183 181 u32 alignment; 184 - u32 range_length; 182 + u32 address_length; 185 183 }; 186 184 187 - struct asl_fixed_memory_32_desc { 188 - ASL_LARGE_HEADER_COMMON u8 information; 189 - u32 base_address; 190 - u32 range_length; 185 + struct aml_resource_fixed_memory32 { 186 + AML_RESOURCE_LARGE_HEADER_COMMON u8 information; 187 + u32 address; 188 + u32 address_length; 191 189 }; 192 190 193 - struct asl_extended_address_desc { 194 - ASL_LARGE_HEADER_COMMON u8 resource_type; 195 - u8 flags; 196 - u8 specific_flags; 197 - u8 revision_iD; 191 + #define AML_RESOURCE_ADDRESS_COMMON \ 192 + u8 resource_type; \ 193 + u8 flags; \ 194 + u8 specific_flags; 195 + 196 + struct aml_resource_address { 197 + AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON}; 198 + 199 + struct aml_resource_extended_address64 { 200 + AML_RESOURCE_LARGE_HEADER_COMMON 201 + AML_RESOURCE_ADDRESS_COMMON u8 revision_iD; 198 202 u8 reserved; 199 203 u64 granularity; 200 - u64 address_min; 201 - u64 address_max; 204 + u64 minimum; 205 + u64 maximum; 202 206 u64 translation_offset; 203 207 u64 address_length; 204 208 u64 type_specific_attributes; 205 - u8 optional_fields[2]; /* Used for length calculation only */ 206 209 }; 207 210 208 - #define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ 211 + #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ 209 212 210 - struct asl_qword_address_desc { 211 - ASL_LARGE_HEADER_COMMON u8 resource_type; 212 - u8 flags; 213 - u8 specific_flags; 214 - u64 granularity; 215 - u64 address_min; 216 - u64 address_max; 213 + struct aml_resource_address64 { 214 + AML_RESOURCE_LARGE_HEADER_COMMON 215 + AML_RESOURCE_ADDRESS_COMMON u64 granularity; 216 + u64 minimum; 217 + u64 maximum; 217 218 u64 translation_offset; 218 219 u64 address_length; 219 - u8 optional_fields[2]; 220 220 }; 221 221 222 - struct asl_dword_address_desc { 223 - ASL_LARGE_HEADER_COMMON u8 resource_type; 224 - u8 flags; 225 - u8 specific_flags; 226 - u32 granularity; 227 - u32 address_min; 228 - u32 address_max; 222 + struct aml_resource_address32 { 223 + AML_RESOURCE_LARGE_HEADER_COMMON 224 + AML_RESOURCE_ADDRESS_COMMON u32 granularity; 225 + u32 minimum; 226 + u32 maximum; 229 227 u32 translation_offset; 230 228 u32 address_length; 231 - u8 optional_fields[2]; 232 229 }; 233 230 234 - struct asl_word_address_desc { 235 - ASL_LARGE_HEADER_COMMON u8 resource_type; 236 - u8 flags; 237 - u8 specific_flags; 238 - u16 granularity; 239 - u16 address_min; 240 - u16 address_max; 231 + struct aml_resource_address16 { 232 + AML_RESOURCE_LARGE_HEADER_COMMON 233 + AML_RESOURCE_ADDRESS_COMMON u16 granularity; 234 + u16 minimum; 235 + u16 maximum; 241 236 u16 translation_offset; 242 237 u16 address_length; 243 - u8 optional_fields[2]; 244 238 }; 245 239 246 - struct asl_extended_xrupt_desc { 247 - ASL_LARGE_HEADER_COMMON u8 flags; 240 + struct aml_resource_extended_irq { 241 + AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; 248 242 u8 table_length; 249 243 u32 interrupt_number[1]; 250 244 /* res_source_index, res_source optional fields follow */ 251 245 }; 252 246 253 - struct asl_generic_register_desc { 254 - ASL_LARGE_HEADER_COMMON u8 address_space_id; 247 + struct aml_resource_generic_register { 248 + AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id; 255 249 u8 bit_width; 256 250 u8 bit_offset; 257 - u8 access_size; /* ACPI 3.0, was Reserved */ 251 + u8 access_size; /* ACPI 3.0, was previously Reserved */ 258 252 u64 address; 259 253 }; 260 254 ··· 258 264 259 265 /* Union of all resource descriptors, so we can allocate the worst case */ 260 266 261 - union asl_resource_desc { 262 - struct asl_irq_format_desc irq; 263 - struct asl_dma_format_desc dma; 264 - struct asl_io_port_desc iop; 265 - struct asl_fixed_io_port_desc fio; 266 - struct asl_start_dependent_desc std; 267 - struct asl_end_dependent_desc end; 268 - struct asl_small_vendor_desc smv; 269 - struct asl_end_tag_desc et; 267 + union aml_resource { 268 + /* Descriptor headers */ 270 269 271 - struct asl_large_header lhd; 272 - struct asl_memory_24_desc M24; 273 - struct asl_large_vendor_desc lgv; 274 - struct asl_memory_32_desc M32; 275 - struct asl_fixed_memory_32_desc F32; 276 - struct asl_qword_address_desc qas; 277 - struct asl_dword_address_desc das; 278 - struct asl_word_address_desc was; 279 - struct asl_extended_address_desc eas; 280 - struct asl_extended_xrupt_desc exx; 281 - struct asl_generic_register_desc grg; 270 + struct aml_resource_small_header small_header; 271 + struct aml_resource_large_header large_header; 272 + 273 + /* Small resource descriptors */ 274 + 275 + struct aml_resource_irq irq; 276 + struct aml_resource_dma dma; 277 + struct aml_resource_start_dependent start_dpf; 278 + struct aml_resource_end_dependent end_dpf; 279 + struct aml_resource_io io; 280 + struct aml_resource_fixed_io fixed_io; 281 + struct aml_resource_vendor_small vendor_small; 282 + struct aml_resource_end_tag end_tag; 283 + 284 + /* Large resource descriptors */ 285 + 286 + struct aml_resource_memory24 memory24; 287 + struct aml_resource_generic_register generic_reg; 288 + struct aml_resource_vendor_large vendor_large; 289 + struct aml_resource_memory32 memory32; 290 + struct aml_resource_fixed_memory32 fixed_memory32; 291 + struct aml_resource_address16 address16; 292 + struct aml_resource_address32 address32; 293 + struct aml_resource_address64 address64; 294 + struct aml_resource_extended_address64 ext_address64; 295 + struct aml_resource_extended_irq extended_irq; 296 + 297 + /* Utility overlays */ 298 + 299 + struct aml_resource_address address; 282 300 u32 u32_item; 283 301 u16 u16_item; 284 302 u8 U8item;
+1 -1
include/asm-x86_64/mpspec.h
··· 188 188 extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); 189 189 extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); 190 190 extern void mp_config_acpi_legacy_irqs (void); 191 - extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low); 191 + extern int mp_register_gsi (u32 gsi, int triggering, int polarity); 192 192 #endif /*CONFIG_X86_IO_APIC*/ 193 193 #endif 194 194
+1 -1
include/linux/acpi.h
··· 435 435 436 436 #endif /* !CONFIG_ACPI */ 437 437 438 - int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); 438 + int acpi_register_gsi (u32 gsi, int triggering, int polarity); 439 439 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 440 440 441 441 /*