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

[ACPI] ACPICA 20051102

Modified the subsystem initialization sequence to improve
GPE support. The GPE initialization has been split into
two parts in order to defer execution of the _PRW methods
(Power Resources for Wake) until after the hardware is
fully initialized and the SCI handler is installed. This
allows the _PRW methods to access fields protected by the
Global Lock. This will fix systems where a NO_GLOBAL_LOCK
exception has been seen during initialization.

Fixed a regression with the ConcatenateResTemplate()
ASL operator introduced in the 20051021 release.

Implemented support for "local" internal ACPI object
types within the debugger "Object" command and the
acpi_walk_namespace() external interfaces. These local
types include RegionFields, BankFields, IndexFields, Alias,
and reference objects.

Moved common AML resource handling code into a new file,
"utresrc.c". This code is shared by both the Resource
Manager and the AML Debugger.

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
96db255c 0897831b

+1371 -989
+42
drivers/acpi/events/evevent.c
··· 100 100 101 101 /******************************************************************************* 102 102 * 103 + * FUNCTION: acpi_ev_install_fadt_gpes 104 + * 105 + * PARAMETERS: None 106 + * 107 + * RETURN: Status 108 + * 109 + * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks 110 + * (0 and 1). This causes the _PRW methods to be run, so the HW 111 + * must be fully initialized at this point, including global lock 112 + * support. 113 + * 114 + ******************************************************************************/ 115 + 116 + acpi_status acpi_ev_install_fadt_gpes(void) 117 + { 118 + acpi_status status; 119 + 120 + ACPI_FUNCTION_TRACE("ev_install_fadt_gpes"); 121 + 122 + /* Namespace must be locked */ 123 + 124 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 125 + if (ACPI_FAILURE(status)) { 126 + return (status); 127 + } 128 + 129 + /* FADT GPE Block 0 */ 130 + 131 + (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device, 132 + acpi_gbl_gpe_fadt_blocks[0]); 133 + 134 + /* FADT GPE Block 1 */ 135 + 136 + (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device, 137 + acpi_gbl_gpe_fadt_blocks[1]); 138 + 139 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 140 + return_ACPI_STATUS(AE_OK); 141 + } 142 + 143 + /******************************************************************************* 144 + * 103 145 * FUNCTION: acpi_ev_install_xrupt_handlers 104 146 * 105 147 * PARAMETERS: None
+101 -58
drivers/acpi/events/evgpeblk.c
··· 78 78 * 79 79 * RETURN: TRUE if the gpe_event is valid 80 80 * 81 - * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. 81 + * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. 82 82 * Should be called only when the GPE lists are semaphore locked 83 83 * and not subject to change. 84 84 * ··· 264 264 * 2) Edge/Level determination is based on the 2nd character 265 265 * of the method name 266 266 * 267 - * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE 267 + * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE 268 268 * if a _PRW object is found that points to this GPE. 269 269 */ 270 270 switch (name[1]) { ··· 313 313 314 314 /* 315 315 * Now we can add this information to the gpe_event_info block 316 - * for use during dispatch of this GPE. Default type is RUNTIME, although 316 + * for use during dispatch of this GPE. Default type is RUNTIME, although 317 317 * this may change when the _PRW methods are executed later. 318 318 */ 319 319 gpe_event_info = 320 320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 321 321 322 - gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 323 - ACPI_GPE_TYPE_RUNTIME); 322 + gpe_event_info->flags = (u8) 323 + (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME); 324 324 325 325 gpe_event_info->dispatch.method_node = 326 326 (struct acpi_namespace_node *)obj_handle; ··· 341 341 * 342 342 * PARAMETERS: Callback from walk_namespace 343 343 * 344 - * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is 344 + * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is 345 345 * not aborted on a single _PRW failure. 346 346 * 347 347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a 348 - * Device. Run the _PRW method. If present, extract the GPE 348 + * Device. Run the _PRW method. If present, extract the GPE 349 349 * number and mark the GPE as a WAKE GPE. 350 350 * 351 351 ******************************************************************************/ ··· 443 443 444 444 gpe_event_info->flags &= 445 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 446 + 446 447 status = 447 448 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 448 449 if (ACPI_FAILURE(status)) { ··· 467 466 * 468 467 * RETURN: A GPE interrupt block 469 468 * 470 - * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 469 + * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 471 470 * block per unique interrupt level used for GPEs. 472 471 * Should be called only when the GPE lists are semaphore locked 473 472 * and not subject to change. ··· 567 566 568 567 /* Disable this interrupt */ 569 568 570 - status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, 571 - acpi_ev_gpe_xrupt_handler); 569 + status = 570 + acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, 571 + acpi_ev_gpe_xrupt_handler); 572 572 if (ACPI_FAILURE(status)) { 573 573 return_ACPI_STATUS(status); 574 574 } ··· 752 750 753 751 /* 754 752 * Allocate the GPE event_info block. There are eight distinct GPEs 755 - * per register. Initialization to zeros is sufficient. 753 + * per register. Initialization to zeros is sufficient. 756 754 */ 757 755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> 758 756 register_count * ··· 771 769 gpe_block->event_info = gpe_event_info; 772 770 773 771 /* 774 - * Initialize the GPE Register and Event structures. A goal of these 772 + * Initialize the GPE Register and Event structures. A goal of these 775 773 * tables is to hide the fact that there are two separate GPE register sets 776 - * in a given gpe hardware block, the status registers occupy the first half, 774 + * in a given GPE hardware block, the status registers occupy the first half, 777 775 * and the enable registers occupy the second half. 778 776 */ 779 777 this_register = gpe_register_info; ··· 814 812 this_event++; 815 813 } 816 814 817 - /* 818 - * Clear the status/enable registers. Note that status registers 819 - * are cleared by writing a '1', while enable registers are cleared 820 - * by writing a '0'. 821 - */ 815 + /* Disable all GPEs within this register */ 816 + 822 817 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 823 818 &this_register-> 824 819 enable_address); 825 820 if (ACPI_FAILURE(status)) { 826 821 goto error_exit; 827 822 } 823 + 824 + /* Clear any pending GPE events within this register */ 828 825 829 826 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 830 827 &this_register-> ··· 861 860 * 862 861 * RETURN: Status 863 862 * 864 - * DESCRIPTION: Create and Install a block of GPE registers 863 + * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within 864 + * the block are disabled at exit. 865 + * Note: Assumes namespace is locked. 865 866 * 866 867 ******************************************************************************/ 867 868 ··· 875 872 u32 interrupt_number, 876 873 struct acpi_gpe_block_info **return_gpe_block) 877 874 { 878 - struct acpi_gpe_block_info *gpe_block; 879 - struct acpi_gpe_event_info *gpe_event_info; 880 - acpi_native_uint i; 881 - acpi_native_uint j; 882 - u32 wake_gpe_count; 883 - u32 gpe_enabled_count; 884 875 acpi_status status; 885 - struct acpi_gpe_walk_info gpe_info; 876 + struct acpi_gpe_block_info *gpe_block; 886 877 887 878 ACPI_FUNCTION_TRACE("ev_create_gpe_block"); 888 879 ··· 893 896 894 897 /* Initialize the new GPE block */ 895 898 899 + gpe_block->node = gpe_device; 896 900 gpe_block->register_count = register_count; 897 901 gpe_block->block_base_number = gpe_block_base_number; 898 - gpe_block->node = gpe_device; 899 902 900 903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, 901 904 sizeof(struct acpi_generic_address)); 902 905 903 - /* Create the register_info and event_info sub-structures */ 904 - 906 + /* 907 + * Create the register_info and event_info sub-structures 908 + * Note: disables and clears all GPEs in the block 909 + */ 905 910 status = acpi_ev_create_gpe_info_blocks(gpe_block); 906 911 if (ACPI_FAILURE(status)) { 907 912 ACPI_MEM_FREE(gpe_block); 908 913 return_ACPI_STATUS(status); 909 914 } 910 915 911 - /* Install the new block in the global list(s) */ 916 + /* Install the new block in the global lists */ 912 917 913 918 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); 914 919 if (ACPI_FAILURE(status)) { ··· 925 926 acpi_ev_save_method_info, gpe_block, 926 927 NULL); 927 928 929 + /* Return the new block */ 930 + 931 + if (return_gpe_block) { 932 + (*return_gpe_block) = gpe_block; 933 + } 934 + 935 + ACPI_DEBUG_PRINT((ACPI_DB_INIT, 936 + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", 937 + (u32) gpe_block->block_base_number, 938 + (u32) (gpe_block->block_base_number + 939 + ((gpe_block->register_count * 940 + ACPI_GPE_REGISTER_WIDTH) - 1)), 941 + gpe_device->name.ascii, gpe_block->register_count, 942 + interrupt_number)); 943 + 944 + return_ACPI_STATUS(AE_OK); 945 + } 946 + 947 + /******************************************************************************* 948 + * 949 + * FUNCTION: acpi_ev_initialize_gpe_block 950 + * 951 + * PARAMETERS: gpe_device - Handle to the parent GPE block 952 + * gpe_block - Gpe Block info 953 + * 954 + * RETURN: Status 955 + * 956 + * DESCRIPTION: Initialize and enable a GPE block. First find and run any 957 + * _PRT methods associated with the block, then enable the 958 + * appropriate GPEs. 959 + * Note: Assumes namespace is locked. 960 + * 961 + ******************************************************************************/ 962 + 963 + acpi_status 964 + acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, 965 + struct acpi_gpe_block_info *gpe_block) 966 + { 967 + acpi_status status; 968 + struct acpi_gpe_event_info *gpe_event_info; 969 + struct acpi_gpe_walk_info gpe_info; 970 + u32 wake_gpe_count; 971 + u32 gpe_enabled_count; 972 + acpi_native_uint i; 973 + acpi_native_uint j; 974 + 975 + ACPI_FUNCTION_TRACE("ev_initialize_gpe_block"); 976 + 977 + /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ 978 + 979 + if (!gpe_block) { 980 + return_ACPI_STATUS(AE_OK); 981 + } 982 + 928 983 /* 929 - * Runtime option: Should Wake GPEs be enabled at runtime? The default 930 - * is No, they should only be enabled just as the machine goes to sleep. 984 + * Runtime option: Should wake GPEs be enabled at runtime? The default 985 + * is no, they should only be enabled just as the machine goes to sleep. 931 986 */ 932 987 if (acpi_gbl_leave_wake_gpes_disabled) { 933 988 /* 934 - * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. 935 - * (Each GPE that has one or more _PRWs that reference it is by 936 - * definition a WAKE GPE and will not be enabled while the machine 937 - * is running.) 989 + * Differentiate runtime vs wake GPEs, via the _PRW control methods. 990 + * Each GPE that has one or more _PRWs that reference it is by 991 + * definition a wake GPE and will not be enabled while the machine 992 + * is running. 938 993 */ 939 994 gpe_info.gpe_block = gpe_block; 940 995 gpe_info.gpe_device = gpe_device; ··· 1001 948 } 1002 949 1003 950 /* 1004 - * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, 1005 - * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must 1006 - * be enabled via the acpi_enable_gpe() external interface. 951 + * Enable all GPEs in this block that have these attributes: 952 + * 1) are "runtime" or "run/wake" GPEs, and 953 + * 2) have a corresponding _Lxx or _Exx method 954 + * 955 + * Any other GPEs within this block must be enabled via the acpi_enable_gpe() 956 + * external interface. 1007 957 */ 1008 958 wake_gpe_count = 0; 1009 959 gpe_enabled_count = 0; ··· 1032 976 } 1033 977 } 1034 978 1035 - /* Dump info about this GPE block */ 1036 - 1037 - ACPI_DEBUG_PRINT((ACPI_DB_INIT, 1038 - "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", 1039 - (u32) gpe_block->block_base_number, 1040 - (u32) (gpe_block->block_base_number + 1041 - ((gpe_block->register_count * 1042 - ACPI_GPE_REGISTER_WIDTH) - 1)), 1043 - gpe_device->name.ascii, gpe_block->register_count, 1044 - interrupt_number)); 1045 - 1046 - /* Enable all valid GPEs found above */ 1047 - 1048 - status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); 1049 - 1050 979 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 1051 980 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 1052 981 wake_gpe_count, gpe_enabled_count)); 1053 982 1054 - /* Return the new block */ 983 + /* Enable all valid runtime GPEs found above */ 1055 984 1056 - if (return_gpe_block) { 1057 - (*return_gpe_block) = gpe_block; 985 + status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); 986 + if (ACPI_FAILURE(status)) { 987 + ACPI_REPORT_ERROR(("Could not enable GPEs in gpe_block %p\n", 988 + gpe_block)); 1058 989 } 1059 990 1060 - return_ACPI_STATUS(AE_OK); 991 + return_ACPI_STATUS(status); 1061 992 } 1062 993 1063 994 /*******************************************************************************
+7
drivers/acpi/events/evxfevnt.c
··· 626 626 goto unlock_and_exit; 627 627 } 628 628 629 + /* Run the _PRW methods and enable the GPEs */ 630 + 631 + status = acpi_ev_initialize_gpe_block(node, gpe_block); 632 + if (ACPI_FAILURE(status)) { 633 + goto unlock_and_exit; 634 + } 635 + 629 636 /* Get the device_object attached to the node */ 630 637 631 638 obj_desc = acpi_ns_get_attached_object(node);
+404 -256
drivers/acpi/executer/exdump.c
··· 55 55 */ 56 56 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 57 57 /* Local prototypes */ 58 - #ifdef ACPI_FUTURE_USAGE 59 58 static void acpi_ex_out_string(char *title, char *value); 60 59 61 60 static void acpi_ex_out_pointer(char *title, void *value); 62 61 63 - static void acpi_ex_out_integer(char *title, u32 value); 64 - 65 62 static void acpi_ex_out_address(char *title, acpi_physical_address value); 66 63 67 - static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc); 64 + static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc); 68 65 69 66 static void 70 - acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index); 71 - #endif /* ACPI_FUTURE_USAGE */ 67 + acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, 68 + u32 level, u32 index); 69 + 70 + /******************************************************************************* 71 + * 72 + * Object Descriptor info tables 73 + * 74 + * Note: The first table entry must be an INIT opcode and must contain 75 + * the table length (number of table entries) 76 + * 77 + ******************************************************************************/ 78 + 79 + static struct acpi_exdump_info acpi_ex_dump_integer[2] = { 80 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL}, 81 + {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"} 82 + }; 83 + 84 + static struct acpi_exdump_info acpi_ex_dump_string[4] = { 85 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL}, 86 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"}, 87 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"}, 88 + {ACPI_EXD_STRING, 0, NULL} 89 + }; 90 + 91 + static struct acpi_exdump_info acpi_ex_dump_buffer[4] = { 92 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL}, 93 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"}, 94 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"}, 95 + {ACPI_EXD_BUFFER, 0, NULL} 96 + }; 97 + 98 + static struct acpi_exdump_info acpi_ex_dump_package[5] = { 99 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL}, 100 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"}, 101 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"}, 102 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"}, 103 + {ACPI_EXD_PACKAGE, 0, NULL} 104 + }; 105 + 106 + static struct acpi_exdump_info acpi_ex_dump_device[4] = { 107 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL}, 108 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"}, 109 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify), 110 + "System Notify"}, 111 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify), 112 + "Device Notify"} 113 + }; 114 + 115 + static struct acpi_exdump_info acpi_ex_dump_event[2] = { 116 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL}, 117 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} 118 + }; 119 + 120 + static struct acpi_exdump_info acpi_ex_dump_method[7] = { 121 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, 122 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"}, 123 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, 124 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, 125 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, 126 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, 127 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"} 128 + }; 129 + 130 + static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { 131 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, 132 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, 133 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, 134 + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), 135 + "Acquire Depth"}, 136 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"} 137 + }; 138 + 139 + static struct acpi_exdump_info acpi_ex_dump_region[7] = { 140 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL}, 141 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"}, 142 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"}, 143 + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"}, 144 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"}, 145 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"}, 146 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"} 147 + }; 148 + 149 + static struct acpi_exdump_info acpi_ex_dump_power[5] = { 150 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL}, 151 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level), 152 + "System Level"}, 153 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order), 154 + "Resource Order"}, 155 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify), 156 + "System Notify"}, 157 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify), 158 + "Device Notify"} 159 + }; 160 + 161 + static struct acpi_exdump_info acpi_ex_dump_processor[7] = { 162 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL}, 163 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"}, 164 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.length), "Length"}, 165 + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"}, 166 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify), 167 + "System Notify"}, 168 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify), 169 + "Device Notify"}, 170 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"} 171 + }; 172 + 173 + static struct acpi_exdump_info acpi_ex_dump_thermal[4] = { 174 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL}, 175 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify), 176 + "System Notify"}, 177 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify), 178 + "Device Notify"}, 179 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"} 180 + }; 181 + 182 + static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = { 183 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL}, 184 + {ACPI_EXD_FIELD, 0, NULL}, 185 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj), 186 + "Buffer Object"} 187 + }; 188 + 189 + static struct acpi_exdump_info acpi_ex_dump_region_field[3] = { 190 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL}, 191 + {ACPI_EXD_FIELD, 0, NULL}, 192 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"} 193 + }; 194 + 195 + static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = { 196 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL}, 197 + {ACPI_EXD_FIELD, 0, NULL}, 198 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"}, 199 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj), 200 + "Region Object"}, 201 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"} 202 + }; 203 + 204 + static struct acpi_exdump_info acpi_ex_dump_index_field[5] = { 205 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL}, 206 + {ACPI_EXD_FIELD, 0, NULL}, 207 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"}, 208 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj), 209 + "Index Object"}, 210 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"} 211 + }; 212 + 213 + static struct acpi_exdump_info acpi_ex_dump_reference[7] = { 214 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL}, 215 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"}, 216 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"}, 217 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"}, 218 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"}, 219 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"}, 220 + {ACPI_EXD_REFERENCE, 0, NULL} 221 + }; 222 + 223 + static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = { 224 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler), 225 + NULL}, 226 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"}, 227 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.next), "Next"}, 228 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.region_list), 229 + "Region List"}, 230 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.node), "Node"}, 231 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"} 232 + }; 233 + 234 + static struct acpi_exdump_info acpi_ex_dump_notify[3] = { 235 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL}, 236 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"}, 237 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"} 238 + }; 239 + 240 + /* Miscellaneous tables */ 241 + 242 + static struct acpi_exdump_info acpi_ex_dump_common[4] = { 243 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL}, 244 + {ACPI_EXD_TYPE, 0, NULL}, 245 + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count), 246 + "Reference Count"}, 247 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"} 248 + }; 249 + 250 + static struct acpi_exdump_info acpi_ex_dump_field_common[7] = { 251 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL}, 252 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags), 253 + "Field Flags"}, 254 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width), 255 + "Access Byte Width"}, 256 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length), 257 + "Bit Length"}, 258 + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset), 259 + "Field Bit Offset"}, 260 + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset), 261 + "Base Byte Offset"}, 262 + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(common_field.node), "Parent Node"} 263 + }; 264 + 265 + static struct acpi_exdump_info acpi_ex_dump_node[6] = { 266 + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL}, 267 + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"}, 268 + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"}, 269 + {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count), 270 + "Reference Count"}, 271 + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"}, 272 + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"} 273 + }; 274 + 275 + /* Dispatch table, indexed by object type */ 276 + 277 + static struct acpi_exdump_info *acpi_ex_dump_info[] = { 278 + NULL, 279 + acpi_ex_dump_integer, 280 + acpi_ex_dump_string, 281 + acpi_ex_dump_buffer, 282 + acpi_ex_dump_package, 283 + NULL, 284 + acpi_ex_dump_device, 285 + acpi_ex_dump_event, 286 + acpi_ex_dump_method, 287 + acpi_ex_dump_mutex, 288 + acpi_ex_dump_region, 289 + acpi_ex_dump_power, 290 + acpi_ex_dump_processor, 291 + acpi_ex_dump_thermal, 292 + acpi_ex_dump_buffer_field, 293 + NULL, 294 + NULL, 295 + acpi_ex_dump_region_field, 296 + acpi_ex_dump_bank_field, 297 + acpi_ex_dump_index_field, 298 + acpi_ex_dump_reference, 299 + NULL, 300 + NULL, 301 + acpi_ex_dump_notify, 302 + acpi_ex_dump_address_handler, 303 + NULL, 304 + NULL, 305 + NULL 306 + }; 307 + 308 + /******************************************************************************* 309 + * 310 + * FUNCTION: acpi_ex_dump_object 311 + * 312 + * PARAMETERS: obj_desc - Descriptor to dump 313 + * Info - Info table corresponding to this object 314 + * type 315 + * 316 + * RETURN: None 317 + * 318 + * DESCRIPTION: Walk the info table for this object 319 + * 320 + ******************************************************************************/ 321 + 322 + static void 323 + acpi_ex_dump_object(union acpi_operand_object *obj_desc, 324 + struct acpi_exdump_info *info) 325 + { 326 + u8 *target; 327 + char *name; 328 + u8 count; 329 + 330 + if (!info) { 331 + acpi_os_printf 332 + ("ex_dump_object: Display not implemented for object type %s\n", 333 + acpi_ut_get_object_type_name(obj_desc)); 334 + return; 335 + } 336 + 337 + /* First table entry must contain the table length (# of table entries) */ 338 + 339 + count = info->offset; 340 + 341 + while (count) { 342 + target = ((u8 *) obj_desc) + info->offset; 343 + name = info->name; 344 + 345 + switch (info->opcode) { 346 + case ACPI_EXD_INIT: 347 + break; 348 + 349 + case ACPI_EXD_TYPE: 350 + acpi_ex_out_string("Type", 351 + acpi_ut_get_object_type_name 352 + (obj_desc)); 353 + break; 354 + 355 + case ACPI_EXD_UINT8: 356 + 357 + acpi_os_printf("%20s : %2.2X\n", name, *target); 358 + break; 359 + 360 + case ACPI_EXD_UINT16: 361 + 362 + acpi_os_printf("%20s : %4.4X\n", name, 363 + *ACPI_CAST_PTR(u16, target)); 364 + break; 365 + 366 + case ACPI_EXD_UINT32: 367 + 368 + acpi_os_printf("%20s : %8.8X\n", name, 369 + *ACPI_CAST_PTR(u32, target)); 370 + break; 371 + 372 + case ACPI_EXD_UINT64: 373 + 374 + acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", 375 + ACPI_FORMAT_UINT64(*ACPI_CAST_PTR 376 + (u64, target))); 377 + break; 378 + 379 + case ACPI_EXD_POINTER: 380 + 381 + acpi_ex_out_pointer(name, 382 + *ACPI_CAST_PTR(void *, target)); 383 + break; 384 + 385 + case ACPI_EXD_ADDRESS: 386 + 387 + acpi_ex_out_address(name, 388 + *ACPI_CAST_PTR 389 + (acpi_physical_address, target)); 390 + break; 391 + 392 + case ACPI_EXD_STRING: 393 + 394 + acpi_ut_print_string(obj_desc->string.pointer, 395 + ACPI_UINT8_MAX); 396 + acpi_os_printf("\n"); 397 + break; 398 + 399 + case ACPI_EXD_BUFFER: 400 + 401 + ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, 402 + obj_desc->buffer.length); 403 + break; 404 + 405 + case ACPI_EXD_PACKAGE: 406 + 407 + /* Dump the package contents */ 408 + 409 + acpi_os_printf("\nPackage Contents:\n"); 410 + acpi_ex_dump_package_obj(obj_desc, 0, 0); 411 + break; 412 + 413 + case ACPI_EXD_FIELD: 414 + 415 + acpi_ex_dump_object(obj_desc, 416 + acpi_ex_dump_field_common); 417 + break; 418 + 419 + case ACPI_EXD_REFERENCE: 420 + 421 + acpi_ex_out_string("Opcode", 422 + (acpi_ps_get_opcode_info 423 + (obj_desc->reference.opcode))-> 424 + name); 425 + acpi_ex_dump_reference_obj(obj_desc); 426 + break; 427 + 428 + default: 429 + acpi_os_printf("**** Invalid table opcode [%X] ****\n", 430 + info->opcode); 431 + return; 432 + } 433 + 434 + info++; 435 + count--; 436 + } 437 + } 72 438 73 439 /******************************************************************************* 74 440 * ··· 807 441 return; 808 442 } 809 443 810 - #ifdef ACPI_FUTURE_USAGE 811 444 /******************************************************************************* 812 445 * 813 446 * FUNCTION: acpi_ex_out* functions ··· 830 465 acpi_os_printf("%20s : %p\n", title, value); 831 466 } 832 467 833 - static void acpi_ex_out_integer(char *title, u32 value) 834 - { 835 - acpi_os_printf("%20s : %.2X\n", title, value); 836 - } 837 - 838 468 static void acpi_ex_out_address(char *title, acpi_physical_address value) 839 469 { 840 470 ··· 842 482 843 483 /******************************************************************************* 844 484 * 845 - * FUNCTION: acpi_ex_dump_node 485 + * FUNCTION: acpi_ex_dump_namespace_node 846 486 * 847 - * PARAMETERS: *Node - Descriptor to dump 487 + * PARAMETERS: Node - Descriptor to dump 848 488 * Flags - Force display if TRUE 849 489 * 850 490 * DESCRIPTION: Dumps the members of the given.Node 851 491 * 852 492 ******************************************************************************/ 853 493 854 - void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) 494 + void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags) 855 495 { 856 496 857 497 ACPI_FUNCTION_ENTRY(); ··· 866 506 867 507 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); 868 508 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); 869 - acpi_ex_out_integer("Flags", node->flags); 870 - acpi_ex_out_integer("Owner Id", node->owner_id); 871 - acpi_ex_out_integer("Reference Count", node->reference_count); 872 509 acpi_ex_out_pointer("Attached Object", 873 510 acpi_ns_get_attached_object(node)); 874 - acpi_ex_out_pointer("child_list", node->child); 875 - acpi_ex_out_pointer("next_peer", node->peer); 876 511 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); 512 + 513 + acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node), 514 + acpi_ex_dump_node); 877 515 } 878 516 879 517 /******************************************************************************* 880 518 * 881 - * FUNCTION: acpi_ex_dump_reference 519 + * FUNCTION: acpi_ex_dump_reference_obj 882 520 * 883 521 * PARAMETERS: Object - Descriptor to dump 884 522 * ··· 884 526 * 885 527 ******************************************************************************/ 886 528 887 - static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) 529 + static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc) 888 530 { 889 531 struct acpi_buffer ret_buf; 890 532 acpi_status status; 891 533 534 + ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 535 + 892 536 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { 893 537 acpi_os_printf("Named Object %p ", obj_desc->reference.node); 894 - ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 538 + 895 539 status = 896 540 acpi_ns_handle_to_pathname(obj_desc->reference.node, 897 541 &ret_buf); ··· 911 551 912 552 /******************************************************************************* 913 553 * 914 - * FUNCTION: acpi_ex_dump_package 554 + * FUNCTION: acpi_ex_dump_package_obj 915 555 * 916 - * PARAMETERS: Object - Descriptor to dump 556 + * PARAMETERS: obj_desc - Descriptor to dump 917 557 * Level - Indentation Level 918 558 * Index - Package index for this object 919 559 * ··· 922 562 ******************************************************************************/ 923 563 924 564 static void 925 - acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) 565 + acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, 566 + u32 level, u32 index) 926 567 { 927 568 u32 i; 928 569 ··· 983 622 obj_desc->package.count); 984 623 985 624 for (i = 0; i < obj_desc->package.count; i++) { 986 - acpi_ex_dump_package(obj_desc->package.elements[i], 987 - level + 1, i); 625 + acpi_ex_dump_package_obj(obj_desc->package.elements[i], 626 + level + 1, i); 988 627 } 989 628 break; 990 629 991 630 case ACPI_TYPE_LOCAL_REFERENCE: 992 631 993 632 acpi_os_printf("[Object Reference] "); 994 - acpi_ex_dump_reference(obj_desc); 633 + acpi_ex_dump_reference_obj(obj_desc); 995 634 break; 996 635 997 636 default: ··· 1006 645 * 1007 646 * FUNCTION: acpi_ex_dump_object_descriptor 1008 647 * 1009 - * PARAMETERS: Object - Descriptor to dump 648 + * PARAMETERS: obj_desc - Descriptor to dump 1010 649 * Flags - Force display if TRUE 1011 650 * 1012 651 * DESCRIPTION: Dumps the members of the object descriptor given. ··· 1031 670 } 1032 671 1033 672 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { 1034 - acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc, 1035 - flags); 673 + acpi_ex_dump_namespace_node((struct acpi_namespace_node *) 674 + obj_desc, flags); 675 + 1036 676 acpi_os_printf("\nAttached Object (%p):\n", 1037 677 ((struct acpi_namespace_node *)obj_desc)-> 1038 678 object); 679 + 1039 680 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) 1040 681 obj_desc)->object, flags); 1041 682 return_VOID; ··· 1050 687 return_VOID; 1051 688 } 1052 689 1053 - /* Common Fields */ 1054 - 1055 - acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc)); 1056 - acpi_ex_out_integer("Reference Count", 1057 - obj_desc->common.reference_count); 1058 - acpi_ex_out_integer("Flags", obj_desc->common.flags); 1059 - 1060 - /* Object-specific Fields */ 1061 - 1062 - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 1063 - case ACPI_TYPE_INTEGER: 1064 - 1065 - acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", 1066 - ACPI_FORMAT_UINT64(obj_desc->integer.value)); 1067 - break; 1068 - 1069 - case ACPI_TYPE_STRING: 1070 - 1071 - acpi_ex_out_integer("Length", obj_desc->string.length); 1072 - 1073 - acpi_os_printf("%20s : %p ", "Pointer", 1074 - obj_desc->string.pointer); 1075 - acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX); 1076 - acpi_os_printf("\n"); 1077 - break; 1078 - 1079 - case ACPI_TYPE_BUFFER: 1080 - 1081 - acpi_ex_out_integer("Length", obj_desc->buffer.length); 1082 - acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer); 1083 - ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, 1084 - obj_desc->buffer.length); 1085 - break; 1086 - 1087 - case ACPI_TYPE_PACKAGE: 1088 - 1089 - acpi_ex_out_integer("Flags", obj_desc->package.flags); 1090 - acpi_ex_out_integer("Elements", obj_desc->package.count); 1091 - acpi_ex_out_pointer("Element List", obj_desc->package.elements); 1092 - 1093 - /* Dump the package contents */ 1094 - 1095 - acpi_os_printf("\nPackage Contents:\n"); 1096 - acpi_ex_dump_package(obj_desc, 0, 0); 1097 - break; 1098 - 1099 - case ACPI_TYPE_DEVICE: 1100 - 1101 - acpi_ex_out_pointer("Handler", obj_desc->device.handler); 1102 - acpi_ex_out_pointer("system_notify", 1103 - obj_desc->device.system_notify); 1104 - acpi_ex_out_pointer("device_notify", 1105 - obj_desc->device.device_notify); 1106 - break; 1107 - 1108 - case ACPI_TYPE_EVENT: 1109 - 1110 - acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore); 1111 - break; 1112 - 1113 - case ACPI_TYPE_METHOD: 1114 - 1115 - acpi_ex_out_integer("param_count", 1116 - obj_desc->method.param_count); 1117 - acpi_ex_out_integer("Concurrency", 1118 - obj_desc->method.concurrency); 1119 - acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore); 1120 - acpi_ex_out_integer("owner_id", obj_desc->method.owner_id); 1121 - acpi_ex_out_integer("aml_length", obj_desc->method.aml_length); 1122 - acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start); 1123 - break; 1124 - 1125 - case ACPI_TYPE_MUTEX: 1126 - 1127 - acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level); 1128 - acpi_ex_out_pointer("owner_thread", 1129 - obj_desc->mutex.owner_thread); 1130 - acpi_ex_out_integer("acquire_depth", 1131 - obj_desc->mutex.acquisition_depth); 1132 - acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore); 1133 - break; 1134 - 1135 - case ACPI_TYPE_REGION: 1136 - 1137 - acpi_ex_out_integer("space_id", obj_desc->region.space_id); 1138 - acpi_ex_out_integer("Flags", obj_desc->region.flags); 1139 - acpi_ex_out_address("Address", obj_desc->region.address); 1140 - acpi_ex_out_integer("Length", obj_desc->region.length); 1141 - acpi_ex_out_pointer("Handler", obj_desc->region.handler); 1142 - acpi_ex_out_pointer("Next", obj_desc->region.next); 1143 - break; 1144 - 1145 - case ACPI_TYPE_POWER: 1146 - 1147 - acpi_ex_out_integer("system_level", 1148 - obj_desc->power_resource.system_level); 1149 - acpi_ex_out_integer("resource_order", 1150 - obj_desc->power_resource.resource_order); 1151 - acpi_ex_out_pointer("system_notify", 1152 - obj_desc->power_resource.system_notify); 1153 - acpi_ex_out_pointer("device_notify", 1154 - obj_desc->power_resource.device_notify); 1155 - break; 1156 - 1157 - case ACPI_TYPE_PROCESSOR: 1158 - 1159 - acpi_ex_out_integer("Processor ID", 1160 - obj_desc->processor.proc_id); 1161 - acpi_ex_out_integer("Length", obj_desc->processor.length); 1162 - acpi_ex_out_address("Address", 1163 - (acpi_physical_address) obj_desc->processor. 1164 - address); 1165 - acpi_ex_out_pointer("system_notify", 1166 - obj_desc->processor.system_notify); 1167 - acpi_ex_out_pointer("device_notify", 1168 - obj_desc->processor.device_notify); 1169 - acpi_ex_out_pointer("Handler", obj_desc->processor.handler); 1170 - break; 1171 - 1172 - case ACPI_TYPE_THERMAL: 1173 - 1174 - acpi_ex_out_pointer("system_notify", 1175 - obj_desc->thermal_zone.system_notify); 1176 - acpi_ex_out_pointer("device_notify", 1177 - obj_desc->thermal_zone.device_notify); 1178 - acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler); 1179 - break; 1180 - 1181 - case ACPI_TYPE_BUFFER_FIELD: 1182 - case ACPI_TYPE_LOCAL_REGION_FIELD: 1183 - case ACPI_TYPE_LOCAL_BANK_FIELD: 1184 - case ACPI_TYPE_LOCAL_INDEX_FIELD: 1185 - 1186 - acpi_ex_out_integer("field_flags", 1187 - obj_desc->common_field.field_flags); 1188 - acpi_ex_out_integer("access_byte_width", 1189 - obj_desc->common_field.access_byte_width); 1190 - acpi_ex_out_integer("bit_length", 1191 - obj_desc->common_field.bit_length); 1192 - acpi_ex_out_integer("fld_bit_offset", 1193 - obj_desc->common_field. 1194 - start_field_bit_offset); 1195 - acpi_ex_out_integer("base_byte_offset", 1196 - obj_desc->common_field.base_byte_offset); 1197 - acpi_ex_out_pointer("parent_node", obj_desc->common_field.node); 1198 - 1199 - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 1200 - case ACPI_TYPE_BUFFER_FIELD: 1201 - acpi_ex_out_pointer("buffer_obj", 1202 - obj_desc->buffer_field.buffer_obj); 1203 - break; 1204 - 1205 - case ACPI_TYPE_LOCAL_REGION_FIELD: 1206 - acpi_ex_out_pointer("region_obj", 1207 - obj_desc->field.region_obj); 1208 - break; 1209 - 1210 - case ACPI_TYPE_LOCAL_BANK_FIELD: 1211 - acpi_ex_out_integer("Value", 1212 - obj_desc->bank_field.value); 1213 - acpi_ex_out_pointer("region_obj", 1214 - obj_desc->bank_field.region_obj); 1215 - acpi_ex_out_pointer("bank_obj", 1216 - obj_desc->bank_field.bank_obj); 1217 - break; 1218 - 1219 - case ACPI_TYPE_LOCAL_INDEX_FIELD: 1220 - acpi_ex_out_integer("Value", 1221 - obj_desc->index_field.value); 1222 - acpi_ex_out_pointer("Index", 1223 - obj_desc->index_field.index_obj); 1224 - acpi_ex_out_pointer("Data", 1225 - obj_desc->index_field.data_obj); 1226 - break; 1227 - 1228 - default: 1229 - /* All object types covered above */ 1230 - break; 1231 - } 1232 - break; 1233 - 1234 - case ACPI_TYPE_LOCAL_REFERENCE: 1235 - 1236 - acpi_ex_out_integer("target_type", 1237 - obj_desc->reference.target_type); 1238 - acpi_ex_out_string("Opcode", 1239 - (acpi_ps_get_opcode_info 1240 - (obj_desc->reference.opcode))->name); 1241 - acpi_ex_out_integer("Offset", obj_desc->reference.offset); 1242 - acpi_ex_out_pointer("obj_desc", obj_desc->reference.object); 1243 - acpi_ex_out_pointer("Node", obj_desc->reference.node); 1244 - acpi_ex_out_pointer("Where", obj_desc->reference.where); 1245 - 1246 - acpi_ex_dump_reference(obj_desc); 1247 - break; 1248 - 1249 - case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: 1250 - 1251 - acpi_ex_out_integer("space_id", 1252 - obj_desc->address_space.space_id); 1253 - acpi_ex_out_pointer("Next", obj_desc->address_space.next); 1254 - acpi_ex_out_pointer("region_list", 1255 - obj_desc->address_space.region_list); 1256 - acpi_ex_out_pointer("Node", obj_desc->address_space.node); 1257 - acpi_ex_out_pointer("Context", obj_desc->address_space.context); 1258 - break; 1259 - 1260 - case ACPI_TYPE_LOCAL_NOTIFY: 1261 - 1262 - acpi_ex_out_pointer("Node", obj_desc->notify.node); 1263 - acpi_ex_out_pointer("Context", obj_desc->notify.context); 1264 - break; 1265 - 1266 - case ACPI_TYPE_LOCAL_ALIAS: 1267 - case ACPI_TYPE_LOCAL_METHOD_ALIAS: 1268 - case ACPI_TYPE_LOCAL_EXTRA: 1269 - case ACPI_TYPE_LOCAL_DATA: 1270 - default: 1271 - 1272 - acpi_os_printf 1273 - ("ex_dump_object_descriptor: Display not implemented for object type %s\n", 1274 - acpi_ut_get_object_type_name(obj_desc)); 1275 - break; 690 + if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) { 691 + return_VOID; 1276 692 } 1277 693 694 + /* Common Fields */ 695 + 696 + acpi_ex_dump_object(obj_desc, acpi_ex_dump_common); 697 + 698 + /* Object-specific fields */ 699 + 700 + acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]); 1278 701 return_VOID; 1279 702 } 1280 703 1281 - #endif /* ACPI_FUTURE_USAGE */ 1282 704 #endif
+31 -18
drivers/acpi/executer/exmisc.c
··· 45 45 #include <acpi/acpi.h> 46 46 #include <acpi/acinterp.h> 47 47 #include <acpi/amlcode.h> 48 + #include <acpi/amlresrc.h> 48 49 49 50 #define _COMPONENT ACPI_EXECUTER 50 51 ACPI_MODULE_NAME("exmisc") ··· 158 157 union acpi_operand_object **actual_return_desc, 159 158 struct acpi_walk_state *walk_state) 160 159 { 160 + acpi_status status; 161 161 union acpi_operand_object *return_desc; 162 162 u8 *new_buf; 163 - u8 *end_tag1; 164 - u8 *end_tag2; 163 + u8 *end_tag; 164 + acpi_size length0; 165 165 acpi_size length1; 166 - acpi_size length2; 167 166 168 167 ACPI_FUNCTION_TRACE("ex_concat_template"); 169 168 170 - /* Find the end_tags in each resource template */ 171 - 172 - end_tag1 = acpi_ut_get_resource_end_tag(operand0); 173 - end_tag2 = acpi_ut_get_resource_end_tag(operand1); 174 - if (!end_tag1 || !end_tag2) { 175 - return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 169 + /* 170 + * Find the end_tag descriptor in each resource template. 171 + * Note: returned pointers point TO the end_tag, not past it. 172 + * 173 + * Compute the length of each resource template 174 + */ 175 + status = acpi_ut_get_resource_end_tag(operand0, &end_tag); 176 + if (ACPI_FAILURE(status)) { 177 + return_ACPI_STATUS(status); 176 178 } 177 179 178 - /* Compute the length of each part */ 180 + length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer); 179 181 180 - length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); 181 - length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */ 182 + status = acpi_ut_get_resource_end_tag(operand1, &end_tag); 183 + if (ACPI_FAILURE(status)) { 184 + return_ACPI_STATUS(status); 185 + } 186 + 187 + /* Include the end_tag in the second template length */ 188 + 189 + length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer) + 190 + sizeof(struct aml_resource_end_tag); 182 191 183 192 /* Create a new buffer object for the result */ 184 193 185 - return_desc = acpi_ut_create_buffer_object(length1 + length2); 194 + return_desc = acpi_ut_create_buffer_object(length0 + length1); 186 195 if (!return_desc) { 187 196 return_ACPI_STATUS(AE_NO_MEMORY); 188 197 } 189 198 190 - /* Copy the templates to the new descriptor */ 191 - 199 + /* 200 + * Copy the templates to the new buffer, 0 first, then 1 follows. One 201 + * end_tag descriptor is copied from Operand1. 202 + */ 192 203 new_buf = return_desc->buffer.pointer; 193 - ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); 194 - ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); 204 + ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0); 205 + ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1); 195 206 196 207 /* Compute the new checksum */ 197 208 ··· 211 198 acpi_ut_generate_checksum(return_desc->buffer.pointer, 212 199 (return_desc->buffer.length - 1)); 213 200 214 - /* Return the completed template descriptor */ 201 + /* Return the completed resource template */ 215 202 216 203 *actual_return_desc = return_desc; 217 204 return_ACPI_STATUS(AE_OK);
+1 -1
drivers/acpi/namespace/nsxfeval.c
··· 399 399 400 400 /* Parameter validation */ 401 401 402 - if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) { 402 + if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) { 403 403 return_ACPI_STATUS(AE_BAD_PARAMETER); 404 404 } 405 405
+111 -140
drivers/acpi/resources/rscalc.c
··· 299 299 300 300 /* Point to the next object */ 301 301 302 - resource = ACPI_PTR_ADD(struct acpi_resource, 303 - resource, resource->length); 302 + resource = 303 + ACPI_PTR_ADD(struct acpi_resource, resource, 304 + resource->length); 304 305 } 305 306 306 - /* Did not find an END_TAG descriptor */ 307 + /* Did not find an end_tag resource descriptor */ 307 308 308 - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 309 + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 309 310 } 310 311 311 312 /******************************************************************************* ··· 329 328 acpi_rs_get_list_length(u8 * aml_buffer, 330 329 u32 aml_buffer_length, acpi_size * size_needed) 331 330 { 331 + acpi_status status; 332 + u8 *end_aml; 332 333 u8 *buffer; 333 - struct acpi_resource_info *resource_info; 334 334 u32 buffer_size = 0; 335 - u32 bytes_parsed = 0; 336 - u8 resource_type; 337 335 u16 temp16; 338 336 u16 resource_length; 339 - u16 header_length; 340 337 u32 extra_struct_bytes; 338 + u8 resource_index; 339 + u8 minimum_aml_resource_length; 341 340 342 341 ACPI_FUNCTION_TRACE("rs_get_list_length"); 343 342 344 - while (bytes_parsed < aml_buffer_length) { 345 - /* The next byte in the stream is the resource descriptor type */ 343 + end_aml = aml_buffer + aml_buffer_length; 346 344 347 - resource_type = acpi_ut_get_resource_type(aml_buffer); 345 + /* Walk the list of AML resource descriptors */ 348 346 349 - /* Get the base stream size and structure sizes for the descriptor */ 347 + while (aml_buffer < end_aml) { 348 + /* Validate the Resource Type and Resource Length */ 350 349 351 - resource_info = acpi_rs_get_resource_info(resource_type); 352 - if (!resource_info) { 353 - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 350 + status = acpi_ut_validate_resource(aml_buffer, &resource_index); 351 + if (ACPI_FAILURE(status)) { 352 + return_ACPI_STATUS(status); 354 353 } 355 354 356 - /* Get the Length field from the input resource descriptor */ 355 + /* Get the resource length and base (minimum) AML size */ 357 356 358 357 resource_length = acpi_ut_get_resource_length(aml_buffer); 358 + minimum_aml_resource_length = 359 + acpi_gbl_resource_aml_sizes[resource_index]; 359 360 360 - /* Augment the size for descriptors with optional fields */ 361 - 361 + /* 362 + * Augment the size for descriptors with optional 363 + * and/or variable length fields 364 + */ 362 365 extra_struct_bytes = 0; 366 + buffer = 367 + aml_buffer + acpi_ut_get_resource_header_length(aml_buffer); 363 368 364 - if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { 369 + switch (acpi_ut_get_resource_type(aml_buffer)) { 370 + case ACPI_RESOURCE_NAME_IRQ: 365 371 /* 366 - * Small resource descriptors 372 + * IRQ Resource: 373 + * Get the number of bits set in the 16-bit IRQ mask 367 374 */ 368 - header_length = 369 - sizeof(struct aml_resource_small_header); 370 - buffer = aml_buffer + header_length; 375 + ACPI_MOVE_16_TO_16(&temp16, buffer); 376 + extra_struct_bytes = 377 + acpi_rs_count_set_bits(temp16) * sizeof(u32); 378 + break; 371 379 372 - switch (resource_type) { 373 - case ACPI_RESOURCE_NAME_IRQ: 374 - /* 375 - * IRQ Resource: 376 - * Get the number of bits set in the IRQ word 377 - */ 378 - ACPI_MOVE_16_TO_16(&temp16, buffer); 379 - extra_struct_bytes = 380 - (acpi_rs_count_set_bits(temp16) * 381 - sizeof(u32)); 382 - break; 383 - 384 - case ACPI_RESOURCE_NAME_DMA: 385 - /* 386 - * DMA Resource: 387 - * Get the number of bits set in the DMA channels byte 388 - */ 389 - ACPI_MOVE_16_TO_16(&temp16, buffer); 390 - extra_struct_bytes = 391 - (acpi_rs_count_set_bits(temp16) * 392 - sizeof(u32)); 393 - break; 394 - 395 - case ACPI_RESOURCE_NAME_VENDOR_SMALL: 396 - /* 397 - * Vendor Specific Resource: 398 - * Ensure a 32-bit boundary for the structure 399 - */ 400 - extra_struct_bytes = 401 - ACPI_ROUND_UP_to_32_bITS(resource_length); 402 - break; 403 - 404 - case ACPI_RESOURCE_NAME_END_TAG: 405 - /* 406 - * End Tag: 407 - * Terminate the loop now 408 - */ 409 - aml_buffer_length = bytes_parsed; 410 - break; 411 - 412 - default: 413 - break; 414 - } 415 - } else { 380 + case ACPI_RESOURCE_NAME_DMA: 416 381 /* 417 - * Large resource descriptors 382 + * DMA Resource: 383 + * Get the number of bits set in the 8-bit DMA mask 418 384 */ 419 - header_length = 420 - sizeof(struct aml_resource_large_header); 421 - buffer = aml_buffer + header_length; 385 + extra_struct_bytes = 386 + acpi_rs_count_set_bits(*buffer) * sizeof(u32); 387 + break; 422 388 423 - switch (resource_type) { 424 - case ACPI_RESOURCE_NAME_VENDOR_LARGE: 425 - /* 426 - * Vendor Defined Resource: 427 - * Add vendor data and ensure a 32-bit boundary for the structure 428 - */ 429 - extra_struct_bytes = 430 - ACPI_ROUND_UP_to_32_bITS(resource_length); 431 - break; 389 + case ACPI_RESOURCE_NAME_VENDOR_SMALL: 390 + /* 391 + * Vendor Resource: 392 + * Ensure a 32-bit boundary for the structure 393 + */ 394 + extra_struct_bytes = 395 + ACPI_ROUND_UP_to_32_bITS(resource_length) - 396 + resource_length; 397 + break; 432 398 433 - case ACPI_RESOURCE_NAME_ADDRESS32: 434 - case ACPI_RESOURCE_NAME_ADDRESS16: 435 - /* 436 - * 32-Bit or 16-bit Address Resource: 437 - * Add the size of any optional data (resource_source) 438 - */ 439 - extra_struct_bytes = 440 - acpi_rs_stream_option_length 441 - (resource_length, 442 - resource_info-> 443 - minimum_aml_resource_length); 444 - break; 399 + case ACPI_RESOURCE_NAME_END_TAG: 400 + /* 401 + * End Tag: This is the normal exit 402 + */ 403 + *size_needed = buffer_size; 404 + return_ACPI_STATUS(AE_OK); 445 405 446 - case ACPI_RESOURCE_NAME_EXTENDED_IRQ: 447 - /* 448 - * Extended IRQ: 449 - * Point past the interrupt_vector_flags to get the 450 - * interrupt_table_length. 451 - */ 452 - buffer++; 406 + case ACPI_RESOURCE_NAME_VENDOR_LARGE: 407 + /* 408 + * Vendor Resource: 409 + * Add vendor data and ensure a 32-bit boundary for the structure 410 + */ 411 + extra_struct_bytes = 412 + ACPI_ROUND_UP_to_32_bITS(resource_length) - 413 + resource_length; 414 + break; 453 415 454 - /* 455 - * Add 4 bytes for each additional interrupt. Note: at least one 456 - * interrupt is required and is included in the minimum 457 - * descriptor size 458 - */ 459 - extra_struct_bytes = 460 - ((*buffer - 1) * sizeof(u32)); 416 + case ACPI_RESOURCE_NAME_ADDRESS32: 417 + case ACPI_RESOURCE_NAME_ADDRESS16: 418 + /* 419 + * 32-Bit or 16-bit Address Resource: 420 + * Add the size of any optional data (resource_source) 421 + */ 422 + extra_struct_bytes = 423 + acpi_rs_stream_option_length(resource_length, 424 + minimum_aml_resource_length); 425 + break; 461 426 462 - /* Add the size of any optional data (resource_source) */ 427 + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: 428 + /* 429 + * Extended IRQ: 430 + * Point past the interrupt_vector_flags to get the 431 + * interrupt_table_length. 432 + */ 433 + buffer++; 463 434 464 - extra_struct_bytes += 465 - acpi_rs_stream_option_length(resource_length 466 - - 467 - extra_struct_bytes, 468 - resource_info-> 469 - minimum_aml_resource_length); 470 - break; 435 + extra_struct_bytes = 436 + /* 437 + * Add 4 bytes for each additional interrupt. Note: at 438 + * least one interrupt is required and is included in 439 + * the minimum descriptor size 440 + */ 441 + ((*buffer - 1) * sizeof(u32)) + 442 + /* Add the size of any optional data (resource_source) */ 443 + acpi_rs_stream_option_length(resource_length - 444 + extra_struct_bytes, 445 + minimum_aml_resource_length); 446 + break; 471 447 472 - case ACPI_RESOURCE_NAME_ADDRESS64: 473 - /* 474 - * 64-Bit Address Resource: 475 - * Add the size of any optional data (resource_source) 476 - * Ensure a 64-bit boundary for the structure 477 - */ 478 - extra_struct_bytes = 479 - ACPI_ROUND_UP_to_64_bITS 480 - (acpi_rs_stream_option_length 481 - (resource_length, 482 - resource_info-> 483 - minimum_aml_resource_length)); 484 - break; 448 + case ACPI_RESOURCE_NAME_ADDRESS64: 449 + /* 450 + * 64-Bit Address Resource: 451 + * Add the size of any optional data (resource_source) 452 + * Ensure a 64-bit boundary for the structure 453 + */ 454 + extra_struct_bytes = 455 + ACPI_ROUND_UP_to_64_bITS 456 + (acpi_rs_stream_option_length 457 + (resource_length, minimum_aml_resource_length)); 458 + break; 485 459 486 - default: 487 - break; 488 - } 460 + default: 461 + break; 489 462 } 490 463 491 464 /* Update the required buffer size for the internal descriptor structs */ 492 465 493 - temp16 = 494 - (u16) (resource_info->minimum_internal_struct_length + 495 - extra_struct_bytes); 466 + temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + 467 + extra_struct_bytes); 496 468 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); 497 469 498 470 /* 499 - * Update byte count and point to the next resource within the stream 471 + * Point to the next resource within the stream 500 472 * using the size of the header plus the length contained in the header 501 473 */ 502 - temp16 = (u16) (header_length + resource_length); 503 - bytes_parsed += temp16; 504 - aml_buffer += temp16; 474 + aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); 505 475 } 506 476 507 - /* This is the data the caller needs */ 477 + /* Did not find an end_tag resource descriptor */ 508 478 509 - *size_needed = buffer_size; 510 - return_ACPI_STATUS(AE_OK); 479 + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 511 480 } 512 481 513 482 /*******************************************************************************
+37 -33
drivers/acpi/resources/rsdump.c
··· 324 324 325 325 static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { 326 326 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), 327 - "Resource Type", "Memory Range"}, 327 + "Resource Type", (void *)"Memory Range"}, 328 328 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), 329 329 "Write Protect", acpi_gbl_RWdecode}, 330 330 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), ··· 337 337 338 338 static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { 339 339 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), 340 - "Resource Type", "I/O Range"}, 340 + "Resource Type", (void *)"I/O Range"}, 341 341 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), 342 342 "Range Type", acpi_gbl_RNGdecode}, 343 343 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), ··· 372 372 static void 373 373 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) 374 374 { 375 - void *target = NULL; 376 - void *previous_target; 375 + u8 *target = NULL; 376 + u8 *previous_target; 377 377 char *name; 378 378 u8 count; 379 379 ··· 399 399 /* Strings */ 400 400 401 401 case ACPI_RSD_LITERAL: 402 - acpi_rs_out_string(name, (char *)table->pointer); 402 + acpi_rs_out_string(name, 403 + ACPI_CAST_PTR(char, table->pointer)); 403 404 break; 404 405 405 406 case ACPI_RSD_STRING: 406 - acpi_rs_out_string(name, (char *)target); 407 + acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); 407 408 break; 408 409 409 410 /* Data items, 8/16/32/64 bit */ 410 411 411 412 case ACPI_RSD_UINT8: 412 - acpi_rs_out_integer8(name, *(u8 *) target); 413 + acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target)); 413 414 break; 414 415 415 416 case ACPI_RSD_UINT16: 416 - acpi_rs_out_integer16(name, *(u16 *) target); 417 + acpi_rs_out_integer16(name, 418 + *ACPI_CAST_PTR(u16, target)); 417 419 break; 418 420 419 421 case ACPI_RSD_UINT32: 420 - acpi_rs_out_integer32(name, *(u32 *) target); 422 + acpi_rs_out_integer32(name, 423 + *ACPI_CAST_PTR(u32, target)); 421 424 break; 422 425 423 426 case ACPI_RSD_UINT64: 424 - acpi_rs_out_integer64(name, *(u64 *) target); 427 + acpi_rs_out_integer64(name, 428 + *ACPI_CAST_PTR(u64, target)); 425 429 break; 426 430 427 431 /* Flags: 1-bit and 2-bit flags supported */ 428 432 429 433 case ACPI_RSD_1BITFLAG: 430 - acpi_rs_out_string(name, (char *) 431 - ((const char **)table-> 432 - pointer)[(*(u8 *) target) & 0x01]); 434 + acpi_rs_out_string(name, ACPI_CAST_PTR(char, 435 + table-> 436 + pointer[*target & 437 + 0x01])); 433 438 break; 434 439 435 440 case ACPI_RSD_2BITFLAG: 436 - acpi_rs_out_string(name, (char *) 437 - ((const char **)table-> 438 - pointer)[(*(u8 *) target) & 0x03]); 441 + acpi_rs_out_string(name, ACPI_CAST_PTR(char, 442 + table-> 443 + pointer[*target & 444 + 0x03])); 439 445 break; 440 446 441 447 case ACPI_RSD_SHORTLIST: ··· 451 445 */ 452 446 if (previous_target) { 453 447 acpi_rs_out_title(name); 454 - acpi_rs_dump_short_byte_list(* 455 - ((u8 *) 456 - previous_target), 457 - (u8 *) target); 448 + acpi_rs_dump_short_byte_list(*previous_target, 449 + target); 458 450 } 459 451 break; 460 452 ··· 462 458 * Note: The list length is obtained from the previous table entry 463 459 */ 464 460 if (previous_target) { 465 - acpi_rs_dump_byte_list(* 466 - ((u16 *) 467 - previous_target), 468 - (u8 *) target); 461 + acpi_rs_dump_byte_list(*ACPI_CAST_PTR 462 + (u16, previous_target), 463 + target); 469 464 } 470 465 break; 471 466 ··· 474 471 * Note: The list length is obtained from the previous table entry 475 472 */ 476 473 if (previous_target) { 477 - acpi_rs_dump_dword_list(* 478 - ((u8 *) 479 - previous_target), 480 - (u32 *) target); 474 + acpi_rs_dump_dword_list(*previous_target, 475 + ACPI_CAST_PTR(u32, 476 + target)); 481 477 } 482 478 break; 483 479 ··· 484 482 /* 485 483 * Common flags for all Address resources 486 484 */ 487 - acpi_rs_dump_address_common((union acpi_resource_data *) 488 - target); 485 + acpi_rs_dump_address_common(ACPI_CAST_PTR 486 + (union acpi_resource_data, 487 + target)); 489 488 break; 490 489 491 490 case ACPI_RSD_SOURCE: 492 491 /* 493 492 * Optional resource_source for Address resources 494 493 */ 495 - acpi_rs_dump_resource_source((struct 496 - acpi_resource_source *) 497 - target); 494 + acpi_rs_dump_resource_source(ACPI_CAST_PTR 495 + (struct 496 + acpi_resource_source, 497 + target)); 498 498 break; 499 499 500 500 default:
+37 -60
drivers/acpi/resources/rsinfo.c
··· 80 80 81 81 /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ 82 82 83 - struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { 83 + struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = { 84 + /* Small descriptors */ 85 + 84 86 NULL, /* 0x00, Reserved */ 85 87 NULL, /* 0x01, Reserved */ 86 88 NULL, /* 0x02, Reserved */ ··· 98 96 NULL, /* 0x0C, Reserved */ 99 97 NULL, /* 0x0D, Reserved */ 100 98 acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ 101 - acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ 102 - }; 99 + acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ 103 100 104 - struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = { 101 + /* Large descriptors */ 102 + 105 103 NULL, /* 0x00, Reserved */ 106 104 acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ 107 105 acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ ··· 140 138 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 141 139 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 142 140 }; 143 - 144 141 #endif 145 142 #endif /* ACPI_FUTURE_USAGE */ 146 143 /* ··· 167 166 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 168 167 }; 169 168 170 - /* Macros used in the tables below */ 169 + const u8 acpi_gbl_resource_struct_sizes[] = { 170 + /* Small descriptors */ 171 171 172 - #define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) 173 - #define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) 172 + 0, 173 + 0, 174 + 0, 175 + 0, 176 + ACPI_RS_SIZE(struct acpi_resource_irq), 177 + ACPI_RS_SIZE(struct acpi_resource_dma), 178 + ACPI_RS_SIZE(struct acpi_resource_start_dependent), 179 + ACPI_RS_SIZE_MIN, 180 + ACPI_RS_SIZE(struct acpi_resource_io), 181 + ACPI_RS_SIZE(struct acpi_resource_fixed_io), 182 + 0, 183 + 0, 184 + 0, 185 + 0, 186 + ACPI_RS_SIZE(struct acpi_resource_vendor), 187 + ACPI_RS_SIZE_MIN, 174 188 175 - /* 176 - * Base sizes of resource descriptors, both the AML stream resource length 177 - * (minus size of header and length fields),and the size of the internal 178 - * struct representation. 179 - */ 180 - struct acpi_resource_info acpi_gbl_sm_resource_info[] = { 181 - {0, 0, 0}, 182 - {0, 0, 0}, 183 - {0, 0, 0}, 184 - {0, 0, 0}, 185 - {2, ACPI_RSMALL(struct aml_resource_irq), 186 - ACPI_RS_SIZE(struct acpi_resource_irq)}, 187 - {0, ACPI_RSMALL(struct aml_resource_dma), 188 - ACPI_RS_SIZE(struct acpi_resource_dma)}, 189 - {2, ACPI_RSMALL(struct aml_resource_start_dependent), 190 - ACPI_RS_SIZE(struct acpi_resource_start_dependent)}, 191 - {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN}, 192 - {0, ACPI_RSMALL(struct aml_resource_io), 193 - ACPI_RS_SIZE(struct acpi_resource_io)}, 194 - {0, ACPI_RSMALL(struct aml_resource_fixed_io), 195 - ACPI_RS_SIZE(struct acpi_resource_fixed_io)}, 196 - {0, 0, 0}, 197 - {0, 0, 0}, 198 - {0, 0, 0}, 199 - {0, 0, 0}, 200 - {1, ACPI_RSMALL(struct aml_resource_vendor_small), 201 - ACPI_RS_SIZE(struct acpi_resource_vendor)}, 202 - {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN} 203 - }; 189 + /* Large descriptors */ 204 190 205 - struct acpi_resource_info acpi_gbl_lg_resource_info[] = { 206 - {0, 0, 0}, 207 - {0, ACPI_RLARGE(struct aml_resource_memory24), 208 - ACPI_RS_SIZE(struct acpi_resource_memory24)}, 209 - {0, ACPI_RLARGE(struct aml_resource_generic_register), 210 - ACPI_RS_SIZE(struct acpi_resource_generic_register)}, 211 - {0, 0, 0}, 212 - {1, ACPI_RLARGE(struct aml_resource_vendor_large), 213 - ACPI_RS_SIZE(struct acpi_resource_vendor)}, 214 - {0, ACPI_RLARGE(struct aml_resource_memory32), 215 - ACPI_RS_SIZE(struct acpi_resource_memory32)}, 216 - {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), 217 - ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)}, 218 - {1, ACPI_RLARGE(struct aml_resource_address32), 219 - ACPI_RS_SIZE(struct acpi_resource_address32)}, 220 - {1, ACPI_RLARGE(struct aml_resource_address16), 221 - ACPI_RS_SIZE(struct acpi_resource_address16)}, 222 - {1, ACPI_RLARGE(struct aml_resource_extended_irq), 223 - ACPI_RS_SIZE(struct acpi_resource_extended_irq)}, 224 - {1, ACPI_RLARGE(struct aml_resource_address64), 225 - ACPI_RS_SIZE(struct acpi_resource_address64)}, 226 - {0, ACPI_RLARGE(struct aml_resource_extended_address64), 227 - ACPI_RS_SIZE(struct acpi_resource_extended_address64)} 191 + 0, 192 + ACPI_RS_SIZE(struct acpi_resource_memory24), 193 + ACPI_RS_SIZE(struct acpi_resource_generic_register), 194 + 0, 195 + ACPI_RS_SIZE(struct acpi_resource_vendor), 196 + ACPI_RS_SIZE(struct acpi_resource_memory32), 197 + ACPI_RS_SIZE(struct acpi_resource_fixed_memory32), 198 + ACPI_RS_SIZE(struct acpi_resource_address32), 199 + ACPI_RS_SIZE(struct acpi_resource_address16), 200 + ACPI_RS_SIZE(struct acpi_resource_extended_irq), 201 + ACPI_RS_SIZE(struct acpi_resource_address64), 202 + ACPI_RS_SIZE(struct acpi_resource_extended_address64) 228 203 };
+32 -163
drivers/acpi/resources/rslist.c
··· 47 47 #define _COMPONENT ACPI_RESOURCES 48 48 ACPI_MODULE_NAME("rslist") 49 49 50 - /* Local prototypes */ 51 - static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 52 - resource_type); 53 - 54 - static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); 55 - 56 - /******************************************************************************* 57 - * 58 - * FUNCTION: acpi_rs_validate_resource_length 59 - * 60 - * PARAMETERS: Aml - Pointer to the AML resource descriptor 61 - * 62 - * RETURN: Status - AE_OK if the resource length appears valid 63 - * 64 - * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must 65 - * have the exact length; variable-length descriptors must be 66 - * at least as long as the minimum. Certain Small descriptors 67 - * can vary in size by at most one byte. 68 - * 69 - ******************************************************************************/ 70 - 71 - static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) 72 - { 73 - struct acpi_resource_info *resource_info; 74 - u16 minimum_aml_resource_length; 75 - u16 resource_length; 76 - 77 - ACPI_FUNCTION_ENTRY(); 78 - 79 - /* Get the size and type info about this resource descriptor */ 80 - 81 - resource_info = 82 - acpi_rs_get_resource_info(aml->small_header.descriptor_type); 83 - if (!resource_info) { 84 - return (AE_AML_INVALID_RESOURCE_TYPE); 85 - } 86 - 87 - resource_length = acpi_ut_get_resource_length(aml); 88 - minimum_aml_resource_length = 89 - resource_info->minimum_aml_resource_length; 90 - 91 - /* Validate based upon the type of resource, fixed length or variable */ 92 - 93 - if (resource_info->length_type == ACPI_FIXED_LENGTH) { 94 - /* Fixed length resource, length must match exactly */ 95 - 96 - if (resource_length != minimum_aml_resource_length) { 97 - return (AE_AML_BAD_RESOURCE_LENGTH); 98 - } 99 - } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { 100 - /* Variable length resource, must be at least the minimum */ 101 - 102 - if (resource_length < minimum_aml_resource_length) { 103 - return (AE_AML_BAD_RESOURCE_LENGTH); 104 - } 105 - } else { 106 - /* Small variable length resource, allowed to be (Min) or (Min-1) */ 107 - 108 - if ((resource_length > minimum_aml_resource_length) || 109 - (resource_length < (minimum_aml_resource_length - 1))) { 110 - return (AE_AML_BAD_RESOURCE_LENGTH); 111 - } 112 - } 113 - 114 - return (AE_OK); 115 - } 116 - 117 - /******************************************************************************* 118 - * 119 - * FUNCTION: acpi_rs_get_conversion_info 120 - * 121 - * PARAMETERS: resource_type - Byte 0 of a resource descriptor 122 - * 123 - * RETURN: Pointer to the resource conversion info table 124 - * 125 - * DESCRIPTION: Get the conversion table associated with this resource type 126 - * 127 - ******************************************************************************/ 128 - 129 - static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) 130 - { 131 - ACPI_FUNCTION_ENTRY(); 132 - 133 - /* Determine if this is a small or large resource */ 134 - 135 - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 136 - /* Large Resource Type -- bits 6:0 contain the name */ 137 - 138 - if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 139 - return (NULL); 140 - } 141 - 142 - return (acpi_gbl_lg_get_resource_dispatch[(resource_type & 143 - ACPI_RESOURCE_NAME_LARGE_MASK)]); 144 - } else { 145 - /* Small Resource Type -- bits 6:3 contain the name */ 146 - 147 - return (acpi_gbl_sm_get_resource_dispatch[((resource_type & 148 - ACPI_RESOURCE_NAME_SMALL_MASK) 149 - >> 3)]); 150 - } 151 - } 152 - 153 50 /******************************************************************************* 154 51 * 155 52 * FUNCTION: acpi_rs_convert_aml_to_resources 156 53 * 157 - * PARAMETERS: aml_buffer - Pointer to the resource byte stream 158 - * aml_buffer_length - Length of aml_buffer 54 + * PARAMETERS: Aml - Pointer to the resource byte stream 55 + * aml_length - Length of Aml 159 56 * output_buffer - Pointer to the buffer that will 160 57 * contain the output structures 161 58 * ··· 62 165 * linked list of resources in the caller's output buffer 63 166 * 64 167 ******************************************************************************/ 65 - 66 168 acpi_status 67 - acpi_rs_convert_aml_to_resources(u8 * aml_buffer, 68 - u32 aml_buffer_length, u8 * output_buffer) 169 + acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) 69 170 { 70 - u8 *buffer = output_buffer; 171 + struct acpi_resource *resource = (void *)output_buffer; 71 172 acpi_status status; 72 - acpi_size bytes_parsed = 0; 73 - struct acpi_resource *resource; 74 - acpi_rsdesc_size descriptor_length; 75 - struct acpi_rsconvert_info *info; 173 + u8 resource_index; 174 + u8 *end_aml; 76 175 77 176 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); 78 177 178 + end_aml = aml + aml_length; 179 + 79 180 /* Loop until end-of-buffer or an end_tag is found */ 80 181 81 - while (bytes_parsed < aml_buffer_length) { 82 - /* Get the conversion table associated with this Descriptor Type */ 182 + while (aml < end_aml) { 183 + /* Validate the Resource Type and Resource Length */ 83 184 84 - info = acpi_rs_get_conversion_info(*aml_buffer); 85 - if (!info) { 86 - /* No table indicates an invalid resource type */ 87 - 88 - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 89 - } 90 - 91 - descriptor_length = acpi_ut_get_descriptor_length(aml_buffer); 92 - 93 - /* 94 - * Perform limited validation of the resource length, based upon 95 - * what we know about the resource type 96 - */ 97 - status = 98 - acpi_rs_validate_resource_length(ACPI_CAST_PTR 99 - (union aml_resource, 100 - aml_buffer)); 185 + status = acpi_ut_validate_resource(aml, &resource_index); 101 186 if (ACPI_FAILURE(status)) { 102 187 return_ACPI_STATUS(status); 103 188 } ··· 87 208 /* Convert the AML byte stream resource to a local resource struct */ 88 209 89 210 status = 90 - acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR 91 - (struct acpi_resource, 92 - buffer), 211 + acpi_rs_convert_aml_to_resource(resource, 93 212 ACPI_CAST_PTR(union 94 213 aml_resource, 95 - aml_buffer), 96 - info); 214 + aml), 215 + acpi_gbl_get_resource_dispatch 216 + [resource_index]); 97 217 if (ACPI_FAILURE(status)) { 98 - ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); 218 + ACPI_REPORT_ERROR(("Could not convert AML resource (Type %X) to resource, %s\n", *aml, acpi_format_exception(status))); 99 219 return_ACPI_STATUS(status); 100 220 } 101 221 102 - /* Set the aligned length of the new resource descriptor */ 103 - 104 - resource = ACPI_CAST_PTR(struct acpi_resource, buffer); 105 - resource->length = 106 - (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length); 107 - 108 222 /* Normal exit on completion of an end_tag resource descriptor */ 109 223 110 - if (acpi_ut_get_resource_type(aml_buffer) == 224 + if (acpi_ut_get_resource_type(aml) == 111 225 ACPI_RESOURCE_NAME_END_TAG) { 112 226 return_ACPI_STATUS(AE_OK); 113 227 } 114 228 115 - /* Update counter and point to the next input resource */ 229 + /* Point to the next input AML resource */ 116 230 117 - bytes_parsed += descriptor_length; 118 - aml_buffer += descriptor_length; 231 + aml += acpi_ut_get_descriptor_length(aml); 119 232 120 233 /* Point to the next structure in the output buffer */ 121 234 122 - buffer += resource->length; 235 + resource = 236 + ACPI_PTR_ADD(struct acpi_resource, resource, 237 + resource->length); 123 238 } 124 239 125 - /* Completed buffer, but did not find an end_tag resource descriptor */ 240 + /* Did not find an end_tag resource descriptor */ 126 241 127 242 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 128 243 } ··· 144 271 acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, 145 272 acpi_size aml_size_needed, u8 * output_buffer) 146 273 { 147 - u8 *aml_buffer = output_buffer; 148 - u8 *end_aml_buffer = output_buffer + aml_size_needed; 274 + u8 *aml = output_buffer; 275 + u8 *end_aml = output_buffer + aml_size_needed; 149 276 acpi_status status; 150 277 151 278 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); 152 279 153 280 /* Walk the resource descriptor list, convert each descriptor */ 154 281 155 - while (aml_buffer < end_aml_buffer) { 156 - /* Validate the Resource Type */ 282 + while (aml < end_aml) { 283 + /* Validate the (internal) Resource Type */ 157 284 158 285 if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 159 286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ··· 167 294 status = acpi_rs_convert_resource_to_aml(resource, 168 295 ACPI_CAST_PTR(union 169 296 aml_resource, 170 - aml_buffer), 297 + aml), 171 298 acpi_gbl_set_resource_dispatch 172 299 [resource->type]); 173 300 if (ACPI_FAILURE(status)) { ··· 178 305 /* Perform final sanity check on the new AML resource descriptor */ 179 306 180 307 status = 181 - acpi_rs_validate_resource_length(ACPI_CAST_PTR 182 - (union aml_resource, 183 - aml_buffer)); 308 + acpi_ut_validate_resource(ACPI_CAST_PTR 309 + (union aml_resource, aml), NULL); 184 310 if (ACPI_FAILURE(status)) { 185 311 return_ACPI_STATUS(status); 186 312 } ··· 194 322 195 323 /* 196 324 * Extract the total length of the new descriptor and set the 197 - * aml_buffer to point to the next (output) resource descriptor 325 + * Aml to point to the next (output) resource descriptor 198 326 */ 199 - aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); 327 + aml += acpi_ut_get_descriptor_length(aml); 200 328 201 329 /* Point to the next input resource descriptor */ 202 330 203 331 resource = 204 332 ACPI_PTR_ADD(struct acpi_resource, resource, 205 333 resource->length); 206 - 207 - /* Check for end-of-list, normal exit */ 208 - 209 334 } 210 335 211 336 /* Completed buffer, but did not find an end_tag resource descriptor */
+22 -68
drivers/acpi/resources/rsutils.c
··· 65 65 acpi_native_uint i; 66 66 u8 bit_count; 67 67 68 + ACPI_FUNCTION_ENTRY(); 69 + 68 70 /* Decode the mask bits */ 69 71 70 72 for (i = 0, bit_count = 0; mask; i++) { ··· 99 97 acpi_native_uint i; 100 98 u16 mask; 101 99 100 + ACPI_FUNCTION_ENTRY(); 101 + 102 102 /* Encode the list into a single bitmask */ 103 103 104 104 for (i = 0, mask = 0; i < count; i++) { ··· 131 127 acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) 132 128 { 133 129 acpi_native_uint i; 130 + 131 + ACPI_FUNCTION_ENTRY(); 134 132 135 133 /* One move per item */ 136 134 ··· 174 168 175 169 /******************************************************************************* 176 170 * 177 - * FUNCTION: acpi_rs_get_resource_info 178 - * 179 - * PARAMETERS: resource_type - Byte 0 of a resource descriptor 180 - * 181 - * RETURN: Pointer to the resource conversion handler 182 - * 183 - * DESCRIPTION: Extract the Resource Type/Name from the first byte of 184 - * a resource descriptor. 185 - * 186 - ******************************************************************************/ 187 - 188 - struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) 189 - { 190 - struct acpi_resource_info *size_info; 191 - 192 - ACPI_FUNCTION_ENTRY(); 193 - 194 - /* Determine if this is a small or large resource */ 195 - 196 - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 197 - /* Large Resource Type -- bits 6:0 contain the name */ 198 - 199 - if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 200 - return (NULL); 201 - } 202 - 203 - size_info = &acpi_gbl_lg_resource_info[(resource_type & 204 - ACPI_RESOURCE_NAME_LARGE_MASK)]; 205 - } else { 206 - /* Small Resource Type -- bits 6:3 contain the name */ 207 - 208 - size_info = &acpi_gbl_sm_resource_info[((resource_type & 209 - ACPI_RESOURCE_NAME_SMALL_MASK) 210 - >> 3)]; 211 - } 212 - 213 - /* Zero entry indicates an invalid resource type */ 214 - 215 - if (!size_info->minimum_internal_struct_length) { 216 - return (NULL); 217 - } 218 - 219 - return (size_info); 220 - } 221 - 222 - /******************************************************************************* 223 - * 224 171 * FUNCTION: acpi_rs_set_resource_length 225 172 * 226 173 * PARAMETERS: total_length - Length of the AML descriptor, including ··· 197 238 198 239 ACPI_FUNCTION_ENTRY(); 199 240 200 - /* Determine if this is a small or large resource */ 241 + /* Length is the total descriptor length minus the header length */ 242 + 243 + resource_length = (acpi_rs_length) 244 + (total_length - acpi_ut_get_resource_header_length(aml)); 245 + 246 + /* Length is stored differently for large and small descriptors */ 201 247 202 248 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 203 - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 204 - 205 - resource_length = (acpi_rs_length) 206 - (total_length - sizeof(struct aml_resource_large_header)); 207 - 208 - /* Insert length into the Large descriptor length field */ 249 + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ 209 250 210 251 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, 211 252 &resource_length); 212 253 } else { 213 - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 214 - 215 - resource_length = (acpi_rs_length) 216 - (total_length - sizeof(struct aml_resource_small_header)); 217 - 218 - /* Insert length into the descriptor type byte */ 254 + /* Small descriptor -- bits 2:0 of byte 0 contain the length */ 219 255 220 256 aml->small_header.descriptor_type = (u8) 221 257 ··· 246 292 { 247 293 ACPI_FUNCTION_ENTRY(); 248 294 249 - /* Set the Descriptor Type */ 295 + /* Set the Resource Type */ 250 296 251 297 aml->small_header.descriptor_type = descriptor_type; 252 298 ··· 363 409 (char *)&aml_resource_source[1]); 364 410 365 411 return ((acpi_rs_length) total_length); 366 - } else { 367 - /* resource_source is not present */ 368 - 369 - resource_source->index = 0; 370 - resource_source->string_length = 0; 371 - resource_source->string_ptr = NULL; 372 - return (0); 373 412 } 413 + 414 + /* resource_source is not present */ 415 + 416 + resource_source->index = 0; 417 + resource_source->string_length = 0; 418 + resource_source->string_ptr = NULL; 419 + return (0); 374 420 } 375 421 376 422 /*******************************************************************************
+3 -2
drivers/acpi/utilities/Makefile
··· 2 2 # Makefile for all Linux ACPI interpreter subdirectories 3 3 # 4 4 5 - obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 6 - utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o 5 + obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 6 + utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ 7 + utstate.o utmutex.o utobject.o utcache.o utresrc.o 7 8 8 9 EXTRA_CFLAGS += $(ACPI_CFLAGS)
-148
drivers/acpi/utilities/utmisc.c
··· 43 43 44 44 #include <acpi/acpi.h> 45 45 #include <acpi/acnamesp.h> 46 - #include <acpi/amlresrc.h> 47 46 48 47 #define _COMPONENT ACPI_UTILITIES 49 48 ACPI_MODULE_NAME("utmisc") ··· 786 787 } 787 788 788 789 return ((u8) (0 - sum)); 789 - } 790 - 791 - /******************************************************************************* 792 - * 793 - * FUNCTION: acpi_ut_get_resource_type 794 - * 795 - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 796 - * 797 - * RETURN: The Resource Type with no extraneous bits (except the 798 - * Large/Small descriptor bit -- this is left alone) 799 - * 800 - * DESCRIPTION: Extract the Resource Type/Name from the first byte of 801 - * a resource descriptor. 802 - * 803 - ******************************************************************************/ 804 - 805 - u8 acpi_ut_get_resource_type(void *aml) 806 - { 807 - ACPI_FUNCTION_ENTRY(); 808 - 809 - /* 810 - * Byte 0 contains the descriptor name (Resource Type) 811 - * Determine if this is a small or large resource 812 - */ 813 - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 814 - /* Large Resource Type -- bits 6:0 contain the name */ 815 - 816 - return (*((u8 *) aml)); 817 - } else { 818 - /* Small Resource Type -- bits 6:3 contain the name */ 819 - 820 - return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); 821 - } 822 - } 823 - 824 - /******************************************************************************* 825 - * 826 - * FUNCTION: acpi_ut_get_resource_length 827 - * 828 - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 829 - * 830 - * RETURN: Byte Length 831 - * 832 - * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By 833 - * definition, this does not include the size of the descriptor 834 - * header or the length field itself. 835 - * 836 - ******************************************************************************/ 837 - 838 - u16 acpi_ut_get_resource_length(void *aml) 839 - { 840 - u16 resource_length; 841 - 842 - ACPI_FUNCTION_ENTRY(); 843 - 844 - /* 845 - * Byte 0 contains the descriptor name (Resource Type) 846 - * Determine if this is a small or large resource 847 - */ 848 - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 849 - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 850 - 851 - ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); 852 - 853 - } else { 854 - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 855 - 856 - resource_length = (u16) (*((u8 *) aml) & 857 - ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 858 - } 859 - 860 - return (resource_length); 861 - } 862 - 863 - /******************************************************************************* 864 - * 865 - * FUNCTION: acpi_ut_get_descriptor_length 866 - * 867 - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 868 - * 869 - * RETURN: Byte length 870 - * 871 - * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the 872 - * length of the descriptor header and the length field itself. 873 - * Used to walk descriptor lists. 874 - * 875 - ******************************************************************************/ 876 - 877 - u32 acpi_ut_get_descriptor_length(void *aml) 878 - { 879 - u32 descriptor_length; 880 - 881 - ACPI_FUNCTION_ENTRY(); 882 - 883 - /* First get the Resource Length (Does not include header length) */ 884 - 885 - descriptor_length = acpi_ut_get_resource_length(aml); 886 - 887 - /* Determine if this is a small or large resource */ 888 - 889 - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 890 - descriptor_length += sizeof(struct aml_resource_large_header); 891 - } else { 892 - descriptor_length += sizeof(struct aml_resource_small_header); 893 - } 894 - 895 - return (descriptor_length); 896 - } 897 - 898 - /******************************************************************************* 899 - * 900 - * FUNCTION: acpi_ut_get_resource_end_tag 901 - * 902 - * PARAMETERS: obj_desc - The resource template buffer object 903 - * 904 - * RETURN: Pointer to the end tag 905 - * 906 - * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template 907 - * 908 - ******************************************************************************/ 909 - 910 - u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) 911 - { 912 - u8 *aml; 913 - u8 *end_aml; 914 - 915 - aml = obj_desc->buffer.pointer; 916 - end_aml = aml + obj_desc->buffer.length; 917 - 918 - /* Walk the resource template, one descriptor per loop */ 919 - 920 - while (aml < end_aml) { 921 - if (acpi_ut_get_resource_type(aml) == 922 - ACPI_RESOURCE_NAME_END_TAG) { 923 - /* Found the end_tag descriptor, all done */ 924 - 925 - return (aml); 926 - } 927 - 928 - /* Point to the next resource descriptor */ 929 - 930 - aml += acpi_ut_get_resource_length(aml); 931 - } 932 - 933 - /* End tag was not found */ 934 - 935 - return (NULL); 936 790 } 937 791 938 792 /*******************************************************************************
+428
drivers/acpi/utilities/utresrc.c
··· 1 + /******************************************************************************* 2 + * 3 + * Module Name: utresrc - Resource managment utilities 4 + * 5 + ******************************************************************************/ 6 + 7 + /* 8 + * Copyright (C) 2000 - 2005, R. Byron Moore 9 + * All rights reserved. 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions, and the following disclaimer, 16 + * without modification. 17 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 + * substantially similar to the "NO WARRANTY" disclaimer below 19 + * ("Disclaimer") and any redistribution must be conditioned upon 20 + * including a substantially similar Disclaimer requirement for further 21 + * binary redistribution. 22 + * 3. Neither the names of the above-listed copyright holders nor the names 23 + * of any contributors may be used to endorse or promote products derived 24 + * from this software without specific prior written permission. 25 + * 26 + * Alternatively, this software may be distributed under the terms of the 27 + * GNU General Public License ("GPL") version 2 as published by the Free 28 + * Software Foundation. 29 + * 30 + * NO WARRANTY 31 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 + * POSSIBILITY OF SUCH DAMAGES. 42 + */ 43 + 44 + #include <acpi/acpi.h> 45 + #include <acpi/amlresrc.h> 46 + 47 + #define _COMPONENT ACPI_UTILITIES 48 + ACPI_MODULE_NAME("utmisc") 49 + 50 + /* 51 + * Base sizes of the raw AML resource descriptors, indexed by resource type. 52 + * Zero indicates a reserved (and therefore invalid) resource type. 53 + */ 54 + const u8 acpi_gbl_resource_aml_sizes[] = { 55 + /* Small descriptors */ 56 + 57 + 0, 58 + 0, 59 + 0, 60 + 0, 61 + ACPI_AML_SIZE_SMALL(struct aml_resource_irq), 62 + ACPI_AML_SIZE_SMALL(struct aml_resource_dma), 63 + ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent), 64 + ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), 65 + ACPI_AML_SIZE_SMALL(struct aml_resource_io), 66 + ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), 67 + 0, 68 + 0, 69 + 0, 70 + 0, 71 + ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small), 72 + ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag), 73 + 74 + /* Large descriptors */ 75 + 76 + 0, 77 + ACPI_AML_SIZE_LARGE(struct aml_resource_memory24), 78 + ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register), 79 + 0, 80 + ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large), 81 + ACPI_AML_SIZE_LARGE(struct aml_resource_memory32), 82 + ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32), 83 + ACPI_AML_SIZE_LARGE(struct aml_resource_address32), 84 + ACPI_AML_SIZE_LARGE(struct aml_resource_address16), 85 + ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), 86 + ACPI_AML_SIZE_LARGE(struct aml_resource_address64), 87 + ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64) 88 + }; 89 + 90 + /* 91 + * Resource types, used to validate the resource length field. 92 + * The length of fixed-length types must match exactly, variable 93 + * lengths must meet the minimum required length, etc. 94 + * Zero indicates a reserved (and therefore invalid) resource type. 95 + */ 96 + static const u8 acpi_gbl_resource_types[] = { 97 + /* Small descriptors */ 98 + 99 + 0, 100 + 0, 101 + 0, 102 + 0, 103 + ACPI_SMALL_VARIABLE_LENGTH, 104 + ACPI_FIXED_LENGTH, 105 + ACPI_SMALL_VARIABLE_LENGTH, 106 + ACPI_FIXED_LENGTH, 107 + ACPI_FIXED_LENGTH, 108 + ACPI_FIXED_LENGTH, 109 + 0, 110 + 0, 111 + 0, 112 + 0, 113 + ACPI_VARIABLE_LENGTH, 114 + ACPI_FIXED_LENGTH, 115 + 116 + /* Large descriptors */ 117 + 118 + 0, 119 + ACPI_FIXED_LENGTH, 120 + ACPI_FIXED_LENGTH, 121 + 0, 122 + ACPI_VARIABLE_LENGTH, 123 + ACPI_FIXED_LENGTH, 124 + ACPI_FIXED_LENGTH, 125 + ACPI_VARIABLE_LENGTH, 126 + ACPI_VARIABLE_LENGTH, 127 + ACPI_VARIABLE_LENGTH, 128 + ACPI_VARIABLE_LENGTH, 129 + ACPI_FIXED_LENGTH 130 + }; 131 + 132 + /******************************************************************************* 133 + * 134 + * FUNCTION: acpi_ut_validate_resource 135 + * 136 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 137 + * return_index - Where the resource index is returned. NULL 138 + * if the index is not required. 139 + * 140 + * RETURN: Status, and optionally the Index into the global resource tables 141 + * 142 + * DESCRIPTION: Validate an AML resource descriptor by checking the Resource 143 + * Type and Resource Length. Returns an index into the global 144 + * resource information/dispatch tables for later use. 145 + * 146 + ******************************************************************************/ 147 + 148 + acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) 149 + { 150 + u8 resource_type; 151 + u8 resource_index; 152 + acpi_rs_length resource_length; 153 + acpi_rs_length minimum_resource_length; 154 + 155 + ACPI_FUNCTION_ENTRY(); 156 + 157 + /* 158 + * 1) Validate the resource_type field (Byte 0) 159 + */ 160 + resource_type = *((u8 *) aml); 161 + 162 + /* 163 + * Byte 0 contains the descriptor name (Resource Type) 164 + * Examine the large/small bit in the resource header 165 + */ 166 + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { 167 + /* Verify the large resource type (name) against the max */ 168 + 169 + if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 170 + return (AE_AML_INVALID_RESOURCE_TYPE); 171 + } 172 + 173 + /* 174 + * Large Resource Type -- bits 6:0 contain the name 175 + * Translate range 0x80-0x8B to index range 0x10-0x1B 176 + */ 177 + resource_index = (u8) (resource_type - 0x70); 178 + } else { 179 + /* 180 + * Small Resource Type -- bits 6:3 contain the name 181 + * Shift range to index range 0x00-0x0F 182 + */ 183 + resource_index = (u8) 184 + ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); 185 + } 186 + 187 + /* Check validity of the resource type, zero indicates name is invalid */ 188 + 189 + if (!acpi_gbl_resource_types[resource_index]) { 190 + return (AE_AML_INVALID_RESOURCE_TYPE); 191 + } 192 + 193 + /* 194 + * 2) Validate the resource_length field. This ensures that the length 195 + * is at least reasonable, and guarantees that it is non-zero. 196 + */ 197 + resource_length = acpi_ut_get_resource_length(aml); 198 + minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; 199 + 200 + /* Validate based upon the type of resource - fixed length or variable */ 201 + 202 + switch (acpi_gbl_resource_types[resource_index]) { 203 + case ACPI_FIXED_LENGTH: 204 + 205 + /* Fixed length resource, length must match exactly */ 206 + 207 + if (resource_length != minimum_resource_length) { 208 + return (AE_AML_BAD_RESOURCE_LENGTH); 209 + } 210 + break; 211 + 212 + case ACPI_VARIABLE_LENGTH: 213 + 214 + /* Variable length resource, length must be at least the minimum */ 215 + 216 + if (resource_length < minimum_resource_length) { 217 + return (AE_AML_BAD_RESOURCE_LENGTH); 218 + } 219 + break; 220 + 221 + case ACPI_SMALL_VARIABLE_LENGTH: 222 + 223 + /* Small variable length resource, length can be (Min) or (Min-1) */ 224 + 225 + if ((resource_length > minimum_resource_length) || 226 + (resource_length < (minimum_resource_length - 1))) { 227 + return (AE_AML_BAD_RESOURCE_LENGTH); 228 + } 229 + break; 230 + 231 + default: 232 + 233 + /* Shouldn't happen (because of validation earlier), but be sure */ 234 + 235 + return (AE_AML_INVALID_RESOURCE_TYPE); 236 + } 237 + 238 + /* Optionally return the resource table index */ 239 + 240 + if (return_index) { 241 + *return_index = resource_index; 242 + } 243 + 244 + return (AE_OK); 245 + } 246 + 247 + /******************************************************************************* 248 + * 249 + * FUNCTION: acpi_ut_get_resource_type 250 + * 251 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 252 + * 253 + * RETURN: The Resource Type with no extraneous bits (except the 254 + * Large/Small descriptor bit -- this is left alone) 255 + * 256 + * DESCRIPTION: Extract the Resource Type/Name from the first byte of 257 + * a resource descriptor. 258 + * 259 + ******************************************************************************/ 260 + 261 + u8 acpi_ut_get_resource_type(void *aml) 262 + { 263 + ACPI_FUNCTION_ENTRY(); 264 + 265 + /* 266 + * Byte 0 contains the descriptor name (Resource Type) 267 + * Examine the large/small bit in the resource header 268 + */ 269 + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 270 + /* Large Resource Type -- bits 6:0 contain the name */ 271 + 272 + return (*((u8 *) aml)); 273 + } else { 274 + /* Small Resource Type -- bits 6:3 contain the name */ 275 + 276 + return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); 277 + } 278 + } 279 + 280 + /******************************************************************************* 281 + * 282 + * FUNCTION: acpi_ut_get_resource_length 283 + * 284 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 285 + * 286 + * RETURN: Byte Length 287 + * 288 + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By 289 + * definition, this does not include the size of the descriptor 290 + * header or the length field itself. 291 + * 292 + ******************************************************************************/ 293 + 294 + u16 acpi_ut_get_resource_length(void *aml) 295 + { 296 + acpi_rs_length resource_length; 297 + 298 + ACPI_FUNCTION_ENTRY(); 299 + 300 + /* 301 + * Byte 0 contains the descriptor name (Resource Type) 302 + * Examine the large/small bit in the resource header 303 + */ 304 + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 305 + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 306 + 307 + ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); 308 + 309 + } else { 310 + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 311 + 312 + resource_length = (u16) (*((u8 *) aml) & 313 + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 314 + } 315 + 316 + return (resource_length); 317 + } 318 + 319 + /******************************************************************************* 320 + * 321 + * FUNCTION: acpi_ut_get_resource_header_length 322 + * 323 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 324 + * 325 + * RETURN: Length of the AML header (depends on large/small descriptor) 326 + * 327 + * DESCRIPTION: Get the length of the header for this resource. 328 + * 329 + ******************************************************************************/ 330 + 331 + u8 acpi_ut_get_resource_header_length(void *aml) 332 + { 333 + ACPI_FUNCTION_ENTRY(); 334 + 335 + /* Examine the large/small bit in the resource header */ 336 + 337 + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 338 + return (sizeof(struct aml_resource_large_header)); 339 + } else { 340 + return (sizeof(struct aml_resource_small_header)); 341 + } 342 + } 343 + 344 + /******************************************************************************* 345 + * 346 + * FUNCTION: acpi_ut_get_descriptor_length 347 + * 348 + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 349 + * 350 + * RETURN: Byte length 351 + * 352 + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the 353 + * length of the descriptor header and the length field itself. 354 + * Used to walk descriptor lists. 355 + * 356 + ******************************************************************************/ 357 + 358 + u32 acpi_ut_get_descriptor_length(void *aml) 359 + { 360 + ACPI_FUNCTION_ENTRY(); 361 + 362 + /* 363 + * Get the Resource Length (does not include header length) and add 364 + * the header length (depends on if this is a small or large resource) 365 + */ 366 + return (acpi_ut_get_resource_length(aml) + 367 + acpi_ut_get_resource_header_length(aml)); 368 + } 369 + 370 + /******************************************************************************* 371 + * 372 + * FUNCTION: acpi_ut_get_resource_end_tag 373 + * 374 + * PARAMETERS: obj_desc - The resource template buffer object 375 + * 376 + * RETURN: Pointer to the end tag 377 + * 378 + * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template 379 + * 380 + ******************************************************************************/ 381 + 382 + acpi_status 383 + acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, 384 + u8 ** end_tag) 385 + { 386 + acpi_status status; 387 + u8 *aml; 388 + u8 *end_aml; 389 + 390 + ACPI_FUNCTION_TRACE("ut_get_resource_end_tag"); 391 + 392 + /* Get start and end pointers */ 393 + 394 + aml = obj_desc->buffer.pointer; 395 + end_aml = aml + obj_desc->buffer.length; 396 + 397 + /* Walk the resource template, one descriptor per iteration */ 398 + 399 + while (aml < end_aml) { 400 + /* Validate the Resource Type and Resource Length */ 401 + 402 + status = acpi_ut_validate_resource(aml, NULL); 403 + if (ACPI_FAILURE(status)) { 404 + return_ACPI_STATUS(status); 405 + } 406 + 407 + /* end_tag resource indicates the end of the resource template */ 408 + 409 + if (acpi_ut_get_resource_type(aml) == 410 + ACPI_RESOURCE_NAME_END_TAG) { 411 + /* Return the pointer to the end_tag */ 412 + 413 + *end_tag = aml; 414 + return_ACPI_STATUS(AE_OK); 415 + } 416 + 417 + /* 418 + * Point to the next resource descriptor in the AML buffer. The 419 + * descriptor length is guaranteed to be non-zero by resource 420 + * validation above. 421 + */ 422 + aml += acpi_ut_get_descriptor_length(aml); 423 + } 424 + 425 + /* Did not find an end_tag resource descriptor */ 426 + 427 + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 428 + }
+1 -1
drivers/acpi/utilities/utstate.c
··· 63 63 acpi_ut_create_pkg_state_and_push(void *internal_object, 64 64 void *external_object, 65 65 u16 index, 66 - union acpi_generic_state ** state_list) 66 + union acpi_generic_state **state_list) 67 67 { 68 68 union acpi_generic_state *state; 69 69
+38 -14
drivers/acpi/utilities/utxface.c
··· 178 178 /* 179 179 * Initialize ACPI Event handling (Fixed and General Purpose) 180 180 * 181 - * NOTE: We must have the hardware AND events initialized before we can 182 - * execute ANY control methods SAFELY. Any control method can require 183 - * ACPI hardware support, so the hardware MUST be initialized before 184 - * execution! 181 + * Note1: We must have the hardware and events initialized before we can 182 + * execute any control methods safely. Any control method can require 183 + * ACPI hardware support, so the hardware must be fully initialized before 184 + * any method execution! 185 + * 186 + * Note2: Fixed events are initialized and enabled here. GPEs are 187 + * initialized, but cannot be enabled until after the hardware is 188 + * completely initialized (SCI and global_lock activated) 185 189 */ 186 190 if (!(flags & ACPI_NO_EVENT_INIT)) { 187 191 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, ··· 197 193 } 198 194 } 199 195 200 - /* Install the SCI handler and Global Lock handler */ 201 - 196 + /* 197 + * Install the SCI handler and Global Lock handler. This completes the 198 + * hardware initialization. 199 + */ 202 200 if (!(flags & ACPI_NO_HANDLER_INIT)) { 203 201 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 204 202 "[Init] Installing SCI/GL handlers\n")); ··· 208 202 status = acpi_ev_install_xrupt_handlers(); 209 203 if (ACPI_FAILURE(status)) { 210 204 return_ACPI_STATUS(status); 205 + } 206 + } 207 + 208 + /* 209 + * Complete the GPE initialization for the GPE blocks defined in the FADT 210 + * (GPE block 0 and 1). 211 + * 212 + * Note1: This is where the _PRW methods are executed for the GPEs. These 213 + * methods can only be executed after the SCI and Global Lock handlers are 214 + * installed and initialized. 215 + * 216 + * Note2: Currently, there seems to be no need to run the _REG methods 217 + * before execution of the _PRW methods and enabling of the GPEs. 218 + */ 219 + if (!(flags & ACPI_NO_EVENT_INIT)) { 220 + status = acpi_ev_install_fadt_gpes(); 221 + if (ACPI_FAILURE(status)) { 222 + return (status); 211 223 } 212 224 } 213 225 ··· 254 230 /* 255 231 * Run all _REG methods 256 232 * 257 - * NOTE: Any objects accessed 258 - * by the _REG methods will be automatically initialized, even if they 259 - * contain executable AML (see call to acpi_ns_initialize_objects below). 233 + * Note: Any objects accessed by the _REG methods will be automatically 234 + * initialized, even if they contain executable AML (see the call to 235 + * acpi_ns_initialize_objects below). 260 236 */ 261 237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 262 238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, ··· 269 245 } 270 246 271 247 /* 272 - * Initialize the objects that remain uninitialized. This 273 - * runs the executable AML that may be part of the declaration of these 274 - * objects: operation_regions, buffer_fields, Buffers, and Packages. 248 + * Initialize the objects that remain uninitialized. This runs the 249 + * executable AML that may be part of the declaration of these objects: 250 + * operation_regions, buffer_fields, Buffers, and Packages. 275 251 */ 276 252 if (!(flags & ACPI_NO_OBJECT_INIT)) { 277 253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, ··· 284 260 } 285 261 286 262 /* 287 - * Initialize all device objects in the namespace 288 - * This runs the _STA and _INI methods. 263 + * Initialize all device objects in the namespace. This runs the device 264 + * _STA and _INI methods. 289 265 */ 290 266 if (!(flags & ACPI_NO_DEVICE_INIT)) { 291 267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
+1 -1
include/acpi/acconfig.h
··· 63 63 64 64 /* Current ACPICA subsystem version in YYYYMMDD format */ 65 65 66 - #define ACPI_CA_VERSION 0x20051021 66 + #define ACPI_CA_VERSION 0x20051102 67 67 68 68 /* 69 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
+6
include/acpi/acevents.h
··· 51 51 52 52 acpi_status acpi_ev_install_xrupt_handlers(void); 53 53 54 + acpi_status acpi_ev_install_fadt_gpes(void); 55 + 54 56 u32 acpi_ev_fixed_event_detect(void); 55 57 56 58 /* ··· 106 104 u8 gpe_block_base_number, 107 105 u32 interrupt_number, 108 106 struct acpi_gpe_block_info **return_gpe_block); 107 + 108 + acpi_status 109 + acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, 110 + struct acpi_gpe_block_info *gpe_block); 109 111 110 112 acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block); 111 113
+44 -2
include/acpi/acinterp.h
··· 44 44 #ifndef __ACINTERP_H__ 45 45 #define __ACINTERP_H__ 46 46 47 - #define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) 47 + #define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) 48 + 49 + /* Macros for tables used for debug output */ 50 + 51 + #define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f) 52 + #define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f) 53 + #define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info)) 54 + 55 + /* 56 + * If possible, pack the following structure to byte alignment, since we 57 + * don't care about performance for debug output 58 + */ 59 + #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED 60 + #pragma pack(1) 61 + #endif 62 + 63 + typedef const struct acpi_exdump_info { 64 + u8 opcode; 65 + u8 offset; 66 + char *name; 67 + 68 + } acpi_exdump_info; 69 + 70 + /* Values for the Opcode field above */ 71 + 72 + #define ACPI_EXD_INIT 0 73 + #define ACPI_EXD_TYPE 1 74 + #define ACPI_EXD_UINT8 2 75 + #define ACPI_EXD_UINT16 3 76 + #define ACPI_EXD_UINT32 4 77 + #define ACPI_EXD_UINT64 5 78 + #define ACPI_EXD_LITERAL 6 79 + #define ACPI_EXD_POINTER 7 80 + #define ACPI_EXD_ADDRESS 8 81 + #define ACPI_EXD_STRING 9 82 + #define ACPI_EXD_BUFFER 10 83 + #define ACPI_EXD_PACKAGE 11 84 + #define ACPI_EXD_FIELD 12 85 + #define ACPI_EXD_REFERENCE 13 86 + 87 + /* restore default alignment */ 88 + 89 + #pragma pack() 48 90 49 91 /* 50 92 * exconvrt - object conversion ··· 369 327 void 370 328 acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags); 371 329 372 - void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags); 330 + void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags); 373 331 #endif /* ACPI_FUTURE_USAGE */ 374 332 375 333 /*
+4 -23
include/acpi/acresrc.h
··· 101 101 #define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) 102 102 #define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) 103 103 104 - /* 105 - * Resource dispatch and info tables 106 - */ 107 - typedef const struct acpi_resource_info { 108 - u8 length_type; 109 - u8 minimum_aml_resource_length; 110 - u8 minimum_internal_struct_length; 111 - 112 - } acpi_resource_info; 113 - 114 - /* Types for length_type above */ 115 - 116 - #define ACPI_FIXED_LENGTH 0 117 - #define ACPI_VARIABLE_LENGTH 1 118 - #define ACPI_SMALL_VARIABLE_LENGTH 2 119 - 120 104 typedef const struct acpi_rsdump_info { 121 105 u8 opcode; 122 106 u8 offset; 123 107 char *name; 124 - const void *pointer; 108 + const char **pointer; 125 109 126 110 } acpi_rsdump_info; 127 111 ··· 137 153 138 154 /* Resource tables indexed by raw AML resource descriptor type */ 139 155 140 - extern struct acpi_resource_info acpi_gbl_sm_resource_info[]; 141 - extern struct acpi_resource_info acpi_gbl_lg_resource_info[]; 142 - extern struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[]; 143 - extern struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[]; 156 + extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[]; 157 + 158 + extern const u8 acpi_gbl_resource_struct_sizes[]; 144 159 145 160 /* 146 161 * rscreate ··· 254 271 void 255 272 acpi_rs_set_resource_length(acpi_rsdesc_size total_length, 256 273 union aml_resource *aml); 257 - 258 - struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type); 259 274 260 275 /* 261 276 * rsdump
+16 -1
include/acpi/acutils.h
··· 44 44 #ifndef _ACUTILS_H 45 45 #define _ACUTILS_H 46 46 47 + extern const u8 acpi_gbl_resource_aml_sizes[]; 48 + 49 + /* Types for Resource descriptor entries */ 50 + 51 + #define ACPI_INVALID_RESOURCE 0 52 + #define ACPI_FIXED_LENGTH 1 53 + #define ACPI_VARIABLE_LENGTH 2 54 + #define ACPI_SMALL_VARIABLE_LENGTH 3 55 + 47 56 typedef 48 57 acpi_status(*acpi_pkg_callback) (u8 object_type, 49 58 union acpi_operand_object * source_object, ··· 427 418 428 419 #define ACPI_ANY_BASE 0 429 420 421 + acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index); 422 + 430 423 u32 acpi_ut_get_descriptor_length(void *aml); 431 424 432 425 u16 acpi_ut_get_resource_length(void *aml); 433 426 427 + u8 acpi_ut_get_resource_header_length(void *aml); 428 + 434 429 u8 acpi_ut_get_resource_type(void *aml); 435 430 436 - u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc); 431 + acpi_status 432 + acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, 433 + u8 ** end_tag); 437 434 438 435 u8 acpi_ut_generate_checksum(u8 * buffer, u32 length); 439 436
+5
include/acpi/amlresrc.h
··· 92 92 struct asl_resource_node *next; 93 93 }; 94 94 95 + /* Macros used to generate AML resource length fields */ 96 + 97 + #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) 98 + #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) 99 + 95 100 /* 96 101 * Resource descriptors defined in the ACPI specification. 97 102 *