aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/events/evevent.c42
-rw-r--r--drivers/acpi/events/evgpeblk.c159
-rw-r--r--drivers/acpi/events/evxfevnt.c7
-rw-r--r--drivers/acpi/executer/exdump.c656
-rw-r--r--drivers/acpi/executer/exmisc.c47
-rw-r--r--drivers/acpi/namespace/nsxfeval.c2
-rw-r--r--drivers/acpi/resources/rscalc.c253
-rw-r--r--drivers/acpi/resources/rsdump.c70
-rw-r--r--drivers/acpi/resources/rsinfo.c97
-rw-r--r--drivers/acpi/resources/rslist.c195
-rw-r--r--drivers/acpi/resources/rsutils.c88
-rw-r--r--drivers/acpi/utilities/Makefile5
-rw-r--r--drivers/acpi/utilities/utmisc.c148
-rw-r--r--drivers/acpi/utilities/utresrc.c428
-rw-r--r--drivers/acpi/utilities/utstate.c2
-rw-r--r--drivers/acpi/utilities/utxface.c52
16 files changed, 1292 insertions, 959 deletions
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index 842d1e3fb37b..9522c643b88b 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -100,6 +100,48 @@ acpi_status acpi_ev_initialize_events(void)
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
116acpi_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 * FUNCTION: acpi_ev_install_xrupt_handlers 145 * FUNCTION: acpi_ev_install_xrupt_handlers
104 * 146 *
105 * PARAMETERS: None 147 * PARAMETERS: None
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index 7ca10c5f2914..8efca2eac27e 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -78,7 +78,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
78 * 78 *
79 * RETURN: TRUE if the gpe_event is valid 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 * Should be called only when the GPE lists are semaphore locked 82 * Should be called only when the GPE lists are semaphore locked
83 * and not subject to change. 83 * and not subject to change.
84 * 84 *
@@ -264,7 +264,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
264 * 2) Edge/Level determination is based on the 2nd character 264 * 2) Edge/Level determination is based on the 2nd character
265 * of the method name 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 * if a _PRW object is found that points to this GPE. 268 * if a _PRW object is found that points to this GPE.
269 */ 269 */
270 switch (name[1]) { 270 switch (name[1]) {
@@ -313,14 +313,14 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
313 313
314 /* 314 /*
315 * Now we can add this information to the gpe_event_info block 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 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
318 */ 318 */
319 gpe_event_info = 319 gpe_event_info =
320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 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 | 322 gpe_event_info->flags = (u8)
323 ACPI_GPE_TYPE_RUNTIME); 323 (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME);
324 324
325 gpe_event_info->dispatch.method_node = 325 gpe_event_info->dispatch.method_node =
326 (struct acpi_namespace_node *)obj_handle; 326 (struct acpi_namespace_node *)obj_handle;
@@ -341,11 +341,11 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
341 * 341 *
342 * PARAMETERS: Callback from walk_namespace 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 * not aborted on a single _PRW failure. 345 * not aborted on a single _PRW failure.
346 * 346 *
347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a 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 * number and mark the GPE as a WAKE GPE. 349 * number and mark the GPE as a WAKE GPE.
350 * 350 *
351 ******************************************************************************/ 351 ******************************************************************************/
@@ -443,6 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
443 443
444 gpe_event_info->flags &= 444 gpe_event_info->flags &=
445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
446
446 status = 447 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 448 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) { 449 if (ACPI_FAILURE(status)) {
@@ -466,7 +467,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
466 * 467 *
467 * RETURN: A GPE interrupt block 468 * RETURN: A GPE interrupt block
468 * 469 *
469 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 470 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
470 * block per unique interrupt level used for GPEs. 471 * block per unique interrupt level used for GPEs.
471 * Should be called only when the GPE lists are semaphore locked 472 * Should be called only when the GPE lists are semaphore locked
472 * and not subject to change. 473 * and not subject to change.
@@ -566,8 +567,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
566 567
567 /* Disable this interrupt */ 568 /* Disable this interrupt */
568 569
569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, 570 status =
570 acpi_ev_gpe_xrupt_handler); 571 acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
572 acpi_ev_gpe_xrupt_handler);
571 if (ACPI_FAILURE(status)) { 573 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS(status); 574 return_ACPI_STATUS(status);
573 } 575 }
@@ -750,7 +752,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
750 752
751 /* 753 /*
752 * Allocate the GPE event_info block. There are eight distinct GPEs 754 * Allocate the GPE event_info block. There are eight distinct GPEs
753 * per register. Initialization to zeros is sufficient. 755 * per register. Initialization to zeros is sufficient.
754 */ 756 */
755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> 757 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
756 register_count * 758 register_count *
@@ -769,9 +771,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
769 gpe_block->event_info = gpe_event_info; 771 gpe_block->event_info = gpe_event_info;
770 772
771 /* 773 /*
772 * Initialize the GPE Register and Event structures. A goal of these 774 * Initialize the GPE Register and Event structures. A goal of these
773 * tables is to hide the fact that there are two separate GPE register sets 775 * tables is to hide the fact that there are two separate GPE register sets
774 * in a given gpe hardware block, the status registers occupy the first half, 776 * in a given GPE hardware block, the status registers occupy the first half,
775 * and the enable registers occupy the second half. 777 * and the enable registers occupy the second half.
776 */ 778 */
777 this_register = gpe_register_info; 779 this_register = gpe_register_info;
@@ -812,11 +814,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
812 this_event++; 814 this_event++;
813 } 815 }
814 816
815 /* 817 /* Disable all GPEs within this register */
816 * Clear the status/enable registers. Note that status registers 818
817 * are cleared by writing a '1', while enable registers are cleared
818 * by writing a '0'.
819 */
820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 819 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
821 &this_register-> 820 &this_register->
822 enable_address); 821 enable_address);
@@ -824,6 +823,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
824 goto error_exit; 823 goto error_exit;
825 } 824 }
826 825
826 /* Clear any pending GPE events within this register */
827
827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 828 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
828 &this_register-> 829 &this_register->
829 status_address); 830 status_address);
@@ -860,7 +861,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
860 * 861 *
861 * RETURN: Status 862 * RETURN: Status
862 * 863 *
863 * DESCRIPTION: Create and Install a block of GPE registers 864 * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
865 * the block are disabled at exit.
866 * Note: Assumes namespace is locked.
864 * 867 *
865 ******************************************************************************/ 868 ******************************************************************************/
866 869
@@ -872,14 +875,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
872 u32 interrupt_number, 875 u32 interrupt_number,
873 struct acpi_gpe_block_info **return_gpe_block) 876 struct acpi_gpe_block_info **return_gpe_block)
874{ 877{
875 struct acpi_gpe_block_info *gpe_block;
876 struct acpi_gpe_event_info *gpe_event_info;
877 acpi_native_uint i;
878 acpi_native_uint j;
879 u32 wake_gpe_count;
880 u32 gpe_enabled_count;
881 acpi_status status; 878 acpi_status status;
882 struct acpi_gpe_walk_info gpe_info; 879 struct acpi_gpe_block_info *gpe_block;
883 880
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block"); 881 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
885 882
@@ -896,22 +893,24 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
896 893
897 /* Initialize the new GPE block */ 894 /* Initialize the new GPE block */
898 895
896 gpe_block->node = gpe_device;
899 gpe_block->register_count = register_count; 897 gpe_block->register_count = register_count;
900 gpe_block->block_base_number = gpe_block_base_number; 898 gpe_block->block_base_number = gpe_block_base_number;
901 gpe_block->node = gpe_device;
902 899
903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, 900 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
904 sizeof(struct acpi_generic_address)); 901 sizeof(struct acpi_generic_address));
905 902
906 /* Create the register_info and event_info sub-structures */ 903 /*
907 904 * Create the register_info and event_info sub-structures
905 * Note: disables and clears all GPEs in the block
906 */
908 status = acpi_ev_create_gpe_info_blocks(gpe_block); 907 status = acpi_ev_create_gpe_info_blocks(gpe_block);
909 if (ACPI_FAILURE(status)) { 908 if (ACPI_FAILURE(status)) {
910 ACPI_MEM_FREE(gpe_block); 909 ACPI_MEM_FREE(gpe_block);
911 return_ACPI_STATUS(status); 910 return_ACPI_STATUS(status);
912 } 911 }
913 912
914 /* Install the new block in the global list(s) */ 913 /* Install the new block in the global lists */
915 914
916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); 915 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
917 if (ACPI_FAILURE(status)) { 916 if (ACPI_FAILURE(status)) {
@@ -926,16 +925,70 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
926 acpi_ev_save_method_info, gpe_block, 925 acpi_ev_save_method_info, gpe_block,
927 NULL); 926 NULL);
928 927
928 /* Return the new block */
929
930 if (return_gpe_block) {
931 (*return_gpe_block) = gpe_block;
932 }
933
934 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
935 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
936 (u32) gpe_block->block_base_number,
937 (u32) (gpe_block->block_base_number +
938 ((gpe_block->register_count *
939 ACPI_GPE_REGISTER_WIDTH) - 1)),
940 gpe_device->name.ascii, gpe_block->register_count,
941 interrupt_number));
942
943 return_ACPI_STATUS(AE_OK);
944}
945
946/*******************************************************************************
947 *
948 * FUNCTION: acpi_ev_initialize_gpe_block
949 *
950 * PARAMETERS: gpe_device - Handle to the parent GPE block
951 * gpe_block - Gpe Block info
952 *
953 * RETURN: Status
954 *
955 * DESCRIPTION: Initialize and enable a GPE block. First find and run any
956 * _PRT methods associated with the block, then enable the
957 * appropriate GPEs.
958 * Note: Assumes namespace is locked.
959 *
960 ******************************************************************************/
961
962acpi_status
963acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
964 struct acpi_gpe_block_info *gpe_block)
965{
966 acpi_status status;
967 struct acpi_gpe_event_info *gpe_event_info;
968 struct acpi_gpe_walk_info gpe_info;
969 u32 wake_gpe_count;
970 u32 gpe_enabled_count;
971 acpi_native_uint i;
972 acpi_native_uint j;
973
974 ACPI_FUNCTION_TRACE("ev_initialize_gpe_block");
975
976 /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */
977
978 if (!gpe_block) {
979 return_ACPI_STATUS(AE_OK);
980 }
981
929 /* 982 /*
930 * Runtime option: Should Wake GPEs be enabled at runtime? The default 983 * Runtime option: Should wake GPEs be enabled at runtime? The default
931 * is No, they should only be enabled just as the machine goes to sleep. 984 * is no, they should only be enabled just as the machine goes to sleep.
932 */ 985 */
933 if (acpi_gbl_leave_wake_gpes_disabled) { 986 if (acpi_gbl_leave_wake_gpes_disabled) {
934 /* 987 /*
935 * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. 988 * Differentiate runtime vs wake GPEs, via the _PRW control methods.
936 * (Each GPE that has one or more _PRWs that reference it is by 989 * Each GPE that has one or more _PRWs that reference it is by
937 * definition a WAKE GPE and will not be enabled while the machine 990 * definition a wake GPE and will not be enabled while the machine
938 * is running.) 991 * is running.
939 */ 992 */
940 gpe_info.gpe_block = gpe_block; 993 gpe_info.gpe_block = gpe_block;
941 gpe_info.gpe_device = gpe_device; 994 gpe_info.gpe_device = gpe_device;
@@ -948,9 +1001,12 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
948 } 1001 }
949 1002
950 /* 1003 /*
951 * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, 1004 * Enable all GPEs in this block that have these attributes:
952 * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must 1005 * 1) are "runtime" or "run/wake" GPEs, and
953 * be enabled via the acpi_enable_gpe() external interface. 1006 * 2) have a corresponding _Lxx or _Exx method
1007 *
1008 * Any other GPEs within this block must be enabled via the acpi_enable_gpe()
1009 * external interface.
954 */ 1010 */
955 wake_gpe_count = 0; 1011 wake_gpe_count = 0;
956 gpe_enabled_count = 0; 1012 gpe_enabled_count = 0;
@@ -976,32 +1032,19 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
976 } 1032 }
977 } 1033 }
978 1034
979 /* Dump info about this GPE block */
980
981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
982 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
983 (u32) gpe_block->block_base_number,
984 (u32) (gpe_block->block_base_number +
985 ((gpe_block->register_count *
986 ACPI_GPE_REGISTER_WIDTH) - 1)),
987 gpe_device->name.ascii, gpe_block->register_count,
988 interrupt_number));
989
990 /* Enable all valid GPEs found above */
991
992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
993
994 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 1035 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 1036 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
996 wake_gpe_count, gpe_enabled_count)); 1037 wake_gpe_count, gpe_enabled_count));
997 1038
998 /* Return the new block */ 1039 /* Enable all valid runtime GPEs found above */
999 1040
1000 if (return_gpe_block) { 1041 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1001 (*return_gpe_block) = gpe_block; 1042 if (ACPI_FAILURE(status)) {
1043 ACPI_REPORT_ERROR(("Could not enable GPEs in gpe_block %p\n",
1044 gpe_block));
1002 } 1045 }
1003 1046
1004 return_ACPI_STATUS(AE_OK); 1047 return_ACPI_STATUS(status);
1005} 1048}
1006 1049
1007/******************************************************************************* 1050/*******************************************************************************
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index 887ff9f28a0d..c1b898928256 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -626,6 +626,13 @@ acpi_install_gpe_block(acpi_handle gpe_device,
626 goto unlock_and_exit; 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 /* Get the device_object attached to the node */ 636 /* Get the device_object attached to the node */
630 637
631 obj_desc = acpi_ns_get_attached_object(node); 638 obj_desc = acpi_ns_get_attached_object(node);
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 4477a62fed56..5a4cca171af6 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -55,20 +55,386 @@ ACPI_MODULE_NAME("exdump")
55 */ 55 */
56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
57/* Local prototypes */ 57/* Local prototypes */
58#ifdef ACPI_FUTURE_USAGE
59static void acpi_ex_out_string(char *title, char *value); 58static void acpi_ex_out_string(char *title, char *value);
60 59
61static void acpi_ex_out_pointer(char *title, void *value); 60static void acpi_ex_out_pointer(char *title, void *value);
62 61
63static void acpi_ex_out_integer(char *title, u32 value);
64
65static void acpi_ex_out_address(char *title, acpi_physical_address value); 62static void acpi_ex_out_address(char *title, acpi_physical_address value);
66 63
67static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc); 64static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
68 65
69static void 66static void
70acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index); 67acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
71#endif /* ACPI_FUTURE_USAGE */ 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
79static 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
84static 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
91static 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
98static 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
106static 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
115static 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
120static 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
130static 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
139static 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
149static 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
161static 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
173static 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
182static 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
189static 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
195static 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
204static 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
213static 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
223static 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
234static 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
242static 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
250static 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
265static 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
277static 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
322static void
323acpi_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 *
@@ -441,7 +807,6 @@ acpi_ex_dump_operands(union acpi_operand_object **operands,
441 return; 807 return;
442} 808}
443 809
444#ifdef ACPI_FUTURE_USAGE
445/******************************************************************************* 810/*******************************************************************************
446 * 811 *
447 * FUNCTION: acpi_ex_out* functions 812 * FUNCTION: acpi_ex_out* functions
@@ -465,11 +830,6 @@ static void acpi_ex_out_pointer(char *title, void *value)
465 acpi_os_printf("%20s : %p\n", title, value); 830 acpi_os_printf("%20s : %p\n", title, value);
466} 831}
467 832
468static void acpi_ex_out_integer(char *title, u32 value)
469{
470 acpi_os_printf("%20s : %.2X\n", title, value);
471}
472
473static void acpi_ex_out_address(char *title, acpi_physical_address value) 833static void acpi_ex_out_address(char *title, acpi_physical_address value)
474{ 834{
475 835
@@ -482,16 +842,16 @@ static void acpi_ex_out_address(char *title, acpi_physical_address value)
482 842
483/******************************************************************************* 843/*******************************************************************************
484 * 844 *
485 * FUNCTION: acpi_ex_dump_node 845 * FUNCTION: acpi_ex_dump_namespace_node
486 * 846 *
487 * PARAMETERS: *Node - Descriptor to dump 847 * PARAMETERS: Node - Descriptor to dump
488 * Flags - Force display if TRUE 848 * Flags - Force display if TRUE
489 * 849 *
490 * DESCRIPTION: Dumps the members of the given.Node 850 * DESCRIPTION: Dumps the members of the given.Node
491 * 851 *
492 ******************************************************************************/ 852 ******************************************************************************/
493 853
494void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) 854void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
495{ 855{
496 856
497 ACPI_FUNCTION_ENTRY(); 857 ACPI_FUNCTION_ENTRY();
@@ -506,19 +866,17 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
506 866
507 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); 867 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
508 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); 868 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
509 acpi_ex_out_integer("Flags", node->flags);
510 acpi_ex_out_integer("Owner Id", node->owner_id);
511 acpi_ex_out_integer("Reference Count", node->reference_count);
512 acpi_ex_out_pointer("Attached Object", 869 acpi_ex_out_pointer("Attached Object",
513 acpi_ns_get_attached_object(node)); 870 acpi_ns_get_attached_object(node));
514 acpi_ex_out_pointer("child_list", node->child);
515 acpi_ex_out_pointer("next_peer", node->peer);
516 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); 871 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
872
873 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
874 acpi_ex_dump_node);
517} 875}
518 876
519/******************************************************************************* 877/*******************************************************************************
520 * 878 *
521 * FUNCTION: acpi_ex_dump_reference 879 * FUNCTION: acpi_ex_dump_reference_obj
522 * 880 *
523 * PARAMETERS: Object - Descriptor to dump 881 * PARAMETERS: Object - Descriptor to dump
524 * 882 *
@@ -526,14 +884,16 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
526 * 884 *
527 ******************************************************************************/ 885 ******************************************************************************/
528 886
529static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) 887static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
530{ 888{
531 struct acpi_buffer ret_buf; 889 struct acpi_buffer ret_buf;
532 acpi_status status; 890 acpi_status status;
533 891
892 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
893
534 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { 894 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
535 acpi_os_printf("Named Object %p ", obj_desc->reference.node); 895 acpi_os_printf("Named Object %p ", obj_desc->reference.node);
536 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 896
537 status = 897 status =
538 acpi_ns_handle_to_pathname(obj_desc->reference.node, 898 acpi_ns_handle_to_pathname(obj_desc->reference.node,
539 &ret_buf); 899 &ret_buf);
@@ -551,9 +911,9 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
551 911
552/******************************************************************************* 912/*******************************************************************************
553 * 913 *
554 * FUNCTION: acpi_ex_dump_package 914 * FUNCTION: acpi_ex_dump_package_obj
555 * 915 *
556 * PARAMETERS: Object - Descriptor to dump 916 * PARAMETERS: obj_desc - Descriptor to dump
557 * Level - Indentation Level 917 * Level - Indentation Level
558 * Index - Package index for this object 918 * Index - Package index for this object
559 * 919 *
@@ -562,7 +922,8 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
562 ******************************************************************************/ 922 ******************************************************************************/
563 923
564static void 924static void
565acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) 925acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
926 u32 level, u32 index)
566{ 927{
567 u32 i; 928 u32 i;
568 929
@@ -622,15 +983,15 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
622 obj_desc->package.count); 983 obj_desc->package.count);
623 984
624 for (i = 0; i < obj_desc->package.count; i++) { 985 for (i = 0; i < obj_desc->package.count; i++) {
625 acpi_ex_dump_package(obj_desc->package.elements[i], 986 acpi_ex_dump_package_obj(obj_desc->package.elements[i],
626 level + 1, i); 987 level + 1, i);
627 } 988 }
628 break; 989 break;
629 990
630 case ACPI_TYPE_LOCAL_REFERENCE: 991 case ACPI_TYPE_LOCAL_REFERENCE:
631 992
632 acpi_os_printf("[Object Reference] "); 993 acpi_os_printf("[Object Reference] ");
633 acpi_ex_dump_reference(obj_desc); 994 acpi_ex_dump_reference_obj(obj_desc);
634 break; 995 break;
635 996
636 default: 997 default:
@@ -645,7 +1006,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
645 * 1006 *
646 * FUNCTION: acpi_ex_dump_object_descriptor 1007 * FUNCTION: acpi_ex_dump_object_descriptor
647 * 1008 *
648 * PARAMETERS: Object - Descriptor to dump 1009 * PARAMETERS: obj_desc - Descriptor to dump
649 * Flags - Force display if TRUE 1010 * Flags - Force display if TRUE
650 * 1011 *
651 * DESCRIPTION: Dumps the members of the object descriptor given. 1012 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -670,11 +1031,13 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
670 } 1031 }
671 1032
672 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { 1033 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
673 acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc, 1034 acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
674 flags); 1035 obj_desc, flags);
1036
675 acpi_os_printf("\nAttached Object (%p):\n", 1037 acpi_os_printf("\nAttached Object (%p):\n",
676 ((struct acpi_namespace_node *)obj_desc)-> 1038 ((struct acpi_namespace_node *)obj_desc)->
677 object); 1039 object);
1040
678 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) 1041 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
679 obj_desc)->object, flags); 1042 obj_desc)->object, flags);
680 return_VOID; 1043 return_VOID;
@@ -687,233 +1050,18 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
687 return_VOID; 1050 return_VOID;
688 } 1051 }
689 1052
690 /* Common Fields */ 1053 if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) {
691 1054 return_VOID;
692 acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc)); 1055 }
693 acpi_ex_out_integer("Reference Count",
694 obj_desc->common.reference_count);
695 acpi_ex_out_integer("Flags", obj_desc->common.flags);
696
697 /* Object-specific Fields */
698
699 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
700 case ACPI_TYPE_INTEGER:
701
702 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
703 ACPI_FORMAT_UINT64(obj_desc->integer.value));
704 break;
705
706 case ACPI_TYPE_STRING:
707
708 acpi_ex_out_integer("Length", obj_desc->string.length);
709
710 acpi_os_printf("%20s : %p ", "Pointer",
711 obj_desc->string.pointer);
712 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
713 acpi_os_printf("\n");
714 break;
715
716 case ACPI_TYPE_BUFFER:
717
718 acpi_ex_out_integer("Length", obj_desc->buffer.length);
719 acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer);
720 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
721 obj_desc->buffer.length);
722 break;
723
724 case ACPI_TYPE_PACKAGE:
725
726 acpi_ex_out_integer("Flags", obj_desc->package.flags);
727 acpi_ex_out_integer("Elements", obj_desc->package.count);
728 acpi_ex_out_pointer("Element List", obj_desc->package.elements);
729
730 /* Dump the package contents */
731
732 acpi_os_printf("\nPackage Contents:\n");
733 acpi_ex_dump_package(obj_desc, 0, 0);
734 break;
735
736 case ACPI_TYPE_DEVICE:
737
738 acpi_ex_out_pointer("Handler", obj_desc->device.handler);
739 acpi_ex_out_pointer("system_notify",
740 obj_desc->device.system_notify);
741 acpi_ex_out_pointer("device_notify",
742 obj_desc->device.device_notify);
743 break;
744
745 case ACPI_TYPE_EVENT:
746
747 acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore);
748 break;
749
750 case ACPI_TYPE_METHOD:
751
752 acpi_ex_out_integer("param_count",
753 obj_desc->method.param_count);
754 acpi_ex_out_integer("Concurrency",
755 obj_desc->method.concurrency);
756 acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore);
757 acpi_ex_out_integer("owner_id", obj_desc->method.owner_id);
758 acpi_ex_out_integer("aml_length", obj_desc->method.aml_length);
759 acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start);
760 break;
761
762 case ACPI_TYPE_MUTEX:
763
764 acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level);
765 acpi_ex_out_pointer("owner_thread",
766 obj_desc->mutex.owner_thread);
767 acpi_ex_out_integer("acquire_depth",
768 obj_desc->mutex.acquisition_depth);
769 acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore);
770 break;
771
772 case ACPI_TYPE_REGION:
773
774 acpi_ex_out_integer("space_id", obj_desc->region.space_id);
775 acpi_ex_out_integer("Flags", obj_desc->region.flags);
776 acpi_ex_out_address("Address", obj_desc->region.address);
777 acpi_ex_out_integer("Length", obj_desc->region.length);
778 acpi_ex_out_pointer("Handler", obj_desc->region.handler);
779 acpi_ex_out_pointer("Next", obj_desc->region.next);
780 break;
781
782 case ACPI_TYPE_POWER:
783
784 acpi_ex_out_integer("system_level",
785 obj_desc->power_resource.system_level);
786 acpi_ex_out_integer("resource_order",
787 obj_desc->power_resource.resource_order);
788 acpi_ex_out_pointer("system_notify",
789 obj_desc->power_resource.system_notify);
790 acpi_ex_out_pointer("device_notify",
791 obj_desc->power_resource.device_notify);
792 break;
793
794 case ACPI_TYPE_PROCESSOR:
795
796 acpi_ex_out_integer("Processor ID",
797 obj_desc->processor.proc_id);
798 acpi_ex_out_integer("Length", obj_desc->processor.length);
799 acpi_ex_out_address("Address",
800 (acpi_physical_address) obj_desc->processor.
801 address);
802 acpi_ex_out_pointer("system_notify",
803 obj_desc->processor.system_notify);
804 acpi_ex_out_pointer("device_notify",
805 obj_desc->processor.device_notify);
806 acpi_ex_out_pointer("Handler", obj_desc->processor.handler);
807 break;
808
809 case ACPI_TYPE_THERMAL:
810
811 acpi_ex_out_pointer("system_notify",
812 obj_desc->thermal_zone.system_notify);
813 acpi_ex_out_pointer("device_notify",
814 obj_desc->thermal_zone.device_notify);
815 acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler);
816 break;
817
818 case ACPI_TYPE_BUFFER_FIELD:
819 case ACPI_TYPE_LOCAL_REGION_FIELD:
820 case ACPI_TYPE_LOCAL_BANK_FIELD:
821 case ACPI_TYPE_LOCAL_INDEX_FIELD:
822
823 acpi_ex_out_integer("field_flags",
824 obj_desc->common_field.field_flags);
825 acpi_ex_out_integer("access_byte_width",
826 obj_desc->common_field.access_byte_width);
827 acpi_ex_out_integer("bit_length",
828 obj_desc->common_field.bit_length);
829 acpi_ex_out_integer("fld_bit_offset",
830 obj_desc->common_field.
831 start_field_bit_offset);
832 acpi_ex_out_integer("base_byte_offset",
833 obj_desc->common_field.base_byte_offset);
834 acpi_ex_out_pointer("parent_node", obj_desc->common_field.node);
835
836 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
837 case ACPI_TYPE_BUFFER_FIELD:
838 acpi_ex_out_pointer("buffer_obj",
839 obj_desc->buffer_field.buffer_obj);
840 break;
841
842 case ACPI_TYPE_LOCAL_REGION_FIELD:
843 acpi_ex_out_pointer("region_obj",
844 obj_desc->field.region_obj);
845 break;
846
847 case ACPI_TYPE_LOCAL_BANK_FIELD:
848 acpi_ex_out_integer("Value",
849 obj_desc->bank_field.value);
850 acpi_ex_out_pointer("region_obj",
851 obj_desc->bank_field.region_obj);
852 acpi_ex_out_pointer("bank_obj",
853 obj_desc->bank_field.bank_obj);
854 break;
855
856 case ACPI_TYPE_LOCAL_INDEX_FIELD:
857 acpi_ex_out_integer("Value",
858 obj_desc->index_field.value);
859 acpi_ex_out_pointer("Index",
860 obj_desc->index_field.index_obj);
861 acpi_ex_out_pointer("Data",
862 obj_desc->index_field.data_obj);
863 break;
864
865 default:
866 /* All object types covered above */
867 break;
868 }
869 break;
870
871 case ACPI_TYPE_LOCAL_REFERENCE:
872
873 acpi_ex_out_integer("target_type",
874 obj_desc->reference.target_type);
875 acpi_ex_out_string("Opcode",
876 (acpi_ps_get_opcode_info
877 (obj_desc->reference.opcode))->name);
878 acpi_ex_out_integer("Offset", obj_desc->reference.offset);
879 acpi_ex_out_pointer("obj_desc", obj_desc->reference.object);
880 acpi_ex_out_pointer("Node", obj_desc->reference.node);
881 acpi_ex_out_pointer("Where", obj_desc->reference.where);
882
883 acpi_ex_dump_reference(obj_desc);
884 break;
885
886 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
887
888 acpi_ex_out_integer("space_id",
889 obj_desc->address_space.space_id);
890 acpi_ex_out_pointer("Next", obj_desc->address_space.next);
891 acpi_ex_out_pointer("region_list",
892 obj_desc->address_space.region_list);
893 acpi_ex_out_pointer("Node", obj_desc->address_space.node);
894 acpi_ex_out_pointer("Context", obj_desc->address_space.context);
895 break;
896 1056
897 case ACPI_TYPE_LOCAL_NOTIFY: 1057 /* Common Fields */
898 1058
899 acpi_ex_out_pointer("Node", obj_desc->notify.node); 1059 acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
900 acpi_ex_out_pointer("Context", obj_desc->notify.context);
901 break;
902 1060
903 case ACPI_TYPE_LOCAL_ALIAS: 1061 /* Object-specific fields */
904 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
905 case ACPI_TYPE_LOCAL_EXTRA:
906 case ACPI_TYPE_LOCAL_DATA:
907 default:
908
909 acpi_os_printf
910 ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
911 acpi_ut_get_object_type_name(obj_desc));
912 break;
913 }
914 1062
1063 acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
915 return_VOID; 1064 return_VOID;
916} 1065}
917 1066
918#endif /* ACPI_FUTURE_USAGE */
919#endif 1067#endif
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 1899ab251393..00a25f8188f4 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -45,6 +45,7 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
48#include <acpi/amlresrc.h>
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exmisc") 51ACPI_MODULE_NAME("exmisc")
@@ -157,40 +158,52 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
157 union acpi_operand_object **actual_return_desc, 158 union acpi_operand_object **actual_return_desc,
158 struct acpi_walk_state *walk_state) 159 struct acpi_walk_state *walk_state)
159{ 160{
161 acpi_status status;
160 union acpi_operand_object *return_desc; 162 union acpi_operand_object *return_desc;
161 u8 *new_buf; 163 u8 *new_buf;
162 u8 *end_tag1; 164 u8 *end_tag;
163 u8 *end_tag2; 165 acpi_size length0;
164 acpi_size length1; 166 acpi_size length1;
165 acpi_size length2;
166 167
167 ACPI_FUNCTION_TRACE("ex_concat_template"); 168 ACPI_FUNCTION_TRACE("ex_concat_template");
168 169
169 /* Find the end_tags in each resource template */ 170 /*
171 * Find the end_tag descriptor in each resource template.
172 * Note: returned pointers point TO the end_tag, not past it.
173 *
174 * Compute the length of each resource template
175 */
176 status = acpi_ut_get_resource_end_tag(operand0, &end_tag);
177 if (ACPI_FAILURE(status)) {
178 return_ACPI_STATUS(status);
179 }
170 180
171 end_tag1 = acpi_ut_get_resource_end_tag(operand0); 181 length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer);
172 end_tag2 = acpi_ut_get_resource_end_tag(operand1); 182
173 if (!end_tag1 || !end_tag2) { 183 status = acpi_ut_get_resource_end_tag(operand1, &end_tag);
174 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 184 if (ACPI_FAILURE(status)) {
185 return_ACPI_STATUS(status);
175 } 186 }
176 187
177 /* Compute the length of each part */ 188 /* Include the end_tag in the second template length */
178 189
179 length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); 190 length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer) +
180 length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */ 191 sizeof(struct aml_resource_end_tag);
181 192
182 /* Create a new buffer object for the result */ 193 /* Create a new buffer object for the result */
183 194
184 return_desc = acpi_ut_create_buffer_object(length1 + length2); 195 return_desc = acpi_ut_create_buffer_object(length0 + length1);
185 if (!return_desc) { 196 if (!return_desc) {
186 return_ACPI_STATUS(AE_NO_MEMORY); 197 return_ACPI_STATUS(AE_NO_MEMORY);
187 } 198 }
188 199
189 /* Copy the templates to the new descriptor */ 200 /*
190 201 * Copy the templates to the new buffer, 0 first, then 1 follows. One
202 * end_tag descriptor is copied from Operand1.
203 */
191 new_buf = return_desc->buffer.pointer; 204 new_buf = return_desc->buffer.pointer;
192 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); 205 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
193 ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); 206 ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
194 207
195 /* Compute the new checksum */ 208 /* Compute the new checksum */
196 209
@@ -198,7 +211,7 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
198 acpi_ut_generate_checksum(return_desc->buffer.pointer, 211 acpi_ut_generate_checksum(return_desc->buffer.pointer,
199 (return_desc->buffer.length - 1)); 212 (return_desc->buffer.length - 1));
200 213
201 /* Return the completed template descriptor */ 214 /* Return the completed resource template */
202 215
203 *actual_return_desc = return_desc; 216 *actual_return_desc = return_desc;
204 return_ACPI_STATUS(AE_OK); 217 return_ACPI_STATUS(AE_OK);
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index c07b046659ff..8167af1fa57b 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -399,7 +399,7 @@ acpi_walk_namespace(acpi_object_type type,
399 399
400 /* Parameter validation */ 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 return_ACPI_STATUS(AE_BAD_PARAMETER); 403 return_ACPI_STATUS(AE_BAD_PARAMETER);
404 } 404 }
405 405
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index c29d3a447278..eca7439ee9da 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -299,13 +299,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
299 299
300 /* Point to the next object */ 300 /* Point to the next object */
301 301
302 resource = ACPI_PTR_ADD(struct acpi_resource, 302 resource =
303 resource, resource->length); 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/*******************************************************************************
@@ -328,185 +329,155 @@ acpi_status
328acpi_rs_get_list_length(u8 * aml_buffer, 329acpi_rs_get_list_length(u8 * aml_buffer,
329 u32 aml_buffer_length, acpi_size * size_needed) 330 u32 aml_buffer_length, acpi_size * size_needed)
330{ 331{
332 acpi_status status;
333 u8 *end_aml;
331 u8 *buffer; 334 u8 *buffer;
332 struct acpi_resource_info *resource_info;
333 u32 buffer_size = 0; 335 u32 buffer_size = 0;
334 u32 bytes_parsed = 0;
335 u8 resource_type;
336 u16 temp16; 336 u16 temp16;
337 u16 resource_length; 337 u16 resource_length;
338 u16 header_length;
339 u32 extra_struct_bytes; 338 u32 extra_struct_bytes;
339 u8 resource_index;
340 u8 minimum_aml_resource_length;
340 341
341 ACPI_FUNCTION_TRACE("rs_get_list_length"); 342 ACPI_FUNCTION_TRACE("rs_get_list_length");
342 343
343 while (bytes_parsed < aml_buffer_length) { 344 end_aml = aml_buffer + aml_buffer_length;
344 /* The next byte in the stream is the resource descriptor type */
345 345
346 resource_type = acpi_ut_get_resource_type(aml_buffer); 346 /* Walk the list of AML resource descriptors */
347 347
348 /* Get the base stream size and structure sizes for the descriptor */ 348 while (aml_buffer < end_aml) {
349 /* Validate the Resource Type and Resource Length */
349 350
350 resource_info = acpi_rs_get_resource_info(resource_type); 351 status = acpi_ut_validate_resource(aml_buffer, &resource_index);
351 if (!resource_info) { 352 if (ACPI_FAILURE(status)) {
352 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 353 return_ACPI_STATUS(status);
353 } 354 }
354 355
355 /* Get the Length field from the input resource descriptor */ 356 /* Get the resource length and base (minimum) AML size */
356 357
357 resource_length = acpi_ut_get_resource_length(aml_buffer); 358 resource_length = acpi_ut_get_resource_length(aml_buffer);
359 minimum_aml_resource_length =
360 acpi_gbl_resource_aml_sizes[resource_index];
358 361
359 /* Augment the size for descriptors with optional fields */ 362 /*
360 363 * Augment the size for descriptors with optional
364 * and/or variable length fields
365 */
361 extra_struct_bytes = 0; 366 extra_struct_bytes = 0;
367 buffer =
368 aml_buffer + acpi_ut_get_resource_header_length(aml_buffer);
362 369
363 if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { 370 switch (acpi_ut_get_resource_type(aml_buffer)) {
371 case ACPI_RESOURCE_NAME_IRQ:
364 /* 372 /*
365 * Small resource descriptors 373 * IRQ Resource:
374 * Get the number of bits set in the 16-bit IRQ mask
366 */ 375 */
367 header_length = 376 ACPI_MOVE_16_TO_16(&temp16, buffer);
368 sizeof(struct aml_resource_small_header); 377 extra_struct_bytes =
369 buffer = aml_buffer + header_length; 378 acpi_rs_count_set_bits(temp16) * sizeof(u32);
370 379 break;
371 switch (resource_type) {
372 case ACPI_RESOURCE_NAME_IRQ:
373 /*
374 * IRQ Resource:
375 * Get the number of bits set in the IRQ word
376 */
377 ACPI_MOVE_16_TO_16(&temp16, buffer);
378 extra_struct_bytes =
379 (acpi_rs_count_set_bits(temp16) *
380 sizeof(u32));
381 break;
382
383 case ACPI_RESOURCE_NAME_DMA:
384 /*
385 * DMA Resource:
386 * Get the number of bits set in the DMA channels byte
387 */
388 ACPI_MOVE_16_TO_16(&temp16, buffer);
389 extra_struct_bytes =
390 (acpi_rs_count_set_bits(temp16) *
391 sizeof(u32));
392 break;
393
394 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
395 /*
396 * Vendor Specific Resource:
397 * Ensure a 32-bit boundary for the structure
398 */
399 extra_struct_bytes =
400 ACPI_ROUND_UP_to_32_bITS(resource_length);
401 break;
402 380
403 case ACPI_RESOURCE_NAME_END_TAG: 381 case ACPI_RESOURCE_NAME_DMA:
404 /* 382 /*
405 * End Tag: 383 * DMA Resource:
406 * Terminate the loop now 384 * Get the number of bits set in the 8-bit DMA mask
407 */ 385 */
408 aml_buffer_length = bytes_parsed; 386 extra_struct_bytes =
409 break; 387 acpi_rs_count_set_bits(*buffer) * sizeof(u32);
388 break;
410 389
411 default: 390 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
412 break;
413 }
414 } else {
415 /* 391 /*
416 * Large resource descriptors 392 * Vendor Resource:
393 * Ensure a 32-bit boundary for the structure
417 */ 394 */
418 header_length = 395 extra_struct_bytes =
419 sizeof(struct aml_resource_large_header); 396 ACPI_ROUND_UP_to_32_bITS(resource_length) -
420 buffer = aml_buffer + header_length; 397 resource_length;
398 break;
421 399
422 switch (resource_type) { 400 case ACPI_RESOURCE_NAME_END_TAG:
423 case ACPI_RESOURCE_NAME_VENDOR_LARGE: 401 /*
424 /* 402 * End Tag: This is the normal exit
425 * Vendor Defined Resource: 403 */
426 * Add vendor data and ensure a 32-bit boundary for the structure 404 *size_needed = buffer_size;
427 */ 405 return_ACPI_STATUS(AE_OK);
428 extra_struct_bytes =
429 ACPI_ROUND_UP_to_32_bITS(resource_length);
430 break;
431 406
432 case ACPI_RESOURCE_NAME_ADDRESS32: 407 case ACPI_RESOURCE_NAME_VENDOR_LARGE:
433 case ACPI_RESOURCE_NAME_ADDRESS16: 408 /*
434 /* 409 * Vendor Resource:
435 * 32-Bit or 16-bit Address Resource: 410 * Add vendor data and ensure a 32-bit boundary for the structure
436 * Add the size of any optional data (resource_source) 411 */
437 */ 412 extra_struct_bytes =
438 extra_struct_bytes = 413 ACPI_ROUND_UP_to_32_bITS(resource_length) -
439 acpi_rs_stream_option_length 414 resource_length;
440 (resource_length, 415 break;
441 resource_info->
442 minimum_aml_resource_length);
443 break;
444
445 case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
446 /*
447 * Extended IRQ:
448 * Point past the interrupt_vector_flags to get the
449 * interrupt_table_length.
450 */
451 buffer++;
452 416
453 /* 417 case ACPI_RESOURCE_NAME_ADDRESS32:
454 * Add 4 bytes for each additional interrupt. Note: at least one 418 case ACPI_RESOURCE_NAME_ADDRESS16:
455 * interrupt is required and is included in the minimum 419 /*
456 * descriptor size 420 * 32-Bit or 16-bit Address Resource:
457 */ 421 * Add the size of any optional data (resource_source)
458 extra_struct_bytes = 422 */
459 ((*buffer - 1) * sizeof(u32)); 423 extra_struct_bytes =
424 acpi_rs_stream_option_length(resource_length,
425 minimum_aml_resource_length);
426 break;
460 427
461 /* Add the size of any optional data (resource_source) */ 428 case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
429 /*
430 * Extended IRQ:
431 * Point past the interrupt_vector_flags to get the
432 * interrupt_table_length.
433 */
434 buffer++;
435
436 extra_struct_bytes =
437 /*
438 * Add 4 bytes for each additional interrupt. Note: at
439 * least one interrupt is required and is included in
440 * the minimum descriptor size
441 */
442 ((*buffer - 1) * sizeof(u32)) +
443 /* Add the size of any optional data (resource_source) */
444 acpi_rs_stream_option_length(resource_length -
445 extra_struct_bytes,
446 minimum_aml_resource_length);
447 break;
462 448
463 extra_struct_bytes += 449 case ACPI_RESOURCE_NAME_ADDRESS64:
464 acpi_rs_stream_option_length(resource_length 450 /*
465 - 451 * 64-Bit Address Resource:
466 extra_struct_bytes, 452 * Add the size of any optional data (resource_source)
467 resource_info-> 453 * Ensure a 64-bit boundary for the structure
468 minimum_aml_resource_length); 454 */
469 break; 455 extra_struct_bytes =
456 ACPI_ROUND_UP_to_64_bITS
457 (acpi_rs_stream_option_length
458 (resource_length, minimum_aml_resource_length));
459 break;
470 460
471 case ACPI_RESOURCE_NAME_ADDRESS64: 461 default:
472 /* 462 break;
473 * 64-Bit Address Resource:
474 * Add the size of any optional data (resource_source)
475 * Ensure a 64-bit boundary for the structure
476 */
477 extra_struct_bytes =
478 ACPI_ROUND_UP_to_64_bITS
479 (acpi_rs_stream_option_length
480 (resource_length,
481 resource_info->
482 minimum_aml_resource_length));
483 break;
484
485 default:
486 break;
487 }
488 } 463 }
489 464
490 /* Update the required buffer size for the internal descriptor structs */ 465 /* Update the required buffer size for the internal descriptor structs */
491 466
492 temp16 = 467 temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] +
493 (u16) (resource_info->minimum_internal_struct_length + 468 extra_struct_bytes);
494 extra_struct_bytes);
495 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); 469 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16);
496 470
497 /* 471 /*
498 * Update byte count and point to the next resource within the stream 472 * Point to the next resource within the stream
499 * using the size of the header plus the length contained in the header 473 * using the size of the header plus the length contained in the header
500 */ 474 */
501 temp16 = (u16) (header_length + resource_length); 475 aml_buffer += acpi_ut_get_descriptor_length(aml_buffer);
502 bytes_parsed += temp16;
503 aml_buffer += temp16;
504 } 476 }
505 477
506 /* This is the data the caller needs */ 478 /* Did not find an end_tag resource descriptor */
507 479
508 *size_needed = buffer_size; 480 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
509 return_ACPI_STATUS(AE_OK);
510} 481}
511 482
512/******************************************************************************* 483/*******************************************************************************
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index 27172a3d55d7..f617ca80c5a6 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -324,7 +324,7 @@ static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
324 324
325static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { 325static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
326 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), 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 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), 328 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
329 "Write Protect", acpi_gbl_RWdecode}, 329 "Write Protect", acpi_gbl_RWdecode},
330 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), 330 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
@@ -337,7 +337,7 @@ static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
337 337
338static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { 338static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
339 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), 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 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), 341 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
342 "Range Type", acpi_gbl_RNGdecode}, 342 "Range Type", acpi_gbl_RNGdecode},
343 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), 343 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
@@ -372,8 +372,8 @@ static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
372static void 372static void
373acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) 373acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
374{ 374{
375 void *target = NULL; 375 u8 *target = NULL;
376 void *previous_target; 376 u8 *previous_target;
377 char *name; 377 char *name;
378 u8 count; 378 u8 count;
379 379
@@ -399,43 +399,49 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
399 /* Strings */ 399 /* Strings */
400 400
401 case ACPI_RSD_LITERAL: 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 break; 404 break;
404 405
405 case ACPI_RSD_STRING: 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 break; 408 break;
408 409
409 /* Data items, 8/16/32/64 bit */ 410 /* Data items, 8/16/32/64 bit */
410 411
411 case ACPI_RSD_UINT8: 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 break; 414 break;
414 415
415 case ACPI_RSD_UINT16: 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 break; 419 break;
418 420
419 case ACPI_RSD_UINT32: 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 break; 424 break;
422 425
423 case ACPI_RSD_UINT64: 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 break; 429 break;
426 430
427 /* Flags: 1-bit and 2-bit flags supported */ 431 /* Flags: 1-bit and 2-bit flags supported */
428 432
429 case ACPI_RSD_1BITFLAG: 433 case ACPI_RSD_1BITFLAG:
430 acpi_rs_out_string(name, (char *) 434 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
431 ((const char **)table-> 435 table->
432 pointer)[(*(u8 *) target) & 0x01]); 436 pointer[*target &
437 0x01]));
433 break; 438 break;
434 439
435 case ACPI_RSD_2BITFLAG: 440 case ACPI_RSD_2BITFLAG:
436 acpi_rs_out_string(name, (char *) 441 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
437 ((const char **)table-> 442 table->
438 pointer)[(*(u8 *) target) & 0x03]); 443 pointer[*target &
444 0x03]));
439 break; 445 break;
440 446
441 case ACPI_RSD_SHORTLIST: 447 case ACPI_RSD_SHORTLIST:
@@ -445,10 +451,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
445 */ 451 */
446 if (previous_target) { 452 if (previous_target) {
447 acpi_rs_out_title(name); 453 acpi_rs_out_title(name);
448 acpi_rs_dump_short_byte_list(* 454 acpi_rs_dump_short_byte_list(*previous_target,
449 ((u8 *) 455 target);
450 previous_target),
451 (u8 *) target);
452 } 456 }
453 break; 457 break;
454 458
@@ -458,10 +462,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
458 * Note: The list length is obtained from the previous table entry 462 * Note: The list length is obtained from the previous table entry
459 */ 463 */
460 if (previous_target) { 464 if (previous_target) {
461 acpi_rs_dump_byte_list(* 465 acpi_rs_dump_byte_list(*ACPI_CAST_PTR
462 ((u16 *) 466 (u16, previous_target),
463 previous_target), 467 target);
464 (u8 *) target);
465 } 468 }
466 break; 469 break;
467 470
@@ -471,10 +474,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
471 * Note: The list length is obtained from the previous table entry 474 * Note: The list length is obtained from the previous table entry
472 */ 475 */
473 if (previous_target) { 476 if (previous_target) {
474 acpi_rs_dump_dword_list(* 477 acpi_rs_dump_dword_list(*previous_target,
475 ((u8 *) 478 ACPI_CAST_PTR(u32,
476 previous_target), 479 target));
477 (u32 *) target);
478 } 480 }
479 break; 481 break;
480 482
@@ -482,17 +484,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
482 /* 484 /*
483 * Common flags for all Address resources 485 * Common flags for all Address resources
484 */ 486 */
485 acpi_rs_dump_address_common((union acpi_resource_data *) 487 acpi_rs_dump_address_common(ACPI_CAST_PTR
486 target); 488 (union acpi_resource_data,
489 target));
487 break; 490 break;
488 491
489 case ACPI_RSD_SOURCE: 492 case ACPI_RSD_SOURCE:
490 /* 493 /*
491 * Optional resource_source for Address resources 494 * Optional resource_source for Address resources
492 */ 495 */
493 acpi_rs_dump_resource_source((struct 496 acpi_rs_dump_resource_source(ACPI_CAST_PTR
494 acpi_resource_source *) 497 (struct
495 target); 498 acpi_resource_source,
499 target));
496 break; 500 break;
497 501
498 default: 502 default:
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c
index 973fc2834cbb..623b06689336 100644
--- a/drivers/acpi/resources/rsinfo.c
+++ b/drivers/acpi/resources/rsinfo.c
@@ -80,7 +80,9 @@ struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
80 80
81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ 81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
82 82
83struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { 83struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
84 /* Small descriptors */
85
84 NULL, /* 0x00, Reserved */ 86 NULL, /* 0x00, Reserved */
85 NULL, /* 0x01, Reserved */ 87 NULL, /* 0x01, Reserved */
86 NULL, /* 0x02, Reserved */ 88 NULL, /* 0x02, Reserved */
@@ -96,10 +98,10 @@ struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = {
96 NULL, /* 0x0C, Reserved */ 98 NULL, /* 0x0C, Reserved */
97 NULL, /* 0x0D, Reserved */ 99 NULL, /* 0x0D, Reserved */
98 acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ 100 acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
99 acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ 101 acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
100}; 102
103 /* Large descriptors */
101 104
102struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = {
103 NULL, /* 0x00, Reserved */ 105 NULL, /* 0x00, Reserved */
104 acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ 106 acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
105 acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ 107 acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
@@ -138,7 +140,6 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
138 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 140 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
139 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 141 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
140}; 142};
141
142#endif 143#endif
143#endif /* ACPI_FUTURE_USAGE */ 144#endif /* ACPI_FUTURE_USAGE */
144/* 145/*
@@ -166,62 +167,38 @@ const u8 acpi_gbl_aml_resource_sizes[] = {
166 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 167 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
167}; 168};
168 169
169/* Macros used in the tables below */ 170const u8 acpi_gbl_resource_struct_sizes[] = {
171 /* Small descriptors */
170 172
171#define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) 173 0,
172#define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) 174 0,
175 0,
176 0,
177 ACPI_RS_SIZE(struct acpi_resource_irq),
178 ACPI_RS_SIZE(struct acpi_resource_dma),
179 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
180 ACPI_RS_SIZE_MIN,
181 ACPI_RS_SIZE(struct acpi_resource_io),
182 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
183 0,
184 0,
185 0,
186 0,
187 ACPI_RS_SIZE(struct acpi_resource_vendor),
188 ACPI_RS_SIZE_MIN,
173 189
174/* 190 /* Large descriptors */
175 * Base sizes of resource descriptors, both the AML stream resource length
176 * (minus size of header and length fields),and the size of the internal
177 * struct representation.
178 */
179struct acpi_resource_info acpi_gbl_sm_resource_info[] = {
180 {0, 0, 0},
181 {0, 0, 0},
182 {0, 0, 0},
183 {0, 0, 0},
184 {2, ACPI_RSMALL(struct aml_resource_irq),
185 ACPI_RS_SIZE(struct acpi_resource_irq)},
186 {0, ACPI_RSMALL(struct aml_resource_dma),
187 ACPI_RS_SIZE(struct acpi_resource_dma)},
188 {2, ACPI_RSMALL(struct aml_resource_start_dependent),
189 ACPI_RS_SIZE(struct acpi_resource_start_dependent)},
190 {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN},
191 {0, ACPI_RSMALL(struct aml_resource_io),
192 ACPI_RS_SIZE(struct acpi_resource_io)},
193 {0, ACPI_RSMALL(struct aml_resource_fixed_io),
194 ACPI_RS_SIZE(struct acpi_resource_fixed_io)},
195 {0, 0, 0},
196 {0, 0, 0},
197 {0, 0, 0},
198 {0, 0, 0},
199 {1, ACPI_RSMALL(struct aml_resource_vendor_small),
200 ACPI_RS_SIZE(struct acpi_resource_vendor)},
201 {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN}
202};
203 191
204struct acpi_resource_info acpi_gbl_lg_resource_info[] = { 192 0,
205 {0, 0, 0}, 193 ACPI_RS_SIZE(struct acpi_resource_memory24),
206 {0, ACPI_RLARGE(struct aml_resource_memory24), 194 ACPI_RS_SIZE(struct acpi_resource_generic_register),
207 ACPI_RS_SIZE(struct acpi_resource_memory24)}, 195 0,
208 {0, ACPI_RLARGE(struct aml_resource_generic_register), 196 ACPI_RS_SIZE(struct acpi_resource_vendor),
209 ACPI_RS_SIZE(struct acpi_resource_generic_register)}, 197 ACPI_RS_SIZE(struct acpi_resource_memory32),
210 {0, 0, 0}, 198 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
211 {1, ACPI_RLARGE(struct aml_resource_vendor_large), 199 ACPI_RS_SIZE(struct acpi_resource_address32),
212 ACPI_RS_SIZE(struct acpi_resource_vendor)}, 200 ACPI_RS_SIZE(struct acpi_resource_address16),
213 {0, ACPI_RLARGE(struct aml_resource_memory32), 201 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
214 ACPI_RS_SIZE(struct acpi_resource_memory32)}, 202 ACPI_RS_SIZE(struct acpi_resource_address64),
215 {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), 203 ACPI_RS_SIZE(struct acpi_resource_extended_address64)
216 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)},
217 {1, ACPI_RLARGE(struct aml_resource_address32),
218 ACPI_RS_SIZE(struct acpi_resource_address32)},
219 {1, ACPI_RLARGE(struct aml_resource_address16),
220 ACPI_RS_SIZE(struct acpi_resource_address16)},
221 {1, ACPI_RLARGE(struct aml_resource_extended_irq),
222 ACPI_RS_SIZE(struct acpi_resource_extended_irq)},
223 {1, ACPI_RLARGE(struct aml_resource_address64),
224 ACPI_RS_SIZE(struct acpi_resource_address64)},
225 {0, ACPI_RLARGE(struct aml_resource_extended_address64),
226 ACPI_RS_SIZE(struct acpi_resource_extended_address64)}
227}; 204};
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index ee17ef3315f8..b83996233c1d 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -47,115 +47,12 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rslist") 48ACPI_MODULE_NAME("rslist")
49 49
50/* Local prototypes */
51static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8
52 resource_type);
53
54static 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
71static 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
129static 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 * FUNCTION: acpi_rs_convert_aml_to_resources 52 * FUNCTION: acpi_rs_convert_aml_to_resources
156 * 53 *
157 * PARAMETERS: aml_buffer - Pointer to the resource byte stream 54 * PARAMETERS: Aml - Pointer to the resource byte stream
158 * aml_buffer_length - Length of aml_buffer 55 * aml_length - Length of Aml
159 * output_buffer - Pointer to the buffer that will 56 * output_buffer - Pointer to the buffer that will
160 * contain the output structures 57 * contain the output structures
161 * 58 *
@@ -165,42 +62,24 @@ static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type)
165 * linked list of resources in the caller's output buffer 62 * linked list of resources in the caller's output buffer
166 * 63 *
167 ******************************************************************************/ 64 ******************************************************************************/
168
169acpi_status 65acpi_status
170acpi_rs_convert_aml_to_resources(u8 * aml_buffer, 66acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer)
171 u32 aml_buffer_length, u8 * output_buffer)
172{ 67{
173 u8 *buffer = output_buffer; 68 struct acpi_resource *resource = (void *)output_buffer;
174 acpi_status status; 69 acpi_status status;
175 acpi_size bytes_parsed = 0; 70 u8 resource_index;
176 struct acpi_resource *resource; 71 u8 *end_aml;
177 acpi_rsdesc_size descriptor_length;
178 struct acpi_rsconvert_info *info;
179 72
180 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); 73 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
181 74
182 /* Loop until end-of-buffer or an end_tag is found */ 75 end_aml = aml + aml_length;
183
184 while (bytes_parsed < aml_buffer_length) {
185 /* Get the conversion table associated with this Descriptor Type */
186
187 info = acpi_rs_get_conversion_info(*aml_buffer);
188 if (!info) {
189 /* No table indicates an invalid resource type */
190 76
191 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 77 /* Loop until end-of-buffer or an end_tag is found */
192 }
193 78
194 descriptor_length = acpi_ut_get_descriptor_length(aml_buffer); 79 while (aml < end_aml) {
80 /* Validate the Resource Type and Resource Length */
195 81
196 /* 82 status = acpi_ut_validate_resource(aml, &resource_index);
197 * Perform limited validation of the resource length, based upon
198 * what we know about the resource type
199 */
200 status =
201 acpi_rs_validate_resource_length(ACPI_CAST_PTR
202 (union aml_resource,
203 aml_buffer));
204 if (ACPI_FAILURE(status)) { 83 if (ACPI_FAILURE(status)) {
205 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
206 } 85 }
@@ -208,42 +87,36 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
208 /* Convert the AML byte stream resource to a local resource struct */ 87 /* Convert the AML byte stream resource to a local resource struct */
209 88
210 status = 89 status =
211 acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR 90 acpi_rs_convert_aml_to_resource(resource,
212 (struct acpi_resource,
213 buffer),
214 ACPI_CAST_PTR(union 91 ACPI_CAST_PTR(union
215 aml_resource, 92 aml_resource,
216 aml_buffer), 93 aml),
217 info); 94 acpi_gbl_get_resource_dispatch
95 [resource_index]);
218 if (ACPI_FAILURE(status)) { 96 if (ACPI_FAILURE(status)) {
219 ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); 97 ACPI_REPORT_ERROR(("Could not convert AML resource (Type %X) to resource, %s\n", *aml, acpi_format_exception(status)));
220 return_ACPI_STATUS(status); 98 return_ACPI_STATUS(status);
221 } 99 }
222 100
223 /* Set the aligned length of the new resource descriptor */
224
225 resource = ACPI_CAST_PTR(struct acpi_resource, buffer);
226 resource->length =
227 (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length);
228
229 /* Normal exit on completion of an end_tag resource descriptor */ 101 /* Normal exit on completion of an end_tag resource descriptor */
230 102
231 if (acpi_ut_get_resource_type(aml_buffer) == 103 if (acpi_ut_get_resource_type(aml) ==
232 ACPI_RESOURCE_NAME_END_TAG) { 104 ACPI_RESOURCE_NAME_END_TAG) {
233 return_ACPI_STATUS(AE_OK); 105 return_ACPI_STATUS(AE_OK);
234 } 106 }
235 107
236 /* Update counter and point to the next input resource */ 108 /* Point to the next input AML resource */
237 109
238 bytes_parsed += descriptor_length; 110 aml += acpi_ut_get_descriptor_length(aml);
239 aml_buffer += descriptor_length;
240 111
241 /* Point to the next structure in the output buffer */ 112 /* Point to the next structure in the output buffer */
242 113
243 buffer += resource->length; 114 resource =
115 ACPI_PTR_ADD(struct acpi_resource, resource,
116 resource->length);
244 } 117 }
245 118
246 /* Completed buffer, but did not find an end_tag resource descriptor */ 119 /* Did not find an end_tag resource descriptor */
247 120
248 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 121 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
249} 122}
@@ -271,16 +144,16 @@ acpi_status
271acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, 144acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
272 acpi_size aml_size_needed, u8 * output_buffer) 145 acpi_size aml_size_needed, u8 * output_buffer)
273{ 146{
274 u8 *aml_buffer = output_buffer; 147 u8 *aml = output_buffer;
275 u8 *end_aml_buffer = output_buffer + aml_size_needed; 148 u8 *end_aml = output_buffer + aml_size_needed;
276 acpi_status status; 149 acpi_status status;
277 150
278 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); 151 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
279 152
280 /* Walk the resource descriptor list, convert each descriptor */ 153 /* Walk the resource descriptor list, convert each descriptor */
281 154
282 while (aml_buffer < end_aml_buffer) { 155 while (aml < end_aml) {
283 /* Validate the Resource Type */ 156 /* Validate the (internal) Resource Type */
284 157
285 if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 158 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 159 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -294,7 +167,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
294 status = acpi_rs_convert_resource_to_aml(resource, 167 status = acpi_rs_convert_resource_to_aml(resource,
295 ACPI_CAST_PTR(union 168 ACPI_CAST_PTR(union
296 aml_resource, 169 aml_resource,
297 aml_buffer), 170 aml),
298 acpi_gbl_set_resource_dispatch 171 acpi_gbl_set_resource_dispatch
299 [resource->type]); 172 [resource->type]);
300 if (ACPI_FAILURE(status)) { 173 if (ACPI_FAILURE(status)) {
@@ -305,9 +178,8 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
305 /* Perform final sanity check on the new AML resource descriptor */ 178 /* Perform final sanity check on the new AML resource descriptor */
306 179
307 status = 180 status =
308 acpi_rs_validate_resource_length(ACPI_CAST_PTR 181 acpi_ut_validate_resource(ACPI_CAST_PTR
309 (union aml_resource, 182 (union aml_resource, aml), NULL);
310 aml_buffer));
311 if (ACPI_FAILURE(status)) { 183 if (ACPI_FAILURE(status)) {
312 return_ACPI_STATUS(status); 184 return_ACPI_STATUS(status);
313 } 185 }
@@ -322,18 +194,15 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
322 194
323 /* 195 /*
324 * Extract the total length of the new descriptor and set the 196 * Extract the total length of the new descriptor and set the
325 * aml_buffer to point to the next (output) resource descriptor 197 * Aml to point to the next (output) resource descriptor
326 */ 198 */
327 aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); 199 aml += acpi_ut_get_descriptor_length(aml);
328 200
329 /* Point to the next input resource descriptor */ 201 /* Point to the next input resource descriptor */
330 202
331 resource = 203 resource =
332 ACPI_PTR_ADD(struct acpi_resource, resource, 204 ACPI_PTR_ADD(struct acpi_resource, resource,
333 resource->length); 205 resource->length);
334
335 /* Check for end-of-list, normal exit */
336
337 } 206 }
338 207
339 /* Completed buffer, but did not find an end_tag resource descriptor */ 208 /* Completed buffer, but did not find an end_tag resource descriptor */
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 7613033f5dcf..a1eac0f1df54 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -65,6 +65,8 @@ u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
65 acpi_native_uint i; 65 acpi_native_uint i;
66 u8 bit_count; 66 u8 bit_count;
67 67
68 ACPI_FUNCTION_ENTRY();
69
68 /* Decode the mask bits */ 70 /* Decode the mask bits */
69 71
70 for (i = 0, bit_count = 0; mask; i++) { 72 for (i = 0, bit_count = 0; mask; i++) {
@@ -97,6 +99,8 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
97 acpi_native_uint i; 99 acpi_native_uint i;
98 u16 mask; 100 u16 mask;
99 101
102 ACPI_FUNCTION_ENTRY();
103
100 /* Encode the list into a single bitmask */ 104 /* Encode the list into a single bitmask */
101 105
102 for (i = 0, mask = 0; i < count; i++) { 106 for (i = 0, mask = 0; i < count; i++) {
@@ -128,6 +132,8 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
128{ 132{
129 acpi_native_uint i; 133 acpi_native_uint i;
130 134
135 ACPI_FUNCTION_ENTRY();
136
131 /* One move per item */ 137 /* One move per item */
132 138
133 for (i = 0; i < item_count; i++) { 139 for (i = 0; i < item_count; i++) {
@@ -168,53 +174,6 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
168 174
169/******************************************************************************* 175/*******************************************************************************
170 * 176 *
171 * FUNCTION: acpi_rs_get_resource_info
172 *
173 * PARAMETERS: resource_type - Byte 0 of a resource descriptor
174 *
175 * RETURN: Pointer to the resource conversion handler
176 *
177 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
178 * a resource descriptor.
179 *
180 ******************************************************************************/
181
182struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type)
183{
184 struct acpi_resource_info *size_info;
185
186 ACPI_FUNCTION_ENTRY();
187
188 /* Determine if this is a small or large resource */
189
190 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
191 /* Large Resource Type -- bits 6:0 contain the name */
192
193 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
194 return (NULL);
195 }
196
197 size_info = &acpi_gbl_lg_resource_info[(resource_type &
198 ACPI_RESOURCE_NAME_LARGE_MASK)];
199 } else {
200 /* Small Resource Type -- bits 6:3 contain the name */
201
202 size_info = &acpi_gbl_sm_resource_info[((resource_type &
203 ACPI_RESOURCE_NAME_SMALL_MASK)
204 >> 3)];
205 }
206
207 /* Zero entry indicates an invalid resource type */
208
209 if (!size_info->minimum_internal_struct_length) {
210 return (NULL);
211 }
212
213 return (size_info);
214}
215
216/*******************************************************************************
217 *
218 * FUNCTION: acpi_rs_set_resource_length 177 * FUNCTION: acpi_rs_set_resource_length
219 * 178 *
220 * PARAMETERS: total_length - Length of the AML descriptor, including 179 * PARAMETERS: total_length - Length of the AML descriptor, including
@@ -238,25 +197,20 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
238 197
239 ACPI_FUNCTION_ENTRY(); 198 ACPI_FUNCTION_ENTRY();
240 199
241 /* Determine if this is a small or large resource */ 200 /* Length is the total descriptor length minus the header length */
242 201
243 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { 202 resource_length = (acpi_rs_length)
244 /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 203 (total_length - acpi_ut_get_resource_header_length(aml));
245 204
246 resource_length = (acpi_rs_length) 205 /* Length is stored differently for large and small descriptors */
247 (total_length - sizeof(struct aml_resource_large_header));
248 206
249 /* Insert length into the Large descriptor length field */ 207 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
208 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
250 209
251 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, 210 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
252 &resource_length); 211 &resource_length);
253 } else { 212 } else {
254 /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 213 /* Small descriptor -- bits 2:0 of byte 0 contain the length */
255
256 resource_length = (acpi_rs_length)
257 (total_length - sizeof(struct aml_resource_small_header));
258
259 /* Insert length into the descriptor type byte */
260 214
261 aml->small_header.descriptor_type = (u8) 215 aml->small_header.descriptor_type = (u8)
262 216
@@ -292,7 +246,7 @@ acpi_rs_set_resource_header(u8 descriptor_type,
292{ 246{
293 ACPI_FUNCTION_ENTRY(); 247 ACPI_FUNCTION_ENTRY();
294 248
295 /* Set the Descriptor Type */ 249 /* Set the Resource Type */
296 250
297 aml->small_header.descriptor_type = descriptor_type; 251 aml->small_header.descriptor_type = descriptor_type;
298 252
@@ -409,14 +363,14 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
409 (char *)&aml_resource_source[1]); 363 (char *)&aml_resource_source[1]);
410 364
411 return ((acpi_rs_length) total_length); 365 return ((acpi_rs_length) total_length);
412 } else {
413 /* resource_source is not present */
414
415 resource_source->index = 0;
416 resource_source->string_length = 0;
417 resource_source->string_ptr = NULL;
418 return (0);
419 } 366 }
367
368 /* resource_source is not present */
369
370 resource_source->index = 0;
371 resource_source->string_length = 0;
372 resource_source->string_ptr = NULL;
373 return (0);
420} 374}
421 375
422/******************************************************************************* 376/*******************************************************************************
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
index e87108b7338a..88eff14c4894 100644
--- a/drivers/acpi/utilities/Makefile
+++ b/drivers/acpi/utilities/Makefile
@@ -2,7 +2,8 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 5obj-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 6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
7 utstate.o utmutex.o utobject.o utcache.o utresrc.o
7 8
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index e9058d4da122..2a9110c06391 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/amlresrc.h>
47 46
48#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utmisc") 48ACPI_MODULE_NAME("utmisc")
@@ -791,153 +790,6 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
791 790
792/******************************************************************************* 791/*******************************************************************************
793 * 792 *
794 * FUNCTION: acpi_ut_get_resource_type
795 *
796 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
797 *
798 * RETURN: The Resource Type with no extraneous bits (except the
799 * Large/Small descriptor bit -- this is left alone)
800 *
801 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
802 * a resource descriptor.
803 *
804 ******************************************************************************/
805
806u8 acpi_ut_get_resource_type(void *aml)
807{
808 ACPI_FUNCTION_ENTRY();
809
810 /*
811 * Byte 0 contains the descriptor name (Resource Type)
812 * Determine if this is a small or large resource
813 */
814 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
815 /* Large Resource Type -- bits 6:0 contain the name */
816
817 return (*((u8 *) aml));
818 } else {
819 /* Small Resource Type -- bits 6:3 contain the name */
820
821 return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
822 }
823}
824
825/*******************************************************************************
826 *
827 * FUNCTION: acpi_ut_get_resource_length
828 *
829 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
830 *
831 * RETURN: Byte Length
832 *
833 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
834 * definition, this does not include the size of the descriptor
835 * header or the length field itself.
836 *
837 ******************************************************************************/
838
839u16 acpi_ut_get_resource_length(void *aml)
840{
841 u16 resource_length;
842
843 ACPI_FUNCTION_ENTRY();
844
845 /*
846 * Byte 0 contains the descriptor name (Resource Type)
847 * Determine if this is a small or large resource
848 */
849 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
850 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
851
852 ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]);
853
854 } else {
855 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
856
857 resource_length = (u16) (*((u8 *) aml) &
858 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
859 }
860
861 return (resource_length);
862}
863
864/*******************************************************************************
865 *
866 * FUNCTION: acpi_ut_get_descriptor_length
867 *
868 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
869 *
870 * RETURN: Byte length
871 *
872 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
873 * length of the descriptor header and the length field itself.
874 * Used to walk descriptor lists.
875 *
876 ******************************************************************************/
877
878u32 acpi_ut_get_descriptor_length(void *aml)
879{
880 u32 descriptor_length;
881
882 ACPI_FUNCTION_ENTRY();
883
884 /* First get the Resource Length (Does not include header length) */
885
886 descriptor_length = acpi_ut_get_resource_length(aml);
887
888 /* Determine if this is a small or large resource */
889
890 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
891 descriptor_length += sizeof(struct aml_resource_large_header);
892 } else {
893 descriptor_length += sizeof(struct aml_resource_small_header);
894 }
895
896 return (descriptor_length);
897}
898
899/*******************************************************************************
900 *
901 * FUNCTION: acpi_ut_get_resource_end_tag
902 *
903 * PARAMETERS: obj_desc - The resource template buffer object
904 *
905 * RETURN: Pointer to the end tag
906 *
907 * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template
908 *
909 ******************************************************************************/
910
911u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
912{
913 u8 *aml;
914 u8 *end_aml;
915
916 aml = obj_desc->buffer.pointer;
917 end_aml = aml + obj_desc->buffer.length;
918
919 /* Walk the resource template, one descriptor per loop */
920
921 while (aml < end_aml) {
922 if (acpi_ut_get_resource_type(aml) ==
923 ACPI_RESOURCE_NAME_END_TAG) {
924 /* Found the end_tag descriptor, all done */
925
926 return (aml);
927 }
928
929 /* Point to the next resource descriptor */
930
931 aml += acpi_ut_get_resource_length(aml);
932 }
933
934 /* End tag was not found */
935
936 return (NULL);
937}
938
939/*******************************************************************************
940 *
941 * FUNCTION: acpi_ut_report_error 793 * FUNCTION: acpi_ut_report_error
942 * 794 *
943 * PARAMETERS: module_name - Caller's module name (for error output) 795 * PARAMETERS: module_name - Caller's module name (for error output)
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
new file mode 100644
index 000000000000..07a314c710d8
--- /dev/null
+++ b/drivers/acpi/utilities/utresrc.c
@@ -0,0 +1,428 @@
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
48ACPI_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 */
54const 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 */
96static 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
148acpi_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
261u8 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
294u16 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
331u8 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
358u32 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
382acpi_status
383acpi_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}
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index c1cb27583be8..6ff1d7073349 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -63,7 +63,7 @@ acpi_status
63acpi_ut_create_pkg_state_and_push(void *internal_object, 63acpi_ut_create_pkg_state_and_push(void *internal_object,
64 void *external_object, 64 void *external_object,
65 u16 index, 65 u16 index,
66 union acpi_generic_state ** state_list) 66 union acpi_generic_state **state_list)
67{ 67{
68 union acpi_generic_state *state; 68 union acpi_generic_state *state;
69 69
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index f06bd5e5e9d1..57adc5bc02f3 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -178,10 +178,14 @@ acpi_status acpi_enable_subsystem(u32 flags)
178 /* 178 /*
179 * Initialize ACPI Event handling (Fixed and General Purpose) 179 * Initialize ACPI Event handling (Fixed and General Purpose)
180 * 180 *
181 * NOTE: We must have the hardware AND events initialized before we can 181 * Note1: We must have the hardware and events initialized before we can
182 * execute ANY control methods SAFELY. Any control method can require 182 * execute any control methods safely. Any control method can require
183 * ACPI hardware support, so the hardware MUST be initialized before 183 * ACPI hardware support, so the hardware must be fully initialized before
184 * execution! 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 if (!(flags & ACPI_NO_EVENT_INIT)) { 190 if (!(flags & ACPI_NO_EVENT_INIT)) {
187 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 191 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -193,8 +197,10 @@ acpi_status acpi_enable_subsystem(u32 flags)
193 } 197 }
194 } 198 }
195 199
196 /* Install the SCI handler and Global Lock handler */ 200 /*
197 201 * Install the SCI handler and Global Lock handler. This completes the
202 * hardware initialization.
203 */
198 if (!(flags & ACPI_NO_HANDLER_INIT)) { 204 if (!(flags & ACPI_NO_HANDLER_INIT)) {
199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 205 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
200 "[Init] Installing SCI/GL handlers\n")); 206 "[Init] Installing SCI/GL handlers\n"));
@@ -205,6 +211,24 @@ acpi_status acpi_enable_subsystem(u32 flags)
205 } 211 }
206 } 212 }
207 213
214 /*
215 * Complete the GPE initialization for the GPE blocks defined in the FADT
216 * (GPE block 0 and 1).
217 *
218 * Note1: This is where the _PRW methods are executed for the GPEs. These
219 * methods can only be executed after the SCI and Global Lock handlers are
220 * installed and initialized.
221 *
222 * Note2: Currently, there seems to be no need to run the _REG methods
223 * before execution of the _PRW methods and enabling of the GPEs.
224 */
225 if (!(flags & ACPI_NO_EVENT_INIT)) {
226 status = acpi_ev_install_fadt_gpes();
227 if (ACPI_FAILURE(status)) {
228 return (status);
229 }
230 }
231
208 return_ACPI_STATUS(status); 232 return_ACPI_STATUS(status);
209} 233}
210 234
@@ -230,9 +254,9 @@ acpi_status acpi_initialize_objects(u32 flags)
230 /* 254 /*
231 * Run all _REG methods 255 * Run all _REG methods
232 * 256 *
233 * NOTE: Any objects accessed 257 * Note: Any objects accessed by the _REG methods will be automatically
234 * by the _REG methods will be automatically initialized, even if they 258 * initialized, even if they contain executable AML (see the call to
235 * contain executable AML (see call to acpi_ns_initialize_objects below). 259 * acpi_ns_initialize_objects below).
236 */ 260 */
237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 261 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 262 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -245,9 +269,9 @@ acpi_status acpi_initialize_objects(u32 flags)
245 } 269 }
246 270
247 /* 271 /*
248 * Initialize the objects that remain uninitialized. This 272 * Initialize the objects that remain uninitialized. This runs the
249 * runs the executable AML that may be part of the declaration of these 273 * executable AML that may be part of the declaration of these objects:
250 * objects: operation_regions, buffer_fields, Buffers, and Packages. 274 * operation_regions, buffer_fields, Buffers, and Packages.
251 */ 275 */
252 if (!(flags & ACPI_NO_OBJECT_INIT)) { 276 if (!(flags & ACPI_NO_OBJECT_INIT)) {
253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 277 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -260,8 +284,8 @@ acpi_status acpi_initialize_objects(u32 flags)
260 } 284 }
261 285
262 /* 286 /*
263 * Initialize all device objects in the namespace 287 * Initialize all device objects in the namespace. This runs the device
264 * This runs the _STA and _INI methods. 288 * _STA and _INI methods.
265 */ 289 */
266 if (!(flags & ACPI_NO_DEVICE_INIT)) { 290 if (!(flags & ACPI_NO_DEVICE_INIT)) {
267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 291 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,