diff options
Diffstat (limited to 'drivers/acpi')
58 files changed, 3030 insertions, 2390 deletions
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index d7790db50178..ebc07aab710c 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c | |||
@@ -99,7 +99,7 @@ acpi_ds_init_one_object ( | |||
99 | * was just loaded | 99 | * was just loaded |
100 | */ | 100 | */ |
101 | if (((struct acpi_namespace_node *) obj_handle)->owner_id != | 101 | if (((struct acpi_namespace_node *) obj_handle)->owner_id != |
102 | info->table_desc->table_id) { | 102 | info->table_desc->owner_id) { |
103 | return (AE_OK); | 103 | return (AE_OK); |
104 | } | 104 | } |
105 | 105 | ||
@@ -168,7 +168,7 @@ acpi_ds_init_one_object ( | |||
168 | */ | 168 | */ |
169 | acpi_ns_delete_namespace_subtree (obj_handle); | 169 | acpi_ns_delete_namespace_subtree (obj_handle); |
170 | acpi_ns_delete_namespace_by_owner ( | 170 | acpi_ns_delete_namespace_by_owner ( |
171 | ((struct acpi_namespace_node *) obj_handle)->object->method.owning_id); | 171 | ((struct acpi_namespace_node *) obj_handle)->object->method.owner_id); |
172 | break; | 172 | break; |
173 | 173 | ||
174 | 174 | ||
@@ -237,7 +237,7 @@ acpi_ds_initialize_objects ( | |||
237 | 237 | ||
238 | ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, | 238 | ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, |
239 | "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", | 239 | "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", |
240 | table_desc->pointer->signature, table_desc->table_id, info.object_count, | 240 | table_desc->pointer->signature, table_desc->owner_id, info.object_count, |
241 | info.device_count, info.method_count, info.op_region_count)); | 241 | info.device_count, info.method_count, info.op_region_count)); |
242 | 242 | ||
243 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, | 243 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, |
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 9fc3f4c033eb..1b90813cbde1 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c | |||
@@ -77,7 +77,6 @@ acpi_ds_parse_method ( | |||
77 | union acpi_operand_object *obj_desc; | 77 | union acpi_operand_object *obj_desc; |
78 | union acpi_parse_object *op; | 78 | union acpi_parse_object *op; |
79 | struct acpi_namespace_node *node; | 79 | struct acpi_namespace_node *node; |
80 | acpi_owner_id owner_id; | ||
81 | struct acpi_walk_state *walk_state; | 80 | struct acpi_walk_state *walk_state; |
82 | 81 | ||
83 | 82 | ||
@@ -132,14 +131,18 @@ acpi_ds_parse_method ( | |||
132 | * objects (such as Operation Regions) can be created during the | 131 | * objects (such as Operation Regions) can be created during the |
133 | * first pass parse. | 132 | * first pass parse. |
134 | */ | 133 | */ |
135 | owner_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); | 134 | status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); |
136 | obj_desc->method.owning_id = owner_id; | 135 | if (ACPI_FAILURE (status)) { |
136 | goto cleanup; | ||
137 | } | ||
137 | 138 | ||
138 | /* Create and initialize a new walk state */ | 139 | /* Create and initialize a new walk state */ |
139 | 140 | ||
140 | walk_state = acpi_ds_create_walk_state (owner_id, NULL, NULL, NULL); | 141 | walk_state = acpi_ds_create_walk_state ( |
142 | obj_desc->method.owner_id, NULL, NULL, NULL); | ||
141 | if (!walk_state) { | 143 | if (!walk_state) { |
142 | return_ACPI_STATUS (AE_NO_MEMORY); | 144 | status = AE_NO_MEMORY; |
145 | goto cleanup2; | ||
143 | } | 146 | } |
144 | 147 | ||
145 | status = acpi_ds_init_aml_walk (walk_state, op, node, | 148 | status = acpi_ds_init_aml_walk (walk_state, op, node, |
@@ -147,7 +150,7 @@ acpi_ds_parse_method ( | |||
147 | obj_desc->method.aml_length, NULL, 1); | 150 | obj_desc->method.aml_length, NULL, 1); |
148 | if (ACPI_FAILURE (status)) { | 151 | if (ACPI_FAILURE (status)) { |
149 | acpi_ds_delete_walk_state (walk_state); | 152 | acpi_ds_delete_walk_state (walk_state); |
150 | return_ACPI_STATUS (status); | 153 | goto cleanup2; |
151 | } | 154 | } |
152 | 155 | ||
153 | /* | 156 | /* |
@@ -161,13 +164,17 @@ acpi_ds_parse_method ( | |||
161 | */ | 164 | */ |
162 | status = acpi_ps_parse_aml (walk_state); | 165 | status = acpi_ps_parse_aml (walk_state); |
163 | if (ACPI_FAILURE (status)) { | 166 | if (ACPI_FAILURE (status)) { |
164 | return_ACPI_STATUS (status); | 167 | goto cleanup2; |
165 | } | 168 | } |
166 | 169 | ||
167 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, | 170 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, |
168 | "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", | 171 | "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", |
169 | acpi_ut_get_node_name (obj_handle), obj_handle, op)); | 172 | acpi_ut_get_node_name (obj_handle), obj_handle, op)); |
170 | 173 | ||
174 | cleanup2: | ||
175 | (void) acpi_ut_release_owner_id (obj_desc->method.owner_id); | ||
176 | |||
177 | cleanup: | ||
171 | acpi_ps_delete_parse_tree (op); | 178 | acpi_ps_delete_parse_tree (op); |
172 | return_ACPI_STATUS (status); | 179 | return_ACPI_STATUS (status); |
173 | } | 180 | } |
@@ -263,7 +270,7 @@ acpi_ds_call_control_method ( | |||
263 | { | 270 | { |
264 | acpi_status status; | 271 | acpi_status status; |
265 | struct acpi_namespace_node *method_node; | 272 | struct acpi_namespace_node *method_node; |
266 | struct acpi_walk_state *next_walk_state; | 273 | struct acpi_walk_state *next_walk_state = NULL; |
267 | union acpi_operand_object *obj_desc; | 274 | union acpi_operand_object *obj_desc; |
268 | struct acpi_parameter_info info; | 275 | struct acpi_parameter_info info; |
269 | u32 i; | 276 | u32 i; |
@@ -287,20 +294,23 @@ acpi_ds_call_control_method ( | |||
287 | return_ACPI_STATUS (AE_NULL_OBJECT); | 294 | return_ACPI_STATUS (AE_NULL_OBJECT); |
288 | } | 295 | } |
289 | 296 | ||
290 | obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); | 297 | status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); |
298 | if (ACPI_FAILURE (status)) { | ||
299 | return_ACPI_STATUS (status); | ||
300 | } | ||
291 | 301 | ||
292 | /* Init for new method, wait on concurrency semaphore */ | 302 | /* Init for new method, wait on concurrency semaphore */ |
293 | 303 | ||
294 | status = acpi_ds_begin_method_execution (method_node, obj_desc, | 304 | status = acpi_ds_begin_method_execution (method_node, obj_desc, |
295 | this_walk_state->method_node); | 305 | this_walk_state->method_node); |
296 | if (ACPI_FAILURE (status)) { | 306 | if (ACPI_FAILURE (status)) { |
297 | return_ACPI_STATUS (status); | 307 | goto cleanup; |
298 | } | 308 | } |
299 | 309 | ||
300 | if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { | 310 | if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { |
301 | /* 1) Parse: Create a new walk state for the preempting walk */ | 311 | /* 1) Parse: Create a new walk state for the preempting walk */ |
302 | 312 | ||
303 | next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, | 313 | next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, |
304 | op, obj_desc, NULL); | 314 | op, obj_desc, NULL); |
305 | if (!next_walk_state) { | 315 | if (!next_walk_state) { |
306 | return_ACPI_STATUS (AE_NO_MEMORY); | 316 | return_ACPI_STATUS (AE_NO_MEMORY); |
@@ -330,7 +340,7 @@ acpi_ds_call_control_method ( | |||
330 | 340 | ||
331 | /* 2) Execute: Create a new state for the preempting walk */ | 341 | /* 2) Execute: Create a new state for the preempting walk */ |
332 | 342 | ||
333 | next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, | 343 | next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, |
334 | NULL, obj_desc, thread); | 344 | NULL, obj_desc, thread); |
335 | if (!next_walk_state) { | 345 | if (!next_walk_state) { |
336 | status = AE_NO_MEMORY; | 346 | status = AE_NO_MEMORY; |
@@ -381,6 +391,7 @@ acpi_ds_call_control_method ( | |||
381 | /* On error, we must delete the new walk state */ | 391 | /* On error, we must delete the new walk state */ |
382 | 392 | ||
383 | cleanup: | 393 | cleanup: |
394 | (void) acpi_ut_release_owner_id (obj_desc->method.owner_id); | ||
384 | if (next_walk_state && (next_walk_state->method_desc)) { | 395 | if (next_walk_state && (next_walk_state->method_desc)) { |
385 | /* Decrement the thread count on the method parse tree */ | 396 | /* Decrement the thread count on the method parse tree */ |
386 | 397 | ||
@@ -582,7 +593,7 @@ acpi_ds_terminate_control_method ( | |||
582 | * Delete any namespace entries created anywhere else within | 593 | * Delete any namespace entries created anywhere else within |
583 | * the namespace | 594 | * the namespace |
584 | */ | 595 | */ |
585 | acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); | 596 | acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id); |
586 | status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); | 597 | status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); |
587 | if (ACPI_FAILURE (status)) { | 598 | if (ACPI_FAILURE (status)) { |
588 | return_ACPI_STATUS (status); | 599 | return_ACPI_STATUS (status); |
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index f7998306f756..c83d53fd6398 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c | |||
@@ -633,22 +633,11 @@ acpi_ds_store_object_to_local ( | |||
633 | */ | 633 | */ |
634 | if (opcode == AML_ARG_OP) { | 634 | if (opcode == AML_ARG_OP) { |
635 | /* | 635 | /* |
636 | * Make sure that the object is the correct type. This may be | ||
637 | * overkill, butit is here because references were NS nodes in | ||
638 | * the past. Now they are operand objects of type Reference. | ||
639 | */ | ||
640 | if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) { | ||
641 | ACPI_REPORT_ERROR (( | ||
642 | "Invalid descriptor type while storing to method arg: [%s]\n", | ||
643 | acpi_ut_get_descriptor_name (current_obj_desc))); | ||
644 | return_ACPI_STATUS (AE_AML_INTERNAL); | ||
645 | } | ||
646 | |||
647 | /* | ||
648 | * If we have a valid reference object that came from ref_of(), | 636 | * If we have a valid reference object that came from ref_of(), |
649 | * do the indirect store | 637 | * do the indirect store |
650 | */ | 638 | */ |
651 | if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && | 639 | if ((ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_OPERAND) && |
640 | (current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && | ||
652 | (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { | 641 | (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { |
653 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | 642 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
654 | "Arg (%p) is an obj_ref(Node), storing in node %p\n", | 643 | "Arg (%p) is an obj_ref(Node), storing in node %p\n", |
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index bfbae4e4c667..1eee2d54180f 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c | |||
@@ -547,6 +547,9 @@ acpi_ds_init_object_from_op ( | |||
547 | case AML_TYPE_LITERAL: | 547 | case AML_TYPE_LITERAL: |
548 | 548 | ||
549 | obj_desc->integer.value = op->common.value.integer; | 549 | obj_desc->integer.value = op->common.value.integer; |
550 | #ifndef ACPI_NO_METHOD_EXECUTION | ||
551 | acpi_ex_truncate_for32bit_table (obj_desc); | ||
552 | #endif | ||
550 | break; | 553 | break; |
551 | 554 | ||
552 | 555 | ||
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index ba13bca28bee..750bdb1ac344 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c | |||
@@ -119,14 +119,15 @@ acpi_ds_execute_arguments ( | |||
119 | 119 | ||
120 | walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); | 120 | walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); |
121 | if (!walk_state) { | 121 | if (!walk_state) { |
122 | return_ACPI_STATUS (AE_NO_MEMORY); | 122 | status = AE_NO_MEMORY; |
123 | goto cleanup; | ||
123 | } | 124 | } |
124 | 125 | ||
125 | status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, | 126 | status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, |
126 | aml_length, NULL, 1); | 127 | aml_length, NULL, 1); |
127 | if (ACPI_FAILURE (status)) { | 128 | if (ACPI_FAILURE (status)) { |
128 | acpi_ds_delete_walk_state (walk_state); | 129 | acpi_ds_delete_walk_state (walk_state); |
129 | return_ACPI_STATUS (status); | 130 | goto cleanup; |
130 | } | 131 | } |
131 | 132 | ||
132 | /* Mark this parse as a deferred opcode */ | 133 | /* Mark this parse as a deferred opcode */ |
@@ -138,8 +139,7 @@ acpi_ds_execute_arguments ( | |||
138 | 139 | ||
139 | status = acpi_ps_parse_aml (walk_state); | 140 | status = acpi_ps_parse_aml (walk_state); |
140 | if (ACPI_FAILURE (status)) { | 141 | if (ACPI_FAILURE (status)) { |
141 | acpi_ps_delete_parse_tree (op); | 142 | goto cleanup; |
142 | return_ACPI_STATUS (status); | ||
143 | } | 143 | } |
144 | 144 | ||
145 | /* Get and init the Op created above */ | 145 | /* Get and init the Op created above */ |
@@ -160,7 +160,8 @@ acpi_ds_execute_arguments ( | |||
160 | 160 | ||
161 | walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); | 161 | walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); |
162 | if (!walk_state) { | 162 | if (!walk_state) { |
163 | return_ACPI_STATUS (AE_NO_MEMORY); | 163 | status = AE_NO_MEMORY; |
164 | goto cleanup; | ||
164 | } | 165 | } |
165 | 166 | ||
166 | /* Execute the opcode and arguments */ | 167 | /* Execute the opcode and arguments */ |
@@ -169,13 +170,15 @@ acpi_ds_execute_arguments ( | |||
169 | aml_length, NULL, 3); | 170 | aml_length, NULL, 3); |
170 | if (ACPI_FAILURE (status)) { | 171 | if (ACPI_FAILURE (status)) { |
171 | acpi_ds_delete_walk_state (walk_state); | 172 | acpi_ds_delete_walk_state (walk_state); |
172 | return_ACPI_STATUS (status); | 173 | goto cleanup; |
173 | } | 174 | } |
174 | 175 | ||
175 | /* Mark this execution as a deferred opcode */ | 176 | /* Mark this execution as a deferred opcode */ |
176 | 177 | ||
177 | walk_state->deferred_node = node; | 178 | walk_state->deferred_node = node; |
178 | status = acpi_ps_parse_aml (walk_state); | 179 | status = acpi_ps_parse_aml (walk_state); |
180 | |||
181 | cleanup: | ||
179 | acpi_ps_delete_parse_tree (op); | 182 | acpi_ps_delete_parse_tree (op); |
180 | return_ACPI_STATUS (status); | 183 | return_ACPI_STATUS (status); |
181 | } | 184 | } |
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 1ac197ccfc80..d2c603f54fd6 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c | |||
@@ -50,7 +50,7 @@ | |||
50 | #include <acpi/acnamesp.h> | 50 | #include <acpi/acnamesp.h> |
51 | #include <acpi/acevents.h> | 51 | #include <acpi/acevents.h> |
52 | 52 | ||
53 | #ifdef _ACPI_ASL_COMPILER | 53 | #ifdef ACPI_ASL_COMPILER |
54 | #include <acpi/acdisasm.h> | 54 | #include <acpi/acdisasm.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
@@ -145,15 +145,6 @@ acpi_ds_load1_begin_op ( | |||
145 | 145 | ||
146 | if (op) { | 146 | if (op) { |
147 | if (!(walk_state->op_info->flags & AML_NAMED)) { | 147 | if (!(walk_state->op_info->flags & AML_NAMED)) { |
148 | #if 0 | ||
149 | if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || | ||
150 | (walk_state->op_info->class == AML_CLASS_CONTROL)) { | ||
151 | acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n", | ||
152 | walk_state->op_info->name); | ||
153 | *out_op = op; | ||
154 | return (AE_CTRL_SKIP); | ||
155 | } | ||
156 | #endif | ||
157 | *out_op = op; | 148 | *out_op = op; |
158 | return (AE_OK); | 149 | return (AE_OK); |
159 | } | 150 | } |
@@ -185,7 +176,7 @@ acpi_ds_load1_begin_op ( | |||
185 | */ | 176 | */ |
186 | status = acpi_ns_lookup (walk_state->scope_info, path, object_type, | 177 | status = acpi_ns_lookup (walk_state->scope_info, path, object_type, |
187 | ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); | 178 | ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); |
188 | #ifdef _ACPI_ASL_COMPILER | 179 | #ifdef ACPI_ASL_COMPILER |
189 | if (status == AE_NOT_FOUND) { | 180 | if (status == AE_NOT_FOUND) { |
190 | /* | 181 | /* |
191 | * Table disassembly: | 182 | * Table disassembly: |
@@ -486,6 +477,15 @@ acpi_ds_load2_begin_op ( | |||
486 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); | 477 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); |
487 | 478 | ||
488 | if (op) { | 479 | if (op) { |
480 | if ((walk_state->control_state) && | ||
481 | (walk_state->control_state->common.state == | ||
482 | ACPI_CONTROL_CONDITIONAL_EXECUTING)) { | ||
483 | /* We are executing a while loop outside of a method */ | ||
484 | |||
485 | status = acpi_ds_exec_begin_op (walk_state, out_op); | ||
486 | return_ACPI_STATUS (status); | ||
487 | } | ||
488 | |||
489 | /* We only care about Namespace opcodes here */ | 489 | /* We only care about Namespace opcodes here */ |
490 | 490 | ||
491 | if ((!(walk_state->op_info->flags & AML_NSOPCODE) && | 491 | if ((!(walk_state->op_info->flags & AML_NSOPCODE) && |
@@ -493,9 +493,14 @@ acpi_ds_load2_begin_op ( | |||
493 | (!(walk_state->op_info->flags & AML_NAMED))) { | 493 | (!(walk_state->op_info->flags & AML_NAMED))) { |
494 | if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || | 494 | if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || |
495 | (walk_state->op_info->class == AML_CLASS_CONTROL)) { | 495 | (walk_state->op_info->class == AML_CLASS_CONTROL)) { |
496 | ACPI_REPORT_WARNING (( | 496 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, |
497 | "Encountered executable code at module level, [%s]\n", | 497 | "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, |
498 | acpi_ps_get_opcode_name (walk_state->opcode))); | 498 | walk_state->op_info->flags)); |
499 | |||
500 | /* Executing a type1 or type2 opcode outside of a method */ | ||
501 | |||
502 | status = acpi_ds_exec_begin_op (walk_state, out_op); | ||
503 | return_ACPI_STATUS (status); | ||
499 | } | 504 | } |
500 | return_ACPI_STATUS (AE_OK); | 505 | return_ACPI_STATUS (AE_OK); |
501 | } | 506 | } |
@@ -564,7 +569,7 @@ acpi_ds_load2_begin_op ( | |||
564 | ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, | 569 | ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, |
565 | walk_state, &(node)); | 570 | walk_state, &(node)); |
566 | if (ACPI_FAILURE (status)) { | 571 | if (ACPI_FAILURE (status)) { |
567 | #ifdef _ACPI_ASL_COMPILER | 572 | #ifdef ACPI_ASL_COMPILER |
568 | if (status == AE_NOT_FOUND) { | 573 | if (status == AE_NOT_FOUND) { |
569 | status = AE_OK; | 574 | status = AE_OK; |
570 | } | 575 | } |
@@ -657,8 +662,10 @@ acpi_ds_load2_begin_op ( | |||
657 | break; | 662 | break; |
658 | } | 663 | } |
659 | 664 | ||
665 | /* Add new entry into namespace */ | ||
666 | |||
660 | status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, | 667 | status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, |
661 | ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, | 668 | ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, |
662 | walk_state, &(node)); | 669 | walk_state, &(node)); |
663 | break; | 670 | break; |
664 | } | 671 | } |
@@ -668,7 +675,6 @@ acpi_ds_load2_begin_op ( | |||
668 | return_ACPI_STATUS (status); | 675 | return_ACPI_STATUS (status); |
669 | } | 676 | } |
670 | 677 | ||
671 | |||
672 | if (!op) { | 678 | if (!op) { |
673 | /* Create a new op */ | 679 | /* Create a new op */ |
674 | 680 | ||
@@ -682,9 +688,7 @@ acpi_ds_load2_begin_op ( | |||
682 | if (node) { | 688 | if (node) { |
683 | op->named.name = node->name.integer; | 689 | op->named.name = node->name.integer; |
684 | } | 690 | } |
685 | if (out_op) { | 691 | *out_op = op; |
686 | *out_op = op; | ||
687 | } | ||
688 | } | 692 | } |
689 | 693 | ||
690 | /* | 694 | /* |
@@ -731,9 +735,24 @@ acpi_ds_load2_end_op ( | |||
731 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", | 735 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", |
732 | walk_state->op_info->name, op, walk_state)); | 736 | walk_state->op_info->name, op, walk_state)); |
733 | 737 | ||
734 | /* Only interested in opcodes that have namespace objects */ | 738 | /* Check if opcode had an associated namespace object */ |
735 | 739 | ||
736 | if (!(walk_state->op_info->flags & AML_NSOBJECT)) { | 740 | if (!(walk_state->op_info->flags & AML_NSOBJECT)) { |
741 | #ifndef ACPI_NO_METHOD_EXECUTION | ||
742 | /* No namespace object. Executable opcode? */ | ||
743 | |||
744 | if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || | ||
745 | (walk_state->op_info->class == AML_CLASS_CONTROL)) { | ||
746 | ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, | ||
747 | "End/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, | ||
748 | walk_state->op_info->flags)); | ||
749 | |||
750 | /* Executing a type1 or type2 opcode outside of a method */ | ||
751 | |||
752 | status = acpi_ds_exec_end_op (walk_state); | ||
753 | return_ACPI_STATUS (status); | ||
754 | } | ||
755 | #endif | ||
737 | return_ACPI_STATUS (AE_OK); | 756 | return_ACPI_STATUS (AE_OK); |
738 | } | 757 | } |
739 | 758 | ||
@@ -742,7 +761,6 @@ acpi_ds_load2_end_op ( | |||
742 | "Ending scope Op=%p State=%p\n", op, walk_state)); | 761 | "Ending scope Op=%p State=%p\n", op, walk_state)); |
743 | } | 762 | } |
744 | 763 | ||
745 | |||
746 | object_type = walk_state->op_info->object_type; | 764 | object_type = walk_state->op_info->object_type; |
747 | 765 | ||
748 | /* | 766 | /* |
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 9cd3db652b31..d360d8e89544 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c | |||
@@ -261,12 +261,12 @@ acpi_ds_result_pop_from_bottom ( | |||
261 | 261 | ||
262 | if (!*object) { | 262 | if (!*object) { |
263 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | 263 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
264 | "Null operand! State=%p #Ops=%X, Index=%X\n", | 264 | "Null operand! State=%p #Ops=%X Index=%X\n", |
265 | walk_state, state->results.num_results, (u32) index)); | 265 | walk_state, state->results.num_results, (u32) index)); |
266 | return (AE_AML_NO_RETURN_VALUE); | 266 | return (AE_AML_NO_RETURN_VALUE); |
267 | } | 267 | } |
268 | 268 | ||
269 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n", | 269 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", |
270 | *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", | 270 | *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL", |
271 | state, walk_state)); | 271 | state, walk_state)); |
272 | 272 | ||
@@ -681,7 +681,7 @@ acpi_ds_create_walk_state ( | |||
681 | ACPI_FUNCTION_TRACE ("ds_create_walk_state"); | 681 | ACPI_FUNCTION_TRACE ("ds_create_walk_state"); |
682 | 682 | ||
683 | 683 | ||
684 | walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK); | 684 | walk_state = ACPI_MEM_CALLOCATE (sizeof (struct acpi_walk_state)); |
685 | if (!walk_state) { | 685 | if (!walk_state) { |
686 | return_PTR (NULL); | 686 | return_PTR (NULL); |
687 | } | 687 | } |
@@ -704,7 +704,7 @@ acpi_ds_create_walk_state ( | |||
704 | 704 | ||
705 | status = acpi_ds_result_stack_push (walk_state); | 705 | status = acpi_ds_result_stack_push (walk_state); |
706 | if (ACPI_FAILURE (status)) { | 706 | if (ACPI_FAILURE (status)) { |
707 | acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); | 707 | ACPI_MEM_FREE (walk_state); |
708 | return_PTR (NULL); | 708 | return_PTR (NULL); |
709 | } | 709 | } |
710 | 710 | ||
@@ -762,6 +762,7 @@ acpi_ds_init_aml_walk ( | |||
762 | /* The next_op of the next_walk will be the beginning of the method */ | 762 | /* The next_op of the next_walk will be the beginning of the method */ |
763 | 763 | ||
764 | walk_state->next_op = NULL; | 764 | walk_state->next_op = NULL; |
765 | walk_state->pass_number = (u8) pass_number; | ||
765 | 766 | ||
766 | if (info) { | 767 | if (info) { |
767 | if (info->parameter_type == ACPI_PARAM_GPE) { | 768 | if (info->parameter_type == ACPI_PARAM_GPE) { |
@@ -899,38 +900,11 @@ acpi_ds_delete_walk_state ( | |||
899 | acpi_ut_delete_generic_state (state); | 900 | acpi_ut_delete_generic_state (state); |
900 | } | 901 | } |
901 | 902 | ||
902 | acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); | 903 | ACPI_MEM_FREE (walk_state); |
903 | return_VOID; | 904 | return_VOID; |
904 | } | 905 | } |
905 | 906 | ||
906 | 907 | ||
907 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
908 | /****************************************************************************** | ||
909 | * | ||
910 | * FUNCTION: acpi_ds_delete_walk_state_cache | ||
911 | * | ||
912 | * PARAMETERS: None | ||
913 | * | ||
914 | * RETURN: None | ||
915 | * | ||
916 | * DESCRIPTION: Purge the global state object cache. Used during subsystem | ||
917 | * termination. | ||
918 | * | ||
919 | ******************************************************************************/ | ||
920 | |||
921 | void | ||
922 | acpi_ds_delete_walk_state_cache ( | ||
923 | void) | ||
924 | { | ||
925 | ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache"); | ||
926 | |||
927 | |||
928 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK); | ||
929 | return_VOID; | ||
930 | } | ||
931 | #endif | ||
932 | |||
933 | |||
934 | #ifdef ACPI_OBSOLETE_FUNCTIONS | 908 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
935 | /******************************************************************************* | 909 | /******************************************************************************* |
936 | * | 910 | * |
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index 081120b109ba..ede834df4f69 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c | |||
@@ -396,6 +396,7 @@ acpi_ev_gpe_detect ( | |||
396 | struct acpi_gpe_register_info *gpe_register_info; | 396 | struct acpi_gpe_register_info *gpe_register_info; |
397 | u32 status_reg; | 397 | u32 status_reg; |
398 | u32 enable_reg; | 398 | u32 enable_reg; |
399 | u32 flags; | ||
399 | acpi_status status; | 400 | acpi_status status; |
400 | struct acpi_gpe_block_info *gpe_block; | 401 | struct acpi_gpe_block_info *gpe_block; |
401 | acpi_native_uint i; | 402 | acpi_native_uint i; |
@@ -412,7 +413,7 @@ acpi_ev_gpe_detect ( | |||
412 | 413 | ||
413 | /* Examine all GPE blocks attached to this interrupt level */ | 414 | /* Examine all GPE blocks attached to this interrupt level */ |
414 | 415 | ||
415 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR); | 416 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
416 | gpe_block = gpe_xrupt_list->gpe_block_list_head; | 417 | gpe_block = gpe_xrupt_list->gpe_block_list_head; |
417 | while (gpe_block) { | 418 | while (gpe_block) { |
418 | /* | 419 | /* |
@@ -476,7 +477,7 @@ acpi_ev_gpe_detect ( | |||
476 | 477 | ||
477 | unlock_and_exit: | 478 | unlock_and_exit: |
478 | 479 | ||
479 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR); | 480 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
480 | return (int_status); | 481 | return (int_status); |
481 | } | 482 | } |
482 | 483 | ||
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index 84186a7d17b2..dfc54692b127 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c | |||
@@ -66,7 +66,7 @@ acpi_ev_match_prw_and_gpe ( | |||
66 | 66 | ||
67 | static struct acpi_gpe_xrupt_info * | 67 | static struct acpi_gpe_xrupt_info * |
68 | acpi_ev_get_gpe_xrupt_block ( | 68 | acpi_ev_get_gpe_xrupt_block ( |
69 | u32 interrupt_level); | 69 | u32 interrupt_number); |
70 | 70 | ||
71 | static acpi_status | 71 | static acpi_status |
72 | acpi_ev_delete_gpe_xrupt ( | 72 | acpi_ev_delete_gpe_xrupt ( |
@@ -75,7 +75,7 @@ acpi_ev_delete_gpe_xrupt ( | |||
75 | static acpi_status | 75 | static acpi_status |
76 | acpi_ev_install_gpe_block ( | 76 | acpi_ev_install_gpe_block ( |
77 | struct acpi_gpe_block_info *gpe_block, | 77 | struct acpi_gpe_block_info *gpe_block, |
78 | u32 interrupt_level); | 78 | u32 interrupt_number); |
79 | 79 | ||
80 | static acpi_status | 80 | static acpi_status |
81 | acpi_ev_create_gpe_info_blocks ( | 81 | acpi_ev_create_gpe_info_blocks ( |
@@ -138,7 +138,6 @@ acpi_ev_valid_gpe_event ( | |||
138 | * FUNCTION: acpi_ev_walk_gpe_list | 138 | * FUNCTION: acpi_ev_walk_gpe_list |
139 | * | 139 | * |
140 | * PARAMETERS: gpe_walk_callback - Routine called for each GPE block | 140 | * PARAMETERS: gpe_walk_callback - Routine called for each GPE block |
141 | * Flags - ACPI_NOT_ISR or ACPI_ISR | ||
142 | * | 141 | * |
143 | * RETURN: Status | 142 | * RETURN: Status |
144 | * | 143 | * |
@@ -148,18 +147,18 @@ acpi_ev_valid_gpe_event ( | |||
148 | 147 | ||
149 | acpi_status | 148 | acpi_status |
150 | acpi_ev_walk_gpe_list ( | 149 | acpi_ev_walk_gpe_list ( |
151 | ACPI_GPE_CALLBACK gpe_walk_callback, | 150 | ACPI_GPE_CALLBACK gpe_walk_callback) |
152 | u32 flags) | ||
153 | { | 151 | { |
154 | struct acpi_gpe_block_info *gpe_block; | 152 | struct acpi_gpe_block_info *gpe_block; |
155 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | 153 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; |
156 | acpi_status status = AE_OK; | 154 | acpi_status status = AE_OK; |
155 | u32 flags; | ||
157 | 156 | ||
158 | 157 | ||
159 | ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); | 158 | ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); |
160 | 159 | ||
161 | 160 | ||
162 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, flags); | 161 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
163 | 162 | ||
164 | /* Walk the interrupt level descriptor list */ | 163 | /* Walk the interrupt level descriptor list */ |
165 | 164 | ||
@@ -482,7 +481,7 @@ cleanup: | |||
482 | * | 481 | * |
483 | * FUNCTION: acpi_ev_get_gpe_xrupt_block | 482 | * FUNCTION: acpi_ev_get_gpe_xrupt_block |
484 | * | 483 | * |
485 | * PARAMETERS: interrupt_level - Interrupt for a GPE block | 484 | * PARAMETERS: interrupt_number - Interrupt for a GPE block |
486 | * | 485 | * |
487 | * RETURN: A GPE interrupt block | 486 | * RETURN: A GPE interrupt block |
488 | * | 487 | * |
@@ -495,11 +494,12 @@ cleanup: | |||
495 | 494 | ||
496 | static struct acpi_gpe_xrupt_info * | 495 | static struct acpi_gpe_xrupt_info * |
497 | acpi_ev_get_gpe_xrupt_block ( | 496 | acpi_ev_get_gpe_xrupt_block ( |
498 | u32 interrupt_level) | 497 | u32 interrupt_number) |
499 | { | 498 | { |
500 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; | 499 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; |
501 | struct acpi_gpe_xrupt_info *gpe_xrupt; | 500 | struct acpi_gpe_xrupt_info *gpe_xrupt; |
502 | acpi_status status; | 501 | acpi_status status; |
502 | u32 flags; | ||
503 | 503 | ||
504 | 504 | ||
505 | ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); | 505 | ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); |
@@ -509,7 +509,7 @@ acpi_ev_get_gpe_xrupt_block ( | |||
509 | 509 | ||
510 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | 510 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; |
511 | while (next_gpe_xrupt) { | 511 | while (next_gpe_xrupt) { |
512 | if (next_gpe_xrupt->interrupt_level == interrupt_level) { | 512 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { |
513 | return_PTR (next_gpe_xrupt); | 513 | return_PTR (next_gpe_xrupt); |
514 | } | 514 | } |
515 | 515 | ||
@@ -523,11 +523,11 @@ acpi_ev_get_gpe_xrupt_block ( | |||
523 | return_PTR (NULL); | 523 | return_PTR (NULL); |
524 | } | 524 | } |
525 | 525 | ||
526 | gpe_xrupt->interrupt_level = interrupt_level; | 526 | gpe_xrupt->interrupt_number = interrupt_number; |
527 | 527 | ||
528 | /* Install new interrupt descriptor with spin lock */ | 528 | /* Install new interrupt descriptor with spin lock */ |
529 | 529 | ||
530 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 530 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
531 | if (acpi_gbl_gpe_xrupt_list_head) { | 531 | if (acpi_gbl_gpe_xrupt_list_head) { |
532 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | 532 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; |
533 | while (next_gpe_xrupt->next) { | 533 | while (next_gpe_xrupt->next) { |
@@ -540,17 +540,17 @@ acpi_ev_get_gpe_xrupt_block ( | |||
540 | else { | 540 | else { |
541 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; | 541 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; |
542 | } | 542 | } |
543 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 543 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
544 | 544 | ||
545 | /* Install new interrupt handler if not SCI_INT */ | 545 | /* Install new interrupt handler if not SCI_INT */ |
546 | 546 | ||
547 | if (interrupt_level != acpi_gbl_FADT->sci_int) { | 547 | if (interrupt_number != acpi_gbl_FADT->sci_int) { |
548 | status = acpi_os_install_interrupt_handler (interrupt_level, | 548 | status = acpi_os_install_interrupt_handler (interrupt_number, |
549 | acpi_ev_gpe_xrupt_handler, gpe_xrupt); | 549 | acpi_ev_gpe_xrupt_handler, gpe_xrupt); |
550 | if (ACPI_FAILURE (status)) { | 550 | if (ACPI_FAILURE (status)) { |
551 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | 551 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
552 | "Could not install GPE interrupt handler at level 0x%X\n", | 552 | "Could not install GPE interrupt handler at level 0x%X\n", |
553 | interrupt_level)); | 553 | interrupt_number)); |
554 | return_PTR (NULL); | 554 | return_PTR (NULL); |
555 | } | 555 | } |
556 | } | 556 | } |
@@ -577,6 +577,7 @@ acpi_ev_delete_gpe_xrupt ( | |||
577 | struct acpi_gpe_xrupt_info *gpe_xrupt) | 577 | struct acpi_gpe_xrupt_info *gpe_xrupt) |
578 | { | 578 | { |
579 | acpi_status status; | 579 | acpi_status status; |
580 | u32 flags; | ||
580 | 581 | ||
581 | 582 | ||
582 | ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt"); | 583 | ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt"); |
@@ -584,14 +585,14 @@ acpi_ev_delete_gpe_xrupt ( | |||
584 | 585 | ||
585 | /* We never want to remove the SCI interrupt handler */ | 586 | /* We never want to remove the SCI interrupt handler */ |
586 | 587 | ||
587 | if (gpe_xrupt->interrupt_level == acpi_gbl_FADT->sci_int) { | 588 | if (gpe_xrupt->interrupt_number == acpi_gbl_FADT->sci_int) { |
588 | gpe_xrupt->gpe_block_list_head = NULL; | 589 | gpe_xrupt->gpe_block_list_head = NULL; |
589 | return_ACPI_STATUS (AE_OK); | 590 | return_ACPI_STATUS (AE_OK); |
590 | } | 591 | } |
591 | 592 | ||
592 | /* Disable this interrupt */ | 593 | /* Disable this interrupt */ |
593 | 594 | ||
594 | status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_level, | 595 | status = acpi_os_remove_interrupt_handler (gpe_xrupt->interrupt_number, |
595 | acpi_ev_gpe_xrupt_handler); | 596 | acpi_ev_gpe_xrupt_handler); |
596 | if (ACPI_FAILURE (status)) { | 597 | if (ACPI_FAILURE (status)) { |
597 | return_ACPI_STATUS (status); | 598 | return_ACPI_STATUS (status); |
@@ -599,7 +600,7 @@ acpi_ev_delete_gpe_xrupt ( | |||
599 | 600 | ||
600 | /* Unlink the interrupt block with lock */ | 601 | /* Unlink the interrupt block with lock */ |
601 | 602 | ||
602 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 603 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
603 | if (gpe_xrupt->previous) { | 604 | if (gpe_xrupt->previous) { |
604 | gpe_xrupt->previous->next = gpe_xrupt->next; | 605 | gpe_xrupt->previous->next = gpe_xrupt->next; |
605 | } | 606 | } |
@@ -607,7 +608,7 @@ acpi_ev_delete_gpe_xrupt ( | |||
607 | if (gpe_xrupt->next) { | 608 | if (gpe_xrupt->next) { |
608 | gpe_xrupt->next->previous = gpe_xrupt->previous; | 609 | gpe_xrupt->next->previous = gpe_xrupt->previous; |
609 | } | 610 | } |
610 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 611 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
611 | 612 | ||
612 | /* Free the block */ | 613 | /* Free the block */ |
613 | 614 | ||
@@ -621,7 +622,7 @@ acpi_ev_delete_gpe_xrupt ( | |||
621 | * FUNCTION: acpi_ev_install_gpe_block | 622 | * FUNCTION: acpi_ev_install_gpe_block |
622 | * | 623 | * |
623 | * PARAMETERS: gpe_block - New GPE block | 624 | * PARAMETERS: gpe_block - New GPE block |
624 | * interrupt_level - Level to be associated with this GPE block | 625 | * interrupt_number - Xrupt to be associated with this GPE block |
625 | * | 626 | * |
626 | * RETURN: Status | 627 | * RETURN: Status |
627 | * | 628 | * |
@@ -632,11 +633,12 @@ acpi_ev_delete_gpe_xrupt ( | |||
632 | static acpi_status | 633 | static acpi_status |
633 | acpi_ev_install_gpe_block ( | 634 | acpi_ev_install_gpe_block ( |
634 | struct acpi_gpe_block_info *gpe_block, | 635 | struct acpi_gpe_block_info *gpe_block, |
635 | u32 interrupt_level) | 636 | u32 interrupt_number) |
636 | { | 637 | { |
637 | struct acpi_gpe_block_info *next_gpe_block; | 638 | struct acpi_gpe_block_info *next_gpe_block; |
638 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; | 639 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; |
639 | acpi_status status; | 640 | acpi_status status; |
641 | u32 flags; | ||
640 | 642 | ||
641 | 643 | ||
642 | ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); | 644 | ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); |
@@ -647,7 +649,7 @@ acpi_ev_install_gpe_block ( | |||
647 | return_ACPI_STATUS (status); | 649 | return_ACPI_STATUS (status); |
648 | } | 650 | } |
649 | 651 | ||
650 | gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_level); | 652 | gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block (interrupt_number); |
651 | if (!gpe_xrupt_block) { | 653 | if (!gpe_xrupt_block) { |
652 | status = AE_NO_MEMORY; | 654 | status = AE_NO_MEMORY; |
653 | goto unlock_and_exit; | 655 | goto unlock_and_exit; |
@@ -655,7 +657,7 @@ acpi_ev_install_gpe_block ( | |||
655 | 657 | ||
656 | /* Install the new block at the end of the list with lock */ | 658 | /* Install the new block at the end of the list with lock */ |
657 | 659 | ||
658 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 660 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
659 | if (gpe_xrupt_block->gpe_block_list_head) { | 661 | if (gpe_xrupt_block->gpe_block_list_head) { |
660 | next_gpe_block = gpe_xrupt_block->gpe_block_list_head; | 662 | next_gpe_block = gpe_xrupt_block->gpe_block_list_head; |
661 | while (next_gpe_block->next) { | 663 | while (next_gpe_block->next) { |
@@ -670,7 +672,7 @@ acpi_ev_install_gpe_block ( | |||
670 | } | 672 | } |
671 | 673 | ||
672 | gpe_block->xrupt_block = gpe_xrupt_block; | 674 | gpe_block->xrupt_block = gpe_xrupt_block; |
673 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 675 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
674 | 676 | ||
675 | unlock_and_exit: | 677 | unlock_and_exit: |
676 | status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); | 678 | status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); |
@@ -695,6 +697,7 @@ acpi_ev_delete_gpe_block ( | |||
695 | struct acpi_gpe_block_info *gpe_block) | 697 | struct acpi_gpe_block_info *gpe_block) |
696 | { | 698 | { |
697 | acpi_status status; | 699 | acpi_status status; |
700 | u32 flags; | ||
698 | 701 | ||
699 | 702 | ||
700 | ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); | 703 | ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); |
@@ -720,7 +723,7 @@ acpi_ev_delete_gpe_block ( | |||
720 | else { | 723 | else { |
721 | /* Remove the block on this interrupt with lock */ | 724 | /* Remove the block on this interrupt with lock */ |
722 | 725 | ||
723 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 726 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
724 | if (gpe_block->previous) { | 727 | if (gpe_block->previous) { |
725 | gpe_block->previous->next = gpe_block->next; | 728 | gpe_block->previous->next = gpe_block->next; |
726 | } | 729 | } |
@@ -731,7 +734,7 @@ acpi_ev_delete_gpe_block ( | |||
731 | if (gpe_block->next) { | 734 | if (gpe_block->next) { |
732 | gpe_block->next->previous = gpe_block->previous; | 735 | gpe_block->next->previous = gpe_block->previous; |
733 | } | 736 | } |
734 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 737 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
735 | } | 738 | } |
736 | 739 | ||
737 | /* Free the gpe_block */ | 740 | /* Free the gpe_block */ |
@@ -887,7 +890,7 @@ error_exit: | |||
887 | * gpe_block_address - Address and space_iD | 890 | * gpe_block_address - Address and space_iD |
888 | * register_count - Number of GPE register pairs in the block | 891 | * register_count - Number of GPE register pairs in the block |
889 | * gpe_block_base_number - Starting GPE number for the block | 892 | * gpe_block_base_number - Starting GPE number for the block |
890 | * interrupt_level - H/W interrupt for the block | 893 | * interrupt_number - H/W interrupt for the block |
891 | * return_gpe_block - Where the new block descriptor is returned | 894 | * return_gpe_block - Where the new block descriptor is returned |
892 | * | 895 | * |
893 | * RETURN: Status | 896 | * RETURN: Status |
@@ -902,7 +905,7 @@ acpi_ev_create_gpe_block ( | |||
902 | struct acpi_generic_address *gpe_block_address, | 905 | struct acpi_generic_address *gpe_block_address, |
903 | u32 register_count, | 906 | u32 register_count, |
904 | u8 gpe_block_base_number, | 907 | u8 gpe_block_base_number, |
905 | u32 interrupt_level, | 908 | u32 interrupt_number, |
906 | struct acpi_gpe_block_info **return_gpe_block) | 909 | struct acpi_gpe_block_info **return_gpe_block) |
907 | { | 910 | { |
908 | struct acpi_gpe_block_info *gpe_block; | 911 | struct acpi_gpe_block_info *gpe_block; |
@@ -948,7 +951,7 @@ acpi_ev_create_gpe_block ( | |||
948 | 951 | ||
949 | /* Install the new block in the global list(s) */ | 952 | /* Install the new block in the global list(s) */ |
950 | 953 | ||
951 | status = acpi_ev_install_gpe_block (gpe_block, interrupt_level); | 954 | status = acpi_ev_install_gpe_block (gpe_block, interrupt_number); |
952 | if (ACPI_FAILURE (status)) { | 955 | if (ACPI_FAILURE (status)) { |
953 | ACPI_MEM_FREE (gpe_block); | 956 | ACPI_MEM_FREE (gpe_block); |
954 | return_ACPI_STATUS (status); | 957 | return_ACPI_STATUS (status); |
@@ -1013,7 +1016,7 @@ acpi_ev_create_gpe_block ( | |||
1013 | ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), | 1016 | ((gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) -1)), |
1014 | gpe_device->name.ascii, | 1017 | gpe_device->name.ascii, |
1015 | gpe_block->register_count, | 1018 | gpe_block->register_count, |
1016 | interrupt_level)); | 1019 | interrupt_number)); |
1017 | 1020 | ||
1018 | /* Enable all valid GPEs found above */ | 1021 | /* Enable all valid GPEs found above */ |
1019 | 1022 | ||
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 659e90956112..38d7ab8aef3a 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c | |||
@@ -589,7 +589,7 @@ acpi_ev_terminate ( | |||
589 | 589 | ||
590 | /* Disable all GPEs in all GPE blocks */ | 590 | /* Disable all GPEs in all GPE blocks */ |
591 | 591 | ||
592 | status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR); | 592 | status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); |
593 | 593 | ||
594 | /* Remove SCI handler */ | 594 | /* Remove SCI handler */ |
595 | 595 | ||
@@ -602,7 +602,7 @@ acpi_ev_terminate ( | |||
602 | 602 | ||
603 | /* Deallocate all handler objects installed within GPE info structs */ | 603 | /* Deallocate all handler objects installed within GPE info structs */ |
604 | 604 | ||
605 | status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR); | 605 | status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers); |
606 | 606 | ||
607 | /* Return to original mode if necessary */ | 607 | /* Return to original mode if necessary */ |
608 | 608 | ||
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index 95bc09c73a6a..f2d53af97610 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c | |||
@@ -218,10 +218,14 @@ acpi_ev_pci_config_region_setup ( | |||
218 | while (pci_root_node != acpi_gbl_root_node) { | 218 | while (pci_root_node != acpi_gbl_root_node) { |
219 | status = acpi_ut_execute_HID (pci_root_node, &object_hID); | 219 | status = acpi_ut_execute_HID (pci_root_node, &object_hID); |
220 | if (ACPI_SUCCESS (status)) { | 220 | if (ACPI_SUCCESS (status)) { |
221 | /* Got a valid _HID, check if this is a PCI root */ | 221 | /* |
222 | 222 | * Got a valid _HID string, check if this is a PCI root. | |
223 | * New for ACPI 3.0: check for a PCI Express root also. | ||
224 | */ | ||
223 | if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, | 225 | if (!(ACPI_STRNCMP (object_hID.value, PCI_ROOT_HID_STRING, |
224 | sizeof (PCI_ROOT_HID_STRING)))) { | 226 | sizeof (PCI_ROOT_HID_STRING)) || |
227 | !(ACPI_STRNCMP (object_hID.value, PCI_EXPRESS_ROOT_HID_STRING, | ||
228 | sizeof (PCI_EXPRESS_ROOT_HID_STRING))))) { | ||
225 | /* Install a handler for this PCI root bridge */ | 229 | /* Install a handler for this PCI root bridge */ |
226 | 230 | ||
227 | status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, | 231 | status = acpi_install_address_space_handler ((acpi_handle) pci_root_node, |
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index 4092d47f6758..4c1c25e316a8 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c | |||
@@ -591,6 +591,7 @@ acpi_install_gpe_handler ( | |||
591 | struct acpi_gpe_event_info *gpe_event_info; | 591 | struct acpi_gpe_event_info *gpe_event_info; |
592 | struct acpi_handler_info *handler; | 592 | struct acpi_handler_info *handler; |
593 | acpi_status status; | 593 | acpi_status status; |
594 | u32 flags; | ||
594 | 595 | ||
595 | 596 | ||
596 | ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler"); | 597 | ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler"); |
@@ -643,7 +644,7 @@ acpi_install_gpe_handler ( | |||
643 | 644 | ||
644 | /* Install the handler */ | 645 | /* Install the handler */ |
645 | 646 | ||
646 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 647 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
647 | gpe_event_info->dispatch.handler = handler; | 648 | gpe_event_info->dispatch.handler = handler; |
648 | 649 | ||
649 | /* Setup up dispatch flags to indicate handler (vs. method) */ | 650 | /* Setup up dispatch flags to indicate handler (vs. method) */ |
@@ -651,7 +652,7 @@ acpi_install_gpe_handler ( | |||
651 | gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ | 652 | gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ |
652 | gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); | 653 | gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); |
653 | 654 | ||
654 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 655 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
655 | 656 | ||
656 | 657 | ||
657 | unlock_and_exit: | 658 | unlock_and_exit: |
@@ -685,6 +686,7 @@ acpi_remove_gpe_handler ( | |||
685 | struct acpi_gpe_event_info *gpe_event_info; | 686 | struct acpi_gpe_event_info *gpe_event_info; |
686 | struct acpi_handler_info *handler; | 687 | struct acpi_handler_info *handler; |
687 | acpi_status status; | 688 | acpi_status status; |
689 | u32 flags; | ||
688 | 690 | ||
689 | 691 | ||
690 | ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler"); | 692 | ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler"); |
@@ -741,7 +743,7 @@ acpi_remove_gpe_handler ( | |||
741 | 743 | ||
742 | /* Remove the handler */ | 744 | /* Remove the handler */ |
743 | 745 | ||
744 | acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 746 | flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock); |
745 | handler = gpe_event_info->dispatch.handler; | 747 | handler = gpe_event_info->dispatch.handler; |
746 | 748 | ||
747 | /* Restore Method node (if any), set dispatch flags */ | 749 | /* Restore Method node (if any), set dispatch flags */ |
@@ -751,7 +753,7 @@ acpi_remove_gpe_handler ( | |||
751 | if (handler->method_node) { | 753 | if (handler->method_node) { |
752 | gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; | 754 | gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; |
753 | } | 755 | } |
754 | acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); | 756 | acpi_os_release_lock (acpi_gbl_gpe_lock, flags); |
755 | 757 | ||
756 | /* Now we can free the handler object */ | 758 | /* Now we can free the handler object */ |
757 | 759 | ||
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index f337dc2cc569..c5f74d7b64d8 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c | |||
@@ -635,7 +635,7 @@ unlock_and_exit: | |||
635 | * PARAMETERS: gpe_device - Handle to the parent GPE Block Device | 635 | * PARAMETERS: gpe_device - Handle to the parent GPE Block Device |
636 | * gpe_block_address - Address and space_iD | 636 | * gpe_block_address - Address and space_iD |
637 | * register_count - Number of GPE register pairs in the block | 637 | * register_count - Number of GPE register pairs in the block |
638 | * interrupt_level - H/W interrupt for the block | 638 | * interrupt_number - H/W interrupt for the block |
639 | * | 639 | * |
640 | * RETURN: Status | 640 | * RETURN: Status |
641 | * | 641 | * |
@@ -648,7 +648,7 @@ acpi_install_gpe_block ( | |||
648 | acpi_handle gpe_device, | 648 | acpi_handle gpe_device, |
649 | struct acpi_generic_address *gpe_block_address, | 649 | struct acpi_generic_address *gpe_block_address, |
650 | u32 register_count, | 650 | u32 register_count, |
651 | u32 interrupt_level) | 651 | u32 interrupt_number) |
652 | { | 652 | { |
653 | acpi_status status; | 653 | acpi_status status; |
654 | union acpi_operand_object *obj_desc; | 654 | union acpi_operand_object *obj_desc; |
@@ -681,7 +681,7 @@ acpi_install_gpe_block ( | |||
681 | * is always zero | 681 | * is always zero |
682 | */ | 682 | */ |
683 | status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count, | 683 | status = acpi_ev_create_gpe_block (node, gpe_block_address, register_count, |
684 | 0, interrupt_level, &gpe_block); | 684 | 0, interrupt_number, &gpe_block); |
685 | if (ACPI_FAILURE (status)) { | 685 | if (ACPI_FAILURE (status)) { |
686 | goto unlock_and_exit; | 686 | goto unlock_and_exit; |
687 | } | 687 | } |
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 734b2f24af48..76c6ebd0231f 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c | |||
@@ -376,16 +376,22 @@ acpi_ex_load_op ( | |||
376 | */ | 376 | */ |
377 | status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); | 377 | status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc); |
378 | if (ACPI_FAILURE (status)) { | 378 | if (ACPI_FAILURE (status)) { |
379 | goto cleanup; | 379 | return_ACPI_STATUS (status); |
380 | } | 380 | } |
381 | 381 | ||
382 | table_ptr = ACPI_CAST_PTR (struct acpi_table_header, | 382 | table_ptr = ACPI_CAST_PTR (struct acpi_table_header, |
383 | buffer_desc->buffer.pointer); | 383 | buffer_desc->buffer.pointer); |
384 | 384 | ||
385 | /* Sanity check the table length */ | 385 | /* All done with the buffer_desc, delete it */ |
386 | |||
387 | buffer_desc->buffer.pointer = NULL; | ||
388 | acpi_ut_remove_reference (buffer_desc); | ||
389 | |||
390 | /* Sanity check the table length */ | ||
386 | 391 | ||
387 | if (table_ptr->length < sizeof (struct acpi_table_header)) { | 392 | if (table_ptr->length < sizeof (struct acpi_table_header)) { |
388 | return_ACPI_STATUS (AE_BAD_HEADER); | 393 | status = AE_BAD_HEADER; |
394 | goto cleanup; | ||
389 | } | 395 | } |
390 | break; | 396 | break; |
391 | 397 | ||
@@ -413,7 +419,9 @@ acpi_ex_load_op ( | |||
413 | 419 | ||
414 | status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); | 420 | status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle); |
415 | if (ACPI_FAILURE (status)) { | 421 | if (ACPI_FAILURE (status)) { |
416 | goto cleanup; | 422 | /* On error, table_ptr was deallocated above */ |
423 | |||
424 | return_ACPI_STATUS (status); | ||
417 | } | 425 | } |
418 | 426 | ||
419 | /* Store the ddb_handle into the Target operand */ | 427 | /* Store the ddb_handle into the Target operand */ |
@@ -421,17 +429,14 @@ acpi_ex_load_op ( | |||
421 | status = acpi_ex_store (ddb_handle, target, walk_state); | 429 | status = acpi_ex_store (ddb_handle, target, walk_state); |
422 | if (ACPI_FAILURE (status)) { | 430 | if (ACPI_FAILURE (status)) { |
423 | (void) acpi_ex_unload_table (ddb_handle); | 431 | (void) acpi_ex_unload_table (ddb_handle); |
424 | } | ||
425 | 432 | ||
426 | return_ACPI_STATUS (status); | 433 | /* table_ptr was deallocated above */ |
427 | 434 | ||
435 | return_ACPI_STATUS (status); | ||
436 | } | ||
428 | 437 | ||
429 | cleanup: | 438 | cleanup: |
430 | 439 | if (ACPI_FAILURE (status)) { | |
431 | if (buffer_desc) { | ||
432 | acpi_ut_remove_reference (buffer_desc); | ||
433 | } | ||
434 | else { | ||
435 | ACPI_MEM_FREE (table_ptr); | 440 | ACPI_MEM_FREE (table_ptr); |
436 | } | 441 | } |
437 | return_ACPI_STATUS (status); | 442 | return_ACPI_STATUS (status); |
@@ -482,7 +487,7 @@ acpi_ex_unload_table ( | |||
482 | * Delete the entire namespace under this table Node | 487 | * Delete the entire namespace under this table Node |
483 | * (Offset contains the table_id) | 488 | * (Offset contains the table_id) |
484 | */ | 489 | */ |
485 | acpi_ns_delete_namespace_by_owner (table_info->table_id); | 490 | acpi_ns_delete_namespace_by_owner (table_info->owner_id); |
486 | 491 | ||
487 | /* Delete the table itself */ | 492 | /* Delete the table itself */ |
488 | 493 | ||
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index 97856c48bd74..21331625e66e 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c | |||
@@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii ( | |||
367 | 367 | ||
368 | /* hex_length: 2 ascii hex chars per data byte */ | 368 | /* hex_length: 2 ascii hex chars per data byte */ |
369 | 369 | ||
370 | hex_length = ACPI_MUL_2 (data_width); | 370 | hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width); |
371 | for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { | 371 | for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { |
372 | /* Get one hex digit, most significant digits first */ | 372 | /* Get one hex digit, most significant digits first */ |
373 | 373 | ||
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 408500648114..fd13cc3db018 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c | |||
@@ -51,6 +51,11 @@ | |||
51 | #define _COMPONENT ACPI_EXECUTER | 51 | #define _COMPONENT ACPI_EXECUTER |
52 | ACPI_MODULE_NAME ("exdump") | 52 | ACPI_MODULE_NAME ("exdump") |
53 | 53 | ||
54 | /* | ||
55 | * The following routines are used for debug output only | ||
56 | */ | ||
57 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | ||
58 | |||
54 | /* Local prototypes */ | 59 | /* Local prototypes */ |
55 | 60 | ||
56 | #ifdef ACPI_FUTURE_USAGE | 61 | #ifdef ACPI_FUTURE_USAGE |
@@ -73,13 +78,17 @@ static void | |||
73 | acpi_ex_out_address ( | 78 | acpi_ex_out_address ( |
74 | char *title, | 79 | char *title, |
75 | acpi_physical_address value); | 80 | acpi_physical_address value); |
76 | #endif /* ACPI_FUTURE_USAGE */ | ||
77 | 81 | ||
82 | static void | ||
83 | acpi_ex_dump_reference ( | ||
84 | union acpi_operand_object *obj_desc); | ||
78 | 85 | ||
79 | /* | 86 | static void |
80 | * The following routines are used for debug output only | 87 | acpi_ex_dump_package ( |
81 | */ | 88 | union acpi_operand_object *obj_desc, |
82 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | 89 | u32 level, |
90 | u32 index); | ||
91 | #endif /* ACPI_FUTURE_USAGE */ | ||
83 | 92 | ||
84 | /******************************************************************************* | 93 | /******************************************************************************* |
85 | * | 94 | * |
@@ -118,7 +127,7 @@ acpi_ex_dump_operand ( | |||
118 | } | 127 | } |
119 | 128 | ||
120 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { | 129 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { |
121 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc)); | 130 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc)); |
122 | ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); | 131 | ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); |
123 | return; | 132 | return; |
124 | } | 133 | } |
@@ -467,7 +476,7 @@ acpi_ex_dump_operands ( | |||
467 | } | 476 | } |
468 | 477 | ||
469 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | 478 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
470 | "************* Stack dump from %s(%d), %s\n", | 479 | "************* Operand Stack dump from %s(%d), %s\n", |
471 | module_name, line_number, note)); | 480 | module_name, line_number, note)); |
472 | return; | 481 | return; |
473 | } | 482 | } |
@@ -508,7 +517,7 @@ acpi_ex_out_integer ( | |||
508 | char *title, | 517 | char *title, |
509 | u32 value) | 518 | u32 value) |
510 | { | 519 | { |
511 | acpi_os_printf ("%20s : %X\n", title, value); | 520 | acpi_os_printf ("%20s : %.2X\n", title, value); |
512 | } | 521 | } |
513 | 522 | ||
514 | static void | 523 | static void |
@@ -565,9 +574,144 @@ acpi_ex_dump_node ( | |||
565 | 574 | ||
566 | /******************************************************************************* | 575 | /******************************************************************************* |
567 | * | 576 | * |
577 | * FUNCTION: acpi_ex_dump_reference | ||
578 | * | ||
579 | * PARAMETERS: Object - Descriptor to dump | ||
580 | * | ||
581 | * DESCRIPTION: Dumps a reference object | ||
582 | * | ||
583 | ******************************************************************************/ | ||
584 | |||
585 | static void | ||
586 | acpi_ex_dump_reference ( | ||
587 | union acpi_operand_object *obj_desc) | ||
588 | { | ||
589 | struct acpi_buffer ret_buf; | ||
590 | acpi_status status; | ||
591 | |||
592 | |||
593 | if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { | ||
594 | acpi_os_printf ("Named Object %p ", obj_desc->reference.node); | ||
595 | ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
596 | status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf); | ||
597 | if (ACPI_FAILURE (status)) { | ||
598 | acpi_os_printf ("Could not convert name to pathname\n"); | ||
599 | } | ||
600 | else { | ||
601 | acpi_os_printf ("%s\n", ret_buf.pointer); | ||
602 | ACPI_MEM_FREE (ret_buf.pointer); | ||
603 | } | ||
604 | } | ||
605 | else if (obj_desc->reference.object) { | ||
606 | acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | |||
611 | /******************************************************************************* | ||
612 | * | ||
613 | * FUNCTION: acpi_ex_dump_package | ||
614 | * | ||
615 | * PARAMETERS: Object - Descriptor to dump | ||
616 | * Level - Indentation Level | ||
617 | * Index - Package index for this object | ||
618 | * | ||
619 | * DESCRIPTION: Dumps the elements of the package | ||
620 | * | ||
621 | ******************************************************************************/ | ||
622 | |||
623 | static void | ||
624 | acpi_ex_dump_package ( | ||
625 | union acpi_operand_object *obj_desc, | ||
626 | u32 level, | ||
627 | u32 index) | ||
628 | { | ||
629 | u32 i; | ||
630 | |||
631 | |||
632 | /* Indentation and index output */ | ||
633 | |||
634 | if (level > 0) { | ||
635 | for (i = 0; i < level; i++) { | ||
636 | acpi_os_printf (" "); | ||
637 | } | ||
638 | |||
639 | acpi_os_printf ("[%.2d] ", index); | ||
640 | } | ||
641 | |||
642 | acpi_os_printf ("%p ", obj_desc); | ||
643 | |||
644 | /* Null package elements are allowed */ | ||
645 | |||
646 | if (!obj_desc) { | ||
647 | acpi_os_printf ("[Null Object]\n"); | ||
648 | return; | ||
649 | } | ||
650 | |||
651 | /* Packages may only contain a few object types */ | ||
652 | |||
653 | switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { | ||
654 | case ACPI_TYPE_INTEGER: | ||
655 | |||
656 | acpi_os_printf ("[Integer] = %8.8X%8.8X\n", | ||
657 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); | ||
658 | break; | ||
659 | |||
660 | |||
661 | case ACPI_TYPE_STRING: | ||
662 | |||
663 | acpi_os_printf ("[String] Value: "); | ||
664 | for (i = 0; i < obj_desc->string.length; i++) { | ||
665 | acpi_os_printf ("%c", obj_desc->string.pointer[i]); | ||
666 | } | ||
667 | acpi_os_printf ("\n"); | ||
668 | break; | ||
669 | |||
670 | |||
671 | case ACPI_TYPE_BUFFER: | ||
672 | |||
673 | acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length); | ||
674 | if (obj_desc->buffer.length) { | ||
675 | acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer, | ||
676 | obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT); | ||
677 | } | ||
678 | else { | ||
679 | acpi_os_printf ("\n"); | ||
680 | } | ||
681 | break; | ||
682 | |||
683 | |||
684 | case ACPI_TYPE_PACKAGE: | ||
685 | |||
686 | acpi_os_printf ("[Package] Contains %d Elements: \n", | ||
687 | obj_desc->package.count); | ||
688 | |||
689 | for (i = 0; i < obj_desc->package.count; i++) { | ||
690 | acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i); | ||
691 | } | ||
692 | break; | ||
693 | |||
694 | |||
695 | case ACPI_TYPE_LOCAL_REFERENCE: | ||
696 | |||
697 | acpi_os_printf ("[Object Reference] "); | ||
698 | acpi_ex_dump_reference (obj_desc); | ||
699 | break; | ||
700 | |||
701 | |||
702 | default: | ||
703 | |||
704 | acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); | ||
705 | break; | ||
706 | } | ||
707 | } | ||
708 | |||
709 | |||
710 | /******************************************************************************* | ||
711 | * | ||
568 | * FUNCTION: acpi_ex_dump_object_descriptor | 712 | * FUNCTION: acpi_ex_dump_object_descriptor |
569 | * | 713 | * |
570 | * PARAMETERS: *Object - Descriptor to dump | 714 | * PARAMETERS: Object - Descriptor to dump |
571 | * Flags - Force display if TRUE | 715 | * Flags - Force display if TRUE |
572 | * | 716 | * |
573 | * DESCRIPTION: Dumps the members of the object descriptor given. | 717 | * DESCRIPTION: Dumps the members of the object descriptor given. |
@@ -579,9 +723,6 @@ acpi_ex_dump_object_descriptor ( | |||
579 | union acpi_operand_object *obj_desc, | 723 | union acpi_operand_object *obj_desc, |
580 | u32 flags) | 724 | u32 flags) |
581 | { | 725 | { |
582 | u32 i; | ||
583 | |||
584 | |||
585 | ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); | 726 | ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); |
586 | 727 | ||
587 | 728 | ||
@@ -648,22 +789,13 @@ acpi_ex_dump_object_descriptor ( | |||
648 | case ACPI_TYPE_PACKAGE: | 789 | case ACPI_TYPE_PACKAGE: |
649 | 790 | ||
650 | acpi_ex_out_integer ("Flags", obj_desc->package.flags); | 791 | acpi_ex_out_integer ("Flags", obj_desc->package.flags); |
651 | acpi_ex_out_integer ("Count", obj_desc->package.count); | 792 | acpi_ex_out_integer ("Elements", obj_desc->package.count); |
652 | acpi_ex_out_pointer ("Elements", obj_desc->package.elements); | 793 | acpi_ex_out_pointer ("Element List", obj_desc->package.elements); |
653 | 794 | ||
654 | /* Dump the package contents */ | 795 | /* Dump the package contents */ |
655 | 796 | ||
656 | if (obj_desc->package.count > 0) { | 797 | acpi_os_printf ("\nPackage Contents:\n"); |
657 | acpi_os_printf ("\nPackage Contents:\n"); | 798 | acpi_ex_dump_package (obj_desc, 0, 0); |
658 | for (i = 0; i < obj_desc->package.count; i++) { | ||
659 | acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]); | ||
660 | if (obj_desc->package.elements[i]) { | ||
661 | acpi_os_printf (" %s", | ||
662 | acpi_ut_get_object_type_name (obj_desc->package.elements[i])); | ||
663 | } | ||
664 | acpi_os_printf ("\n"); | ||
665 | } | ||
666 | } | ||
667 | break; | 799 | break; |
668 | 800 | ||
669 | 801 | ||
@@ -686,7 +818,7 @@ acpi_ex_dump_object_descriptor ( | |||
686 | acpi_ex_out_integer ("param_count", obj_desc->method.param_count); | 818 | acpi_ex_out_integer ("param_count", obj_desc->method.param_count); |
687 | acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); | 819 | acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); |
688 | acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); | 820 | acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); |
689 | acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id); | 821 | acpi_ex_out_integer ("owner_id", obj_desc->method.owner_id); |
690 | acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); | 822 | acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); |
691 | acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); | 823 | acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); |
692 | break; | 824 | break; |
@@ -790,10 +922,7 @@ acpi_ex_dump_object_descriptor ( | |||
790 | acpi_ex_out_pointer ("Node", obj_desc->reference.node); | 922 | acpi_ex_out_pointer ("Node", obj_desc->reference.node); |
791 | acpi_ex_out_pointer ("Where", obj_desc->reference.where); | 923 | acpi_ex_out_pointer ("Where", obj_desc->reference.where); |
792 | 924 | ||
793 | if (obj_desc->reference.object) { | 925 | acpi_ex_dump_reference (obj_desc); |
794 | acpi_os_printf ("\nReferenced Object:\n"); | ||
795 | acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags); | ||
796 | } | ||
797 | break; | 926 | break; |
798 | 927 | ||
799 | 928 | ||
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c index 22c8fa480f60..a690c9250990 100644 --- a/drivers/acpi/executer/exfield.c +++ b/drivers/acpi/executer/exfield.c | |||
@@ -87,6 +87,9 @@ acpi_ex_read_data_from_field ( | |||
87 | if (!obj_desc) { | 87 | if (!obj_desc) { |
88 | return_ACPI_STATUS (AE_AML_NO_OPERAND); | 88 | return_ACPI_STATUS (AE_AML_NO_OPERAND); |
89 | } | 89 | } |
90 | if (!ret_buffer_desc) { | ||
91 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
92 | } | ||
90 | 93 | ||
91 | if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { | 94 | if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_BUFFER_FIELD) { |
92 | /* | 95 | /* |
@@ -182,7 +185,7 @@ exit: | |||
182 | if (ACPI_FAILURE (status)) { | 185 | if (ACPI_FAILURE (status)) { |
183 | acpi_ut_remove_reference (buffer_desc); | 186 | acpi_ut_remove_reference (buffer_desc); |
184 | } | 187 | } |
185 | else if (ret_buffer_desc) { | 188 | else { |
186 | *ret_buffer_desc = buffer_desc; | 189 | *ret_buffer_desc = buffer_desc; |
187 | } | 190 | } |
188 | 191 | ||
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 022f281345b8..237ef28c8132 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c | |||
@@ -302,7 +302,7 @@ acpi_ex_do_concatenate ( | |||
302 | /* Result of two Integers is a Buffer */ | 302 | /* Result of two Integers is a Buffer */ |
303 | /* Need enough buffer space for two integers */ | 303 | /* Need enough buffer space for two integers */ |
304 | 304 | ||
305 | return_desc = acpi_ut_create_buffer_object ( | 305 | return_desc = acpi_ut_create_buffer_object ((acpi_size) |
306 | ACPI_MUL_2 (acpi_gbl_integer_byte_width)); | 306 | ACPI_MUL_2 (acpi_gbl_integer_byte_width)); |
307 | if (!return_desc) { | 307 | if (!return_desc) { |
308 | status = AE_NO_MEMORY; | 308 | status = AE_NO_MEMORY; |
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index 639f0bd3f6d8..b6ba1a7a677a 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c | |||
@@ -438,6 +438,13 @@ acpi_ex_get_name_string ( | |||
438 | status = AE_AML_BAD_NAME; | 438 | status = AE_AML_BAD_NAME; |
439 | } | 439 | } |
440 | 440 | ||
441 | if (ACPI_FAILURE (status)) { | ||
442 | if (name_string) { | ||
443 | ACPI_MEM_FREE (name_string); | ||
444 | } | ||
445 | return_ACPI_STATUS (status); | ||
446 | } | ||
447 | |||
441 | *out_name_string = name_string; | 448 | *out_name_string = name_string; |
442 | *out_name_length = (u32) (aml_address - in_aml_address); | 449 | *out_name_length = (u32) (aml_address - in_aml_address); |
443 | 450 | ||
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index dbdf8262ba00..c1ba8b48228e 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c | |||
@@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R ( | |||
113 | status = AE_NO_MEMORY; | 113 | status = AE_NO_MEMORY; |
114 | goto cleanup; | 114 | goto cleanup; |
115 | } | 115 | } |
116 | 116 | #if ACPI_MACHINE_WIDTH != 16 | |
117 | return_desc->integer.value = acpi_os_get_timer (); | 117 | return_desc->integer.value = acpi_os_get_timer (); |
118 | #endif | ||
118 | break; | 119 | break; |
119 | 120 | ||
120 | default: /* Unknown opcode */ | 121 | default: /* Unknown opcode */ |
@@ -127,15 +128,16 @@ acpi_ex_opcode_0A_0T_1R ( | |||
127 | 128 | ||
128 | cleanup: | 129 | cleanup: |
129 | 130 | ||
130 | if (!walk_state->result_obj) { | ||
131 | walk_state->result_obj = return_desc; | ||
132 | } | ||
133 | |||
134 | /* Delete return object on error */ | 131 | /* Delete return object on error */ |
135 | 132 | ||
136 | if (ACPI_FAILURE (status)) { | 133 | if ((ACPI_FAILURE (status)) || walk_state->result_obj) { |
137 | acpi_ut_remove_reference (return_desc); | 134 | acpi_ut_remove_reference (return_desc); |
138 | } | 135 | } |
136 | else { | ||
137 | /* Save the return value */ | ||
138 | |||
139 | walk_state->result_obj = return_desc; | ||
140 | } | ||
139 | 141 | ||
140 | return_ACPI_STATUS (status); | 142 | return_ACPI_STATUS (status); |
141 | } | 143 | } |
@@ -902,6 +904,7 @@ acpi_ex_opcode_1A_0T_1R ( | |||
902 | */ | 904 | */ |
903 | return_desc = acpi_ns_get_attached_object ( | 905 | return_desc = acpi_ns_get_attached_object ( |
904 | (struct acpi_namespace_node *) operand[0]); | 906 | (struct acpi_namespace_node *) operand[0]); |
907 | acpi_ut_add_reference (return_desc); | ||
905 | } | 908 | } |
906 | else { | 909 | else { |
907 | /* | 910 | /* |
@@ -951,20 +954,10 @@ acpi_ex_opcode_1A_0T_1R ( | |||
951 | * add another reference to the referenced object, however. | 954 | * add another reference to the referenced object, however. |
952 | */ | 955 | */ |
953 | return_desc = *(operand[0]->reference.where); | 956 | return_desc = *(operand[0]->reference.where); |
954 | if (!return_desc) { | 957 | if (return_desc) { |
955 | /* | 958 | acpi_ut_add_reference (return_desc); |
956 | * We can't return a NULL dereferenced value. This is | ||
957 | * an uninitialized package element and is thus a | ||
958 | * severe error. | ||
959 | */ | ||
960 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
961 | "NULL package element obj %p\n", | ||
962 | operand[0])); | ||
963 | status = AE_AML_UNINITIALIZED_ELEMENT; | ||
964 | goto cleanup; | ||
965 | } | 959 | } |
966 | 960 | ||
967 | acpi_ut_add_reference (return_desc); | ||
968 | break; | 961 | break; |
969 | 962 | ||
970 | 963 | ||
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index 23b068adbf58..197890f443b5 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c | |||
@@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R ( | |||
160 | { | 160 | { |
161 | union acpi_operand_object **operand = &walk_state->operands[0]; | 161 | union acpi_operand_object **operand = &walk_state->operands[0]; |
162 | union acpi_operand_object *return_desc = NULL; | 162 | union acpi_operand_object *return_desc = NULL; |
163 | char *buffer; | 163 | char *buffer = NULL; |
164 | acpi_status status = AE_OK; | 164 | acpi_status status = AE_OK; |
165 | acpi_integer index; | 165 | acpi_integer index; |
166 | acpi_size length; | 166 | acpi_size length; |
@@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R ( | |||
193 | * If the index is beyond the length of the String/Buffer, or if the | 193 | * If the index is beyond the length of the String/Buffer, or if the |
194 | * requested length is zero, return a zero-length String/Buffer | 194 | * requested length is zero, return a zero-length String/Buffer |
195 | */ | 195 | */ |
196 | if ((index < operand[0]->string.length) && | 196 | if (index >= operand[0]->string.length) { |
197 | (length > 0)) { | 197 | length = 0; |
198 | /* Truncate request if larger than the actual String/Buffer */ | 198 | } |
199 | 199 | ||
200 | if ((index + length) > | 200 | /* Truncate request if larger than the actual String/Buffer */ |
201 | operand[0]->string.length) { | 201 | |
202 | length = (acpi_size) operand[0]->string.length - | 202 | else if ((index + length) > operand[0]->string.length) { |
203 | (acpi_size) index; | 203 | length = (acpi_size) operand[0]->string.length - |
204 | } | 204 | (acpi_size) index; |
205 | } | ||
205 | 206 | ||
206 | /* Allocate a new buffer for the String/Buffer */ | 207 | /* Strings always have a sub-pointer, not so for buffers */ |
208 | |||
209 | switch (ACPI_GET_OBJECT_TYPE (operand[0])) { | ||
210 | case ACPI_TYPE_STRING: | ||
211 | |||
212 | /* Always allocate a new buffer for the String */ | ||
207 | 213 | ||
208 | buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); | 214 | buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); |
209 | if (!buffer) { | 215 | if (!buffer) { |
210 | status = AE_NO_MEMORY; | 216 | status = AE_NO_MEMORY; |
211 | goto cleanup; | 217 | goto cleanup; |
212 | } | 218 | } |
219 | break; | ||
220 | |||
221 | case ACPI_TYPE_BUFFER: | ||
222 | |||
223 | /* If the requested length is zero, don't allocate a buffer */ | ||
224 | |||
225 | if (length > 0) { | ||
226 | /* Allocate a new buffer for the Buffer */ | ||
227 | |||
228 | buffer = ACPI_MEM_CALLOCATE (length); | ||
229 | if (!buffer) { | ||
230 | status = AE_NO_MEMORY; | ||
231 | goto cleanup; | ||
232 | } | ||
233 | } | ||
234 | break; | ||
213 | 235 | ||
236 | default: /* Should not happen */ | ||
237 | |||
238 | status = AE_AML_OPERAND_TYPE; | ||
239 | goto cleanup; | ||
240 | } | ||
241 | |||
242 | if (length > 0) { | ||
214 | /* Copy the portion requested */ | 243 | /* Copy the portion requested */ |
215 | 244 | ||
216 | ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, | 245 | ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, |
217 | length); | 246 | length); |
247 | } | ||
218 | 248 | ||
219 | /* Set the length of the new String/Buffer */ | 249 | /* Set the length of the new String/Buffer */ |
220 | 250 | ||
221 | return_desc->string.pointer = buffer; | 251 | return_desc->string.pointer = buffer; |
222 | return_desc->string.length = (u32) length; | 252 | return_desc->string.length = (u32) length; |
223 | } | ||
224 | 253 | ||
225 | /* Mark buffer initialized */ | 254 | /* Mark buffer initialized */ |
226 | 255 | ||
@@ -244,13 +273,13 @@ cleanup: | |||
244 | 273 | ||
245 | /* Delete return object on error */ | 274 | /* Delete return object on error */ |
246 | 275 | ||
247 | if (ACPI_FAILURE (status)) { | 276 | if (ACPI_FAILURE (status) || walk_state->result_obj) { |
248 | acpi_ut_remove_reference (return_desc); | 277 | acpi_ut_remove_reference (return_desc); |
249 | } | 278 | } |
250 | 279 | ||
251 | /* Set the return object and exit */ | 280 | /* Set the return object and exit */ |
252 | 281 | ||
253 | if (!walk_state->result_obj) { | 282 | else { |
254 | walk_state->result_obj = return_desc; | 283 | walk_state->result_obj = return_desc; |
255 | } | 284 | } |
256 | return_ACPI_STATUS (status); | 285 | return_ACPI_STATUS (status); |
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index d8b470eefe7a..aaba7abcb52d 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c | |||
@@ -426,6 +426,10 @@ acpi_ex_resolve_operands ( | |||
426 | 426 | ||
427 | return_ACPI_STATUS (status); | 427 | return_ACPI_STATUS (status); |
428 | } | 428 | } |
429 | |||
430 | if (obj_desc != *stack_ptr) { | ||
431 | acpi_ut_remove_reference (obj_desc); | ||
432 | } | ||
429 | goto next_operand; | 433 | goto next_operand; |
430 | 434 | ||
431 | 435 | ||
@@ -448,6 +452,10 @@ acpi_ex_resolve_operands ( | |||
448 | 452 | ||
449 | return_ACPI_STATUS (status); | 453 | return_ACPI_STATUS (status); |
450 | } | 454 | } |
455 | |||
456 | if (obj_desc != *stack_ptr) { | ||
457 | acpi_ut_remove_reference (obj_desc); | ||
458 | } | ||
451 | goto next_operand; | 459 | goto next_operand; |
452 | 460 | ||
453 | 461 | ||
@@ -471,6 +479,10 @@ acpi_ex_resolve_operands ( | |||
471 | 479 | ||
472 | return_ACPI_STATUS (status); | 480 | return_ACPI_STATUS (status); |
473 | } | 481 | } |
482 | |||
483 | if (obj_desc != *stack_ptr) { | ||
484 | acpi_ut_remove_reference (obj_desc); | ||
485 | } | ||
474 | goto next_operand; | 486 | goto next_operand; |
475 | 487 | ||
476 | 488 | ||
@@ -515,6 +527,10 @@ acpi_ex_resolve_operands ( | |||
515 | if (ACPI_FAILURE (status)) { | 527 | if (ACPI_FAILURE (status)) { |
516 | return_ACPI_STATUS (status); | 528 | return_ACPI_STATUS (status); |
517 | } | 529 | } |
530 | |||
531 | if (obj_desc != *stack_ptr) { | ||
532 | acpi_ut_remove_reference (obj_desc); | ||
533 | } | ||
518 | break; | 534 | break; |
519 | 535 | ||
520 | default: | 536 | default: |
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 2725db0901b8..59dbfeaa54c0 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c | |||
@@ -147,7 +147,7 @@ acpi_ex_do_debug_object ( | |||
147 | 147 | ||
148 | case ACPI_TYPE_BUFFER: | 148 | case ACPI_TYPE_BUFFER: |
149 | 149 | ||
150 | ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", | 150 | ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", |
151 | (u32) source_desc->buffer.length)); | 151 | (u32) source_desc->buffer.length)); |
152 | ACPI_DUMP_BUFFER (source_desc->buffer.pointer, | 152 | ACPI_DUMP_BUFFER (source_desc->buffer.pointer, |
153 | (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); | 153 | (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); |
@@ -574,7 +574,7 @@ acpi_ex_store_object_to_node ( | |||
574 | 574 | ||
575 | /* If no implicit conversion, drop into the default case below */ | 575 | /* If no implicit conversion, drop into the default case below */ |
576 | 576 | ||
577 | if (!implicit_conversion) { | 577 | if ((!implicit_conversion) || (walk_state->opcode == AML_COPY_OP)) { |
578 | /* Force execution of default (no implicit conversion) */ | 578 | /* Force execution of default (no implicit conversion) */ |
579 | 579 | ||
580 | target_type = ACPI_TYPE_ANY; | 580 | target_type = ACPI_TYPE_ANY; |
@@ -634,7 +634,7 @@ acpi_ex_store_object_to_node ( | |||
634 | default: | 634 | default: |
635 | 635 | ||
636 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | 636 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
637 | "Storing %s (%p) directly into node (%p), no implicit conversion\n", | 637 | "Storing %s (%p) directly into node (%p) with no implicit conversion\n", |
638 | acpi_ut_get_object_type_name (source_desc), source_desc, node)); | 638 | acpi_ut_get_object_type_name (source_desc), source_desc, node)); |
639 | 639 | ||
640 | /* No conversions for all other types. Just attach the source object */ | 640 | /* No conversions for all other types. Just attach the source object */ |
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index 120f30ed0bd4..433588ab432a 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c | |||
@@ -265,10 +265,6 @@ acpi_ex_store_object_to_object ( | |||
265 | 265 | ||
266 | case ACPI_TYPE_BUFFER: | 266 | case ACPI_TYPE_BUFFER: |
267 | 267 | ||
268 | /* | ||
269 | * Note: There is different store behavior depending on the original | ||
270 | * source type | ||
271 | */ | ||
272 | status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc); | 268 | status = acpi_ex_store_buffer_to_buffer (actual_src_desc, dest_desc); |
273 | break; | 269 | break; |
274 | 270 | ||
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index 5c7ec0c04177..d00b0dcba96a 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c | |||
@@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string ( | |||
369 | * | 369 | * |
370 | * RETURN: None, string | 370 | * RETURN: None, string |
371 | * | 371 | * |
372 | * DESCRIPTOIN: Convert a number to string representation. Assumes string | 372 | * DESCRIPTION: Convert a number to string representation. Assumes string |
373 | * buffer is large enough to hold the string. | 373 | * buffer is large enough to hold the string. |
374 | * | 374 | * |
375 | ******************************************************************************/ | 375 | ******************************************************************************/ |
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c index 8daeabb2fc7a..3536bbb990c3 100644 --- a/drivers/acpi/hardware/hwgpe.c +++ b/drivers/acpi/hardware/hwgpe.c | |||
@@ -374,7 +374,7 @@ acpi_hw_enable_wakeup_gpe_block ( | |||
374 | * | 374 | * |
375 | * FUNCTION: acpi_hw_disable_all_gpes | 375 | * FUNCTION: acpi_hw_disable_all_gpes |
376 | * | 376 | * |
377 | * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR | 377 | * PARAMETERS: None |
378 | * | 378 | * |
379 | * RETURN: Status | 379 | * RETURN: Status |
380 | * | 380 | * |
@@ -384,7 +384,7 @@ acpi_hw_enable_wakeup_gpe_block ( | |||
384 | 384 | ||
385 | acpi_status | 385 | acpi_status |
386 | acpi_hw_disable_all_gpes ( | 386 | acpi_hw_disable_all_gpes ( |
387 | u32 flags) | 387 | void) |
388 | { | 388 | { |
389 | acpi_status status; | 389 | acpi_status status; |
390 | 390 | ||
@@ -392,8 +392,8 @@ acpi_hw_disable_all_gpes ( | |||
392 | ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); | 392 | ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); |
393 | 393 | ||
394 | 394 | ||
395 | status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, flags); | 395 | status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); |
396 | status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, flags); | 396 | status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); |
397 | return_ACPI_STATUS (status); | 397 | return_ACPI_STATUS (status); |
398 | } | 398 | } |
399 | 399 | ||
@@ -402,7 +402,7 @@ acpi_hw_disable_all_gpes ( | |||
402 | * | 402 | * |
403 | * FUNCTION: acpi_hw_enable_all_runtime_gpes | 403 | * FUNCTION: acpi_hw_enable_all_runtime_gpes |
404 | * | 404 | * |
405 | * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR | 405 | * PARAMETERS: None |
406 | * | 406 | * |
407 | * RETURN: Status | 407 | * RETURN: Status |
408 | * | 408 | * |
@@ -412,7 +412,7 @@ acpi_hw_disable_all_gpes ( | |||
412 | 412 | ||
413 | acpi_status | 413 | acpi_status |
414 | acpi_hw_enable_all_runtime_gpes ( | 414 | acpi_hw_enable_all_runtime_gpes ( |
415 | u32 flags) | 415 | void) |
416 | { | 416 | { |
417 | acpi_status status; | 417 | acpi_status status; |
418 | 418 | ||
@@ -420,7 +420,7 @@ acpi_hw_enable_all_runtime_gpes ( | |||
420 | ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); | 420 | ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); |
421 | 421 | ||
422 | 422 | ||
423 | status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block, flags); | 423 | status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block); |
424 | return_ACPI_STATUS (status); | 424 | return_ACPI_STATUS (status); |
425 | } | 425 | } |
426 | 426 | ||
@@ -429,7 +429,7 @@ acpi_hw_enable_all_runtime_gpes ( | |||
429 | * | 429 | * |
430 | * FUNCTION: acpi_hw_enable_all_wakeup_gpes | 430 | * FUNCTION: acpi_hw_enable_all_wakeup_gpes |
431 | * | 431 | * |
432 | * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR | 432 | * PARAMETERS: None |
433 | * | 433 | * |
434 | * RETURN: Status | 434 | * RETURN: Status |
435 | * | 435 | * |
@@ -439,7 +439,7 @@ acpi_hw_enable_all_runtime_gpes ( | |||
439 | 439 | ||
440 | acpi_status | 440 | acpi_status |
441 | acpi_hw_enable_all_wakeup_gpes ( | 441 | acpi_hw_enable_all_wakeup_gpes ( |
442 | u32 flags) | 442 | void) |
443 | { | 443 | { |
444 | acpi_status status; | 444 | acpi_status status; |
445 | 445 | ||
@@ -447,7 +447,7 @@ acpi_hw_enable_all_wakeup_gpes ( | |||
447 | ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); | 447 | ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); |
448 | 448 | ||
449 | 449 | ||
450 | status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block, flags); | 450 | status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block); |
451 | return_ACPI_STATUS (status); | 451 | return_ACPI_STATUS (status); |
452 | } | 452 | } |
453 | 453 | ||
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index 6d9e4eb84836..04a058565d8d 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c | |||
@@ -106,7 +106,7 @@ acpi_hw_clear_acpi_status ( | |||
106 | 106 | ||
107 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ | 107 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ |
108 | 108 | ||
109 | status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, ACPI_ISR); | 109 | status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); |
110 | 110 | ||
111 | unlock_and_exit: | 111 | unlock_and_exit: |
112 | if (flags & ACPI_MTX_LOCK) { | 112 | if (flags & ACPI_MTX_LOCK) { |
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index 415d342aeab5..cedee0c43b5f 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c | |||
@@ -274,13 +274,13 @@ acpi_enter_sleep_state ( | |||
274 | * 1) Disable/Clear all GPEs | 274 | * 1) Disable/Clear all GPEs |
275 | * 2) Enable all wakeup GPEs | 275 | * 2) Enable all wakeup GPEs |
276 | */ | 276 | */ |
277 | status = acpi_hw_disable_all_gpes (ACPI_ISR); | 277 | status = acpi_hw_disable_all_gpes (); |
278 | if (ACPI_FAILURE (status)) { | 278 | if (ACPI_FAILURE (status)) { |
279 | return_ACPI_STATUS (status); | 279 | return_ACPI_STATUS (status); |
280 | } | 280 | } |
281 | acpi_gbl_system_awake_and_running = FALSE; | 281 | acpi_gbl_system_awake_and_running = FALSE; |
282 | 282 | ||
283 | status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); | 283 | status = acpi_hw_enable_all_wakeup_gpes (); |
284 | if (ACPI_FAILURE (status)) { | 284 | if (ACPI_FAILURE (status)) { |
285 | return_ACPI_STATUS (status); | 285 | return_ACPI_STATUS (status); |
286 | } | 286 | } |
@@ -424,13 +424,13 @@ acpi_enter_sleep_state_s4bios ( | |||
424 | * 1) Disable/Clear all GPEs | 424 | * 1) Disable/Clear all GPEs |
425 | * 2) Enable all wakeup GPEs | 425 | * 2) Enable all wakeup GPEs |
426 | */ | 426 | */ |
427 | status = acpi_hw_disable_all_gpes (ACPI_ISR); | 427 | status = acpi_hw_disable_all_gpes (); |
428 | if (ACPI_FAILURE (status)) { | 428 | if (ACPI_FAILURE (status)) { |
429 | return_ACPI_STATUS (status); | 429 | return_ACPI_STATUS (status); |
430 | } | 430 | } |
431 | acpi_gbl_system_awake_and_running = FALSE; | 431 | acpi_gbl_system_awake_and_running = FALSE; |
432 | 432 | ||
433 | status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); | 433 | status = acpi_hw_enable_all_wakeup_gpes (); |
434 | if (ACPI_FAILURE (status)) { | 434 | if (ACPI_FAILURE (status)) { |
435 | return_ACPI_STATUS (status); | 435 | return_ACPI_STATUS (status); |
436 | } | 436 | } |
@@ -557,13 +557,13 @@ acpi_leave_sleep_state ( | |||
557 | * 1) Disable/Clear all GPEs | 557 | * 1) Disable/Clear all GPEs |
558 | * 2) Enable all runtime GPEs | 558 | * 2) Enable all runtime GPEs |
559 | */ | 559 | */ |
560 | status = acpi_hw_disable_all_gpes (ACPI_NOT_ISR); | 560 | status = acpi_hw_disable_all_gpes (); |
561 | if (ACPI_FAILURE (status)) { | 561 | if (ACPI_FAILURE (status)) { |
562 | return_ACPI_STATUS (status); | 562 | return_ACPI_STATUS (status); |
563 | } | 563 | } |
564 | acpi_gbl_system_awake_and_running = TRUE; | 564 | acpi_gbl_system_awake_and_running = TRUE; |
565 | 565 | ||
566 | status = acpi_hw_enable_all_runtime_gpes (ACPI_NOT_ISR); | 566 | status = acpi_hw_enable_all_runtime_gpes (); |
567 | if (ACPI_FAILURE (status)) { | 567 | if (ACPI_FAILURE (status)) { |
568 | return_ACPI_STATUS (status); | 568 | return_ACPI_STATUS (status); |
569 | } | 569 | } |
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index ece7a9dedd5c..0bda88d18685 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c | |||
@@ -159,11 +159,11 @@ acpi_ns_root_initialize ( | |||
159 | obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); | 159 | obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); |
160 | obj_desc->common.flags |= AOPOBJ_DATA_VALID; | 160 | obj_desc->common.flags |= AOPOBJ_DATA_VALID; |
161 | 161 | ||
162 | #if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App) | 162 | #if defined (ACPI_ASL_COMPILER) || defined (ACPI_DUMP_App) |
163 | 163 | ||
164 | /* | 164 | /* |
165 | * i_aSL Compiler cheats by putting parameter count | 165 | * i_aSL Compiler cheats by putting parameter count |
166 | * in the owner_iD | 166 | * in the owner_iD (param_count max is 7) |
167 | */ | 167 | */ |
168 | new_node->owner_id = obj_desc->method.param_count; | 168 | new_node->owner_id = obj_desc->method.param_count; |
169 | #else | 169 | #else |
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index 5653a19d7172..edbf1db36b68 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c | |||
@@ -83,7 +83,7 @@ acpi_ns_create_node ( | |||
83 | return_PTR (NULL); | 83 | return_PTR (NULL); |
84 | } | 84 | } |
85 | 85 | ||
86 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++); | 86 | ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_allocated++); |
87 | 87 | ||
88 | node->name.integer = name; | 88 | node->name.integer = name; |
89 | node->reference_count = 1; | 89 | node->reference_count = 1; |
@@ -151,7 +151,7 @@ acpi_ns_delete_node ( | |||
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); | 154 | ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); |
155 | 155 | ||
156 | /* | 156 | /* |
157 | * Detach an object if there is one then delete the node | 157 | * Detach an object if there is one then delete the node |
@@ -190,7 +190,7 @@ acpi_ns_install_node ( | |||
190 | struct acpi_namespace_node *node, /* New Child*/ | 190 | struct acpi_namespace_node *node, /* New Child*/ |
191 | acpi_object_type type) | 191 | acpi_object_type type) |
192 | { | 192 | { |
193 | u16 owner_id = 0; | 193 | acpi_owner_id owner_id = 0; |
194 | struct acpi_namespace_node *child_node; | 194 | struct acpi_namespace_node *child_node; |
195 | #ifdef ACPI_ALPHABETIC_NAMESPACE | 195 | #ifdef ACPI_ALPHABETIC_NAMESPACE |
196 | 196 | ||
@@ -362,7 +362,7 @@ acpi_ns_delete_children ( | |||
362 | 362 | ||
363 | /* Now we can free this child object */ | 363 | /* Now we can free this child object */ |
364 | 364 | ||
365 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); | 365 | ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++); |
366 | 366 | ||
367 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", | 367 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", |
368 | child_node, acpi_gbl_current_node_count)); | 368 | child_node, acpi_gbl_current_node_count)); |
@@ -559,7 +559,7 @@ acpi_ns_remove_reference ( | |||
559 | 559 | ||
560 | void | 560 | void |
561 | acpi_ns_delete_namespace_by_owner ( | 561 | acpi_ns_delete_namespace_by_owner ( |
562 | u16 owner_id) | 562 | acpi_owner_id owner_id) |
563 | { | 563 | { |
564 | struct acpi_namespace_node *child_node; | 564 | struct acpi_namespace_node *child_node; |
565 | struct acpi_namespace_node *deletion_node; | 565 | struct acpi_namespace_node *deletion_node; |
@@ -635,6 +635,7 @@ acpi_ns_delete_namespace_by_owner ( | |||
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | (void) acpi_ut_release_owner_id (owner_id); | ||
638 | return_VOID; | 639 | return_VOID; |
639 | } | 640 | } |
640 | 641 | ||
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 6c2aef0e0dd4..d86ccbc8a134 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c | |||
@@ -203,38 +203,42 @@ acpi_ns_dump_one_object ( | |||
203 | 203 | ||
204 | /* Check if the owner matches */ | 204 | /* Check if the owner matches */ |
205 | 205 | ||
206 | if ((info->owner_id != ACPI_UINT32_MAX) && | 206 | if ((info->owner_id != ACPI_OWNER_ID_MAX) && |
207 | (info->owner_id != this_node->owner_id)) { | 207 | (info->owner_id != this_node->owner_id)) { |
208 | return (AE_OK); | 208 | return (AE_OK); |
209 | } | 209 | } |
210 | 210 | ||
211 | /* Indent the object according to the level */ | 211 | if (!(info->display_type & ACPI_DISPLAY_SHORT)) { |
212 | /* Indent the object according to the level */ | ||
212 | 213 | ||
213 | acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); | 214 | acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); |
214 | 215 | ||
215 | /* Check the node type and name */ | 216 | /* Check the node type and name */ |
216 | 217 | ||
217 | if (type > ACPI_TYPE_LOCAL_MAX) { | 218 | if (type > ACPI_TYPE_LOCAL_MAX) { |
218 | ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); | 219 | ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); |
219 | } | 220 | } |
221 | |||
222 | if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { | ||
223 | ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", | ||
224 | this_node->name.integer)); | ||
225 | } | ||
220 | 226 | ||
221 | if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { | 227 | acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node)); |
222 | ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", | ||
223 | this_node->name.integer)); | ||
224 | } | 228 | } |
225 | 229 | ||
226 | /* | 230 | /* |
227 | * Now we can print out the pertinent information | 231 | * Now we can print out the pertinent information |
228 | */ | 232 | */ |
229 | acpi_os_printf ("%4.4s %-12s %p ", | 233 | acpi_os_printf (" %-12s %p ", |
230 | acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node); | 234 | acpi_ut_get_type_name (type), this_node); |
231 | 235 | ||
232 | dbg_level = acpi_dbg_level; | 236 | dbg_level = acpi_dbg_level; |
233 | acpi_dbg_level = 0; | 237 | acpi_dbg_level = 0; |
234 | obj_desc = acpi_ns_get_attached_object (this_node); | 238 | obj_desc = acpi_ns_get_attached_object (this_node); |
235 | acpi_dbg_level = dbg_level; | 239 | acpi_dbg_level = dbg_level; |
236 | 240 | ||
237 | switch (info->display_type) { | 241 | switch (info->display_type & ACPI_DISPLAY_MASK) { |
238 | case ACPI_DISPLAY_SUMMARY: | 242 | case ACPI_DISPLAY_SUMMARY: |
239 | 243 | ||
240 | if (!obj_desc) { | 244 | if (!obj_desc) { |
@@ -475,7 +479,7 @@ acpi_ns_dump_one_object ( | |||
475 | 479 | ||
476 | while (obj_desc) { | 480 | while (obj_desc) { |
477 | obj_type = ACPI_TYPE_INVALID; | 481 | obj_type = ACPI_TYPE_INVALID; |
478 | acpi_os_printf (" Attached Object %p: ", obj_desc); | 482 | acpi_os_printf ("Attached Object %p: ", obj_desc); |
479 | 483 | ||
480 | /* Decode the type of attached object and dump the contents */ | 484 | /* Decode the type of attached object and dump the contents */ |
481 | 485 | ||
@@ -484,9 +488,9 @@ acpi_ns_dump_one_object ( | |||
484 | 488 | ||
485 | acpi_os_printf ("(Ptr to Node)\n"); | 489 | acpi_os_printf ("(Ptr to Node)\n"); |
486 | bytes_to_dump = sizeof (struct acpi_namespace_node); | 490 | bytes_to_dump = sizeof (struct acpi_namespace_node); |
491 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); | ||
487 | break; | 492 | break; |
488 | 493 | ||
489 | |||
490 | case ACPI_DESC_TYPE_OPERAND: | 494 | case ACPI_DESC_TYPE_OPERAND: |
491 | 495 | ||
492 | obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); | 496 | obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); |
@@ -497,24 +501,19 @@ acpi_ns_dump_one_object ( | |||
497 | bytes_to_dump = 32; | 501 | bytes_to_dump = 32; |
498 | } | 502 | } |
499 | else { | 503 | else { |
500 | acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n", | 504 | acpi_os_printf ("(Ptr to ACPI Object type %X [%s])\n", |
501 | acpi_ut_get_type_name (obj_type), obj_type); | 505 | obj_type, acpi_ut_get_type_name (obj_type)); |
502 | bytes_to_dump = sizeof (union acpi_operand_object); | 506 | bytes_to_dump = sizeof (union acpi_operand_object); |
503 | } | 507 | } |
504 | break; | ||
505 | 508 | ||
509 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); | ||
510 | break; | ||
506 | 511 | ||
507 | default: | 512 | default: |
508 | 513 | ||
509 | acpi_os_printf ( | ||
510 | "(String or Buffer ptr - not an object descriptor) [%s]\n", | ||
511 | acpi_ut_get_descriptor_name (obj_desc)); | ||
512 | bytes_to_dump = 16; | ||
513 | break; | 514 | break; |
514 | } | 515 | } |
515 | 516 | ||
516 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); | ||
517 | |||
518 | /* If value is NOT an internal object, we are done */ | 517 | /* If value is NOT an internal object, we are done */ |
519 | 518 | ||
520 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { | 519 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { |
@@ -525,13 +524,17 @@ acpi_ns_dump_one_object ( | |||
525 | * Valid object, get the pointer to next level, if any | 524 | * Valid object, get the pointer to next level, if any |
526 | */ | 525 | */ |
527 | switch (obj_type) { | 526 | switch (obj_type) { |
527 | case ACPI_TYPE_BUFFER: | ||
528 | case ACPI_TYPE_STRING: | 528 | case ACPI_TYPE_STRING: |
529 | /* | ||
530 | * NOTE: takes advantage of common fields between string/buffer | ||
531 | */ | ||
532 | bytes_to_dump = obj_desc->string.length; | ||
529 | obj_desc = (void *) obj_desc->string.pointer; | 533 | obj_desc = (void *) obj_desc->string.pointer; |
530 | break; | 534 | acpi_os_printf ( "(Buffer/String pointer %p length %X)\n", |
531 | 535 | obj_desc, bytes_to_dump); | |
532 | case ACPI_TYPE_BUFFER: | 536 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); |
533 | obj_desc = (void *) obj_desc->buffer.pointer; | 537 | goto cleanup; |
534 | break; | ||
535 | 538 | ||
536 | case ACPI_TYPE_BUFFER_FIELD: | 539 | case ACPI_TYPE_BUFFER_FIELD: |
537 | obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; | 540 | obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; |
@@ -595,7 +598,7 @@ acpi_ns_dump_objects ( | |||
595 | acpi_object_type type, | 598 | acpi_object_type type, |
596 | u8 display_type, | 599 | u8 display_type, |
597 | u32 max_depth, | 600 | u32 max_depth, |
598 | u32 owner_id, | 601 | acpi_owner_id owner_id, |
599 | acpi_handle start_handle) | 602 | acpi_handle start_handle) |
600 | { | 603 | { |
601 | struct acpi_walk_info info; | 604 | struct acpi_walk_info info; |
@@ -640,14 +643,14 @@ acpi_ns_dump_entry ( | |||
640 | 643 | ||
641 | 644 | ||
642 | info.debug_level = debug_level; | 645 | info.debug_level = debug_level; |
643 | info.owner_id = ACPI_UINT32_MAX; | 646 | info.owner_id = ACPI_OWNER_ID_MAX; |
644 | info.display_type = ACPI_DISPLAY_SUMMARY; | 647 | info.display_type = ACPI_DISPLAY_SUMMARY; |
645 | 648 | ||
646 | (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); | 649 | (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); |
647 | } | 650 | } |
648 | 651 | ||
649 | 652 | ||
650 | #ifdef _ACPI_ASL_COMPILER | 653 | #ifdef ACPI_ASL_COMPILER |
651 | /******************************************************************************* | 654 | /******************************************************************************* |
652 | * | 655 | * |
653 | * FUNCTION: acpi_ns_dump_tables | 656 | * FUNCTION: acpi_ns_dump_tables |
@@ -691,7 +694,7 @@ acpi_ns_dump_tables ( | |||
691 | } | 694 | } |
692 | 695 | ||
693 | acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, | 696 | acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, |
694 | ACPI_UINT32_MAX, search_handle); | 697 | ACPI_OWNER_ID_MAX, search_handle); |
695 | return_VOID; | 698 | return_VOID; |
696 | } | 699 | } |
697 | #endif /* _ACPI_ASL_COMPILER */ | 700 | #endif /* _ACPI_ASL_COMPILER */ |
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index a0e13e8d3764..64e0b2b9f55c 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c | |||
@@ -87,7 +87,7 @@ acpi_ns_one_complete_parse ( | |||
87 | 87 | ||
88 | /* Create and initialize a new walk state */ | 88 | /* Create and initialize a new walk state */ |
89 | 89 | ||
90 | walk_state = acpi_ds_create_walk_state (table_desc->table_id, | 90 | walk_state = acpi_ds_create_walk_state (table_desc->owner_id, |
91 | NULL, NULL, NULL); | 91 | NULL, NULL, NULL); |
92 | if (!walk_state) { | 92 | if (!walk_state) { |
93 | acpi_ps_free_op (parse_root); | 93 | acpi_ps_free_op (parse_root); |
@@ -146,6 +146,7 @@ acpi_ns_parse_table ( | |||
146 | * to service the entire parse. The second pass of the parse then | 146 | * to service the entire parse. The second pass of the parse then |
147 | * performs another complete parse of the AML.. | 147 | * performs another complete parse of the AML.. |
148 | */ | 148 | */ |
149 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); | ||
149 | status = acpi_ns_one_complete_parse (1, table_desc); | 150 | status = acpi_ns_one_complete_parse (1, table_desc); |
150 | if (ACPI_FAILURE (status)) { | 151 | if (ACPI_FAILURE (status)) { |
151 | return_ACPI_STATUS (status); | 152 | return_ACPI_STATUS (status); |
@@ -160,6 +161,7 @@ acpi_ns_parse_table ( | |||
160 | * overhead of this is compensated for by the fact that the | 161 | * overhead of this is compensated for by the fact that the |
161 | * parse objects are all cached. | 162 | * parse objects are all cached. |
162 | */ | 163 | */ |
164 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); | ||
163 | status = acpi_ns_one_complete_parse (2, table_desc); | 165 | status = acpi_ns_one_complete_parse (2, table_desc); |
164 | if (ACPI_FAILURE (status)) { | 166 | if (ACPI_FAILURE (status)) { |
165 | return_ACPI_STATUS (status); | 167 | return_ACPI_STATUS (status); |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index bdd9f37f8101..56e7cedba919 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -778,54 +778,6 @@ acpi_os_delete_lock ( | |||
778 | return_VOID; | 778 | return_VOID; |
779 | } | 779 | } |
780 | 780 | ||
781 | /* | ||
782 | * Acquire a spinlock. | ||
783 | * | ||
784 | * handle is a pointer to the spinlock_t. | ||
785 | * flags is *not* the result of save_flags - it is an ACPI-specific flag variable | ||
786 | * that indicates whether we are at interrupt level. | ||
787 | */ | ||
788 | void | ||
789 | acpi_os_acquire_lock ( | ||
790 | acpi_handle handle, | ||
791 | u32 flags) | ||
792 | { | ||
793 | ACPI_FUNCTION_TRACE ("os_acquire_lock"); | ||
794 | |||
795 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle, | ||
796 | ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); | ||
797 | |||
798 | if (flags & ACPI_NOT_ISR) | ||
799 | ACPI_DISABLE_IRQS(); | ||
800 | |||
801 | spin_lock((spinlock_t *)handle); | ||
802 | |||
803 | return_VOID; | ||
804 | } | ||
805 | |||
806 | |||
807 | /* | ||
808 | * Release a spinlock. See above. | ||
809 | */ | ||
810 | void | ||
811 | acpi_os_release_lock ( | ||
812 | acpi_handle handle, | ||
813 | u32 flags) | ||
814 | { | ||
815 | ACPI_FUNCTION_TRACE ("os_release_lock"); | ||
816 | |||
817 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle, | ||
818 | ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); | ||
819 | |||
820 | spin_unlock((spinlock_t *)handle); | ||
821 | |||
822 | if (flags & ACPI_NOT_ISR) | ||
823 | ACPI_ENABLE_IRQS(); | ||
824 | |||
825 | return_VOID; | ||
826 | } | ||
827 | |||
828 | |||
829 | acpi_status | 781 | acpi_status |
830 | acpi_os_create_semaphore( | 782 | acpi_os_create_semaphore( |
831 | u32 max_units, | 783 | u32 max_units, |
@@ -1172,3 +1124,151 @@ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; | |||
1172 | 1124 | ||
1173 | 1125 | ||
1174 | EXPORT_SYMBOL(max_cstate); | 1126 | EXPORT_SYMBOL(max_cstate); |
1127 | |||
1128 | /* | ||
1129 | * Acquire a spinlock. | ||
1130 | * | ||
1131 | * handle is a pointer to the spinlock_t. | ||
1132 | * flags is *not* the result of save_flags - it is an ACPI-specific flag variable | ||
1133 | * that indicates whether we are at interrupt level. | ||
1134 | */ | ||
1135 | |||
1136 | unsigned long | ||
1137 | acpi_os_acquire_lock ( | ||
1138 | acpi_handle handle) | ||
1139 | { | ||
1140 | unsigned long flags; | ||
1141 | spin_lock_irqsave((spinlock_t *)handle, flags); | ||
1142 | return flags; | ||
1143 | } | ||
1144 | |||
1145 | /* | ||
1146 | * Release a spinlock. See above. | ||
1147 | */ | ||
1148 | |||
1149 | void | ||
1150 | acpi_os_release_lock ( | ||
1151 | acpi_handle handle, | ||
1152 | unsigned long flags) | ||
1153 | { | ||
1154 | spin_unlock_irqrestore((spinlock_t *)handle, flags); | ||
1155 | } | ||
1156 | |||
1157 | |||
1158 | #ifndef ACPI_USE_LOCAL_CACHE | ||
1159 | |||
1160 | /******************************************************************************* | ||
1161 | * | ||
1162 | * FUNCTION: acpi_os_create_cache | ||
1163 | * | ||
1164 | * PARAMETERS: CacheName - Ascii name for the cache | ||
1165 | * ObjectSize - Size of each cached object | ||
1166 | * MaxDepth - Maximum depth of the cache (in objects) | ||
1167 | * ReturnCache - Where the new cache object is returned | ||
1168 | * | ||
1169 | * RETURN: Status | ||
1170 | * | ||
1171 | * DESCRIPTION: Create a cache object | ||
1172 | * | ||
1173 | ******************************************************************************/ | ||
1174 | |||
1175 | acpi_status | ||
1176 | acpi_os_create_cache ( | ||
1177 | char *name, | ||
1178 | u16 size, | ||
1179 | u16 depth, | ||
1180 | acpi_cache_t **cache) | ||
1181 | { | ||
1182 | *cache = kmem_cache_create (name, size, 0, 0, NULL, NULL); | ||
1183 | return AE_OK; | ||
1184 | } | ||
1185 | |||
1186 | /******************************************************************************* | ||
1187 | * | ||
1188 | * FUNCTION: acpi_os_purge_cache | ||
1189 | * | ||
1190 | * PARAMETERS: Cache - Handle to cache object | ||
1191 | * | ||
1192 | * RETURN: Status | ||
1193 | * | ||
1194 | * DESCRIPTION: Free all objects within the requested cache. | ||
1195 | * | ||
1196 | ******************************************************************************/ | ||
1197 | |||
1198 | acpi_status | ||
1199 | acpi_os_purge_cache ( | ||
1200 | acpi_cache_t *cache) | ||
1201 | { | ||
1202 | (void) kmem_cache_shrink(cache); | ||
1203 | return (AE_OK); | ||
1204 | } | ||
1205 | |||
1206 | /******************************************************************************* | ||
1207 | * | ||
1208 | * FUNCTION: acpi_os_delete_cache | ||
1209 | * | ||
1210 | * PARAMETERS: Cache - Handle to cache object | ||
1211 | * | ||
1212 | * RETURN: Status | ||
1213 | * | ||
1214 | * DESCRIPTION: Free all objects within the requested cache and delete the | ||
1215 | * cache object. | ||
1216 | * | ||
1217 | ******************************************************************************/ | ||
1218 | |||
1219 | acpi_status | ||
1220 | acpi_os_delete_cache ( | ||
1221 | acpi_cache_t *cache) | ||
1222 | { | ||
1223 | (void)kmem_cache_destroy(cache); | ||
1224 | return (AE_OK); | ||
1225 | } | ||
1226 | |||
1227 | /******************************************************************************* | ||
1228 | * | ||
1229 | * FUNCTION: acpi_os_release_object | ||
1230 | * | ||
1231 | * PARAMETERS: Cache - Handle to cache object | ||
1232 | * Object - The object to be released | ||
1233 | * | ||
1234 | * RETURN: None | ||
1235 | * | ||
1236 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | ||
1237 | * the object is deleted. | ||
1238 | * | ||
1239 | ******************************************************************************/ | ||
1240 | |||
1241 | acpi_status | ||
1242 | acpi_os_release_object ( | ||
1243 | acpi_cache_t *cache, | ||
1244 | void *object) | ||
1245 | { | ||
1246 | kmem_cache_free(cache, object); | ||
1247 | return (AE_OK); | ||
1248 | } | ||
1249 | |||
1250 | /******************************************************************************* | ||
1251 | * | ||
1252 | * FUNCTION: acpi_os_acquire_object | ||
1253 | * | ||
1254 | * PARAMETERS: Cache - Handle to cache object | ||
1255 | * ReturnObject - Where the object is returned | ||
1256 | * | ||
1257 | * RETURN: Status | ||
1258 | * | ||
1259 | * DESCRIPTION: Get an object from the specified cache. If cache is empty, | ||
1260 | * the object is allocated. | ||
1261 | * | ||
1262 | ******************************************************************************/ | ||
1263 | |||
1264 | void * | ||
1265 | acpi_os_acquire_object ( | ||
1266 | acpi_cache_t *cache) | ||
1267 | { | ||
1268 | void *object = kmem_cache_alloc(cache, GFP_KERNEL); | ||
1269 | WARN_ON(!object); | ||
1270 | return object; | ||
1271 | } | ||
1272 | |||
1273 | #endif | ||
1274 | |||
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile index bbdd286c660d..db24ee09cf11 100644 --- a/drivers/acpi/parser/Makefile +++ b/drivers/acpi/parser/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for all Linux ACPI interpreter subdirectories | 2 | # Makefile for all Linux ACPI interpreter subdirectories |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := psargs.o psparse.o pstree.o pswalk.o \ | 5 | obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \ |
6 | psopcode.o psscope.o psutils.o psxface.o | 6 | psopcode.o psscope.o psutils.o psxface.o |
7 | 7 | ||
8 | EXTRA_CFLAGS += $(ACPI_CFLAGS) | 8 | EXTRA_CFLAGS += $(ACPI_CFLAGS) |
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c new file mode 100644 index 000000000000..edf8aa5f86ca --- /dev/null +++ b/drivers/acpi/parser/psloop.c | |||
@@ -0,0 +1,782 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psloop - Main AML parse loop | ||
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 | |||
45 | /* | ||
46 | * Parse the AML and build an operation tree as most interpreters, | ||
47 | * like Perl, do. Parsing is done by hand rather than with a YACC | ||
48 | * generated parser to tightly constrain stack and dynamic memory | ||
49 | * usage. At the same time, parsing is kept flexible and the code | ||
50 | * fairly compact by parsing based on a list of AML opcode | ||
51 | * templates in aml_op_info[] | ||
52 | */ | ||
53 | |||
54 | #include <acpi/acpi.h> | ||
55 | #include <acpi/acparser.h> | ||
56 | #include <acpi/acdispat.h> | ||
57 | #include <acpi/amlcode.h> | ||
58 | #include <acpi/acnamesp.h> | ||
59 | #include <acpi/acinterp.h> | ||
60 | |||
61 | #define _COMPONENT ACPI_PARSER | ||
62 | ACPI_MODULE_NAME ("psloop") | ||
63 | |||
64 | static u32 acpi_gbl_depth = 0; | ||
65 | |||
66 | |||
67 | /******************************************************************************* | ||
68 | * | ||
69 | * FUNCTION: acpi_ps_parse_loop | ||
70 | * | ||
71 | * PARAMETERS: walk_state - Current state | ||
72 | * | ||
73 | * RETURN: Status | ||
74 | * | ||
75 | * DESCRIPTION: Parse AML (pointed to by the current parser state) and return | ||
76 | * a tree of ops. | ||
77 | * | ||
78 | ******************************************************************************/ | ||
79 | |||
80 | acpi_status | ||
81 | acpi_ps_parse_loop ( | ||
82 | struct acpi_walk_state *walk_state) | ||
83 | { | ||
84 | acpi_status status = AE_OK; | ||
85 | acpi_status status2; | ||
86 | union acpi_parse_object *op = NULL; /* current op */ | ||
87 | union acpi_parse_object *arg = NULL; | ||
88 | union acpi_parse_object *pre_op = NULL; | ||
89 | struct acpi_parse_state *parser_state; | ||
90 | u8 *aml_op_start = NULL; | ||
91 | |||
92 | |||
93 | ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); | ||
94 | |||
95 | if (walk_state->descending_callback == NULL) { | ||
96 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
97 | } | ||
98 | |||
99 | parser_state = &walk_state->parser_state; | ||
100 | walk_state->arg_types = 0; | ||
101 | |||
102 | #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) | ||
103 | |||
104 | if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { | ||
105 | /* We are restarting a preempted control method */ | ||
106 | |||
107 | if (acpi_ps_has_completed_scope (parser_state)) { | ||
108 | /* | ||
109 | * We must check if a predicate to an IF or WHILE statement | ||
110 | * was just completed | ||
111 | */ | ||
112 | if ((parser_state->scope->parse_scope.op) && | ||
113 | ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || | ||
114 | (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && | ||
115 | (walk_state->control_state) && | ||
116 | (walk_state->control_state->common.state == | ||
117 | ACPI_CONTROL_PREDICATE_EXECUTING)) { | ||
118 | /* | ||
119 | * A predicate was just completed, get the value of the | ||
120 | * predicate and branch based on that value | ||
121 | */ | ||
122 | walk_state->op = NULL; | ||
123 | status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); | ||
124 | if (ACPI_FAILURE (status) && | ||
125 | ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { | ||
126 | if (status == AE_AML_NO_RETURN_VALUE) { | ||
127 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
128 | "Invoked method did not return a value, %s\n", | ||
129 | acpi_format_exception (status))); | ||
130 | |||
131 | } | ||
132 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
133 | "get_predicate Failed, %s\n", | ||
134 | acpi_format_exception (status))); | ||
135 | return_ACPI_STATUS (status); | ||
136 | } | ||
137 | |||
138 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
139 | } | ||
140 | |||
141 | acpi_ps_pop_scope (parser_state, &op, | ||
142 | &walk_state->arg_types, &walk_state->arg_count); | ||
143 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); | ||
144 | } | ||
145 | else if (walk_state->prev_op) { | ||
146 | /* We were in the middle of an op */ | ||
147 | |||
148 | op = walk_state->prev_op; | ||
149 | walk_state->arg_types = walk_state->prev_arg_types; | ||
150 | } | ||
151 | } | ||
152 | #endif | ||
153 | |||
154 | /* Iterative parsing loop, while there is more AML to process: */ | ||
155 | |||
156 | while ((parser_state->aml < parser_state->aml_end) || (op)) { | ||
157 | aml_op_start = parser_state->aml; | ||
158 | if (!op) { | ||
159 | /* Get the next opcode from the AML stream */ | ||
160 | |||
161 | walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, | ||
162 | parser_state->aml_start); | ||
163 | walk_state->opcode = acpi_ps_peek_opcode (parser_state); | ||
164 | |||
165 | /* | ||
166 | * First cut to determine what we have found: | ||
167 | * 1) A valid AML opcode | ||
168 | * 2) A name string | ||
169 | * 3) An unknown/invalid opcode | ||
170 | */ | ||
171 | walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); | ||
172 | switch (walk_state->op_info->class) { | ||
173 | case AML_CLASS_ASCII: | ||
174 | case AML_CLASS_PREFIX: | ||
175 | /* | ||
176 | * Starts with a valid prefix or ASCII char, this is a name | ||
177 | * string. Convert the bare name string to a namepath. | ||
178 | */ | ||
179 | walk_state->opcode = AML_INT_NAMEPATH_OP; | ||
180 | walk_state->arg_types = ARGP_NAMESTRING; | ||
181 | break; | ||
182 | |||
183 | case AML_CLASS_UNKNOWN: | ||
184 | |||
185 | /* The opcode is unrecognized. Just skip unknown opcodes */ | ||
186 | |||
187 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
188 | "Found unknown opcode %X at AML address %p offset %X, ignoring\n", | ||
189 | walk_state->opcode, parser_state->aml, walk_state->aml_offset)); | ||
190 | |||
191 | ACPI_DUMP_BUFFER (parser_state->aml, 128); | ||
192 | |||
193 | /* Assume one-byte bad opcode */ | ||
194 | |||
195 | parser_state->aml++; | ||
196 | continue; | ||
197 | |||
198 | default: | ||
199 | |||
200 | /* Found opcode info, this is a normal opcode */ | ||
201 | |||
202 | parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); | ||
203 | walk_state->arg_types = walk_state->op_info->parse_args; | ||
204 | break; | ||
205 | } | ||
206 | |||
207 | /* Create Op structure and append to parent's argument list */ | ||
208 | |||
209 | if (walk_state->op_info->flags & AML_NAMED) { | ||
210 | /* Allocate a new pre_op if necessary */ | ||
211 | |||
212 | if (!pre_op) { | ||
213 | pre_op = acpi_ps_alloc_op (walk_state->opcode); | ||
214 | if (!pre_op) { | ||
215 | status = AE_NO_MEMORY; | ||
216 | goto close_this_op; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | pre_op->common.value.arg = NULL; | ||
221 | pre_op->common.aml_opcode = walk_state->opcode; | ||
222 | |||
223 | /* | ||
224 | * Get and append arguments until we find the node that contains | ||
225 | * the name (the type ARGP_NAME). | ||
226 | */ | ||
227 | while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && | ||
228 | (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { | ||
229 | status = acpi_ps_get_next_arg (walk_state, parser_state, | ||
230 | GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); | ||
231 | if (ACPI_FAILURE (status)) { | ||
232 | goto close_this_op; | ||
233 | } | ||
234 | |||
235 | acpi_ps_append_arg (pre_op, arg); | ||
236 | INCREMENT_ARG_LIST (walk_state->arg_types); | ||
237 | } | ||
238 | |||
239 | /* | ||
240 | * Make sure that we found a NAME and didn't run out of | ||
241 | * arguments | ||
242 | */ | ||
243 | if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { | ||
244 | status = AE_AML_NO_OPERAND; | ||
245 | goto close_this_op; | ||
246 | } | ||
247 | |||
248 | /* We know that this arg is a name, move to next arg */ | ||
249 | |||
250 | INCREMENT_ARG_LIST (walk_state->arg_types); | ||
251 | |||
252 | /* | ||
253 | * Find the object. This will either insert the object into | ||
254 | * the namespace or simply look it up | ||
255 | */ | ||
256 | walk_state->op = NULL; | ||
257 | |||
258 | status = walk_state->descending_callback (walk_state, &op); | ||
259 | if (ACPI_FAILURE (status)) { | ||
260 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
261 | "During name lookup/catalog, %s\n", | ||
262 | acpi_format_exception (status))); | ||
263 | goto close_this_op; | ||
264 | } | ||
265 | |||
266 | if (!op) { | ||
267 | continue; | ||
268 | } | ||
269 | |||
270 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
271 | if (status == AE_CTRL_PENDING) { | ||
272 | status = AE_OK; | ||
273 | goto close_this_op; | ||
274 | } | ||
275 | |||
276 | if (ACPI_FAILURE (status)) { | ||
277 | goto close_this_op; | ||
278 | } | ||
279 | |||
280 | acpi_ps_append_arg (op, pre_op->common.value.arg); | ||
281 | acpi_gbl_depth++; | ||
282 | |||
283 | if (op->common.aml_opcode == AML_REGION_OP) { | ||
284 | /* | ||
285 | * Defer final parsing of an operation_region body, | ||
286 | * because we don't have enough info in the first pass | ||
287 | * to parse it correctly (i.e., there may be method | ||
288 | * calls within the term_arg elements of the body.) | ||
289 | * | ||
290 | * However, we must continue parsing because | ||
291 | * the opregion is not a standalone package -- | ||
292 | * we don't know where the end is at this point. | ||
293 | * | ||
294 | * (Length is unknown until parse of the body complete) | ||
295 | */ | ||
296 | op->named.data = aml_op_start; | ||
297 | op->named.length = 0; | ||
298 | } | ||
299 | } | ||
300 | else { | ||
301 | /* Not a named opcode, just allocate Op and append to parent */ | ||
302 | |||
303 | walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); | ||
304 | op = acpi_ps_alloc_op (walk_state->opcode); | ||
305 | if (!op) { | ||
306 | status = AE_NO_MEMORY; | ||
307 | goto close_this_op; | ||
308 | } | ||
309 | |||
310 | if (walk_state->op_info->flags & AML_CREATE) { | ||
311 | /* | ||
312 | * Backup to beginning of create_xXXfield declaration | ||
313 | * body_length is unknown until we parse the body | ||
314 | */ | ||
315 | op->named.data = aml_op_start; | ||
316 | op->named.length = 0; | ||
317 | } | ||
318 | |||
319 | acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); | ||
320 | |||
321 | if ((walk_state->descending_callback != NULL)) { | ||
322 | /* | ||
323 | * Find the object. This will either insert the object into | ||
324 | * the namespace or simply look it up | ||
325 | */ | ||
326 | walk_state->op = op; | ||
327 | |||
328 | status = walk_state->descending_callback (walk_state, &op); | ||
329 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
330 | if (status == AE_CTRL_PENDING) { | ||
331 | status = AE_OK; | ||
332 | goto close_this_op; | ||
333 | } | ||
334 | |||
335 | if (ACPI_FAILURE (status)) { | ||
336 | goto close_this_op; | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | |||
341 | op->common.aml_offset = walk_state->aml_offset; | ||
342 | |||
343 | if (walk_state->op_info) { | ||
344 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, | ||
345 | "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", | ||
346 | (u32) op->common.aml_opcode, walk_state->op_info->name, | ||
347 | op, parser_state->aml, op->common.aml_offset)); | ||
348 | } | ||
349 | } | ||
350 | |||
351 | |||
352 | /* | ||
353 | * Start arg_count at zero because we don't know if there are | ||
354 | * any args yet | ||
355 | */ | ||
356 | walk_state->arg_count = 0; | ||
357 | |||
358 | /* Are there any arguments that must be processed? */ | ||
359 | |||
360 | if (walk_state->arg_types) { | ||
361 | /* Get arguments */ | ||
362 | |||
363 | switch (op->common.aml_opcode) { | ||
364 | case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ | ||
365 | case AML_WORD_OP: /* AML_WORDDATA_ARG */ | ||
366 | case AML_DWORD_OP: /* AML_DWORDATA_ARG */ | ||
367 | case AML_QWORD_OP: /* AML_QWORDATA_ARG */ | ||
368 | case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ | ||
369 | |||
370 | /* Fill in constant or string argument directly */ | ||
371 | |||
372 | acpi_ps_get_next_simple_arg (parser_state, | ||
373 | GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); | ||
374 | break; | ||
375 | |||
376 | case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ | ||
377 | |||
378 | status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); | ||
379 | if (ACPI_FAILURE (status)) { | ||
380 | goto close_this_op; | ||
381 | } | ||
382 | |||
383 | walk_state->arg_types = 0; | ||
384 | break; | ||
385 | |||
386 | default: | ||
387 | /* | ||
388 | * Op is not a constant or string, append each argument | ||
389 | * to the Op | ||
390 | */ | ||
391 | while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && | ||
392 | !walk_state->arg_count) { | ||
393 | walk_state->aml_offset = (u32) | ||
394 | ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); | ||
395 | |||
396 | status = acpi_ps_get_next_arg (walk_state, parser_state, | ||
397 | GET_CURRENT_ARG_TYPE (walk_state->arg_types), | ||
398 | &arg); | ||
399 | if (ACPI_FAILURE (status)) { | ||
400 | goto close_this_op; | ||
401 | } | ||
402 | |||
403 | if (arg) { | ||
404 | arg->common.aml_offset = walk_state->aml_offset; | ||
405 | acpi_ps_append_arg (op, arg); | ||
406 | } | ||
407 | INCREMENT_ARG_LIST (walk_state->arg_types); | ||
408 | } | ||
409 | |||
410 | |||
411 | /* Special processing for certain opcodes */ | ||
412 | |||
413 | #define ACPI_NO_MODULE_LEVEL_CODE | ||
414 | |||
415 | /* TBD (remove): Temporary mechanism to disable this code if needed */ | ||
416 | |||
417 | #ifndef ACPI_NO_MODULE_LEVEL_CODE | ||
418 | |||
419 | if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) && | ||
420 | ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { | ||
421 | /* | ||
422 | * We want to skip If/Else/While constructs during Pass1 | ||
423 | * because we want to actually conditionally execute the | ||
424 | * code during Pass2. | ||
425 | * | ||
426 | * Except for disassembly, where we always want to | ||
427 | * walk the If/Else/While packages | ||
428 | */ | ||
429 | switch (op->common.aml_opcode) { | ||
430 | case AML_IF_OP: | ||
431 | case AML_ELSE_OP: | ||
432 | case AML_WHILE_OP: | ||
433 | |||
434 | /* Skip body of if/else/while in pass 1 */ | ||
435 | |||
436 | parser_state->aml = parser_state->pkg_end; | ||
437 | walk_state->arg_count = 0; | ||
438 | break; | ||
439 | |||
440 | default: | ||
441 | break; | ||
442 | } | ||
443 | } | ||
444 | #endif | ||
445 | switch (op->common.aml_opcode) { | ||
446 | case AML_METHOD_OP: | ||
447 | |||
448 | /* | ||
449 | * Skip parsing of control method | ||
450 | * because we don't have enough info in the first pass | ||
451 | * to parse it correctly. | ||
452 | * | ||
453 | * Save the length and address of the body | ||
454 | */ | ||
455 | op->named.data = parser_state->aml; | ||
456 | op->named.length = (u32) (parser_state->pkg_end - | ||
457 | parser_state->aml); | ||
458 | |||
459 | /* Skip body of method */ | ||
460 | |||
461 | parser_state->aml = parser_state->pkg_end; | ||
462 | walk_state->arg_count = 0; | ||
463 | break; | ||
464 | |||
465 | case AML_BUFFER_OP: | ||
466 | case AML_PACKAGE_OP: | ||
467 | case AML_VAR_PACKAGE_OP: | ||
468 | |||
469 | if ((op->common.parent) && | ||
470 | (op->common.parent->common.aml_opcode == AML_NAME_OP) && | ||
471 | (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { | ||
472 | /* | ||
473 | * Skip parsing of Buffers and Packages | ||
474 | * because we don't have enough info in the first pass | ||
475 | * to parse them correctly. | ||
476 | */ | ||
477 | op->named.data = aml_op_start; | ||
478 | op->named.length = (u32) (parser_state->pkg_end - | ||
479 | aml_op_start); | ||
480 | |||
481 | /* Skip body */ | ||
482 | |||
483 | parser_state->aml = parser_state->pkg_end; | ||
484 | walk_state->arg_count = 0; | ||
485 | } | ||
486 | break; | ||
487 | |||
488 | case AML_WHILE_OP: | ||
489 | |||
490 | if (walk_state->control_state) { | ||
491 | walk_state->control_state->control.package_end = | ||
492 | parser_state->pkg_end; | ||
493 | } | ||
494 | break; | ||
495 | |||
496 | default: | ||
497 | |||
498 | /* No action for all other opcodes */ | ||
499 | break; | ||
500 | } | ||
501 | break; | ||
502 | } | ||
503 | } | ||
504 | |||
505 | /* Check for arguments that need to be processed */ | ||
506 | |||
507 | if (walk_state->arg_count) { | ||
508 | /* | ||
509 | * There are arguments (complex ones), push Op and | ||
510 | * prepare for argument | ||
511 | */ | ||
512 | status = acpi_ps_push_scope (parser_state, op, | ||
513 | walk_state->arg_types, walk_state->arg_count); | ||
514 | if (ACPI_FAILURE (status)) { | ||
515 | goto close_this_op; | ||
516 | } | ||
517 | op = NULL; | ||
518 | continue; | ||
519 | } | ||
520 | |||
521 | /* | ||
522 | * All arguments have been processed -- Op is complete, | ||
523 | * prepare for next | ||
524 | */ | ||
525 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
526 | if (walk_state->op_info->flags & AML_NAMED) { | ||
527 | if (acpi_gbl_depth) { | ||
528 | acpi_gbl_depth--; | ||
529 | } | ||
530 | |||
531 | if (op->common.aml_opcode == AML_REGION_OP) { | ||
532 | /* | ||
533 | * Skip parsing of control method or opregion body, | ||
534 | * because we don't have enough info in the first pass | ||
535 | * to parse them correctly. | ||
536 | * | ||
537 | * Completed parsing an op_region declaration, we now | ||
538 | * know the length. | ||
539 | */ | ||
540 | op->named.length = (u32) (parser_state->aml - op->named.data); | ||
541 | } | ||
542 | } | ||
543 | |||
544 | if (walk_state->op_info->flags & AML_CREATE) { | ||
545 | /* | ||
546 | * Backup to beginning of create_xXXfield declaration (1 for | ||
547 | * Opcode) | ||
548 | * | ||
549 | * body_length is unknown until we parse the body | ||
550 | */ | ||
551 | op->named.length = (u32) (parser_state->aml - op->named.data); | ||
552 | } | ||
553 | |||
554 | /* This op complete, notify the dispatcher */ | ||
555 | |||
556 | if (walk_state->ascending_callback != NULL) { | ||
557 | walk_state->op = op; | ||
558 | walk_state->opcode = op->common.aml_opcode; | ||
559 | |||
560 | status = walk_state->ascending_callback (walk_state); | ||
561 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
562 | if (status == AE_CTRL_PENDING) { | ||
563 | status = AE_OK; | ||
564 | goto close_this_op; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | |||
569 | close_this_op: | ||
570 | /* | ||
571 | * Finished one argument of the containing scope | ||
572 | */ | ||
573 | parser_state->scope->parse_scope.arg_count--; | ||
574 | |||
575 | /* Finished with pre_op */ | ||
576 | |||
577 | if (pre_op) { | ||
578 | acpi_ps_free_op (pre_op); | ||
579 | pre_op = NULL; | ||
580 | } | ||
581 | |||
582 | /* Close this Op (will result in parse subtree deletion) */ | ||
583 | |||
584 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
585 | if (ACPI_FAILURE (status2)) { | ||
586 | return_ACPI_STATUS (status2); | ||
587 | } | ||
588 | op = NULL; | ||
589 | |||
590 | switch (status) { | ||
591 | case AE_OK: | ||
592 | break; | ||
593 | |||
594 | |||
595 | case AE_CTRL_TRANSFER: | ||
596 | |||
597 | /* We are about to transfer to a called method. */ | ||
598 | |||
599 | walk_state->prev_op = op; | ||
600 | walk_state->prev_arg_types = walk_state->arg_types; | ||
601 | return_ACPI_STATUS (status); | ||
602 | |||
603 | |||
604 | case AE_CTRL_END: | ||
605 | |||
606 | acpi_ps_pop_scope (parser_state, &op, | ||
607 | &walk_state->arg_types, &walk_state->arg_count); | ||
608 | |||
609 | if (op) { | ||
610 | walk_state->op = op; | ||
611 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
612 | walk_state->opcode = op->common.aml_opcode; | ||
613 | |||
614 | status = walk_state->ascending_callback (walk_state); | ||
615 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
616 | |||
617 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
618 | if (ACPI_FAILURE (status2)) { | ||
619 | return_ACPI_STATUS (status2); | ||
620 | } | ||
621 | op = NULL; | ||
622 | } | ||
623 | status = AE_OK; | ||
624 | break; | ||
625 | |||
626 | |||
627 | case AE_CTRL_BREAK: | ||
628 | case AE_CTRL_CONTINUE: | ||
629 | |||
630 | /* Pop off scopes until we find the While */ | ||
631 | |||
632 | while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { | ||
633 | acpi_ps_pop_scope (parser_state, &op, | ||
634 | &walk_state->arg_types, &walk_state->arg_count); | ||
635 | } | ||
636 | |||
637 | /* Close this iteration of the While loop */ | ||
638 | |||
639 | walk_state->op = op; | ||
640 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
641 | walk_state->opcode = op->common.aml_opcode; | ||
642 | |||
643 | status = walk_state->ascending_callback (walk_state); | ||
644 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
645 | |||
646 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
647 | if (ACPI_FAILURE (status2)) { | ||
648 | return_ACPI_STATUS (status2); | ||
649 | } | ||
650 | op = NULL; | ||
651 | |||
652 | status = AE_OK; | ||
653 | break; | ||
654 | |||
655 | |||
656 | case AE_CTRL_TERMINATE: | ||
657 | |||
658 | status = AE_OK; | ||
659 | |||
660 | /* Clean up */ | ||
661 | do { | ||
662 | if (op) { | ||
663 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
664 | if (ACPI_FAILURE (status2)) { | ||
665 | return_ACPI_STATUS (status2); | ||
666 | } | ||
667 | } | ||
668 | acpi_ps_pop_scope (parser_state, &op, | ||
669 | &walk_state->arg_types, &walk_state->arg_count); | ||
670 | |||
671 | } while (op); | ||
672 | |||
673 | return_ACPI_STATUS (status); | ||
674 | |||
675 | |||
676 | default: /* All other non-AE_OK status */ | ||
677 | |||
678 | do { | ||
679 | if (op) { | ||
680 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
681 | if (ACPI_FAILURE (status2)) { | ||
682 | return_ACPI_STATUS (status2); | ||
683 | } | ||
684 | } | ||
685 | acpi_ps_pop_scope (parser_state, &op, | ||
686 | &walk_state->arg_types, &walk_state->arg_count); | ||
687 | |||
688 | } while (op); | ||
689 | |||
690 | |||
691 | /* | ||
692 | * TBD: Cleanup parse ops on error | ||
693 | */ | ||
694 | #if 0 | ||
695 | if (op == NULL) { | ||
696 | acpi_ps_pop_scope (parser_state, &op, | ||
697 | &walk_state->arg_types, &walk_state->arg_count); | ||
698 | } | ||
699 | #endif | ||
700 | walk_state->prev_op = op; | ||
701 | walk_state->prev_arg_types = walk_state->arg_types; | ||
702 | return_ACPI_STATUS (status); | ||
703 | } | ||
704 | |||
705 | /* This scope complete? */ | ||
706 | |||
707 | if (acpi_ps_has_completed_scope (parser_state)) { | ||
708 | acpi_ps_pop_scope (parser_state, &op, | ||
709 | &walk_state->arg_types, &walk_state->arg_count); | ||
710 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); | ||
711 | } | ||
712 | else { | ||
713 | op = NULL; | ||
714 | } | ||
715 | |||
716 | } /* while parser_state->Aml */ | ||
717 | |||
718 | |||
719 | /* | ||
720 | * Complete the last Op (if not completed), and clear the scope stack. | ||
721 | * It is easily possible to end an AML "package" with an unbounded number | ||
722 | * of open scopes (such as when several ASL blocks are closed with | ||
723 | * sequential closing braces). We want to terminate each one cleanly. | ||
724 | */ | ||
725 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); | ||
726 | do { | ||
727 | if (op) { | ||
728 | if (walk_state->ascending_callback != NULL) { | ||
729 | walk_state->op = op; | ||
730 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
731 | walk_state->opcode = op->common.aml_opcode; | ||
732 | |||
733 | status = walk_state->ascending_callback (walk_state); | ||
734 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
735 | if (status == AE_CTRL_PENDING) { | ||
736 | status = AE_OK; | ||
737 | goto close_this_op; | ||
738 | } | ||
739 | |||
740 | if (status == AE_CTRL_TERMINATE) { | ||
741 | status = AE_OK; | ||
742 | |||
743 | /* Clean up */ | ||
744 | do { | ||
745 | if (op) { | ||
746 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
747 | if (ACPI_FAILURE (status2)) { | ||
748 | return_ACPI_STATUS (status2); | ||
749 | } | ||
750 | } | ||
751 | |||
752 | acpi_ps_pop_scope (parser_state, &op, | ||
753 | &walk_state->arg_types, &walk_state->arg_count); | ||
754 | |||
755 | } while (op); | ||
756 | |||
757 | return_ACPI_STATUS (status); | ||
758 | } | ||
759 | |||
760 | else if (ACPI_FAILURE (status)) { | ||
761 | /* First error is most important */ | ||
762 | |||
763 | (void) acpi_ps_complete_this_op (walk_state, op); | ||
764 | return_ACPI_STATUS (status); | ||
765 | } | ||
766 | } | ||
767 | |||
768 | status2 = acpi_ps_complete_this_op (walk_state, op); | ||
769 | if (ACPI_FAILURE (status2)) { | ||
770 | return_ACPI_STATUS (status2); | ||
771 | } | ||
772 | } | ||
773 | |||
774 | acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, | ||
775 | &walk_state->arg_count); | ||
776 | |||
777 | } while (op); | ||
778 | |||
779 | return_ACPI_STATUS (status); | ||
780 | } | ||
781 | |||
782 | |||
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 5744673568c0..6f7594a516d2 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c | |||
@@ -311,7 +311,7 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = | |||
311 | /* ACPI 2.0 opcodes */ | 311 | /* ACPI 2.0 opcodes */ |
312 | 312 | ||
313 | /* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), | 313 | /* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), |
314 | /* 6F */ ACPI_OP ("Package /*Var*/", ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), | 314 | /* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), |
315 | /* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | 315 | /* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), |
316 | /* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), | 316 | /* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), |
317 | /* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), | 317 | /* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), |
@@ -428,33 +428,23 @@ acpi_ps_get_opcode_info ( | |||
428 | /* | 428 | /* |
429 | * Detect normal 8-bit opcode or extended 16-bit opcode | 429 | * Detect normal 8-bit opcode or extended 16-bit opcode |
430 | */ | 430 | */ |
431 | switch ((u8) (opcode >> 8)) { | 431 | if (!(opcode & 0xFF00)) { |
432 | case 0: | ||
433 | |||
434 | /* Simple (8-bit) opcode: 0-255, can't index beyond table */ | 432 | /* Simple (8-bit) opcode: 0-255, can't index beyond table */ |
435 | 433 | ||
436 | return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); | 434 | return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); |
435 | } | ||
437 | 436 | ||
438 | case AML_EXTOP: | 437 | if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && |
439 | 438 | (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { | |
440 | /* Extended (16-bit, prefix+opcode) opcode */ | 439 | /* Valid extended (16-bit) opcode */ |
441 | |||
442 | if (((u8) opcode) <= MAX_EXTENDED_OPCODE) { | ||
443 | return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]); | ||
444 | } | ||
445 | |||
446 | /* Else fall through to error case below */ | ||
447 | /*lint -fallthrough */ | ||
448 | |||
449 | default: | ||
450 | 440 | ||
451 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | 441 | return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]); |
452 | "Unknown AML opcode [%4.4X]\n", opcode)); | ||
453 | break; | ||
454 | } | 442 | } |
455 | 443 | ||
444 | /* Unknown AML opcode */ | ||
456 | 445 | ||
457 | /* Default is "unknown opcode" */ | 446 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
447 | "Unknown AML opcode [%4.4X]\n", opcode)); | ||
458 | 448 | ||
459 | return (&acpi_gbl_aml_op_info [_UNK]); | 449 | return (&acpi_gbl_aml_op_info [_UNK]); |
460 | } | 450 | } |
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index bbfdc1a58c27..16b84a3d0436 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c | |||
@@ -62,26 +62,6 @@ | |||
62 | ACPI_MODULE_NAME ("psparse") | 62 | ACPI_MODULE_NAME ("psparse") |
63 | 63 | ||
64 | 64 | ||
65 | static u32 acpi_gbl_depth = 0; | ||
66 | |||
67 | /* Local prototypes */ | ||
68 | |||
69 | static void | ||
70 | acpi_ps_complete_this_op ( | ||
71 | struct acpi_walk_state *walk_state, | ||
72 | union acpi_parse_object *op); | ||
73 | |||
74 | static acpi_status | ||
75 | acpi_ps_next_parse_state ( | ||
76 | struct acpi_walk_state *walk_state, | ||
77 | union acpi_parse_object *op, | ||
78 | acpi_status callback_status); | ||
79 | |||
80 | static acpi_status | ||
81 | acpi_ps_parse_loop ( | ||
82 | struct acpi_walk_state *walk_state); | ||
83 | |||
84 | |||
85 | /******************************************************************************* | 65 | /******************************************************************************* |
86 | * | 66 | * |
87 | * FUNCTION: acpi_ps_get_opcode_size | 67 | * FUNCTION: acpi_ps_get_opcode_size |
@@ -134,8 +114,8 @@ acpi_ps_peek_opcode ( | |||
134 | aml = parser_state->aml; | 114 | aml = parser_state->aml; |
135 | opcode = (u16) ACPI_GET8 (aml); | 115 | opcode = (u16) ACPI_GET8 (aml); |
136 | 116 | ||
137 | if (opcode == AML_EXTOP) { | 117 | if (opcode == AML_EXTENDED_OP_PREFIX) { |
138 | /* Extended opcode */ | 118 | /* Extended opcode, get the second opcode byte */ |
139 | 119 | ||
140 | aml++; | 120 | aml++; |
141 | opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); | 121 | opcode = (u16) ((opcode << 8) | ACPI_GET8 (aml)); |
@@ -152,13 +132,13 @@ acpi_ps_peek_opcode ( | |||
152 | * PARAMETERS: walk_state - Current State | 132 | * PARAMETERS: walk_state - Current State |
153 | * Op - Op to complete | 133 | * Op - Op to complete |
154 | * | 134 | * |
155 | * RETURN: None. | 135 | * RETURN: Status |
156 | * | 136 | * |
157 | * DESCRIPTION: Perform any cleanup at the completion of an Op. | 137 | * DESCRIPTION: Perform any cleanup at the completion of an Op. |
158 | * | 138 | * |
159 | ******************************************************************************/ | 139 | ******************************************************************************/ |
160 | 140 | ||
161 | static void | 141 | acpi_status |
162 | acpi_ps_complete_this_op ( | 142 | acpi_ps_complete_this_op ( |
163 | struct acpi_walk_state *walk_state, | 143 | struct acpi_walk_state *walk_state, |
164 | union acpi_parse_object *op) | 144 | union acpi_parse_object *op) |
@@ -175,19 +155,26 @@ acpi_ps_complete_this_op ( | |||
175 | /* Check for null Op, can happen if AML code is corrupt */ | 155 | /* Check for null Op, can happen if AML code is corrupt */ |
176 | 156 | ||
177 | if (!op) { | 157 | if (!op) { |
178 | return_VOID; | 158 | return_ACPI_STATUS (AE_OK); /* OK for now */ |
179 | } | 159 | } |
180 | 160 | ||
181 | /* Delete this op and the subtree below it if asked to */ | 161 | /* Delete this op and the subtree below it if asked to */ |
182 | 162 | ||
183 | if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || | 163 | if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || |
184 | (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { | 164 | (walk_state->op_info->class == AML_CLASS_ARGUMENT)) { |
185 | return_VOID; | 165 | return_ACPI_STATUS (AE_OK); |
186 | } | 166 | } |
187 | 167 | ||
188 | /* Make sure that we only delete this subtree */ | 168 | /* Make sure that we only delete this subtree */ |
189 | 169 | ||
190 | if (op->common.parent) { | 170 | if (op->common.parent) { |
171 | prev = op->common.parent->common.value.arg; | ||
172 | if (!prev) { | ||
173 | /* Nothing more to do */ | ||
174 | |||
175 | goto cleanup; | ||
176 | } | ||
177 | |||
191 | /* | 178 | /* |
192 | * Check if we need to replace the operator and its subtree | 179 | * Check if we need to replace the operator and its subtree |
193 | * with a return value op (placeholder op) | 180 | * with a return value op (placeholder op) |
@@ -206,7 +193,7 @@ acpi_ps_complete_this_op ( | |||
206 | */ | 193 | */ |
207 | replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); | 194 | replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); |
208 | if (!replacement_op) { | 195 | if (!replacement_op) { |
209 | goto cleanup; | 196 | goto allocate_error; |
210 | } | 197 | } |
211 | break; | 198 | break; |
212 | 199 | ||
@@ -223,18 +210,17 @@ acpi_ps_complete_this_op ( | |||
223 | (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { | 210 | (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { |
224 | replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); | 211 | replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); |
225 | if (!replacement_op) { | 212 | if (!replacement_op) { |
226 | goto cleanup; | 213 | goto allocate_error; |
227 | } | 214 | } |
228 | } | 215 | } |
229 | 216 | else if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && | |
230 | if ((op->common.parent->common.aml_opcode == AML_NAME_OP) && | 217 | (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2)) { |
231 | (walk_state->descending_callback != acpi_ds_exec_begin_op)) { | ||
232 | if ((op->common.aml_opcode == AML_BUFFER_OP) || | 218 | if ((op->common.aml_opcode == AML_BUFFER_OP) || |
233 | (op->common.aml_opcode == AML_PACKAGE_OP) || | 219 | (op->common.aml_opcode == AML_PACKAGE_OP) || |
234 | (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) { | 220 | (op->common.aml_opcode == AML_VAR_PACKAGE_OP)) { |
235 | replacement_op = acpi_ps_alloc_op (op->common.aml_opcode); | 221 | replacement_op = acpi_ps_alloc_op (op->common.aml_opcode); |
236 | if (!replacement_op) { | 222 | if (!replacement_op) { |
237 | goto cleanup; | 223 | goto allocate_error; |
238 | } | 224 | } |
239 | 225 | ||
240 | replacement_op->named.data = op->named.data; | 226 | replacement_op->named.data = op->named.data; |
@@ -244,15 +230,15 @@ acpi_ps_complete_this_op ( | |||
244 | break; | 230 | break; |
245 | 231 | ||
246 | default: | 232 | default: |
233 | |||
247 | replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); | 234 | replacement_op = acpi_ps_alloc_op (AML_INT_RETURN_VALUE_OP); |
248 | if (!replacement_op) { | 235 | if (!replacement_op) { |
249 | goto cleanup; | 236 | goto allocate_error; |
250 | } | 237 | } |
251 | } | 238 | } |
252 | 239 | ||
253 | /* We must unlink this op from the parent tree */ | 240 | /* We must unlink this op from the parent tree */ |
254 | 241 | ||
255 | prev = op->common.parent->common.value.arg; | ||
256 | if (prev == op) { | 242 | if (prev == op) { |
257 | /* This op is the first in the list */ | 243 | /* This op is the first in the list */ |
258 | 244 | ||
@@ -298,7 +284,15 @@ cleanup: | |||
298 | /* Now we can actually delete the subtree rooted at Op */ | 284 | /* Now we can actually delete the subtree rooted at Op */ |
299 | 285 | ||
300 | acpi_ps_delete_parse_tree (op); | 286 | acpi_ps_delete_parse_tree (op); |
301 | return_VOID; | 287 | return_ACPI_STATUS (AE_OK); |
288 | |||
289 | |||
290 | allocate_error: | ||
291 | |||
292 | /* Always delete the subtree, even on error */ | ||
293 | |||
294 | acpi_ps_delete_parse_tree (op); | ||
295 | return_ACPI_STATUS (AE_NO_MEMORY); | ||
302 | } | 296 | } |
303 | 297 | ||
304 | 298 | ||
@@ -317,7 +311,7 @@ cleanup: | |||
317 | * | 311 | * |
318 | ******************************************************************************/ | 312 | ******************************************************************************/ |
319 | 313 | ||
320 | static acpi_status | 314 | acpi_status |
321 | acpi_ps_next_parse_state ( | 315 | acpi_ps_next_parse_state ( |
322 | struct acpi_walk_state *walk_state, | 316 | struct acpi_walk_state *walk_state, |
323 | union acpi_parse_object *op, | 317 | union acpi_parse_object *op, |
@@ -427,663 +421,6 @@ acpi_ps_next_parse_state ( | |||
427 | 421 | ||
428 | /******************************************************************************* | 422 | /******************************************************************************* |
429 | * | 423 | * |
430 | * FUNCTION: acpi_ps_parse_loop | ||
431 | * | ||
432 | * PARAMETERS: walk_state - Current state | ||
433 | * | ||
434 | * RETURN: Status | ||
435 | * | ||
436 | * DESCRIPTION: Parse AML (pointed to by the current parser state) and return | ||
437 | * a tree of ops. | ||
438 | * | ||
439 | ******************************************************************************/ | ||
440 | |||
441 | static acpi_status | ||
442 | acpi_ps_parse_loop ( | ||
443 | struct acpi_walk_state *walk_state) | ||
444 | { | ||
445 | acpi_status status = AE_OK; | ||
446 | union acpi_parse_object *op = NULL; /* current op */ | ||
447 | union acpi_parse_object *arg = NULL; | ||
448 | union acpi_parse_object *pre_op = NULL; | ||
449 | struct acpi_parse_state *parser_state; | ||
450 | u8 *aml_op_start = NULL; | ||
451 | |||
452 | |||
453 | ACPI_FUNCTION_TRACE_PTR ("ps_parse_loop", walk_state); | ||
454 | |||
455 | if (walk_state->descending_callback == NULL) { | ||
456 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
457 | } | ||
458 | |||
459 | parser_state = &walk_state->parser_state; | ||
460 | walk_state->arg_types = 0; | ||
461 | |||
462 | #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) | ||
463 | |||
464 | if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { | ||
465 | /* We are restarting a preempted control method */ | ||
466 | |||
467 | if (acpi_ps_has_completed_scope (parser_state)) { | ||
468 | /* | ||
469 | * We must check if a predicate to an IF or WHILE statement | ||
470 | * was just completed | ||
471 | */ | ||
472 | if ((parser_state->scope->parse_scope.op) && | ||
473 | ((parser_state->scope->parse_scope.op->common.aml_opcode == AML_IF_OP) || | ||
474 | (parser_state->scope->parse_scope.op->common.aml_opcode == AML_WHILE_OP)) && | ||
475 | (walk_state->control_state) && | ||
476 | (walk_state->control_state->common.state == | ||
477 | ACPI_CONTROL_PREDICATE_EXECUTING)) { | ||
478 | /* | ||
479 | * A predicate was just completed, get the value of the | ||
480 | * predicate and branch based on that value | ||
481 | */ | ||
482 | walk_state->op = NULL; | ||
483 | status = acpi_ds_get_predicate_value (walk_state, ACPI_TO_POINTER (TRUE)); | ||
484 | if (ACPI_FAILURE (status) && | ||
485 | ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { | ||
486 | if (status == AE_AML_NO_RETURN_VALUE) { | ||
487 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
488 | "Invoked method did not return a value, %s\n", | ||
489 | acpi_format_exception (status))); | ||
490 | |||
491 | } | ||
492 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
493 | "get_predicate Failed, %s\n", | ||
494 | acpi_format_exception (status))); | ||
495 | return_ACPI_STATUS (status); | ||
496 | } | ||
497 | |||
498 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
499 | } | ||
500 | |||
501 | acpi_ps_pop_scope (parser_state, &op, | ||
502 | &walk_state->arg_types, &walk_state->arg_count); | ||
503 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); | ||
504 | } | ||
505 | else if (walk_state->prev_op) { | ||
506 | /* We were in the middle of an op */ | ||
507 | |||
508 | op = walk_state->prev_op; | ||
509 | walk_state->arg_types = walk_state->prev_arg_types; | ||
510 | } | ||
511 | } | ||
512 | #endif | ||
513 | |||
514 | /* Iterative parsing loop, while there is more AML to process: */ | ||
515 | |||
516 | while ((parser_state->aml < parser_state->aml_end) || (op)) { | ||
517 | aml_op_start = parser_state->aml; | ||
518 | if (!op) { | ||
519 | /* Get the next opcode from the AML stream */ | ||
520 | |||
521 | walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml, | ||
522 | parser_state->aml_start); | ||
523 | walk_state->opcode = acpi_ps_peek_opcode (parser_state); | ||
524 | |||
525 | /* | ||
526 | * First cut to determine what we have found: | ||
527 | * 1) A valid AML opcode | ||
528 | * 2) A name string | ||
529 | * 3) An unknown/invalid opcode | ||
530 | */ | ||
531 | walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); | ||
532 | switch (walk_state->op_info->class) { | ||
533 | case AML_CLASS_ASCII: | ||
534 | case AML_CLASS_PREFIX: | ||
535 | /* | ||
536 | * Starts with a valid prefix or ASCII char, this is a name | ||
537 | * string. Convert the bare name string to a namepath. | ||
538 | */ | ||
539 | walk_state->opcode = AML_INT_NAMEPATH_OP; | ||
540 | walk_state->arg_types = ARGP_NAMESTRING; | ||
541 | break; | ||
542 | |||
543 | case AML_CLASS_UNKNOWN: | ||
544 | |||
545 | /* The opcode is unrecognized. Just skip unknown opcodes */ | ||
546 | |||
547 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
548 | "Found unknown opcode %X at AML address %p offset %X, ignoring\n", | ||
549 | walk_state->opcode, parser_state->aml, walk_state->aml_offset)); | ||
550 | |||
551 | ACPI_DUMP_BUFFER (parser_state->aml, 128); | ||
552 | |||
553 | /* Assume one-byte bad opcode */ | ||
554 | |||
555 | parser_state->aml++; | ||
556 | continue; | ||
557 | |||
558 | default: | ||
559 | |||
560 | /* Found opcode info, this is a normal opcode */ | ||
561 | |||
562 | parser_state->aml += acpi_ps_get_opcode_size (walk_state->opcode); | ||
563 | walk_state->arg_types = walk_state->op_info->parse_args; | ||
564 | break; | ||
565 | } | ||
566 | |||
567 | /* Create Op structure and append to parent's argument list */ | ||
568 | |||
569 | if (walk_state->op_info->flags & AML_NAMED) { | ||
570 | /* Allocate a new pre_op if necessary */ | ||
571 | |||
572 | if (!pre_op) { | ||
573 | pre_op = acpi_ps_alloc_op (walk_state->opcode); | ||
574 | if (!pre_op) { | ||
575 | status = AE_NO_MEMORY; | ||
576 | goto close_this_op; | ||
577 | } | ||
578 | } | ||
579 | |||
580 | pre_op->common.value.arg = NULL; | ||
581 | pre_op->common.aml_opcode = walk_state->opcode; | ||
582 | |||
583 | /* | ||
584 | * Get and append arguments until we find the node that contains | ||
585 | * the name (the type ARGP_NAME). | ||
586 | */ | ||
587 | while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && | ||
588 | (GET_CURRENT_ARG_TYPE (walk_state->arg_types) != ARGP_NAME)) { | ||
589 | status = acpi_ps_get_next_arg (walk_state, parser_state, | ||
590 | GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg); | ||
591 | if (ACPI_FAILURE (status)) { | ||
592 | goto close_this_op; | ||
593 | } | ||
594 | |||
595 | acpi_ps_append_arg (pre_op, arg); | ||
596 | INCREMENT_ARG_LIST (walk_state->arg_types); | ||
597 | } | ||
598 | |||
599 | /* | ||
600 | * Make sure that we found a NAME and didn't run out of | ||
601 | * arguments | ||
602 | */ | ||
603 | if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) { | ||
604 | status = AE_AML_NO_OPERAND; | ||
605 | goto close_this_op; | ||
606 | } | ||
607 | |||
608 | /* We know that this arg is a name, move to next arg */ | ||
609 | |||
610 | INCREMENT_ARG_LIST (walk_state->arg_types); | ||
611 | |||
612 | /* | ||
613 | * Find the object. This will either insert the object into | ||
614 | * the namespace or simply look it up | ||
615 | */ | ||
616 | walk_state->op = NULL; | ||
617 | |||
618 | status = walk_state->descending_callback (walk_state, &op); | ||
619 | if (ACPI_FAILURE (status)) { | ||
620 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
621 | "During name lookup/catalog, %s\n", | ||
622 | acpi_format_exception (status))); | ||
623 | goto close_this_op; | ||
624 | } | ||
625 | |||
626 | if (!op) { | ||
627 | continue; | ||
628 | } | ||
629 | |||
630 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
631 | if (status == AE_CTRL_PENDING) { | ||
632 | status = AE_OK; | ||
633 | goto close_this_op; | ||
634 | } | ||
635 | |||
636 | if (ACPI_FAILURE (status)) { | ||
637 | goto close_this_op; | ||
638 | } | ||
639 | |||
640 | acpi_ps_append_arg (op, pre_op->common.value.arg); | ||
641 | acpi_gbl_depth++; | ||
642 | |||
643 | if (op->common.aml_opcode == AML_REGION_OP) { | ||
644 | /* | ||
645 | * Defer final parsing of an operation_region body, | ||
646 | * because we don't have enough info in the first pass | ||
647 | * to parse it correctly (i.e., there may be method | ||
648 | * calls within the term_arg elements of the body.) | ||
649 | * | ||
650 | * However, we must continue parsing because | ||
651 | * the opregion is not a standalone package -- | ||
652 | * we don't know where the end is at this point. | ||
653 | * | ||
654 | * (Length is unknown until parse of the body complete) | ||
655 | */ | ||
656 | op->named.data = aml_op_start; | ||
657 | op->named.length = 0; | ||
658 | } | ||
659 | } | ||
660 | else { | ||
661 | /* Not a named opcode, just allocate Op and append to parent */ | ||
662 | |||
663 | walk_state->op_info = acpi_ps_get_opcode_info (walk_state->opcode); | ||
664 | op = acpi_ps_alloc_op (walk_state->opcode); | ||
665 | if (!op) { | ||
666 | status = AE_NO_MEMORY; | ||
667 | goto close_this_op; | ||
668 | } | ||
669 | |||
670 | if (walk_state->op_info->flags & AML_CREATE) { | ||
671 | /* | ||
672 | * Backup to beginning of create_xXXfield declaration | ||
673 | * body_length is unknown until we parse the body | ||
674 | */ | ||
675 | op->named.data = aml_op_start; | ||
676 | op->named.length = 0; | ||
677 | } | ||
678 | |||
679 | acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); | ||
680 | |||
681 | if ((walk_state->descending_callback != NULL)) { | ||
682 | /* | ||
683 | * Find the object. This will either insert the object into | ||
684 | * the namespace or simply look it up | ||
685 | */ | ||
686 | walk_state->op = op; | ||
687 | |||
688 | status = walk_state->descending_callback (walk_state, &op); | ||
689 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
690 | if (status == AE_CTRL_PENDING) { | ||
691 | status = AE_OK; | ||
692 | goto close_this_op; | ||
693 | } | ||
694 | |||
695 | if (ACPI_FAILURE (status)) { | ||
696 | goto close_this_op; | ||
697 | } | ||
698 | } | ||
699 | } | ||
700 | |||
701 | op->common.aml_offset = walk_state->aml_offset; | ||
702 | |||
703 | if (walk_state->op_info) { | ||
704 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, | ||
705 | "Opcode %4.4X [%s] Op %p Aml %p aml_offset %5.5X\n", | ||
706 | (u32) op->common.aml_opcode, walk_state->op_info->name, | ||
707 | op, parser_state->aml, op->common.aml_offset)); | ||
708 | } | ||
709 | } | ||
710 | |||
711 | |||
712 | /* | ||
713 | * Start arg_count at zero because we don't know if there are | ||
714 | * any args yet | ||
715 | */ | ||
716 | walk_state->arg_count = 0; | ||
717 | |||
718 | /* Are there any arguments that must be processed? */ | ||
719 | |||
720 | if (walk_state->arg_types) { | ||
721 | /* Get arguments */ | ||
722 | |||
723 | switch (op->common.aml_opcode) { | ||
724 | case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ | ||
725 | case AML_WORD_OP: /* AML_WORDDATA_ARG */ | ||
726 | case AML_DWORD_OP: /* AML_DWORDATA_ARG */ | ||
727 | case AML_QWORD_OP: /* AML_QWORDATA_ARG */ | ||
728 | case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ | ||
729 | |||
730 | /* Fill in constant or string argument directly */ | ||
731 | |||
732 | acpi_ps_get_next_simple_arg (parser_state, | ||
733 | GET_CURRENT_ARG_TYPE (walk_state->arg_types), op); | ||
734 | break; | ||
735 | |||
736 | case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ | ||
737 | |||
738 | status = acpi_ps_get_next_namepath (walk_state, parser_state, op, 1); | ||
739 | if (ACPI_FAILURE (status)) { | ||
740 | goto close_this_op; | ||
741 | } | ||
742 | |||
743 | walk_state->arg_types = 0; | ||
744 | break; | ||
745 | |||
746 | default: | ||
747 | |||
748 | /* | ||
749 | * Op is not a constant or string, append each argument | ||
750 | * to the Op | ||
751 | */ | ||
752 | while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) && | ||
753 | !walk_state->arg_count) { | ||
754 | walk_state->aml_offset = (u32) | ||
755 | ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start); | ||
756 | |||
757 | status = acpi_ps_get_next_arg (walk_state, parser_state, | ||
758 | GET_CURRENT_ARG_TYPE (walk_state->arg_types), | ||
759 | &arg); | ||
760 | if (ACPI_FAILURE (status)) { | ||
761 | goto close_this_op; | ||
762 | } | ||
763 | |||
764 | if (arg) { | ||
765 | arg->common.aml_offset = walk_state->aml_offset; | ||
766 | acpi_ps_append_arg (op, arg); | ||
767 | } | ||
768 | INCREMENT_ARG_LIST (walk_state->arg_types); | ||
769 | } | ||
770 | |||
771 | /* Special processing for certain opcodes */ | ||
772 | |||
773 | switch (op->common.aml_opcode) { | ||
774 | case AML_METHOD_OP: | ||
775 | |||
776 | /* | ||
777 | * Skip parsing of control method | ||
778 | * because we don't have enough info in the first pass | ||
779 | * to parse it correctly. | ||
780 | * | ||
781 | * Save the length and address of the body | ||
782 | */ | ||
783 | op->named.data = parser_state->aml; | ||
784 | op->named.length = (u32) (parser_state->pkg_end - | ||
785 | parser_state->aml); | ||
786 | |||
787 | /* Skip body of method */ | ||
788 | |||
789 | parser_state->aml = parser_state->pkg_end; | ||
790 | walk_state->arg_count = 0; | ||
791 | break; | ||
792 | |||
793 | case AML_BUFFER_OP: | ||
794 | case AML_PACKAGE_OP: | ||
795 | case AML_VAR_PACKAGE_OP: | ||
796 | |||
797 | if ((op->common.parent) && | ||
798 | (op->common.parent->common.aml_opcode == AML_NAME_OP) && | ||
799 | (walk_state->descending_callback != acpi_ds_exec_begin_op)) { | ||
800 | /* | ||
801 | * Skip parsing of Buffers and Packages | ||
802 | * because we don't have enough info in the first pass | ||
803 | * to parse them correctly. | ||
804 | */ | ||
805 | op->named.data = aml_op_start; | ||
806 | op->named.length = (u32) (parser_state->pkg_end - | ||
807 | aml_op_start); | ||
808 | |||
809 | /* Skip body */ | ||
810 | |||
811 | parser_state->aml = parser_state->pkg_end; | ||
812 | walk_state->arg_count = 0; | ||
813 | } | ||
814 | break; | ||
815 | |||
816 | case AML_WHILE_OP: | ||
817 | |||
818 | if (walk_state->control_state) { | ||
819 | walk_state->control_state->control.package_end = | ||
820 | parser_state->pkg_end; | ||
821 | } | ||
822 | break; | ||
823 | |||
824 | default: | ||
825 | |||
826 | /* No action for all other opcodes */ | ||
827 | break; | ||
828 | } | ||
829 | break; | ||
830 | } | ||
831 | } | ||
832 | |||
833 | /* Check for arguments that need to be processed */ | ||
834 | |||
835 | if (walk_state->arg_count) { | ||
836 | /* | ||
837 | * There are arguments (complex ones), push Op and | ||
838 | * prepare for argument | ||
839 | */ | ||
840 | status = acpi_ps_push_scope (parser_state, op, | ||
841 | walk_state->arg_types, walk_state->arg_count); | ||
842 | if (ACPI_FAILURE (status)) { | ||
843 | goto close_this_op; | ||
844 | } | ||
845 | op = NULL; | ||
846 | continue; | ||
847 | } | ||
848 | |||
849 | /* | ||
850 | * All arguments have been processed -- Op is complete, | ||
851 | * prepare for next | ||
852 | */ | ||
853 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
854 | if (walk_state->op_info->flags & AML_NAMED) { | ||
855 | if (acpi_gbl_depth) { | ||
856 | acpi_gbl_depth--; | ||
857 | } | ||
858 | |||
859 | if (op->common.aml_opcode == AML_REGION_OP) { | ||
860 | /* | ||
861 | * Skip parsing of control method or opregion body, | ||
862 | * because we don't have enough info in the first pass | ||
863 | * to parse them correctly. | ||
864 | * | ||
865 | * Completed parsing an op_region declaration, we now | ||
866 | * know the length. | ||
867 | */ | ||
868 | op->named.length = (u32) (parser_state->aml - op->named.data); | ||
869 | } | ||
870 | } | ||
871 | |||
872 | if (walk_state->op_info->flags & AML_CREATE) { | ||
873 | /* | ||
874 | * Backup to beginning of create_xXXfield declaration (1 for | ||
875 | * Opcode) | ||
876 | * | ||
877 | * body_length is unknown until we parse the body | ||
878 | */ | ||
879 | op->named.length = (u32) (parser_state->aml - op->named.data); | ||
880 | } | ||
881 | |||
882 | /* This op complete, notify the dispatcher */ | ||
883 | |||
884 | if (walk_state->ascending_callback != NULL) { | ||
885 | walk_state->op = op; | ||
886 | walk_state->opcode = op->common.aml_opcode; | ||
887 | |||
888 | status = walk_state->ascending_callback (walk_state); | ||
889 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
890 | if (status == AE_CTRL_PENDING) { | ||
891 | status = AE_OK; | ||
892 | goto close_this_op; | ||
893 | } | ||
894 | } | ||
895 | |||
896 | |||
897 | close_this_op: | ||
898 | /* | ||
899 | * Finished one argument of the containing scope | ||
900 | */ | ||
901 | parser_state->scope->parse_scope.arg_count--; | ||
902 | |||
903 | /* Close this Op (will result in parse subtree deletion) */ | ||
904 | |||
905 | acpi_ps_complete_this_op (walk_state, op); | ||
906 | op = NULL; | ||
907 | if (pre_op) { | ||
908 | acpi_ps_free_op (pre_op); | ||
909 | pre_op = NULL; | ||
910 | } | ||
911 | |||
912 | switch (status) { | ||
913 | case AE_OK: | ||
914 | break; | ||
915 | |||
916 | |||
917 | case AE_CTRL_TRANSFER: | ||
918 | |||
919 | /* We are about to transfer to a called method. */ | ||
920 | |||
921 | walk_state->prev_op = op; | ||
922 | walk_state->prev_arg_types = walk_state->arg_types; | ||
923 | return_ACPI_STATUS (status); | ||
924 | |||
925 | |||
926 | case AE_CTRL_END: | ||
927 | |||
928 | acpi_ps_pop_scope (parser_state, &op, | ||
929 | &walk_state->arg_types, &walk_state->arg_count); | ||
930 | |||
931 | if (op) { | ||
932 | walk_state->op = op; | ||
933 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
934 | walk_state->opcode = op->common.aml_opcode; | ||
935 | |||
936 | status = walk_state->ascending_callback (walk_state); | ||
937 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
938 | |||
939 | acpi_ps_complete_this_op (walk_state, op); | ||
940 | op = NULL; | ||
941 | } | ||
942 | status = AE_OK; | ||
943 | break; | ||
944 | |||
945 | |||
946 | case AE_CTRL_BREAK: | ||
947 | case AE_CTRL_CONTINUE: | ||
948 | |||
949 | /* Pop off scopes until we find the While */ | ||
950 | |||
951 | while (!op || (op->common.aml_opcode != AML_WHILE_OP)) { | ||
952 | acpi_ps_pop_scope (parser_state, &op, | ||
953 | &walk_state->arg_types, &walk_state->arg_count); | ||
954 | } | ||
955 | |||
956 | /* Close this iteration of the While loop */ | ||
957 | |||
958 | walk_state->op = op; | ||
959 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
960 | walk_state->opcode = op->common.aml_opcode; | ||
961 | |||
962 | status = walk_state->ascending_callback (walk_state); | ||
963 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
964 | |||
965 | acpi_ps_complete_this_op (walk_state, op); | ||
966 | op = NULL; | ||
967 | |||
968 | status = AE_OK; | ||
969 | break; | ||
970 | |||
971 | |||
972 | case AE_CTRL_TERMINATE: | ||
973 | |||
974 | status = AE_OK; | ||
975 | |||
976 | /* Clean up */ | ||
977 | do { | ||
978 | if (op) { | ||
979 | acpi_ps_complete_this_op (walk_state, op); | ||
980 | } | ||
981 | acpi_ps_pop_scope (parser_state, &op, | ||
982 | &walk_state->arg_types, &walk_state->arg_count); | ||
983 | |||
984 | } while (op); | ||
985 | |||
986 | return_ACPI_STATUS (status); | ||
987 | |||
988 | |||
989 | default: /* All other non-AE_OK status */ | ||
990 | |||
991 | do { | ||
992 | if (op) { | ||
993 | acpi_ps_complete_this_op (walk_state, op); | ||
994 | } | ||
995 | acpi_ps_pop_scope (parser_state, &op, | ||
996 | &walk_state->arg_types, &walk_state->arg_count); | ||
997 | |||
998 | } while (op); | ||
999 | |||
1000 | |||
1001 | /* | ||
1002 | * TBD: Cleanup parse ops on error | ||
1003 | */ | ||
1004 | #if 0 | ||
1005 | if (op == NULL) { | ||
1006 | acpi_ps_pop_scope (parser_state, &op, | ||
1007 | &walk_state->arg_types, &walk_state->arg_count); | ||
1008 | } | ||
1009 | #endif | ||
1010 | walk_state->prev_op = op; | ||
1011 | walk_state->prev_arg_types = walk_state->arg_types; | ||
1012 | return_ACPI_STATUS (status); | ||
1013 | } | ||
1014 | |||
1015 | /* This scope complete? */ | ||
1016 | |||
1017 | if (acpi_ps_has_completed_scope (parser_state)) { | ||
1018 | acpi_ps_pop_scope (parser_state, &op, | ||
1019 | &walk_state->arg_types, &walk_state->arg_count); | ||
1020 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); | ||
1021 | } | ||
1022 | else { | ||
1023 | op = NULL; | ||
1024 | } | ||
1025 | |||
1026 | } /* while parser_state->Aml */ | ||
1027 | |||
1028 | |||
1029 | /* | ||
1030 | * Complete the last Op (if not completed), and clear the scope stack. | ||
1031 | * It is easily possible to end an AML "package" with an unbounded number | ||
1032 | * of open scopes (such as when several ASL blocks are closed with | ||
1033 | * sequential closing braces). We want to terminate each one cleanly. | ||
1034 | */ | ||
1035 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", op)); | ||
1036 | do { | ||
1037 | if (op) { | ||
1038 | if (walk_state->ascending_callback != NULL) { | ||
1039 | walk_state->op = op; | ||
1040 | walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode); | ||
1041 | walk_state->opcode = op->common.aml_opcode; | ||
1042 | |||
1043 | status = walk_state->ascending_callback (walk_state); | ||
1044 | status = acpi_ps_next_parse_state (walk_state, op, status); | ||
1045 | if (status == AE_CTRL_PENDING) { | ||
1046 | status = AE_OK; | ||
1047 | goto close_this_op; | ||
1048 | } | ||
1049 | |||
1050 | if (status == AE_CTRL_TERMINATE) { | ||
1051 | status = AE_OK; | ||
1052 | |||
1053 | /* Clean up */ | ||
1054 | do { | ||
1055 | if (op) { | ||
1056 | acpi_ps_complete_this_op (walk_state, op); | ||
1057 | } | ||
1058 | |||
1059 | acpi_ps_pop_scope (parser_state, &op, | ||
1060 | &walk_state->arg_types, &walk_state->arg_count); | ||
1061 | |||
1062 | } while (op); | ||
1063 | |||
1064 | return_ACPI_STATUS (status); | ||
1065 | } | ||
1066 | |||
1067 | else if (ACPI_FAILURE (status)) { | ||
1068 | acpi_ps_complete_this_op (walk_state, op); | ||
1069 | return_ACPI_STATUS (status); | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | acpi_ps_complete_this_op (walk_state, op); | ||
1074 | } | ||
1075 | |||
1076 | acpi_ps_pop_scope (parser_state, &op, &walk_state->arg_types, | ||
1077 | &walk_state->arg_count); | ||
1078 | |||
1079 | } while (op); | ||
1080 | |||
1081 | return_ACPI_STATUS (status); | ||
1082 | } | ||
1083 | |||
1084 | |||
1085 | /******************************************************************************* | ||
1086 | * | ||
1087 | * FUNCTION: acpi_ps_parse_aml | 424 | * FUNCTION: acpi_ps_parse_aml |
1088 | * | 425 | * |
1089 | * PARAMETERS: walk_state - Current state | 426 | * PARAMETERS: walk_state - Current state |
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index a10f88715d43..19a27020eeef 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c | |||
@@ -154,12 +154,14 @@ acpi_ps_alloc_op ( | |||
154 | if (flags == ACPI_PARSEOP_GENERIC) { | 154 | if (flags == ACPI_PARSEOP_GENERIC) { |
155 | /* The generic op (default) is by far the most common (16 to 1) */ | 155 | /* The generic op (default) is by far the most common (16 to 1) */ |
156 | 156 | ||
157 | op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); | 157 | op = acpi_os_acquire_object (acpi_gbl_ps_node_cache); |
158 | memset(op, 0, sizeof(struct acpi_parse_obj_common)); | ||
158 | } | 159 | } |
159 | else { | 160 | else { |
160 | /* Extended parseop */ | 161 | /* Extended parseop */ |
161 | 162 | ||
162 | op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); | 163 | op = acpi_os_acquire_object (acpi_gbl_ps_node_ext_cache); |
164 | memset(op, 0, sizeof(struct acpi_parse_obj_named)); | ||
163 | } | 165 | } |
164 | 166 | ||
165 | /* Initialize the Op */ | 167 | /* Initialize the Op */ |
@@ -198,41 +200,14 @@ acpi_ps_free_op ( | |||
198 | } | 200 | } |
199 | 201 | ||
200 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { | 202 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { |
201 | acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op); | 203 | acpi_os_release_object (acpi_gbl_ps_node_cache, op); |
202 | } | 204 | } |
203 | else { | 205 | else { |
204 | acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op); | 206 | acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op); |
205 | } | 207 | } |
206 | } | 208 | } |
207 | 209 | ||
208 | 210 | ||
209 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
210 | /******************************************************************************* | ||
211 | * | ||
212 | * FUNCTION: acpi_ps_delete_parse_cache | ||
213 | * | ||
214 | * PARAMETERS: None | ||
215 | * | ||
216 | * RETURN: None | ||
217 | * | ||
218 | * DESCRIPTION: Free all objects that are on the parse cache list. | ||
219 | * | ||
220 | ******************************************************************************/ | ||
221 | |||
222 | void | ||
223 | acpi_ps_delete_parse_cache ( | ||
224 | void) | ||
225 | { | ||
226 | ACPI_FUNCTION_TRACE ("ps_delete_parse_cache"); | ||
227 | |||
228 | |||
229 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE); | ||
230 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT); | ||
231 | return_VOID; | ||
232 | } | ||
233 | #endif | ||
234 | |||
235 | |||
236 | /******************************************************************************* | 211 | /******************************************************************************* |
237 | * | 212 | * |
238 | * FUNCTION: Utility functions | 213 | * FUNCTION: Utility functions |
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index dba893648e84..5279b51e7787 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c | |||
@@ -138,11 +138,14 @@ acpi_psx_execute ( | |||
138 | * objects (such as Operation Regions) can be created during the | 138 | * objects (such as Operation Regions) can be created during the |
139 | * first pass parse. | 139 | * first pass parse. |
140 | */ | 140 | */ |
141 | obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); | 141 | status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); |
142 | if (ACPI_FAILURE (status)) { | ||
143 | goto cleanup2; | ||
144 | } | ||
142 | 145 | ||
143 | /* Create and initialize a new walk state */ | 146 | /* Create and initialize a new walk state */ |
144 | 147 | ||
145 | walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, | 148 | walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, |
146 | NULL, NULL, NULL); | 149 | NULL, NULL, NULL); |
147 | if (!walk_state) { | 150 | if (!walk_state) { |
148 | status = AE_NO_MEMORY; | 151 | status = AE_NO_MEMORY; |
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 1935dab2ab51..2c3bb8c35741 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c | |||
@@ -48,6 +48,9 @@ | |||
48 | #define _COMPONENT ACPI_RESOURCES | 48 | #define _COMPONENT ACPI_RESOURCES |
49 | ACPI_MODULE_NAME ("rsdump") | 49 | ACPI_MODULE_NAME ("rsdump") |
50 | 50 | ||
51 | |||
52 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | ||
53 | |||
51 | /* Local prototypes */ | 54 | /* Local prototypes */ |
52 | 55 | ||
53 | static void | 56 | static void |
@@ -103,7 +106,6 @@ acpi_rs_dump_vendor_specific ( | |||
103 | union acpi_resource_data *data); | 106 | union acpi_resource_data *data); |
104 | 107 | ||
105 | 108 | ||
106 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | ||
107 | /******************************************************************************* | 109 | /******************************************************************************* |
108 | * | 110 | * |
109 | * FUNCTION: acpi_rs_dump_irq | 111 | * FUNCTION: acpi_rs_dump_irq |
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index 92e0c31539be..d4ff71f5fe5d 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c | |||
@@ -97,7 +97,9 @@ acpi_tb_get_table_count ( | |||
97 | ACPI_FUNCTION_ENTRY (); | 97 | ACPI_FUNCTION_ENTRY (); |
98 | 98 | ||
99 | 99 | ||
100 | if (RSDP->revision < 2) { | 100 | /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ |
101 | |||
102 | if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { | ||
101 | pointer_size = sizeof (u32); | 103 | pointer_size = sizeof (u32); |
102 | } | 104 | } |
103 | else { | 105 | else { |
@@ -158,7 +160,9 @@ acpi_tb_convert_to_xsdt ( | |||
158 | /* Copy the table pointers */ | 160 | /* Copy the table pointers */ |
159 | 161 | ||
160 | for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { | 162 | for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { |
161 | if (acpi_gbl_RSDP->revision < 2) { | 163 | /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ |
164 | |||
165 | if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { | ||
162 | ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], | 166 | ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], |
163 | (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, | 167 | (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, |
164 | table_info->pointer))->table_offset_entry[i]); | 168 | table_info->pointer))->table_offset_entry[i]); |
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 629b64c8193d..2ad72f204551 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c | |||
@@ -251,6 +251,7 @@ acpi_tb_init_table_descriptor ( | |||
251 | { | 251 | { |
252 | struct acpi_table_list *list_head; | 252 | struct acpi_table_list *list_head; |
253 | struct acpi_table_desc *table_desc; | 253 | struct acpi_table_desc *table_desc; |
254 | acpi_status status; | ||
254 | 255 | ||
255 | 256 | ||
256 | ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type); | 257 | ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type); |
@@ -263,6 +264,13 @@ acpi_tb_init_table_descriptor ( | |||
263 | return_ACPI_STATUS (AE_NO_MEMORY); | 264 | return_ACPI_STATUS (AE_NO_MEMORY); |
264 | } | 265 | } |
265 | 266 | ||
267 | /* Get a new owner ID for the table */ | ||
268 | |||
269 | status = acpi_ut_allocate_owner_id (&table_desc->owner_id); | ||
270 | if (ACPI_FAILURE (status)) { | ||
271 | return_ACPI_STATUS (status); | ||
272 | } | ||
273 | |||
266 | /* Install the table into the global data structure */ | 274 | /* Install the table into the global data structure */ |
267 | 275 | ||
268 | list_head = &acpi_gbl_table_lists[table_type]; | 276 | list_head = &acpi_gbl_table_lists[table_type]; |
@@ -325,8 +333,6 @@ acpi_tb_init_table_descriptor ( | |||
325 | table_desc->aml_start = (u8 *) (table_desc->pointer + 1), | 333 | table_desc->aml_start = (u8 *) (table_desc->pointer + 1), |
326 | table_desc->aml_length = (u32) (table_desc->length - | 334 | table_desc->aml_length = (u32) (table_desc->length - |
327 | (u32) sizeof (struct acpi_table_header)); | 335 | (u32) sizeof (struct acpi_table_header)); |
328 | table_desc->table_id = acpi_ut_allocate_owner_id ( | ||
329 | ACPI_OWNER_TYPE_TABLE); | ||
330 | table_desc->loaded_into_namespace = FALSE; | 336 | table_desc->loaded_into_namespace = FALSE; |
331 | 337 | ||
332 | /* | 338 | /* |
@@ -339,7 +345,7 @@ acpi_tb_init_table_descriptor ( | |||
339 | 345 | ||
340 | /* Return Data */ | 346 | /* Return Data */ |
341 | 347 | ||
342 | table_info->table_id = table_desc->table_id; | 348 | table_info->owner_id = table_desc->owner_id; |
343 | table_info->installed_desc = table_desc; | 349 | table_info->installed_desc = table_desc; |
344 | 350 | ||
345 | return_ACPI_STATUS (AE_OK); | 351 | return_ACPI_STATUS (AE_OK); |
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index b7ffe39c3626..069d498465d0 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c | |||
@@ -96,32 +96,13 @@ acpi_tb_verify_rsdp ( | |||
96 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 96 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
97 | } | 97 | } |
98 | 98 | ||
99 | /* | 99 | /* Verify RSDP signature and checksum */ |
100 | * The signature and checksum must both be correct | ||
101 | */ | ||
102 | if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { | ||
103 | /* Nope, BAD Signature */ | ||
104 | |||
105 | status = AE_BAD_SIGNATURE; | ||
106 | goto cleanup; | ||
107 | } | ||
108 | |||
109 | /* Check the standard checksum */ | ||
110 | 100 | ||
111 | if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { | 101 | status = acpi_tb_validate_rsdp (rsdp); |
112 | status = AE_BAD_CHECKSUM; | 102 | if (ACPI_FAILURE (status)) { |
113 | goto cleanup; | 103 | goto cleanup; |
114 | } | 104 | } |
115 | 105 | ||
116 | /* Check extended checksum if table version >= 2 */ | ||
117 | |||
118 | if (rsdp->revision >= 2) { | ||
119 | if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) { | ||
120 | status = AE_BAD_CHECKSUM; | ||
121 | goto cleanup; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | /* The RSDP supplied is OK */ | 106 | /* The RSDP supplied is OK */ |
126 | 107 | ||
127 | table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); | 108 | table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); |
@@ -159,8 +140,8 @@ cleanup: | |||
159 | * | 140 | * |
160 | * RETURN: None, Address | 141 | * RETURN: None, Address |
161 | * | 142 | * |
162 | * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the | 143 | * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the |
163 | * version of the RSDP | 144 | * version of the RSDP and whether the XSDT pointer is valid |
164 | * | 145 | * |
165 | ******************************************************************************/ | 146 | ******************************************************************************/ |
166 | 147 | ||
@@ -174,16 +155,19 @@ acpi_tb_get_rsdt_address ( | |||
174 | 155 | ||
175 | out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; | 156 | out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; |
176 | 157 | ||
177 | /* | 158 | /* Use XSDT if it is present */ |
178 | * For RSDP revision 0 or 1, we use the RSDT. | 159 | |
179 | * For RSDP revision 2 (and above), we use the XSDT | 160 | if ((acpi_gbl_RSDP->revision >= 2) && |
180 | */ | 161 | acpi_gbl_RSDP->xsdt_physical_address) { |
181 | if (acpi_gbl_RSDP->revision < 2) { | ||
182 | out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; | ||
183 | } | ||
184 | else { | ||
185 | out_address->pointer.value = | 162 | out_address->pointer.value = |
186 | acpi_gbl_RSDP->xsdt_physical_address; | 163 | acpi_gbl_RSDP->xsdt_physical_address; |
164 | acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT; | ||
165 | } | ||
166 | else { | ||
167 | /* No XSDT, use the RSDT */ | ||
168 | |||
169 | out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address; | ||
170 | acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT; | ||
187 | } | 171 | } |
188 | } | 172 | } |
189 | 173 | ||
@@ -211,10 +195,9 @@ acpi_tb_validate_rsdt ( | |||
211 | 195 | ||
212 | 196 | ||
213 | /* | 197 | /* |
214 | * For RSDP revision 0 or 1, we use the RSDT. | 198 | * Search for appropriate signature, RSDT or XSDT |
215 | * For RSDP revision 2 and above, we use the XSDT | ||
216 | */ | 199 | */ |
217 | if (acpi_gbl_RSDP->revision < 2) { | 200 | if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { |
218 | no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, | 201 | no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, |
219 | sizeof (RSDT_SIG) -1); | 202 | sizeof (RSDT_SIG) -1); |
220 | } | 203 | } |
@@ -236,11 +219,11 @@ acpi_tb_validate_rsdt ( | |||
236 | acpi_gbl_RSDP->rsdt_physical_address, | 219 | acpi_gbl_RSDP->rsdt_physical_address, |
237 | (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); | 220 | (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); |
238 | 221 | ||
239 | if (acpi_gbl_RSDP->revision < 2) { | 222 | if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { |
240 | ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) | 223 | ACPI_REPORT_ERROR (("Looking for RSDT\n")) |
241 | } | 224 | } |
242 | else { | 225 | else { |
243 | ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n")) | 226 | ACPI_REPORT_ERROR (("Looking for XSDT\n")) |
244 | } | 227 | } |
245 | 228 | ||
246 | ACPI_DUMP_BUFFER ((char *) table_ptr, 48); | 229 | ACPI_DUMP_BUFFER ((char *) table_ptr, 48); |
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 0c0b9085dbeb..ca2dbdd23ed3 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c | |||
@@ -260,8 +260,7 @@ acpi_unload_table ( | |||
260 | * "Scope" operator. Thus, we need to track ownership by an ID, not | 260 | * "Scope" operator. Thus, we need to track ownership by an ID, not |
261 | * simply a position within the hierarchy | 261 | * simply a position within the hierarchy |
262 | */ | 262 | */ |
263 | acpi_ns_delete_namespace_by_owner (table_desc->table_id); | 263 | acpi_ns_delete_namespace_by_owner (table_desc->owner_id); |
264 | |||
265 | table_desc = table_desc->next; | 264 | table_desc = table_desc->next; |
266 | } | 265 | } |
267 | 266 | ||
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index dc3c3f6a9f62..abb4c9346560 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c | |||
@@ -65,6 +65,51 @@ acpi_tb_scan_memory_for_rsdp ( | |||
65 | 65 | ||
66 | /******************************************************************************* | 66 | /******************************************************************************* |
67 | * | 67 | * |
68 | * FUNCTION: acpi_tb_validate_rsdp | ||
69 | * | ||
70 | * PARAMETERS: Rsdp - Pointer to unvalidated RSDP | ||
71 | * | ||
72 | * RETURN: Status | ||
73 | * | ||
74 | * DESCRIPTION: Validate the RSDP (ptr) | ||
75 | * | ||
76 | ******************************************************************************/ | ||
77 | |||
78 | acpi_status | ||
79 | acpi_tb_validate_rsdp ( | ||
80 | struct rsdp_descriptor *rsdp) | ||
81 | { | ||
82 | ACPI_FUNCTION_ENTRY (); | ||
83 | |||
84 | |||
85 | /* | ||
86 | * The signature and checksum must both be correct | ||
87 | */ | ||
88 | if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { | ||
89 | /* Nope, BAD Signature */ | ||
90 | |||
91 | return (AE_BAD_SIGNATURE); | ||
92 | } | ||
93 | |||
94 | /* Check the standard checksum */ | ||
95 | |||
96 | if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { | ||
97 | return (AE_BAD_CHECKSUM); | ||
98 | } | ||
99 | |||
100 | /* Check extended checksum if table version >= 2 */ | ||
101 | |||
102 | if ((rsdp->revision >= 2) && | ||
103 | (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { | ||
104 | return (AE_BAD_CHECKSUM); | ||
105 | } | ||
106 | |||
107 | return (AE_OK); | ||
108 | } | ||
109 | |||
110 | |||
111 | /******************************************************************************* | ||
112 | * | ||
68 | * FUNCTION: acpi_tb_find_table | 113 | * FUNCTION: acpi_tb_find_table |
69 | * | 114 | * |
70 | * PARAMETERS: Signature - String with ACPI table signature | 115 | * PARAMETERS: Signature - String with ACPI table signature |
@@ -218,19 +263,11 @@ acpi_get_firmware_table ( | |||
218 | acpi_gbl_RSDP = address.pointer.logical; | 263 | acpi_gbl_RSDP = address.pointer.logical; |
219 | } | 264 | } |
220 | 265 | ||
221 | /* The signature and checksum must both be correct */ | 266 | /* The RDSP signature and checksum must both be correct */ |
222 | |||
223 | if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG, | ||
224 | sizeof (RSDP_SIG)-1) != 0) { | ||
225 | /* Nope, BAD Signature */ | ||
226 | |||
227 | return_ACPI_STATUS (AE_BAD_SIGNATURE); | ||
228 | } | ||
229 | |||
230 | if (acpi_tb_checksum (acpi_gbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { | ||
231 | /* Nope, BAD Checksum */ | ||
232 | 267 | ||
233 | return_ACPI_STATUS (AE_BAD_CHECKSUM); | 268 | status = acpi_tb_validate_rsdp (acpi_gbl_RSDP); |
269 | if (ACPI_FAILURE (status)) { | ||
270 | return_ACPI_STATUS (status); | ||
234 | } | 271 | } |
235 | } | 272 | } |
236 | 273 | ||
@@ -287,9 +324,11 @@ acpi_get_firmware_table ( | |||
287 | * requested table | 324 | * requested table |
288 | */ | 325 | */ |
289 | for (i = 0, j = 0; i < table_count; i++) { | 326 | for (i = 0, j = 0; i < table_count; i++) { |
290 | /* Get the next table pointer, handle RSDT vs. XSDT */ | 327 | /* |
291 | 328 | * Get the next table pointer, handle RSDT vs. XSDT | |
292 | if (acpi_gbl_RSDP->revision < 2) { | 329 | * RSDT pointers are 32 bits, XSDT pointers are 64 bits |
330 | */ | ||
331 | if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { | ||
293 | address.pointer.value = (ACPI_CAST_PTR ( | 332 | address.pointer.value = (ACPI_CAST_PTR ( |
294 | RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; | 333 | RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; |
295 | } | 334 | } |
@@ -331,8 +370,10 @@ acpi_get_firmware_table ( | |||
331 | 370 | ||
332 | 371 | ||
333 | cleanup: | 372 | cleanup: |
334 | acpi_os_unmap_memory (rsdt_info->pointer, | 373 | if (rsdt_info->pointer) { |
335 | (acpi_size) rsdt_info->pointer->length); | 374 | acpi_os_unmap_memory (rsdt_info->pointer, |
375 | (acpi_size) rsdt_info->pointer->length); | ||
376 | } | ||
336 | ACPI_MEM_FREE (rsdt_info); | 377 | ACPI_MEM_FREE (rsdt_info); |
337 | 378 | ||
338 | if (header) { | 379 | if (header) { |
@@ -410,9 +451,9 @@ acpi_tb_scan_memory_for_rsdp ( | |||
410 | u8 *start_address, | 451 | u8 *start_address, |
411 | u32 length) | 452 | u32 length) |
412 | { | 453 | { |
454 | acpi_status status; | ||
413 | u8 *mem_rover; | 455 | u8 *mem_rover; |
414 | u8 *end_address; | 456 | u8 *end_address; |
415 | u8 checksum; | ||
416 | 457 | ||
417 | 458 | ||
418 | ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp"); | 459 | ACPI_FUNCTION_TRACE ("tb_scan_memory_for_rsdp"); |
@@ -424,45 +465,25 @@ acpi_tb_scan_memory_for_rsdp ( | |||
424 | 465 | ||
425 | for (mem_rover = start_address; mem_rover < end_address; | 466 | for (mem_rover = start_address; mem_rover < end_address; |
426 | mem_rover += ACPI_RSDP_SCAN_STEP) { | 467 | mem_rover += ACPI_RSDP_SCAN_STEP) { |
427 | /* The signature and checksum must both be correct */ | 468 | /* The RSDP signature and checksum must both be correct */ |
428 | |||
429 | if (ACPI_STRNCMP ((char *) mem_rover, | ||
430 | RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) { | ||
431 | /* No signature match, keep looking */ | ||
432 | |||
433 | continue; | ||
434 | } | ||
435 | |||
436 | /* Signature matches, check the appropriate checksum */ | ||
437 | |||
438 | if ((ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover))->revision < 2) { | ||
439 | /* ACPI version 1.0 */ | ||
440 | 469 | ||
441 | checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_CHECKSUM_LENGTH); | 470 | status = acpi_tb_validate_rsdp (ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover)); |
442 | } | 471 | if (ACPI_SUCCESS (status)) { |
443 | else { | 472 | /* Sig and checksum valid, we have found a real RSDP */ |
444 | /* Post ACPI 1.0, use extended_checksum */ | ||
445 | |||
446 | checksum = acpi_tb_checksum (mem_rover, ACPI_RSDP_XCHECKSUM_LENGTH); | ||
447 | } | ||
448 | |||
449 | if (checksum == 0) { | ||
450 | /* Checksum valid, we have found a valid RSDP */ | ||
451 | 473 | ||
452 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, | 474 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, |
453 | "RSDP located at physical address %p\n", mem_rover)); | 475 | "RSDP located at physical address %p\n", mem_rover)); |
454 | return_PTR (mem_rover); | 476 | return_PTR (mem_rover); |
455 | } | 477 | } |
456 | 478 | ||
457 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, | 479 | /* No sig match or bad checksum, keep searching */ |
458 | "Found an RSDP at physical address %p, but it has a bad checksum\n", | ||
459 | mem_rover)); | ||
460 | } | 480 | } |
461 | 481 | ||
462 | /* Searched entire block, no RSDP was found */ | 482 | /* Searched entire block, no RSDP was found */ |
463 | 483 | ||
464 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, | 484 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, |
465 | "Searched entire block, no valid RSDP was found.\n")); | 485 | "Searched entire block from %p, valid RSDP was not found\n", |
486 | start_address)); | ||
466 | return_PTR (NULL); | 487 | return_PTR (NULL); |
467 | } | 488 | } |
468 | 489 | ||
@@ -550,7 +571,7 @@ acpi_tb_find_rsdp ( | |||
550 | acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); | 571 | acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE); |
551 | 572 | ||
552 | if (mem_rover) { | 573 | if (mem_rover) { |
553 | /* Found it, return the physical address */ | 574 | /* Return the physical address */ |
554 | 575 | ||
555 | physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); | 576 | physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr); |
556 | 577 | ||
@@ -579,7 +600,7 @@ acpi_tb_find_rsdp ( | |||
579 | acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); | 600 | acpi_os_unmap_memory (table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); |
580 | 601 | ||
581 | if (mem_rover) { | 602 | if (mem_rover) { |
582 | /* Found it, return the physical address */ | 603 | /* Return the physical address */ |
583 | 604 | ||
584 | physical_address = | 605 | physical_address = |
585 | ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); | 606 | ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr); |
@@ -610,7 +631,7 @@ acpi_tb_find_rsdp ( | |||
610 | ACPI_PHYSADDR_TO_PTR (physical_address), | 631 | ACPI_PHYSADDR_TO_PTR (physical_address), |
611 | ACPI_EBDA_WINDOW_SIZE); | 632 | ACPI_EBDA_WINDOW_SIZE); |
612 | if (mem_rover) { | 633 | if (mem_rover) { |
613 | /* Found it, return the physical address */ | 634 | /* Return the physical address */ |
614 | 635 | ||
615 | table_info->physical_address = ACPI_TO_INTEGER (mem_rover); | 636 | table_info->physical_address = ACPI_TO_INTEGER (mem_rover); |
616 | return_ACPI_STATUS (AE_OK); | 637 | return_ACPI_STATUS (AE_OK); |
@@ -630,8 +651,9 @@ acpi_tb_find_rsdp ( | |||
630 | } | 651 | } |
631 | } | 652 | } |
632 | 653 | ||
633 | /* RSDP signature was not found */ | 654 | /* A valid RSDP was not found */ |
634 | 655 | ||
656 | ACPI_REPORT_ERROR (("No valid RSDP was found\n")); | ||
635 | return_ACPI_STATUS (AE_NOT_FOUND); | 657 | return_ACPI_STATUS (AE_NOT_FOUND); |
636 | } | 658 | } |
637 | 659 | ||
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile index 939c447dd52a..e87108b7338a 100644 --- a/drivers/acpi/utilities/Makefile +++ b/drivers/acpi/utilities/Makefile | |||
@@ -3,6 +3,6 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ | 5 | obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ |
6 | utcopy.o utdelete.o utglobal.o utmath.o utobject.o | 6 | utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o |
7 | 7 | ||
8 | EXTRA_CFLAGS += $(ACPI_CFLAGS) | 8 | EXTRA_CFLAGS += $(ACPI_CFLAGS) |
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index c4e7f989a2bd..5061c6f0ee66 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: utalloc - local cache and memory allocation routines | 3 | * Module Name: utalloc - local memory allocation routines |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
@@ -52,12 +52,10 @@ | |||
52 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | 52 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
53 | static struct acpi_debug_mem_block * | 53 | static struct acpi_debug_mem_block * |
54 | acpi_ut_find_allocation ( | 54 | acpi_ut_find_allocation ( |
55 | u32 list_id, | ||
56 | void *allocation); | 55 | void *allocation); |
57 | 56 | ||
58 | static acpi_status | 57 | static acpi_status |
59 | acpi_ut_track_allocation ( | 58 | acpi_ut_track_allocation ( |
60 | u32 list_id, | ||
61 | struct acpi_debug_mem_block *address, | 59 | struct acpi_debug_mem_block *address, |
62 | acpi_size size, | 60 | acpi_size size, |
63 | u8 alloc_type, | 61 | u8 alloc_type, |
@@ -67,206 +65,118 @@ acpi_ut_track_allocation ( | |||
67 | 65 | ||
68 | static acpi_status | 66 | static acpi_status |
69 | acpi_ut_remove_allocation ( | 67 | acpi_ut_remove_allocation ( |
70 | u32 list_id, | ||
71 | struct acpi_debug_mem_block *address, | 68 | struct acpi_debug_mem_block *address, |
72 | u32 component, | 69 | u32 component, |
73 | char *module, | 70 | char *module, |
74 | u32 line); | 71 | u32 line); |
75 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ | 72 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ |
76 | 73 | ||
77 | 74 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | |
78 | /******************************************************************************* | 75 | static acpi_status |
79 | * | 76 | acpi_ut_create_list ( |
80 | * FUNCTION: acpi_ut_release_to_cache | 77 | char *list_name, |
81 | * | 78 | u16 object_size, |
82 | * PARAMETERS: list_id - Memory list/cache ID | 79 | acpi_handle *return_cache); |
83 | * Object - The object to be released | ||
84 | * | ||
85 | * RETURN: None | ||
86 | * | ||
87 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | ||
88 | * the object is deleted. | ||
89 | * | ||
90 | ******************************************************************************/ | ||
91 | |||
92 | void | ||
93 | acpi_ut_release_to_cache ( | ||
94 | u32 list_id, | ||
95 | void *object) | ||
96 | { | ||
97 | struct acpi_memory_list *cache_info; | ||
98 | |||
99 | |||
100 | ACPI_FUNCTION_ENTRY (); | ||
101 | |||
102 | |||
103 | cache_info = &acpi_gbl_memory_lists[list_id]; | ||
104 | |||
105 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
106 | |||
107 | /* If walk cache is full, just free this wallkstate object */ | ||
108 | |||
109 | if (cache_info->cache_depth >= cache_info->max_cache_depth) { | ||
110 | ACPI_MEM_FREE (object); | ||
111 | ACPI_MEM_TRACKING (cache_info->total_freed++); | ||
112 | } | ||
113 | |||
114 | /* Otherwise put this object back into the cache */ | ||
115 | |||
116 | else { | ||
117 | if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { | ||
118 | return; | ||
119 | } | ||
120 | |||
121 | /* Mark the object as cached */ | ||
122 | |||
123 | ACPI_MEMSET (object, 0xCA, cache_info->object_size); | ||
124 | ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); | ||
125 | |||
126 | /* Put the object at the head of the cache list */ | ||
127 | |||
128 | * (ACPI_CAST_INDIRECT_PTR (char, | ||
129 | &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head; | ||
130 | cache_info->list_head = object; | ||
131 | cache_info->cache_depth++; | ||
132 | |||
133 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
134 | } | ||
135 | |||
136 | #else | ||
137 | |||
138 | /* Object cache is disabled; just free the object */ | ||
139 | |||
140 | ACPI_MEM_FREE (object); | ||
141 | ACPI_MEM_TRACKING (cache_info->total_freed++); | ||
142 | #endif | 80 | #endif |
143 | } | ||
144 | 81 | ||
145 | 82 | ||
146 | /******************************************************************************* | 83 | /******************************************************************************* |
147 | * | 84 | * |
148 | * FUNCTION: acpi_ut_acquire_from_cache | 85 | * FUNCTION: acpi_ut_create_caches |
149 | * | 86 | * |
150 | * PARAMETERS: list_id - Memory list ID | 87 | * PARAMETERS: None |
151 | * | 88 | * |
152 | * RETURN: A requested object. NULL if the object could not be | 89 | * RETURN: Status |
153 | * allocated. | ||
154 | * | 90 | * |
155 | * DESCRIPTION: Get an object from the specified cache. If cache is empty, | 91 | * DESCRIPTION: Create all local caches |
156 | * the object is allocated. | ||
157 | * | 92 | * |
158 | ******************************************************************************/ | 93 | ******************************************************************************/ |
159 | 94 | ||
160 | void * | 95 | acpi_status |
161 | acpi_ut_acquire_from_cache ( | 96 | acpi_ut_create_caches ( |
162 | u32 list_id) | 97 | void) |
163 | { | 98 | { |
164 | struct acpi_memory_list *cache_info; | 99 | acpi_status status; |
165 | void *object; | ||
166 | |||
167 | |||
168 | ACPI_FUNCTION_NAME ("ut_acquire_from_cache"); | ||
169 | 100 | ||
170 | 101 | ||
171 | cache_info = &acpi_gbl_memory_lists[list_id]; | 102 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
172 | 103 | ||
173 | #ifdef ACPI_ENABLE_OBJECT_CACHE | 104 | /* Memory allocation lists */ |
174 | 105 | ||
175 | if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { | 106 | status = acpi_ut_create_list ("Acpi-Global", 0, |
176 | return (NULL); | 107 | &acpi_gbl_global_list); |
108 | if (ACPI_FAILURE (status)) { | ||
109 | return (status); | ||
177 | } | 110 | } |
178 | 111 | ||
179 | ACPI_MEM_TRACKING (cache_info->cache_requests++); | 112 | status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node), |
180 | 113 | &acpi_gbl_ns_node_list); | |
181 | /* Check the cache first */ | 114 | if (ACPI_FAILURE (status)) { |
182 | 115 | return (status); | |
183 | if (cache_info->list_head) { | 116 | } |
184 | /* There is an object available, use it */ | ||
185 | |||
186 | object = cache_info->list_head; | ||
187 | cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char, | ||
188 | &(((char *) object)[cache_info->link_offset]))); | ||
189 | |||
190 | ACPI_MEM_TRACKING (cache_info->cache_hits++); | ||
191 | cache_info->cache_depth--; | ||
192 | |||
193 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
194 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n", | ||
195 | object, acpi_gbl_memory_lists[list_id].list_name)); | ||
196 | #endif | 117 | #endif |
197 | 118 | ||
198 | if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { | 119 | /* Object Caches, for frequently used objects */ |
199 | return (NULL); | ||
200 | } | ||
201 | |||
202 | /* Clear (zero) the previously used Object */ | ||
203 | 120 | ||
204 | ACPI_MEMSET (object, 0, cache_info->object_size); | 121 | status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state), |
122 | ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache); | ||
123 | if (ACPI_FAILURE (status)) { | ||
124 | return (status); | ||
205 | } | 125 | } |
206 | 126 | ||
207 | else { | 127 | status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common), |
208 | /* The cache is empty, create a new object */ | 128 | ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache); |
209 | 129 | if (ACPI_FAILURE (status)) { | |
210 | /* Avoid deadlock with ACPI_MEM_CALLOCATE */ | 130 | return (status); |
211 | |||
212 | if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { | ||
213 | return (NULL); | ||
214 | } | ||
215 | |||
216 | object = ACPI_MEM_CALLOCATE (cache_info->object_size); | ||
217 | ACPI_MEM_TRACKING (cache_info->total_allocated++); | ||
218 | } | 131 | } |
219 | 132 | ||
220 | #else | 133 | status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named), |
221 | 134 | ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache); | |
222 | /* Object cache is disabled; just allocate the object */ | 135 | if (ACPI_FAILURE (status)) { |
136 | return (status); | ||
137 | } | ||
223 | 138 | ||
224 | object = ACPI_MEM_CALLOCATE (cache_info->object_size); | 139 | status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object), |
225 | ACPI_MEM_TRACKING (cache_info->total_allocated++); | 140 | ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache); |
226 | #endif | 141 | if (ACPI_FAILURE (status)) { |
142 | return (status); | ||
143 | } | ||
227 | 144 | ||
228 | return (object); | 145 | return (AE_OK); |
229 | } | 146 | } |
230 | 147 | ||
231 | 148 | ||
232 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
233 | /******************************************************************************* | 149 | /******************************************************************************* |
234 | * | 150 | * |
235 | * FUNCTION: acpi_ut_delete_generic_cache | 151 | * FUNCTION: acpi_ut_delete_caches |
236 | * | 152 | * |
237 | * PARAMETERS: list_id - Memory list ID | 153 | * PARAMETERS: None |
238 | * | 154 | * |
239 | * RETURN: None | 155 | * RETURN: Status |
240 | * | 156 | * |
241 | * DESCRIPTION: Free all objects within the requested cache. | 157 | * DESCRIPTION: Purge and delete all local caches |
242 | * | 158 | * |
243 | ******************************************************************************/ | 159 | ******************************************************************************/ |
244 | 160 | ||
245 | void | 161 | acpi_status |
246 | acpi_ut_delete_generic_cache ( | 162 | acpi_ut_delete_caches ( |
247 | u32 list_id) | 163 | void) |
248 | { | 164 | { |
249 | struct acpi_memory_list *cache_info; | ||
250 | char *next; | ||
251 | 165 | ||
166 | (void) acpi_os_delete_cache (acpi_gbl_state_cache); | ||
167 | acpi_gbl_state_cache = NULL; | ||
252 | 168 | ||
253 | ACPI_FUNCTION_ENTRY (); | 169 | (void) acpi_os_delete_cache (acpi_gbl_operand_cache); |
254 | 170 | acpi_gbl_operand_cache = NULL; | |
255 | 171 | ||
256 | cache_info = &acpi_gbl_memory_lists[list_id]; | 172 | (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache); |
257 | while (cache_info->list_head) { | 173 | acpi_gbl_ps_node_cache = NULL; |
258 | /* Delete one cached state object */ | ||
259 | 174 | ||
260 | next = *(ACPI_CAST_INDIRECT_PTR (char, | 175 | (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache); |
261 | &(((char *) cache_info->list_head)[cache_info->link_offset]))); | 176 | acpi_gbl_ps_node_ext_cache = NULL; |
262 | ACPI_MEM_FREE (cache_info->list_head); | ||
263 | 177 | ||
264 | cache_info->list_head = next; | 178 | return (AE_OK); |
265 | cache_info->cache_depth--; | ||
266 | } | ||
267 | } | 179 | } |
268 | #endif | ||
269 | |||
270 | 180 | ||
271 | /******************************************************************************* | 181 | /******************************************************************************* |
272 | * | 182 | * |
@@ -500,6 +410,43 @@ acpi_ut_callocate ( | |||
500 | * occurs in the body of acpi_ut_free. | 410 | * occurs in the body of acpi_ut_free. |
501 | */ | 411 | */ |
502 | 412 | ||
413 | /******************************************************************************* | ||
414 | * | ||
415 | * FUNCTION: acpi_ut_create_list | ||
416 | * | ||
417 | * PARAMETERS: cache_name - Ascii name for the cache | ||
418 | * object_size - Size of each cached object | ||
419 | * return_cache - Where the new cache object is returned | ||
420 | * | ||
421 | * RETURN: Status | ||
422 | * | ||
423 | * DESCRIPTION: Create a local memory list for tracking purposed | ||
424 | * | ||
425 | ******************************************************************************/ | ||
426 | |||
427 | static acpi_status | ||
428 | acpi_ut_create_list ( | ||
429 | char *list_name, | ||
430 | u16 object_size, | ||
431 | acpi_handle *return_cache) | ||
432 | { | ||
433 | struct acpi_memory_list *cache; | ||
434 | |||
435 | |||
436 | cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); | ||
437 | if (!cache) { | ||
438 | return (AE_NO_MEMORY); | ||
439 | } | ||
440 | |||
441 | ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); | ||
442 | |||
443 | cache->list_name = list_name; | ||
444 | cache->object_size = object_size; | ||
445 | |||
446 | *return_cache = cache; | ||
447 | return (AE_OK); | ||
448 | } | ||
449 | |||
503 | 450 | ||
504 | /******************************************************************************* | 451 | /******************************************************************************* |
505 | * | 452 | * |
@@ -533,15 +480,15 @@ acpi_ut_allocate_and_track ( | |||
533 | return (NULL); | 480 | return (NULL); |
534 | } | 481 | } |
535 | 482 | ||
536 | status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, | 483 | status = acpi_ut_track_allocation (allocation, size, |
537 | ACPI_MEM_MALLOC, component, module, line); | 484 | ACPI_MEM_MALLOC, component, module, line); |
538 | if (ACPI_FAILURE (status)) { | 485 | if (ACPI_FAILURE (status)) { |
539 | acpi_os_free (allocation); | 486 | acpi_os_free (allocation); |
540 | return (NULL); | 487 | return (NULL); |
541 | } | 488 | } |
542 | 489 | ||
543 | acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; | 490 | acpi_gbl_global_list->total_allocated++; |
544 | acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; | 491 | acpi_gbl_global_list->current_total_size += (u32) size; |
545 | 492 | ||
546 | return ((void *) &allocation->user_space); | 493 | return ((void *) &allocation->user_space); |
547 | } | 494 | } |
@@ -583,15 +530,15 @@ acpi_ut_callocate_and_track ( | |||
583 | return (NULL); | 530 | return (NULL); |
584 | } | 531 | } |
585 | 532 | ||
586 | status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, | 533 | status = acpi_ut_track_allocation (allocation, size, |
587 | ACPI_MEM_CALLOC, component, module, line); | 534 | ACPI_MEM_CALLOC, component, module, line); |
588 | if (ACPI_FAILURE (status)) { | 535 | if (ACPI_FAILURE (status)) { |
589 | acpi_os_free (allocation); | 536 | acpi_os_free (allocation); |
590 | return (NULL); | 537 | return (NULL); |
591 | } | 538 | } |
592 | 539 | ||
593 | acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; | 540 | acpi_gbl_global_list->total_allocated++; |
594 | acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; | 541 | acpi_gbl_global_list->current_total_size += (u32) size; |
595 | 542 | ||
596 | return ((void *) &allocation->user_space); | 543 | return ((void *) &allocation->user_space); |
597 | } | 544 | } |
@@ -636,10 +583,10 @@ acpi_ut_free_and_track ( | |||
636 | debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, | 583 | debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, |
637 | (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); | 584 | (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); |
638 | 585 | ||
639 | acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++; | 586 | acpi_gbl_global_list->total_freed++; |
640 | acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size; | 587 | acpi_gbl_global_list->current_total_size -= debug_block->size; |
641 | 588 | ||
642 | status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block, | 589 | status = acpi_ut_remove_allocation (debug_block, |
643 | component, module, line); | 590 | component, module, line); |
644 | if (ACPI_FAILURE (status)) { | 591 | if (ACPI_FAILURE (status)) { |
645 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", | 592 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", |
@@ -658,8 +605,7 @@ acpi_ut_free_and_track ( | |||
658 | * | 605 | * |
659 | * FUNCTION: acpi_ut_find_allocation | 606 | * FUNCTION: acpi_ut_find_allocation |
660 | * | 607 | * |
661 | * PARAMETERS: list_id - Memory list to search | 608 | * PARAMETERS: Allocation - Address of allocated memory |
662 | * Allocation - Address of allocated memory | ||
663 | * | 609 | * |
664 | * RETURN: A list element if found; NULL otherwise. | 610 | * RETURN: A list element if found; NULL otherwise. |
665 | * | 611 | * |
@@ -669,7 +615,6 @@ acpi_ut_free_and_track ( | |||
669 | 615 | ||
670 | static struct acpi_debug_mem_block * | 616 | static struct acpi_debug_mem_block * |
671 | acpi_ut_find_allocation ( | 617 | acpi_ut_find_allocation ( |
672 | u32 list_id, | ||
673 | void *allocation) | 618 | void *allocation) |
674 | { | 619 | { |
675 | struct acpi_debug_mem_block *element; | 620 | struct acpi_debug_mem_block *element; |
@@ -678,11 +623,7 @@ acpi_ut_find_allocation ( | |||
678 | ACPI_FUNCTION_ENTRY (); | 623 | ACPI_FUNCTION_ENTRY (); |
679 | 624 | ||
680 | 625 | ||
681 | if (list_id > ACPI_MEM_LIST_MAX) { | 626 | element = acpi_gbl_global_list->list_head; |
682 | return (NULL); | ||
683 | } | ||
684 | |||
685 | element = acpi_gbl_memory_lists[list_id].list_head; | ||
686 | 627 | ||
687 | /* Search for the address. */ | 628 | /* Search for the address. */ |
688 | 629 | ||
@@ -702,8 +643,7 @@ acpi_ut_find_allocation ( | |||
702 | * | 643 | * |
703 | * FUNCTION: acpi_ut_track_allocation | 644 | * FUNCTION: acpi_ut_track_allocation |
704 | * | 645 | * |
705 | * PARAMETERS: list_id - Memory list to search | 646 | * PARAMETERS: Allocation - Address of allocated memory |
706 | * Allocation - Address of allocated memory | ||
707 | * Size - Size of the allocation | 647 | * Size - Size of the allocation |
708 | * alloc_type - MEM_MALLOC or MEM_CALLOC | 648 | * alloc_type - MEM_MALLOC or MEM_CALLOC |
709 | * Component - Component type of caller | 649 | * Component - Component type of caller |
@@ -718,7 +658,6 @@ acpi_ut_find_allocation ( | |||
718 | 658 | ||
719 | static acpi_status | 659 | static acpi_status |
720 | acpi_ut_track_allocation ( | 660 | acpi_ut_track_allocation ( |
721 | u32 list_id, | ||
722 | struct acpi_debug_mem_block *allocation, | 661 | struct acpi_debug_mem_block *allocation, |
723 | acpi_size size, | 662 | acpi_size size, |
724 | u8 alloc_type, | 663 | u8 alloc_type, |
@@ -734,11 +673,7 @@ acpi_ut_track_allocation ( | |||
734 | ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); | 673 | ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); |
735 | 674 | ||
736 | 675 | ||
737 | if (list_id > ACPI_MEM_LIST_MAX) { | 676 | mem_list = acpi_gbl_global_list; |
738 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
739 | } | ||
740 | |||
741 | mem_list = &acpi_gbl_memory_lists[list_id]; | ||
742 | status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); | 677 | status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); |
743 | if (ACPI_FAILURE (status)) { | 678 | if (ACPI_FAILURE (status)) { |
744 | return_ACPI_STATUS (status); | 679 | return_ACPI_STATUS (status); |
@@ -748,8 +683,7 @@ acpi_ut_track_allocation ( | |||
748 | * Search list for this address to make sure it is not already on the list. | 683 | * Search list for this address to make sure it is not already on the list. |
749 | * This will catch several kinds of problems. | 684 | * This will catch several kinds of problems. |
750 | */ | 685 | */ |
751 | 686 | element = acpi_ut_find_allocation (allocation); | |
752 | element = acpi_ut_find_allocation (list_id, allocation); | ||
753 | if (element) { | 687 | if (element) { |
754 | ACPI_REPORT_ERROR (( | 688 | ACPI_REPORT_ERROR (( |
755 | "ut_track_allocation: Allocation already present in list! (%p)\n", | 689 | "ut_track_allocation: Allocation already present in list! (%p)\n", |
@@ -793,8 +727,7 @@ unlock_and_exit: | |||
793 | * | 727 | * |
794 | * FUNCTION: acpi_ut_remove_allocation | 728 | * FUNCTION: acpi_ut_remove_allocation |
795 | * | 729 | * |
796 | * PARAMETERS: list_id - Memory list to search | 730 | * PARAMETERS: Allocation - Address of allocated memory |
797 | * Allocation - Address of allocated memory | ||
798 | * Component - Component type of caller | 731 | * Component - Component type of caller |
799 | * Module - Source file name of caller | 732 | * Module - Source file name of caller |
800 | * Line - Line number of caller | 733 | * Line - Line number of caller |
@@ -807,7 +740,6 @@ unlock_and_exit: | |||
807 | 740 | ||
808 | static acpi_status | 741 | static acpi_status |
809 | acpi_ut_remove_allocation ( | 742 | acpi_ut_remove_allocation ( |
810 | u32 list_id, | ||
811 | struct acpi_debug_mem_block *allocation, | 743 | struct acpi_debug_mem_block *allocation, |
812 | u32 component, | 744 | u32 component, |
813 | char *module, | 745 | char *module, |
@@ -820,11 +752,7 @@ acpi_ut_remove_allocation ( | |||
820 | ACPI_FUNCTION_TRACE ("ut_remove_allocation"); | 752 | ACPI_FUNCTION_TRACE ("ut_remove_allocation"); |
821 | 753 | ||
822 | 754 | ||
823 | if (list_id > ACPI_MEM_LIST_MAX) { | 755 | mem_list = acpi_gbl_global_list; |
824 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
825 | } | ||
826 | |||
827 | mem_list = &acpi_gbl_memory_lists[list_id]; | ||
828 | if (NULL == mem_list->list_head) { | 756 | if (NULL == mem_list->list_head) { |
829 | /* No allocations! */ | 757 | /* No allocations! */ |
830 | 758 | ||
@@ -959,7 +887,7 @@ acpi_ut_dump_allocations ( | |||
959 | return; | 887 | return; |
960 | } | 888 | } |
961 | 889 | ||
962 | element = acpi_gbl_memory_lists[0].list_head; | 890 | element = acpi_gbl_global_list->list_head; |
963 | while (element) { | 891 | while (element) { |
964 | if ((element->component & component) && | 892 | if ((element->component & component) && |
965 | ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { | 893 | ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { |
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c new file mode 100644 index 000000000000..c0df0585c683 --- /dev/null +++ b/drivers/acpi/utilities/utcache.c | |||
@@ -0,0 +1,328 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: utcache - local cache allocation routines | ||
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 | |||
45 | #include <acpi/acpi.h> | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME ("utcache") | ||
49 | |||
50 | |||
51 | #ifdef ACPI_USE_LOCAL_CACHE | ||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * FUNCTION: acpi_os_create_cache | ||
55 | * | ||
56 | * PARAMETERS: cache_name - Ascii name for the cache | ||
57 | * object_size - Size of each cached object | ||
58 | * max_depth - Maximum depth of the cache (in objects) | ||
59 | * return_cache - Where the new cache object is returned | ||
60 | * | ||
61 | * RETURN: Status | ||
62 | * | ||
63 | * DESCRIPTION: Create a cache object | ||
64 | * | ||
65 | ******************************************************************************/ | ||
66 | |||
67 | acpi_status | ||
68 | acpi_os_create_cache ( | ||
69 | char *cache_name, | ||
70 | u16 object_size, | ||
71 | u16 max_depth, | ||
72 | struct acpi_memory_list **return_cache) | ||
73 | { | ||
74 | struct acpi_memory_list *cache; | ||
75 | |||
76 | |||
77 | ACPI_FUNCTION_ENTRY (); | ||
78 | |||
79 | |||
80 | if (!cache_name || !return_cache || (object_size < 16)) { | ||
81 | return (AE_BAD_PARAMETER); | ||
82 | } | ||
83 | |||
84 | /* Create the cache object */ | ||
85 | |||
86 | cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); | ||
87 | if (!cache) { | ||
88 | return (AE_NO_MEMORY); | ||
89 | } | ||
90 | |||
91 | /* Populate the cache object and return it */ | ||
92 | |||
93 | ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); | ||
94 | cache->link_offset = 8; | ||
95 | cache->list_name = cache_name; | ||
96 | cache->object_size = object_size; | ||
97 | cache->max_depth = max_depth; | ||
98 | |||
99 | *return_cache = cache; | ||
100 | return (AE_OK); | ||
101 | } | ||
102 | |||
103 | |||
104 | /******************************************************************************* | ||
105 | * | ||
106 | * FUNCTION: acpi_os_purge_cache | ||
107 | * | ||
108 | * PARAMETERS: Cache - Handle to cache object | ||
109 | * | ||
110 | * RETURN: Status | ||
111 | * | ||
112 | * DESCRIPTION: Free all objects within the requested cache. | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | acpi_status | ||
117 | acpi_os_purge_cache ( | ||
118 | struct acpi_memory_list *cache) | ||
119 | { | ||
120 | char *next; | ||
121 | |||
122 | |||
123 | ACPI_FUNCTION_ENTRY (); | ||
124 | |||
125 | |||
126 | if (!cache) { | ||
127 | return (AE_BAD_PARAMETER); | ||
128 | } | ||
129 | |||
130 | /* Walk the list of objects in this cache */ | ||
131 | |||
132 | while (cache->list_head) { | ||
133 | /* Delete and unlink one cached state object */ | ||
134 | |||
135 | next = *(ACPI_CAST_INDIRECT_PTR (char, | ||
136 | &(((char *) cache->list_head)[cache->link_offset]))); | ||
137 | ACPI_MEM_FREE (cache->list_head); | ||
138 | |||
139 | cache->list_head = next; | ||
140 | cache->current_depth--; | ||
141 | } | ||
142 | |||
143 | return (AE_OK); | ||
144 | } | ||
145 | |||
146 | |||
147 | /******************************************************************************* | ||
148 | * | ||
149 | * FUNCTION: acpi_os_delete_cache | ||
150 | * | ||
151 | * PARAMETERS: Cache - Handle to cache object | ||
152 | * | ||
153 | * RETURN: Status | ||
154 | * | ||
155 | * DESCRIPTION: Free all objects within the requested cache and delete the | ||
156 | * cache object. | ||
157 | * | ||
158 | ******************************************************************************/ | ||
159 | |||
160 | acpi_status | ||
161 | acpi_os_delete_cache ( | ||
162 | struct acpi_memory_list *cache) | ||
163 | { | ||
164 | acpi_status status; | ||
165 | |||
166 | |||
167 | ACPI_FUNCTION_ENTRY (); | ||
168 | |||
169 | |||
170 | /* Purge all objects in the cache */ | ||
171 | |||
172 | status = acpi_os_purge_cache (cache); | ||
173 | if (ACPI_FAILURE (status)) { | ||
174 | return (status); | ||
175 | } | ||
176 | |||
177 | /* Now we can delete the cache object */ | ||
178 | |||
179 | acpi_os_free (cache); | ||
180 | return (AE_OK); | ||
181 | } | ||
182 | |||
183 | |||
184 | /******************************************************************************* | ||
185 | * | ||
186 | * FUNCTION: acpi_os_release_object | ||
187 | * | ||
188 | * PARAMETERS: Cache - Handle to cache object | ||
189 | * Object - The object to be released | ||
190 | * | ||
191 | * RETURN: None | ||
192 | * | ||
193 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | ||
194 | * the object is deleted. | ||
195 | * | ||
196 | ******************************************************************************/ | ||
197 | |||
198 | acpi_status | ||
199 | acpi_os_release_object ( | ||
200 | struct acpi_memory_list *cache, | ||
201 | void *object) | ||
202 | { | ||
203 | acpi_status status; | ||
204 | |||
205 | |||
206 | ACPI_FUNCTION_ENTRY (); | ||
207 | |||
208 | |||
209 | if (!cache || !object) { | ||
210 | return (AE_BAD_PARAMETER); | ||
211 | } | ||
212 | |||
213 | /* If cache is full, just free this object */ | ||
214 | |||
215 | if (cache->current_depth >= cache->max_depth) { | ||
216 | ACPI_MEM_FREE (object); | ||
217 | ACPI_MEM_TRACKING (cache->total_freed++); | ||
218 | } | ||
219 | |||
220 | /* Otherwise put this object back into the cache */ | ||
221 | |||
222 | else { | ||
223 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | ||
224 | if (ACPI_FAILURE (status)) { | ||
225 | return (status); | ||
226 | } | ||
227 | |||
228 | /* Mark the object as cached */ | ||
229 | |||
230 | ACPI_MEMSET (object, 0xCA, cache->object_size); | ||
231 | ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); | ||
232 | |||
233 | /* Put the object at the head of the cache list */ | ||
234 | |||
235 | * (ACPI_CAST_INDIRECT_PTR (char, | ||
236 | &(((char *) object)[cache->link_offset]))) = cache->list_head; | ||
237 | cache->list_head = object; | ||
238 | cache->current_depth++; | ||
239 | |||
240 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
241 | } | ||
242 | |||
243 | return (AE_OK); | ||
244 | } | ||
245 | |||
246 | |||
247 | /******************************************************************************* | ||
248 | * | ||
249 | * FUNCTION: acpi_os_acquire_object | ||
250 | * | ||
251 | * PARAMETERS: Cache - Handle to cache object | ||
252 | * | ||
253 | * RETURN: the acquired object. NULL on error | ||
254 | * | ||
255 | * DESCRIPTION: Get an object from the specified cache. If cache is empty, | ||
256 | * the object is allocated. | ||
257 | * | ||
258 | ******************************************************************************/ | ||
259 | |||
260 | void * | ||
261 | acpi_os_acquire_object ( | ||
262 | struct acpi_memory_list *cache) | ||
263 | { | ||
264 | acpi_status status; | ||
265 | void *object; | ||
266 | |||
267 | |||
268 | ACPI_FUNCTION_NAME ("os_acquire_object"); | ||
269 | |||
270 | |||
271 | if (!cache) { | ||
272 | return (NULL); | ||
273 | } | ||
274 | |||
275 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | ||
276 | if (ACPI_FAILURE (status)) { | ||
277 | return (NULL); | ||
278 | } | ||
279 | |||
280 | ACPI_MEM_TRACKING (cache->requests++); | ||
281 | |||
282 | /* Check the cache first */ | ||
283 | |||
284 | if (cache->list_head) { | ||
285 | /* There is an object available, use it */ | ||
286 | |||
287 | object = cache->list_head; | ||
288 | cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, | ||
289 | &(((char *) object)[cache->link_offset]))); | ||
290 | |||
291 | cache->current_depth--; | ||
292 | |||
293 | ACPI_MEM_TRACKING (cache->hits++); | ||
294 | ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | ||
295 | "Object %p from %s cache\n", object, cache->list_name))); | ||
296 | |||
297 | status = acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
298 | if (ACPI_FAILURE (status)) { | ||
299 | return (NULL); | ||
300 | } | ||
301 | |||
302 | /* Clear (zero) the previously used Object */ | ||
303 | |||
304 | ACPI_MEMSET (object, 0, cache->object_size); | ||
305 | } | ||
306 | else { | ||
307 | /* The cache is empty, create a new object */ | ||
308 | |||
309 | ACPI_MEM_TRACKING (cache->total_allocated++); | ||
310 | |||
311 | /* Avoid deadlock with ACPI_MEM_CALLOCATE */ | ||
312 | |||
313 | status = acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
314 | if (ACPI_FAILURE (status)) { | ||
315 | return (NULL); | ||
316 | } | ||
317 | |||
318 | object = ACPI_MEM_CALLOCATE (cache->object_size); | ||
319 | if (!object) { | ||
320 | return (NULL); | ||
321 | } | ||
322 | } | ||
323 | |||
324 | return (object); | ||
325 | } | ||
326 | #endif /* ACPI_USE_LOCAL_CACHE */ | ||
327 | |||
328 | |||
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 11e884957162..31c30a32e5c9 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c | |||
@@ -694,58 +694,50 @@ acpi_ut_copy_simple_object ( | |||
694 | dest_desc->common.reference_count = reference_count; | 694 | dest_desc->common.reference_count = reference_count; |
695 | dest_desc->common.next_object = next_object; | 695 | dest_desc->common.next_object = next_object; |
696 | 696 | ||
697 | /* New object is not static, regardless of source */ | ||
698 | |||
699 | dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER; | ||
700 | |||
697 | /* Handle the objects with extra data */ | 701 | /* Handle the objects with extra data */ |
698 | 702 | ||
699 | switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { | 703 | switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { |
700 | case ACPI_TYPE_BUFFER: | 704 | case ACPI_TYPE_BUFFER: |
701 | |||
702 | dest_desc->buffer.node = NULL; | ||
703 | dest_desc->common.flags = source_desc->common.flags; | ||
704 | |||
705 | /* | 705 | /* |
706 | * Allocate and copy the actual buffer if and only if: | 706 | * Allocate and copy the actual buffer if and only if: |
707 | * 1) There is a valid buffer pointer | 707 | * 1) There is a valid buffer pointer |
708 | * 2) The buffer is not static (not in an ACPI table) (in this case, | 708 | * 2) The buffer has a length > 0 |
709 | * the actual pointer was already copied above) | ||
710 | */ | 709 | */ |
711 | if ((source_desc->buffer.pointer) && | 710 | if ((source_desc->buffer.pointer) && |
712 | (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { | 711 | (source_desc->buffer.length)) { |
713 | dest_desc->buffer.pointer = NULL; | 712 | dest_desc->buffer.pointer = |
714 | 713 | ACPI_MEM_ALLOCATE (source_desc->buffer.length); | |
715 | /* Create an actual buffer only if length > 0 */ | 714 | if (!dest_desc->buffer.pointer) { |
716 | 715 | return (AE_NO_MEMORY); | |
717 | if (source_desc->buffer.length) { | 716 | } |
718 | dest_desc->buffer.pointer = | ||
719 | ACPI_MEM_ALLOCATE (source_desc->buffer.length); | ||
720 | if (!dest_desc->buffer.pointer) { | ||
721 | return (AE_NO_MEMORY); | ||
722 | } | ||
723 | 717 | ||
724 | /* Copy the actual buffer data */ | 718 | /* Copy the actual buffer data */ |
725 | 719 | ||
726 | ACPI_MEMCPY (dest_desc->buffer.pointer, | 720 | ACPI_MEMCPY (dest_desc->buffer.pointer, |
727 | source_desc->buffer.pointer, | 721 | source_desc->buffer.pointer, |
728 | source_desc->buffer.length); | 722 | source_desc->buffer.length); |
729 | } | ||
730 | } | 723 | } |
731 | break; | 724 | break; |
732 | 725 | ||
733 | case ACPI_TYPE_STRING: | 726 | case ACPI_TYPE_STRING: |
734 | |||
735 | /* | 727 | /* |
736 | * Allocate and copy the actual string if and only if: | 728 | * Allocate and copy the actual string if and only if: |
737 | * 1) There is a valid string pointer | 729 | * 1) There is a valid string pointer |
738 | * 2) The string is not static (not in an ACPI table) (in this case, | 730 | * (Pointer to a NULL string is allowed) |
739 | * the actual pointer was already copied above) | ||
740 | */ | 731 | */ |
741 | if ((source_desc->string.pointer) && | 732 | if (source_desc->string.pointer) { |
742 | (!(source_desc->common.flags & AOPOBJ_STATIC_POINTER))) { | ||
743 | dest_desc->string.pointer = | 733 | dest_desc->string.pointer = |
744 | ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); | 734 | ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); |
745 | if (!dest_desc->string.pointer) { | 735 | if (!dest_desc->string.pointer) { |
746 | return (AE_NO_MEMORY); | 736 | return (AE_NO_MEMORY); |
747 | } | 737 | } |
748 | 738 | ||
739 | /* Copy the actual string data */ | ||
740 | |||
749 | ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, | 741 | ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, |
750 | (acpi_size) source_desc->string.length + 1); | 742 | (acpi_size) source_desc->string.length + 1); |
751 | } | 743 | } |
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 794c7df3f2ad..3d5fbc810b0b 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c | |||
@@ -116,10 +116,9 @@ acpi_ut_track_stack_ptr ( | |||
116 | * | 116 | * |
117 | * PARAMETERS: requested_debug_level - Requested debug print level | 117 | * PARAMETERS: requested_debug_level - Requested debug print level |
118 | * line_number - Caller's line number (for error output) | 118 | * line_number - Caller's line number (for error output) |
119 | * dbg_info - Contains: | 119 | * function_name - Caller's procedure name |
120 | * proc_name - Caller's procedure name | 120 | * module_name - Caller's module name |
121 | * module_name - Caller's module name | 121 | * component_id - Caller's component ID |
122 | * component_id - Caller's component ID | ||
123 | * Format - Printf format field | 122 | * Format - Printf format field |
124 | * ... - Optional printf arguments | 123 | * ... - Optional printf arguments |
125 | * | 124 | * |
@@ -134,7 +133,9 @@ void ACPI_INTERNAL_VAR_XFACE | |||
134 | acpi_ut_debug_print ( | 133 | acpi_ut_debug_print ( |
135 | u32 requested_debug_level, | 134 | u32 requested_debug_level, |
136 | u32 line_number, | 135 | u32 line_number, |
137 | struct acpi_debug_print_info *dbg_info, | 136 | char *function_name, |
137 | char *module_name, | ||
138 | u32 component_id, | ||
138 | char *format, | 139 | char *format, |
139 | ...) | 140 | ...) |
140 | { | 141 | { |
@@ -146,7 +147,7 @@ acpi_ut_debug_print ( | |||
146 | * Stay silent if the debug level or component ID is disabled | 147 | * Stay silent if the debug level or component ID is disabled |
147 | */ | 148 | */ |
148 | if (!(requested_debug_level & acpi_dbg_level) || | 149 | if (!(requested_debug_level & acpi_dbg_level) || |
149 | !(dbg_info->component_id & acpi_dbg_layer)) { | 150 | !(component_id & acpi_dbg_layer)) { |
150 | return; | 151 | return; |
151 | } | 152 | } |
152 | 153 | ||
@@ -169,14 +170,14 @@ acpi_ut_debug_print ( | |||
169 | * Display the module name, current line number, thread ID (if requested), | 170 | * Display the module name, current line number, thread ID (if requested), |
170 | * current procedure nesting level, and the current procedure name | 171 | * current procedure nesting level, and the current procedure name |
171 | */ | 172 | */ |
172 | acpi_os_printf ("%8s-%04ld ", dbg_info->module_name, line_number); | 173 | acpi_os_printf ("%8s-%04ld ", module_name, line_number); |
173 | 174 | ||
174 | if (ACPI_LV_THREADS & acpi_dbg_level) { | 175 | if (ACPI_LV_THREADS & acpi_dbg_level) { |
175 | acpi_os_printf ("[%04lX] ", thread_id); | 176 | acpi_os_printf ("[%04lX] ", thread_id); |
176 | } | 177 | } |
177 | 178 | ||
178 | acpi_os_printf ("[%02ld] %-22.22s: ", | 179 | acpi_os_printf ("[%02ld] %-22.22s: ", |
179 | acpi_gbl_nesting_level, dbg_info->proc_name); | 180 | acpi_gbl_nesting_level, function_name); |
180 | 181 | ||
181 | va_start (args, format); | 182 | va_start (args, format); |
182 | acpi_os_vprintf (format, args); | 183 | acpi_os_vprintf (format, args); |
@@ -190,10 +191,9 @@ EXPORT_SYMBOL(acpi_ut_debug_print); | |||
190 | * | 191 | * |
191 | * PARAMETERS: requested_debug_level - Requested debug print level | 192 | * PARAMETERS: requested_debug_level - Requested debug print level |
192 | * line_number - Caller's line number | 193 | * line_number - Caller's line number |
193 | * dbg_info - Contains: | 194 | * function_name - Caller's procedure name |
194 | * proc_name - Caller's procedure name | 195 | * module_name - Caller's module name |
195 | * module_name - Caller's module name | 196 | * component_id - Caller's component ID |
196 | * component_id - Caller's component ID | ||
197 | * Format - Printf format field | 197 | * Format - Printf format field |
198 | * ... - Optional printf arguments | 198 | * ... - Optional printf arguments |
199 | * | 199 | * |
@@ -208,7 +208,9 @@ void ACPI_INTERNAL_VAR_XFACE | |||
208 | acpi_ut_debug_print_raw ( | 208 | acpi_ut_debug_print_raw ( |
209 | u32 requested_debug_level, | 209 | u32 requested_debug_level, |
210 | u32 line_number, | 210 | u32 line_number, |
211 | struct acpi_debug_print_info *dbg_info, | 211 | char *function_name, |
212 | char *module_name, | ||
213 | u32 component_id, | ||
212 | char *format, | 214 | char *format, |
213 | ...) | 215 | ...) |
214 | { | 216 | { |
@@ -216,7 +218,7 @@ acpi_ut_debug_print_raw ( | |||
216 | 218 | ||
217 | 219 | ||
218 | if (!(requested_debug_level & acpi_dbg_level) || | 220 | if (!(requested_debug_level & acpi_dbg_level) || |
219 | !(dbg_info->component_id & acpi_dbg_layer)) { | 221 | !(component_id & acpi_dbg_layer)) { |
220 | return; | 222 | return; |
221 | } | 223 | } |
222 | 224 | ||
@@ -231,10 +233,9 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); | |||
231 | * FUNCTION: acpi_ut_trace | 233 | * FUNCTION: acpi_ut_trace |
232 | * | 234 | * |
233 | * PARAMETERS: line_number - Caller's line number | 235 | * PARAMETERS: line_number - Caller's line number |
234 | * dbg_info - Contains: | 236 | * function_name - Caller's procedure name |
235 | * proc_name - Caller's procedure name | 237 | * module_name - Caller's module name |
236 | * module_name - Caller's module name | 238 | * component_id - Caller's component ID |
237 | * component_id - Caller's component ID | ||
238 | * | 239 | * |
239 | * RETURN: None | 240 | * RETURN: None |
240 | * | 241 | * |
@@ -246,14 +247,17 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); | |||
246 | void | 247 | void |
247 | acpi_ut_trace ( | 248 | acpi_ut_trace ( |
248 | u32 line_number, | 249 | u32 line_number, |
249 | struct acpi_debug_print_info *dbg_info) | 250 | char *function_name, |
251 | char *module_name, | ||
252 | u32 component_id) | ||
250 | { | 253 | { |
251 | 254 | ||
252 | acpi_gbl_nesting_level++; | 255 | acpi_gbl_nesting_level++; |
253 | acpi_ut_track_stack_ptr (); | 256 | acpi_ut_track_stack_ptr (); |
254 | 257 | ||
255 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 258 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
256 | "%s\n", acpi_gbl_fn_entry_str); | 259 | line_number, function_name, module_name, component_id, |
260 | "%s\n", acpi_gbl_fn_entry_str); | ||
257 | } | 261 | } |
258 | EXPORT_SYMBOL(acpi_ut_trace); | 262 | EXPORT_SYMBOL(acpi_ut_trace); |
259 | 263 | ||
@@ -263,10 +267,9 @@ EXPORT_SYMBOL(acpi_ut_trace); | |||
263 | * FUNCTION: acpi_ut_trace_ptr | 267 | * FUNCTION: acpi_ut_trace_ptr |
264 | * | 268 | * |
265 | * PARAMETERS: line_number - Caller's line number | 269 | * PARAMETERS: line_number - Caller's line number |
266 | * dbg_info - Contains: | 270 | * function_name - Caller's procedure name |
267 | * proc_name - Caller's procedure name | 271 | * module_name - Caller's module name |
268 | * module_name - Caller's module name | 272 | * component_id - Caller's component ID |
269 | * component_id - Caller's component ID | ||
270 | * Pointer - Pointer to display | 273 | * Pointer - Pointer to display |
271 | * | 274 | * |
272 | * RETURN: None | 275 | * RETURN: None |
@@ -279,14 +282,17 @@ EXPORT_SYMBOL(acpi_ut_trace); | |||
279 | void | 282 | void |
280 | acpi_ut_trace_ptr ( | 283 | acpi_ut_trace_ptr ( |
281 | u32 line_number, | 284 | u32 line_number, |
282 | struct acpi_debug_print_info *dbg_info, | 285 | char *function_name, |
286 | char *module_name, | ||
287 | u32 component_id, | ||
283 | void *pointer) | 288 | void *pointer) |
284 | { | 289 | { |
285 | acpi_gbl_nesting_level++; | 290 | acpi_gbl_nesting_level++; |
286 | acpi_ut_track_stack_ptr (); | 291 | acpi_ut_track_stack_ptr (); |
287 | 292 | ||
288 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 293 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
289 | "%s %p\n", acpi_gbl_fn_entry_str, pointer); | 294 | line_number, function_name, module_name, component_id, |
295 | "%s %p\n", acpi_gbl_fn_entry_str, pointer); | ||
290 | } | 296 | } |
291 | 297 | ||
292 | 298 | ||
@@ -295,10 +301,9 @@ acpi_ut_trace_ptr ( | |||
295 | * FUNCTION: acpi_ut_trace_str | 301 | * FUNCTION: acpi_ut_trace_str |
296 | * | 302 | * |
297 | * PARAMETERS: line_number - Caller's line number | 303 | * PARAMETERS: line_number - Caller's line number |
298 | * dbg_info - Contains: | 304 | * function_name - Caller's procedure name |
299 | * proc_name - Caller's procedure name | 305 | * module_name - Caller's module name |
300 | * module_name - Caller's module name | 306 | * component_id - Caller's component ID |
301 | * component_id - Caller's component ID | ||
302 | * String - Additional string to display | 307 | * String - Additional string to display |
303 | * | 308 | * |
304 | * RETURN: None | 309 | * RETURN: None |
@@ -311,15 +316,18 @@ acpi_ut_trace_ptr ( | |||
311 | void | 316 | void |
312 | acpi_ut_trace_str ( | 317 | acpi_ut_trace_str ( |
313 | u32 line_number, | 318 | u32 line_number, |
314 | struct acpi_debug_print_info *dbg_info, | 319 | char *function_name, |
320 | char *module_name, | ||
321 | u32 component_id, | ||
315 | char *string) | 322 | char *string) |
316 | { | 323 | { |
317 | 324 | ||
318 | acpi_gbl_nesting_level++; | 325 | acpi_gbl_nesting_level++; |
319 | acpi_ut_track_stack_ptr (); | 326 | acpi_ut_track_stack_ptr (); |
320 | 327 | ||
321 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 328 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
322 | "%s %s\n", acpi_gbl_fn_entry_str, string); | 329 | line_number, function_name, module_name, component_id, |
330 | "%s %s\n", acpi_gbl_fn_entry_str, string); | ||
323 | } | 331 | } |
324 | 332 | ||
325 | 333 | ||
@@ -328,10 +336,9 @@ acpi_ut_trace_str ( | |||
328 | * FUNCTION: acpi_ut_trace_u32 | 336 | * FUNCTION: acpi_ut_trace_u32 |
329 | * | 337 | * |
330 | * PARAMETERS: line_number - Caller's line number | 338 | * PARAMETERS: line_number - Caller's line number |
331 | * dbg_info - Contains: | 339 | * function_name - Caller's procedure name |
332 | * proc_name - Caller's procedure name | 340 | * module_name - Caller's module name |
333 | * module_name - Caller's module name | 341 | * component_id - Caller's component ID |
334 | * component_id - Caller's component ID | ||
335 | * Integer - Integer to display | 342 | * Integer - Integer to display |
336 | * | 343 | * |
337 | * RETURN: None | 344 | * RETURN: None |
@@ -344,15 +351,18 @@ acpi_ut_trace_str ( | |||
344 | void | 351 | void |
345 | acpi_ut_trace_u32 ( | 352 | acpi_ut_trace_u32 ( |
346 | u32 line_number, | 353 | u32 line_number, |
347 | struct acpi_debug_print_info *dbg_info, | 354 | char *function_name, |
355 | char *module_name, | ||
356 | u32 component_id, | ||
348 | u32 integer) | 357 | u32 integer) |
349 | { | 358 | { |
350 | 359 | ||
351 | acpi_gbl_nesting_level++; | 360 | acpi_gbl_nesting_level++; |
352 | acpi_ut_track_stack_ptr (); | 361 | acpi_ut_track_stack_ptr (); |
353 | 362 | ||
354 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 363 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
355 | "%s %08X\n", acpi_gbl_fn_entry_str, integer); | 364 | line_number, function_name, module_name, component_id, |
365 | "%s %08X\n", acpi_gbl_fn_entry_str, integer); | ||
356 | } | 366 | } |
357 | 367 | ||
358 | 368 | ||
@@ -361,10 +371,9 @@ acpi_ut_trace_u32 ( | |||
361 | * FUNCTION: acpi_ut_exit | 371 | * FUNCTION: acpi_ut_exit |
362 | * | 372 | * |
363 | * PARAMETERS: line_number - Caller's line number | 373 | * PARAMETERS: line_number - Caller's line number |
364 | * dbg_info - Contains: | 374 | * function_name - Caller's procedure name |
365 | * proc_name - Caller's procedure name | 375 | * module_name - Caller's module name |
366 | * module_name - Caller's module name | 376 | * component_id - Caller's component ID |
367 | * component_id - Caller's component ID | ||
368 | * | 377 | * |
369 | * RETURN: None | 378 | * RETURN: None |
370 | * | 379 | * |
@@ -376,11 +385,14 @@ acpi_ut_trace_u32 ( | |||
376 | void | 385 | void |
377 | acpi_ut_exit ( | 386 | acpi_ut_exit ( |
378 | u32 line_number, | 387 | u32 line_number, |
379 | struct acpi_debug_print_info *dbg_info) | 388 | char *function_name, |
389 | char *module_name, | ||
390 | u32 component_id) | ||
380 | { | 391 | { |
381 | 392 | ||
382 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 393 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
383 | "%s\n", acpi_gbl_fn_exit_str); | 394 | line_number, function_name, module_name, component_id, |
395 | "%s\n", acpi_gbl_fn_exit_str); | ||
384 | 396 | ||
385 | acpi_gbl_nesting_level--; | 397 | acpi_gbl_nesting_level--; |
386 | } | 398 | } |
@@ -392,10 +404,9 @@ EXPORT_SYMBOL(acpi_ut_exit); | |||
392 | * FUNCTION: acpi_ut_status_exit | 404 | * FUNCTION: acpi_ut_status_exit |
393 | * | 405 | * |
394 | * PARAMETERS: line_number - Caller's line number | 406 | * PARAMETERS: line_number - Caller's line number |
395 | * dbg_info - Contains: | 407 | * function_name - Caller's procedure name |
396 | * proc_name - Caller's procedure name | 408 | * module_name - Caller's module name |
397 | * module_name - Caller's module name | 409 | * component_id - Caller's component ID |
398 | * component_id - Caller's component ID | ||
399 | * Status - Exit status code | 410 | * Status - Exit status code |
400 | * | 411 | * |
401 | * RETURN: None | 412 | * RETURN: None |
@@ -408,19 +419,23 @@ EXPORT_SYMBOL(acpi_ut_exit); | |||
408 | void | 419 | void |
409 | acpi_ut_status_exit ( | 420 | acpi_ut_status_exit ( |
410 | u32 line_number, | 421 | u32 line_number, |
411 | struct acpi_debug_print_info *dbg_info, | 422 | char *function_name, |
423 | char *module_name, | ||
424 | u32 component_id, | ||
412 | acpi_status status) | 425 | acpi_status status) |
413 | { | 426 | { |
414 | 427 | ||
415 | if (ACPI_SUCCESS (status)) { | 428 | if (ACPI_SUCCESS (status)) { |
416 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 429 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
417 | "%s %s\n", acpi_gbl_fn_exit_str, | 430 | line_number, function_name, module_name, component_id, |
418 | acpi_format_exception (status)); | 431 | "%s %s\n", acpi_gbl_fn_exit_str, |
432 | acpi_format_exception (status)); | ||
419 | } | 433 | } |
420 | else { | 434 | else { |
421 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 435 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
422 | "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, | 436 | line_number, function_name, module_name, component_id, |
423 | acpi_format_exception (status)); | 437 | "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, |
438 | acpi_format_exception (status)); | ||
424 | } | 439 | } |
425 | 440 | ||
426 | acpi_gbl_nesting_level--; | 441 | acpi_gbl_nesting_level--; |
@@ -433,10 +448,9 @@ EXPORT_SYMBOL(acpi_ut_status_exit); | |||
433 | * FUNCTION: acpi_ut_value_exit | 448 | * FUNCTION: acpi_ut_value_exit |
434 | * | 449 | * |
435 | * PARAMETERS: line_number - Caller's line number | 450 | * PARAMETERS: line_number - Caller's line number |
436 | * dbg_info - Contains: | 451 | * function_name - Caller's procedure name |
437 | * proc_name - Caller's procedure name | 452 | * module_name - Caller's module name |
438 | * module_name - Caller's module name | 453 | * component_id - Caller's component ID |
439 | * component_id - Caller's component ID | ||
440 | * Value - Value to be printed with exit msg | 454 | * Value - Value to be printed with exit msg |
441 | * | 455 | * |
442 | * RETURN: None | 456 | * RETURN: None |
@@ -449,13 +463,16 @@ EXPORT_SYMBOL(acpi_ut_status_exit); | |||
449 | void | 463 | void |
450 | acpi_ut_value_exit ( | 464 | acpi_ut_value_exit ( |
451 | u32 line_number, | 465 | u32 line_number, |
452 | struct acpi_debug_print_info *dbg_info, | 466 | char *function_name, |
467 | char *module_name, | ||
468 | u32 component_id, | ||
453 | acpi_integer value) | 469 | acpi_integer value) |
454 | { | 470 | { |
455 | 471 | ||
456 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 472 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
457 | "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, | 473 | line_number, function_name, module_name, component_id, |
458 | ACPI_FORMAT_UINT64 (value)); | 474 | "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, |
475 | ACPI_FORMAT_UINT64 (value)); | ||
459 | 476 | ||
460 | acpi_gbl_nesting_level--; | 477 | acpi_gbl_nesting_level--; |
461 | } | 478 | } |
@@ -467,10 +484,9 @@ EXPORT_SYMBOL(acpi_ut_value_exit); | |||
467 | * FUNCTION: acpi_ut_ptr_exit | 484 | * FUNCTION: acpi_ut_ptr_exit |
468 | * | 485 | * |
469 | * PARAMETERS: line_number - Caller's line number | 486 | * PARAMETERS: line_number - Caller's line number |
470 | * dbg_info - Contains: | 487 | * function_name - Caller's procedure name |
471 | * proc_name - Caller's procedure name | 488 | * module_name - Caller's module name |
472 | * module_name - Caller's module name | 489 | * component_id - Caller's component ID |
473 | * component_id - Caller's component ID | ||
474 | * Ptr - Pointer to display | 490 | * Ptr - Pointer to display |
475 | * | 491 | * |
476 | * RETURN: None | 492 | * RETURN: None |
@@ -483,12 +499,15 @@ EXPORT_SYMBOL(acpi_ut_value_exit); | |||
483 | void | 499 | void |
484 | acpi_ut_ptr_exit ( | 500 | acpi_ut_ptr_exit ( |
485 | u32 line_number, | 501 | u32 line_number, |
486 | struct acpi_debug_print_info *dbg_info, | 502 | char *function_name, |
503 | char *module_name, | ||
504 | u32 component_id, | ||
487 | u8 *ptr) | 505 | u8 *ptr) |
488 | { | 506 | { |
489 | 507 | ||
490 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, line_number, dbg_info, | 508 | acpi_ut_debug_print (ACPI_LV_FUNCTIONS, |
491 | "%s %p\n", acpi_gbl_fn_exit_str, ptr); | 509 | line_number, function_name, module_name, component_id, |
510 | "%s %p\n", acpi_gbl_fn_exit_str, ptr); | ||
492 | 511 | ||
493 | acpi_gbl_nesting_level--; | 512 | acpi_gbl_nesting_level--; |
494 | } | 513 | } |
@@ -549,7 +568,7 @@ acpi_ut_dump_buffer ( | |||
549 | /* Dump fill spaces */ | 568 | /* Dump fill spaces */ |
550 | 569 | ||
551 | acpi_os_printf ("%*s", ((display * 2) + 1), " "); | 570 | acpi_os_printf ("%*s", ((display * 2) + 1), " "); |
552 | j += display; | 571 | j += (acpi_native_uint) display; |
553 | continue; | 572 | continue; |
554 | } | 573 | } |
555 | 574 | ||
@@ -584,7 +603,7 @@ acpi_ut_dump_buffer ( | |||
584 | break; | 603 | break; |
585 | } | 604 | } |
586 | 605 | ||
587 | j += display; | 606 | j += (acpi_native_uint) display; |
588 | } | 607 | } |
589 | 608 | ||
590 | /* | 609 | /* |
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index bc5403022681..eeafb324c504 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c | |||
@@ -435,35 +435,24 @@ acpi_ut_update_object_reference ( | |||
435 | union acpi_operand_object *object, | 435 | union acpi_operand_object *object, |
436 | u16 action) | 436 | u16 action) |
437 | { | 437 | { |
438 | acpi_status status; | 438 | acpi_status status = AE_OK; |
439 | u32 i; | 439 | union acpi_generic_state *state_list = NULL; |
440 | union acpi_generic_state *state_list = NULL; | 440 | union acpi_operand_object *next_object = NULL; |
441 | union acpi_generic_state *state; | 441 | union acpi_generic_state *state; |
442 | union acpi_operand_object *tmp; | 442 | acpi_native_uint i; |
443 | |||
444 | ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); | ||
445 | 443 | ||
446 | 444 | ||
447 | /* Ignore a null object ptr */ | 445 | ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object); |
448 | |||
449 | if (!object) { | ||
450 | return_ACPI_STATUS (AE_OK); | ||
451 | } | ||
452 | 446 | ||
453 | /* Make sure that this isn't a namespace handle */ | ||
454 | 447 | ||
455 | if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { | 448 | while (object) { |
456 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, | 449 | /* Make sure that this isn't a namespace handle */ |
457 | "Object %p is NS handle\n", object)); | ||
458 | return_ACPI_STATUS (AE_OK); | ||
459 | } | ||
460 | 450 | ||
461 | state = acpi_ut_create_update_state (object, action); | 451 | if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { |
462 | 452 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, | |
463 | while (state) { | 453 | "Object %p is NS handle\n", object)); |
464 | object = state->update.object; | 454 | return_ACPI_STATUS (AE_OK); |
465 | action = state->update.value; | 455 | } |
466 | acpi_ut_delete_generic_state (state); | ||
467 | 456 | ||
468 | /* | 457 | /* |
469 | * All sub-objects must have their reference count incremented also. | 458 | * All sub-objects must have their reference count incremented also. |
@@ -472,24 +461,14 @@ acpi_ut_update_object_reference ( | |||
472 | switch (ACPI_GET_OBJECT_TYPE (object)) { | 461 | switch (ACPI_GET_OBJECT_TYPE (object)) { |
473 | case ACPI_TYPE_DEVICE: | 462 | case ACPI_TYPE_DEVICE: |
474 | 463 | ||
475 | tmp = object->device.system_notify; | 464 | acpi_ut_update_ref_count (object->device.system_notify, action); |
476 | if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | 465 | acpi_ut_update_ref_count (object->device.device_notify, action); |
477 | object->device.system_notify = NULL; | ||
478 | acpi_ut_update_ref_count (tmp, action); | ||
479 | |||
480 | tmp = object->device.device_notify; | ||
481 | if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
482 | object->device.device_notify = NULL; | ||
483 | acpi_ut_update_ref_count (tmp, action); | ||
484 | |||
485 | break; | 466 | break; |
486 | 467 | ||
487 | |||
488 | case ACPI_TYPE_PACKAGE: | 468 | case ACPI_TYPE_PACKAGE: |
489 | |||
490 | /* | 469 | /* |
491 | * We must update all the sub-objects of the package | 470 | * We must update all the sub-objects of the package, |
492 | * (Each of whom may have their own sub-objects, etc. | 471 | * each of whom may have their own sub-objects. |
493 | */ | 472 | */ |
494 | for (i = 0; i < object->package.count; i++) { | 473 | for (i = 0; i < object->package.count; i++) { |
495 | /* | 474 | /* |
@@ -502,111 +481,52 @@ acpi_ut_update_object_reference ( | |||
502 | if (ACPI_FAILURE (status)) { | 481 | if (ACPI_FAILURE (status)) { |
503 | goto error_exit; | 482 | goto error_exit; |
504 | } | 483 | } |
505 | |||
506 | tmp = object->package.elements[i]; | ||
507 | if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
508 | object->package.elements[i] = NULL; | ||
509 | } | 484 | } |
510 | break; | 485 | break; |
511 | 486 | ||
512 | |||
513 | case ACPI_TYPE_BUFFER_FIELD: | 487 | case ACPI_TYPE_BUFFER_FIELD: |
514 | 488 | ||
515 | status = acpi_ut_create_update_state_and_push ( | 489 | next_object = object->buffer_field.buffer_obj; |
516 | object->buffer_field.buffer_obj, action, &state_list); | ||
517 | if (ACPI_FAILURE (status)) { | ||
518 | goto error_exit; | ||
519 | } | ||
520 | |||
521 | tmp = object->buffer_field.buffer_obj; | ||
522 | if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
523 | object->buffer_field.buffer_obj = NULL; | ||
524 | break; | 490 | break; |
525 | 491 | ||
526 | |||
527 | case ACPI_TYPE_LOCAL_REGION_FIELD: | 492 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
528 | 493 | ||
529 | status = acpi_ut_create_update_state_and_push ( | 494 | next_object = object->field.region_obj; |
530 | object->field.region_obj, action, &state_list); | 495 | break; |
531 | if (ACPI_FAILURE (status)) { | ||
532 | goto error_exit; | ||
533 | } | ||
534 | |||
535 | tmp = object->field.region_obj; | ||
536 | if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
537 | object->field.region_obj = NULL; | ||
538 | break; | ||
539 | |||
540 | 496 | ||
541 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 497 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
542 | 498 | ||
543 | status = acpi_ut_create_update_state_and_push ( | 499 | next_object = object->bank_field.bank_obj; |
544 | object->bank_field.bank_obj, action, &state_list); | ||
545 | if (ACPI_FAILURE (status)) { | ||
546 | goto error_exit; | ||
547 | } | ||
548 | |||
549 | tmp = object->bank_field.bank_obj; | ||
550 | if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
551 | object->bank_field.bank_obj = NULL; | ||
552 | |||
553 | status = acpi_ut_create_update_state_and_push ( | 500 | status = acpi_ut_create_update_state_and_push ( |
554 | object->bank_field.region_obj, action, &state_list); | 501 | object->bank_field.region_obj, action, &state_list); |
555 | if (ACPI_FAILURE (status)) { | 502 | if (ACPI_FAILURE (status)) { |
556 | goto error_exit; | 503 | goto error_exit; |
557 | } | 504 | } |
558 | |||
559 | tmp = object->bank_field.region_obj; | ||
560 | if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
561 | object->bank_field.region_obj = NULL; | ||
562 | break; | 505 | break; |
563 | 506 | ||
564 | |||
565 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | 507 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
566 | 508 | ||
567 | status = acpi_ut_create_update_state_and_push ( | 509 | next_object = object->index_field.index_obj; |
568 | object->index_field.index_obj, action, &state_list); | ||
569 | if (ACPI_FAILURE (status)) { | ||
570 | goto error_exit; | ||
571 | } | ||
572 | |||
573 | tmp = object->index_field.index_obj; | ||
574 | if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
575 | object->index_field.index_obj = NULL; | ||
576 | |||
577 | status = acpi_ut_create_update_state_and_push ( | 510 | status = acpi_ut_create_update_state_and_push ( |
578 | object->index_field.data_obj, action, &state_list); | 511 | object->index_field.data_obj, action, &state_list); |
579 | if (ACPI_FAILURE (status)) { | 512 | if (ACPI_FAILURE (status)) { |
580 | goto error_exit; | 513 | goto error_exit; |
581 | } | 514 | } |
582 | |||
583 | tmp = object->index_field.data_obj; | ||
584 | if ( tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT) | ||
585 | object->index_field.data_obj = NULL; | ||
586 | break; | 515 | break; |
587 | 516 | ||
588 | |||
589 | case ACPI_TYPE_LOCAL_REFERENCE: | 517 | case ACPI_TYPE_LOCAL_REFERENCE: |
590 | |||
591 | /* | 518 | /* |
592 | * The target of an Index (a package, string, or buffer) must track | 519 | * The target of an Index (a package, string, or buffer) must track |
593 | * changes to the ref count of the index. | 520 | * changes to the ref count of the index. |
594 | */ | 521 | */ |
595 | if (object->reference.opcode == AML_INDEX_OP) { | 522 | if (object->reference.opcode == AML_INDEX_OP) { |
596 | status = acpi_ut_create_update_state_and_push ( | 523 | next_object = object->reference.object; |
597 | object->reference.object, action, &state_list); | ||
598 | if (ACPI_FAILURE (status)) { | ||
599 | goto error_exit; | ||
600 | } | ||
601 | } | 524 | } |
602 | break; | 525 | break; |
603 | 526 | ||
604 | |||
605 | case ACPI_TYPE_REGION: | 527 | case ACPI_TYPE_REGION: |
606 | default: | 528 | default: |
607 | 529 | break;/* No subobjects */ | |
608 | /* No subobjects */ | ||
609 | break; | ||
610 | } | 530 | } |
611 | 531 | ||
612 | /* | 532 | /* |
@@ -615,15 +535,23 @@ acpi_ut_update_object_reference ( | |||
615 | * main object to be deleted. | 535 | * main object to be deleted. |
616 | */ | 536 | */ |
617 | acpi_ut_update_ref_count (object, action); | 537 | acpi_ut_update_ref_count (object, action); |
538 | object = NULL; | ||
618 | 539 | ||
619 | /* Move on to the next object to be updated */ | 540 | /* Move on to the next object to be updated */ |
620 | 541 | ||
621 | state = acpi_ut_pop_generic_state (&state_list); | 542 | if (next_object) { |
543 | object = next_object; | ||
544 | next_object = NULL; | ||
545 | } | ||
546 | else if (state_list) { | ||
547 | state = acpi_ut_pop_generic_state (&state_list); | ||
548 | object = state->update.object; | ||
549 | acpi_ut_delete_generic_state (state); | ||
550 | } | ||
622 | } | 551 | } |
623 | 552 | ||
624 | return_ACPI_STATUS (AE_OK); | 553 | return_ACPI_STATUS (AE_OK); |
625 | 554 | ||
626 | |||
627 | error_exit: | 555 | error_exit: |
628 | 556 | ||
629 | ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", | 557 | ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", |
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 4146019b543f..0e4161c81076 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c | |||
@@ -738,73 +738,6 @@ acpi_ut_valid_object_type ( | |||
738 | 738 | ||
739 | /******************************************************************************* | 739 | /******************************************************************************* |
740 | * | 740 | * |
741 | * FUNCTION: acpi_ut_allocate_owner_id | ||
742 | * | ||
743 | * PARAMETERS: id_type - Type of ID (method or table) | ||
744 | * | ||
745 | * DESCRIPTION: Allocate a table or method owner id | ||
746 | * | ||
747 | * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and | ||
748 | * should be revisited (TBD) | ||
749 | * | ||
750 | ******************************************************************************/ | ||
751 | |||
752 | acpi_owner_id | ||
753 | acpi_ut_allocate_owner_id ( | ||
754 | u32 id_type) | ||
755 | { | ||
756 | acpi_owner_id owner_id = 0xFFFF; | ||
757 | |||
758 | |||
759 | ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); | ||
760 | |||
761 | |||
762 | if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) | ||
763 | { | ||
764 | return (0); | ||
765 | } | ||
766 | |||
767 | switch (id_type) | ||
768 | { | ||
769 | case ACPI_OWNER_TYPE_TABLE: | ||
770 | |||
771 | owner_id = acpi_gbl_next_table_owner_id; | ||
772 | acpi_gbl_next_table_owner_id++; | ||
773 | |||
774 | /* Check for wraparound */ | ||
775 | |||
776 | if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID) | ||
777 | { | ||
778 | acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; | ||
779 | ACPI_REPORT_WARNING (("Table owner ID wraparound\n")); | ||
780 | } | ||
781 | break; | ||
782 | |||
783 | |||
784 | case ACPI_OWNER_TYPE_METHOD: | ||
785 | |||
786 | owner_id = acpi_gbl_next_method_owner_id; | ||
787 | acpi_gbl_next_method_owner_id++; | ||
788 | |||
789 | if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID) | ||
790 | { | ||
791 | /* Check for wraparound */ | ||
792 | |||
793 | acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; | ||
794 | } | ||
795 | break; | ||
796 | |||
797 | default: | ||
798 | break; | ||
799 | } | ||
800 | |||
801 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
802 | return_VALUE (owner_id); | ||
803 | } | ||
804 | |||
805 | |||
806 | /******************************************************************************* | ||
807 | * | ||
808 | * FUNCTION: acpi_ut_init_globals | 741 | * FUNCTION: acpi_ut_init_globals |
809 | * | 742 | * |
810 | * PARAMETERS: None | 743 | * PARAMETERS: None |
@@ -820,42 +753,20 @@ void | |||
820 | acpi_ut_init_globals ( | 753 | acpi_ut_init_globals ( |
821 | void) | 754 | void) |
822 | { | 755 | { |
756 | acpi_status status; | ||
823 | u32 i; | 757 | u32 i; |
824 | 758 | ||
825 | 759 | ||
826 | ACPI_FUNCTION_TRACE ("ut_init_globals"); | 760 | ACPI_FUNCTION_TRACE ("ut_init_globals"); |
827 | 761 | ||
828 | 762 | ||
829 | /* Memory allocation and cache lists */ | 763 | /* Create all memory caches */ |
830 | |||
831 | ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS); | ||
832 | 764 | ||
833 | acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL); | 765 | status = acpi_ut_create_caches (); |
834 | acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); | 766 | if (ACPI_FAILURE (status)) |
835 | acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); | 767 | { |
836 | acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL); | 768 | return; |
837 | acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL); | 769 | } |
838 | |||
839 | acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node); | ||
840 | acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state); | ||
841 | acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common); | ||
842 | acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named); | ||
843 | acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object); | ||
844 | acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state); | ||
845 | |||
846 | acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH; | ||
847 | acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH; | ||
848 | acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH; | ||
849 | acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH; | ||
850 | acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH; | ||
851 | |||
852 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation"); | ||
853 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes"); | ||
854 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache"); | ||
855 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache"); | ||
856 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache"); | ||
857 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache"); | ||
858 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache"); | ||
859 | 770 | ||
860 | /* ACPI table structure */ | 771 | /* ACPI table structure */ |
861 | 772 | ||
@@ -870,7 +781,7 @@ acpi_ut_init_globals ( | |||
870 | for (i = 0; i < NUM_MUTEX; i++) | 781 | for (i = 0; i < NUM_MUTEX; i++) |
871 | { | 782 | { |
872 | acpi_gbl_mutex_info[i].mutex = NULL; | 783 | acpi_gbl_mutex_info[i].mutex = NULL; |
873 | acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED; | 784 | acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; |
874 | acpi_gbl_mutex_info[i].use_count = 0; | 785 | acpi_gbl_mutex_info[i].use_count = 0; |
875 | } | 786 | } |
876 | 787 | ||
@@ -911,8 +822,7 @@ acpi_ut_init_globals ( | |||
911 | acpi_gbl_ns_lookup_count = 0; | 822 | acpi_gbl_ns_lookup_count = 0; |
912 | acpi_gbl_ps_find_count = 0; | 823 | acpi_gbl_ps_find_count = 0; |
913 | acpi_gbl_acpi_hardware_present = TRUE; | 824 | acpi_gbl_acpi_hardware_present = TRUE; |
914 | acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID; | 825 | acpi_gbl_owner_id_mask = 0; |
915 | acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID; | ||
916 | acpi_gbl_debugger_configuration = DEBUGGER_THREADING; | 826 | acpi_gbl_debugger_configuration = DEBUGGER_THREADING; |
917 | acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; | 827 | acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; |
918 | 828 | ||
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index 7f3713889ff0..fd7ceba83229 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c | |||
@@ -264,7 +264,7 @@ acpi_ut_subsystem_shutdown ( | |||
264 | 264 | ||
265 | /* Purge the local caches */ | 265 | /* Purge the local caches */ |
266 | 266 | ||
267 | (void) acpi_purge_cached_objects (); | 267 | (void) acpi_ut_delete_caches (); |
268 | 268 | ||
269 | /* Debug only - display leftover memory allocation, if any */ | 269 | /* Debug only - display leftover memory allocation, if any */ |
270 | 270 | ||
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index f6de4ed3d527..df715cd89105 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c | |||
@@ -49,15 +49,99 @@ | |||
49 | #define _COMPONENT ACPI_UTILITIES | 49 | #define _COMPONENT ACPI_UTILITIES |
50 | ACPI_MODULE_NAME ("utmisc") | 50 | ACPI_MODULE_NAME ("utmisc") |
51 | 51 | ||
52 | /* Local prototypes */ | ||
53 | 52 | ||
54 | static acpi_status | 53 | /******************************************************************************* |
55 | acpi_ut_create_mutex ( | 54 | * |
56 | acpi_mutex_handle mutex_id); | 55 | * FUNCTION: acpi_ut_allocate_owner_id |
56 | * | ||
57 | * PARAMETERS: owner_id - Where the new owner ID is returned | ||
58 | * | ||
59 | * DESCRIPTION: Allocate a table or method owner id | ||
60 | * | ||
61 | ******************************************************************************/ | ||
57 | 62 | ||
58 | static acpi_status | 63 | acpi_status |
59 | acpi_ut_delete_mutex ( | 64 | acpi_ut_allocate_owner_id ( |
60 | acpi_mutex_handle mutex_id); | 65 | acpi_owner_id *owner_id) |
66 | { | ||
67 | acpi_native_uint i; | ||
68 | acpi_status status; | ||
69 | |||
70 | |||
71 | ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); | ||
72 | |||
73 | |||
74 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | ||
75 | if (ACPI_FAILURE (status)) { | ||
76 | return_ACPI_STATUS (status); | ||
77 | } | ||
78 | |||
79 | /* Find a free owner ID */ | ||
80 | |||
81 | for (i = 0; i < 32; i++) { | ||
82 | if (!(acpi_gbl_owner_id_mask & (1 << i))) { | ||
83 | acpi_gbl_owner_id_mask |= (1 << i); | ||
84 | *owner_id = (acpi_owner_id) i; | ||
85 | goto exit; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * If we are here, all owner_ids have been allocated. This probably should | ||
91 | * not happen since the IDs are reused after deallocation. The IDs are | ||
92 | * allocated upon table load (one per table) and method execution, and | ||
93 | * they are released when a table is unloaded or a method completes | ||
94 | * execution. | ||
95 | */ | ||
96 | status = AE_OWNER_ID_LIMIT; | ||
97 | ACPI_REPORT_ERROR (( | ||
98 | "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); | ||
99 | |||
100 | exit: | ||
101 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
102 | return_ACPI_STATUS (status); | ||
103 | } | ||
104 | |||
105 | |||
106 | /******************************************************************************* | ||
107 | * | ||
108 | * FUNCTION: acpi_ut_release_owner_id | ||
109 | * | ||
110 | * PARAMETERS: owner_id - A previously allocated owner ID | ||
111 | * | ||
112 | * DESCRIPTION: Release a table or method owner id | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | acpi_status | ||
117 | acpi_ut_release_owner_id ( | ||
118 | acpi_owner_id owner_id) | ||
119 | { | ||
120 | acpi_status status; | ||
121 | |||
122 | |||
123 | ACPI_FUNCTION_TRACE ("ut_release_owner_id"); | ||
124 | |||
125 | |||
126 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | ||
127 | if (ACPI_FAILURE (status)) { | ||
128 | return_ACPI_STATUS (status); | ||
129 | } | ||
130 | |||
131 | /* Free the owner ID */ | ||
132 | |||
133 | if (acpi_gbl_owner_id_mask & (1 << owner_id)) { | ||
134 | acpi_gbl_owner_id_mask ^= (1 << owner_id); | ||
135 | } | ||
136 | else { | ||
137 | /* This owner_id has not been allocated */ | ||
138 | |||
139 | status = AE_NOT_EXIST; | ||
140 | } | ||
141 | |||
142 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | ||
143 | return_ACPI_STATUS (status); | ||
144 | } | ||
61 | 145 | ||
62 | 146 | ||
63 | /******************************************************************************* | 147 | /******************************************************************************* |
@@ -84,6 +168,10 @@ acpi_ut_strupr ( | |||
84 | ACPI_FUNCTION_ENTRY (); | 168 | ACPI_FUNCTION_ENTRY (); |
85 | 169 | ||
86 | 170 | ||
171 | if (!src_string) { | ||
172 | return (NULL); | ||
173 | } | ||
174 | |||
87 | /* Walk entire string, uppercasing the letters */ | 175 | /* Walk entire string, uppercasing the letters */ |
88 | 176 | ||
89 | for (string = src_string; *string; string++) { | 177 | for (string = src_string; *string; string++) { |
@@ -543,320 +631,6 @@ error_exit: | |||
543 | 631 | ||
544 | /******************************************************************************* | 632 | /******************************************************************************* |
545 | * | 633 | * |
546 | * FUNCTION: acpi_ut_mutex_initialize | ||
547 | * | ||
548 | * PARAMETERS: None. | ||
549 | * | ||
550 | * RETURN: Status | ||
551 | * | ||
552 | * DESCRIPTION: Create the system mutex objects. | ||
553 | * | ||
554 | ******************************************************************************/ | ||
555 | |||
556 | acpi_status | ||
557 | acpi_ut_mutex_initialize ( | ||
558 | void) | ||
559 | { | ||
560 | u32 i; | ||
561 | acpi_status status; | ||
562 | |||
563 | |||
564 | ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); | ||
565 | |||
566 | |||
567 | /* | ||
568 | * Create each of the predefined mutex objects | ||
569 | */ | ||
570 | for (i = 0; i < NUM_MUTEX; i++) { | ||
571 | status = acpi_ut_create_mutex (i); | ||
572 | if (ACPI_FAILURE (status)) { | ||
573 | return_ACPI_STATUS (status); | ||
574 | } | ||
575 | } | ||
576 | |||
577 | status = acpi_os_create_lock (&acpi_gbl_gpe_lock); | ||
578 | return_ACPI_STATUS (status); | ||
579 | } | ||
580 | |||
581 | |||
582 | /******************************************************************************* | ||
583 | * | ||
584 | * FUNCTION: acpi_ut_mutex_terminate | ||
585 | * | ||
586 | * PARAMETERS: None. | ||
587 | * | ||
588 | * RETURN: None. | ||
589 | * | ||
590 | * DESCRIPTION: Delete all of the system mutex objects. | ||
591 | * | ||
592 | ******************************************************************************/ | ||
593 | |||
594 | void | ||
595 | acpi_ut_mutex_terminate ( | ||
596 | void) | ||
597 | { | ||
598 | u32 i; | ||
599 | |||
600 | |||
601 | ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); | ||
602 | |||
603 | |||
604 | /* | ||
605 | * Delete each predefined mutex object | ||
606 | */ | ||
607 | for (i = 0; i < NUM_MUTEX; i++) { | ||
608 | (void) acpi_ut_delete_mutex (i); | ||
609 | } | ||
610 | |||
611 | acpi_os_delete_lock (acpi_gbl_gpe_lock); | ||
612 | return_VOID; | ||
613 | } | ||
614 | |||
615 | |||
616 | /******************************************************************************* | ||
617 | * | ||
618 | * FUNCTION: acpi_ut_create_mutex | ||
619 | * | ||
620 | * PARAMETERS: mutex_iD - ID of the mutex to be created | ||
621 | * | ||
622 | * RETURN: Status | ||
623 | * | ||
624 | * DESCRIPTION: Create a mutex object. | ||
625 | * | ||
626 | ******************************************************************************/ | ||
627 | |||
628 | static acpi_status | ||
629 | acpi_ut_create_mutex ( | ||
630 | acpi_mutex_handle mutex_id) | ||
631 | { | ||
632 | acpi_status status = AE_OK; | ||
633 | |||
634 | |||
635 | ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); | ||
636 | |||
637 | |||
638 | if (mutex_id > MAX_MUTEX) { | ||
639 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
640 | } | ||
641 | |||
642 | if (!acpi_gbl_mutex_info[mutex_id].mutex) { | ||
643 | status = acpi_os_create_semaphore (1, 1, | ||
644 | &acpi_gbl_mutex_info[mutex_id].mutex); | ||
645 | acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
646 | acpi_gbl_mutex_info[mutex_id].use_count = 0; | ||
647 | } | ||
648 | |||
649 | return_ACPI_STATUS (status); | ||
650 | } | ||
651 | |||
652 | |||
653 | /******************************************************************************* | ||
654 | * | ||
655 | * FUNCTION: acpi_ut_delete_mutex | ||
656 | * | ||
657 | * PARAMETERS: mutex_iD - ID of the mutex to be deleted | ||
658 | * | ||
659 | * RETURN: Status | ||
660 | * | ||
661 | * DESCRIPTION: Delete a mutex object. | ||
662 | * | ||
663 | ******************************************************************************/ | ||
664 | |||
665 | static acpi_status | ||
666 | acpi_ut_delete_mutex ( | ||
667 | acpi_mutex_handle mutex_id) | ||
668 | { | ||
669 | acpi_status status; | ||
670 | |||
671 | |||
672 | ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); | ||
673 | |||
674 | |||
675 | if (mutex_id > MAX_MUTEX) { | ||
676 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
677 | } | ||
678 | |||
679 | status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); | ||
680 | |||
681 | acpi_gbl_mutex_info[mutex_id].mutex = NULL; | ||
682 | acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
683 | |||
684 | return_ACPI_STATUS (status); | ||
685 | } | ||
686 | |||
687 | |||
688 | /******************************************************************************* | ||
689 | * | ||
690 | * FUNCTION: acpi_ut_acquire_mutex | ||
691 | * | ||
692 | * PARAMETERS: mutex_iD - ID of the mutex to be acquired | ||
693 | * | ||
694 | * RETURN: Status | ||
695 | * | ||
696 | * DESCRIPTION: Acquire a mutex object. | ||
697 | * | ||
698 | ******************************************************************************/ | ||
699 | |||
700 | acpi_status | ||
701 | acpi_ut_acquire_mutex ( | ||
702 | acpi_mutex_handle mutex_id) | ||
703 | { | ||
704 | acpi_status status; | ||
705 | u32 this_thread_id; | ||
706 | |||
707 | |||
708 | ACPI_FUNCTION_NAME ("ut_acquire_mutex"); | ||
709 | |||
710 | |||
711 | if (mutex_id > MAX_MUTEX) { | ||
712 | return (AE_BAD_PARAMETER); | ||
713 | } | ||
714 | |||
715 | this_thread_id = acpi_os_get_thread_id (); | ||
716 | |||
717 | #ifdef ACPI_MUTEX_DEBUG | ||
718 | { | ||
719 | u32 i; | ||
720 | /* | ||
721 | * Mutex debug code, for internal debugging only. | ||
722 | * | ||
723 | * Deadlock prevention. Check if this thread owns any mutexes of value | ||
724 | * greater than or equal to this one. If so, the thread has violated | ||
725 | * the mutex ordering rule. This indicates a coding error somewhere in | ||
726 | * the ACPI subsystem code. | ||
727 | */ | ||
728 | for (i = mutex_id; i < MAX_MUTEX; i++) { | ||
729 | if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { | ||
730 | if (i == mutex_id) { | ||
731 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
732 | "Mutex [%s] already acquired by this thread [%X]\n", | ||
733 | acpi_ut_get_mutex_name (mutex_id), this_thread_id)); | ||
734 | |||
735 | return (AE_ALREADY_ACQUIRED); | ||
736 | } | ||
737 | |||
738 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
739 | "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", | ||
740 | this_thread_id, acpi_ut_get_mutex_name (i), | ||
741 | acpi_ut_get_mutex_name (mutex_id))); | ||
742 | |||
743 | return (AE_ACQUIRE_DEADLOCK); | ||
744 | } | ||
745 | } | ||
746 | } | ||
747 | #endif | ||
748 | |||
749 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, | ||
750 | "Thread %X attempting to acquire Mutex [%s]\n", | ||
751 | this_thread_id, acpi_ut_get_mutex_name (mutex_id))); | ||
752 | |||
753 | status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, | ||
754 | 1, ACPI_WAIT_FOREVER); | ||
755 | if (ACPI_SUCCESS (status)) { | ||
756 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", | ||
757 | this_thread_id, acpi_ut_get_mutex_name (mutex_id))); | ||
758 | |||
759 | acpi_gbl_mutex_info[mutex_id].use_count++; | ||
760 | acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; | ||
761 | } | ||
762 | else { | ||
763 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
764 | "Thread %X could not acquire Mutex [%s] %s\n", | ||
765 | this_thread_id, acpi_ut_get_mutex_name (mutex_id), | ||
766 | acpi_format_exception (status))); | ||
767 | } | ||
768 | |||
769 | return (status); | ||
770 | } | ||
771 | |||
772 | |||
773 | /******************************************************************************* | ||
774 | * | ||
775 | * FUNCTION: acpi_ut_release_mutex | ||
776 | * | ||
777 | * PARAMETERS: mutex_iD - ID of the mutex to be released | ||
778 | * | ||
779 | * RETURN: Status | ||
780 | * | ||
781 | * DESCRIPTION: Release a mutex object. | ||
782 | * | ||
783 | ******************************************************************************/ | ||
784 | |||
785 | acpi_status | ||
786 | acpi_ut_release_mutex ( | ||
787 | acpi_mutex_handle mutex_id) | ||
788 | { | ||
789 | acpi_status status; | ||
790 | u32 i; | ||
791 | u32 this_thread_id; | ||
792 | |||
793 | |||
794 | ACPI_FUNCTION_NAME ("ut_release_mutex"); | ||
795 | |||
796 | |||
797 | this_thread_id = acpi_os_get_thread_id (); | ||
798 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, | ||
799 | "Thread %X releasing Mutex [%s]\n", this_thread_id, | ||
800 | acpi_ut_get_mutex_name (mutex_id))); | ||
801 | |||
802 | if (mutex_id > MAX_MUTEX) { | ||
803 | return (AE_BAD_PARAMETER); | ||
804 | } | ||
805 | |||
806 | /* | ||
807 | * Mutex must be acquired in order to release it! | ||
808 | */ | ||
809 | if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { | ||
810 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
811 | "Mutex [%s] is not acquired, cannot release\n", | ||
812 | acpi_ut_get_mutex_name (mutex_id))); | ||
813 | |||
814 | return (AE_NOT_ACQUIRED); | ||
815 | } | ||
816 | |||
817 | /* | ||
818 | * Deadlock prevention. Check if this thread owns any mutexes of value | ||
819 | * greater than this one. If so, the thread has violated the mutex | ||
820 | * ordering rule. This indicates a coding error somewhere in | ||
821 | * the ACPI subsystem code. | ||
822 | */ | ||
823 | for (i = mutex_id; i < MAX_MUTEX; i++) { | ||
824 | if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { | ||
825 | if (i == mutex_id) { | ||
826 | continue; | ||
827 | } | ||
828 | |||
829 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
830 | "Invalid release order: owns [%s], releasing [%s]\n", | ||
831 | acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); | ||
832 | |||
833 | return (AE_RELEASE_DEADLOCK); | ||
834 | } | ||
835 | } | ||
836 | |||
837 | /* Mark unlocked FIRST */ | ||
838 | |||
839 | acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
840 | |||
841 | status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); | ||
842 | |||
843 | if (ACPI_FAILURE (status)) { | ||
844 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
845 | "Thread %X could not release Mutex [%s] %s\n", | ||
846 | this_thread_id, acpi_ut_get_mutex_name (mutex_id), | ||
847 | acpi_format_exception (status))); | ||
848 | } | ||
849 | else { | ||
850 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", | ||
851 | this_thread_id, acpi_ut_get_mutex_name (mutex_id))); | ||
852 | } | ||
853 | |||
854 | return (status); | ||
855 | } | ||
856 | |||
857 | |||
858 | /******************************************************************************* | ||
859 | * | ||
860 | * FUNCTION: acpi_ut_create_update_state_and_push | 634 | * FUNCTION: acpi_ut_create_update_state_and_push |
861 | * | 635 | * |
862 | * PARAMETERS: Object - Object to be added to the new state | 636 | * PARAMETERS: Object - Object to be added to the new state |
@@ -899,361 +673,6 @@ acpi_ut_create_update_state_and_push ( | |||
899 | 673 | ||
900 | /******************************************************************************* | 674 | /******************************************************************************* |
901 | * | 675 | * |
902 | * FUNCTION: acpi_ut_create_pkg_state_and_push | ||
903 | * | ||
904 | * PARAMETERS: Object - Object to be added to the new state | ||
905 | * Action - Increment/Decrement | ||
906 | * state_list - List the state will be added to | ||
907 | * | ||
908 | * RETURN: Status | ||
909 | * | ||
910 | * DESCRIPTION: Create a new state and push it | ||
911 | * | ||
912 | ******************************************************************************/ | ||
913 | |||
914 | #ifdef ACPI_FUTURE_USAGE | ||
915 | acpi_status | ||
916 | acpi_ut_create_pkg_state_and_push ( | ||
917 | void *internal_object, | ||
918 | void *external_object, | ||
919 | u16 index, | ||
920 | union acpi_generic_state **state_list) | ||
921 | { | ||
922 | union acpi_generic_state *state; | ||
923 | |||
924 | |||
925 | ACPI_FUNCTION_ENTRY (); | ||
926 | |||
927 | |||
928 | state = acpi_ut_create_pkg_state (internal_object, external_object, index); | ||
929 | if (!state) { | ||
930 | return (AE_NO_MEMORY); | ||
931 | } | ||
932 | |||
933 | acpi_ut_push_generic_state (state_list, state); | ||
934 | return (AE_OK); | ||
935 | } | ||
936 | #endif /* ACPI_FUTURE_USAGE */ | ||
937 | |||
938 | /******************************************************************************* | ||
939 | * | ||
940 | * FUNCTION: acpi_ut_push_generic_state | ||
941 | * | ||
942 | * PARAMETERS: list_head - Head of the state stack | ||
943 | * State - State object to push | ||
944 | * | ||
945 | * RETURN: None | ||
946 | * | ||
947 | * DESCRIPTION: Push a state object onto a state stack | ||
948 | * | ||
949 | ******************************************************************************/ | ||
950 | |||
951 | void | ||
952 | acpi_ut_push_generic_state ( | ||
953 | union acpi_generic_state **list_head, | ||
954 | union acpi_generic_state *state) | ||
955 | { | ||
956 | ACPI_FUNCTION_TRACE ("ut_push_generic_state"); | ||
957 | |||
958 | |||
959 | /* Push the state object onto the front of the list (stack) */ | ||
960 | |||
961 | state->common.next = *list_head; | ||
962 | *list_head = state; | ||
963 | |||
964 | return_VOID; | ||
965 | } | ||
966 | |||
967 | |||
968 | /******************************************************************************* | ||
969 | * | ||
970 | * FUNCTION: acpi_ut_pop_generic_state | ||
971 | * | ||
972 | * PARAMETERS: list_head - Head of the state stack | ||
973 | * | ||
974 | * RETURN: The popped state object | ||
975 | * | ||
976 | * DESCRIPTION: Pop a state object from a state stack | ||
977 | * | ||
978 | ******************************************************************************/ | ||
979 | |||
980 | union acpi_generic_state * | ||
981 | acpi_ut_pop_generic_state ( | ||
982 | union acpi_generic_state **list_head) | ||
983 | { | ||
984 | union acpi_generic_state *state; | ||
985 | |||
986 | |||
987 | ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); | ||
988 | |||
989 | |||
990 | /* Remove the state object at the head of the list (stack) */ | ||
991 | |||
992 | state = *list_head; | ||
993 | if (state) { | ||
994 | /* Update the list head */ | ||
995 | |||
996 | *list_head = state->common.next; | ||
997 | } | ||
998 | |||
999 | return_PTR (state); | ||
1000 | } | ||
1001 | |||
1002 | |||
1003 | /******************************************************************************* | ||
1004 | * | ||
1005 | * FUNCTION: acpi_ut_create_generic_state | ||
1006 | * | ||
1007 | * PARAMETERS: None | ||
1008 | * | ||
1009 | * RETURN: The new state object. NULL on failure. | ||
1010 | * | ||
1011 | * DESCRIPTION: Create a generic state object. Attempt to obtain one from | ||
1012 | * the global state cache; If none available, create a new one. | ||
1013 | * | ||
1014 | ******************************************************************************/ | ||
1015 | |||
1016 | union acpi_generic_state * | ||
1017 | acpi_ut_create_generic_state ( | ||
1018 | void) | ||
1019 | { | ||
1020 | union acpi_generic_state *state; | ||
1021 | |||
1022 | |||
1023 | ACPI_FUNCTION_ENTRY (); | ||
1024 | |||
1025 | |||
1026 | state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE); | ||
1027 | |||
1028 | /* Initialize */ | ||
1029 | |||
1030 | if (state) { | ||
1031 | state->common.data_type = ACPI_DESC_TYPE_STATE; | ||
1032 | } | ||
1033 | |||
1034 | return (state); | ||
1035 | } | ||
1036 | |||
1037 | |||
1038 | /******************************************************************************* | ||
1039 | * | ||
1040 | * FUNCTION: acpi_ut_create_thread_state | ||
1041 | * | ||
1042 | * PARAMETERS: None | ||
1043 | * | ||
1044 | * RETURN: New Thread State. NULL on failure | ||
1045 | * | ||
1046 | * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used | ||
1047 | * to track per-thread info during method execution | ||
1048 | * | ||
1049 | ******************************************************************************/ | ||
1050 | |||
1051 | struct acpi_thread_state * | ||
1052 | acpi_ut_create_thread_state ( | ||
1053 | void) | ||
1054 | { | ||
1055 | union acpi_generic_state *state; | ||
1056 | |||
1057 | |||
1058 | ACPI_FUNCTION_TRACE ("ut_create_thread_state"); | ||
1059 | |||
1060 | |||
1061 | /* Create the generic state object */ | ||
1062 | |||
1063 | state = acpi_ut_create_generic_state (); | ||
1064 | if (!state) { | ||
1065 | return_PTR (NULL); | ||
1066 | } | ||
1067 | |||
1068 | /* Init fields specific to the update struct */ | ||
1069 | |||
1070 | state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; | ||
1071 | state->thread.thread_id = acpi_os_get_thread_id (); | ||
1072 | |||
1073 | return_PTR ((struct acpi_thread_state *) state); | ||
1074 | } | ||
1075 | |||
1076 | |||
1077 | /******************************************************************************* | ||
1078 | * | ||
1079 | * FUNCTION: acpi_ut_create_update_state | ||
1080 | * | ||
1081 | * PARAMETERS: Object - Initial Object to be installed in the state | ||
1082 | * Action - Update action to be performed | ||
1083 | * | ||
1084 | * RETURN: New state object, null on failure | ||
1085 | * | ||
1086 | * DESCRIPTION: Create an "Update State" - a flavor of the generic state used | ||
1087 | * to update reference counts and delete complex objects such | ||
1088 | * as packages. | ||
1089 | * | ||
1090 | ******************************************************************************/ | ||
1091 | |||
1092 | union acpi_generic_state * | ||
1093 | acpi_ut_create_update_state ( | ||
1094 | union acpi_operand_object *object, | ||
1095 | u16 action) | ||
1096 | { | ||
1097 | union acpi_generic_state *state; | ||
1098 | |||
1099 | |||
1100 | ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); | ||
1101 | |||
1102 | |||
1103 | /* Create the generic state object */ | ||
1104 | |||
1105 | state = acpi_ut_create_generic_state (); | ||
1106 | if (!state) { | ||
1107 | return_PTR (NULL); | ||
1108 | } | ||
1109 | |||
1110 | /* Init fields specific to the update struct */ | ||
1111 | |||
1112 | state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; | ||
1113 | state->update.object = object; | ||
1114 | state->update.value = action; | ||
1115 | |||
1116 | return_PTR (state); | ||
1117 | } | ||
1118 | |||
1119 | |||
1120 | /******************************************************************************* | ||
1121 | * | ||
1122 | * FUNCTION: acpi_ut_create_pkg_state | ||
1123 | * | ||
1124 | * PARAMETERS: Object - Initial Object to be installed in the state | ||
1125 | * Action - Update action to be performed | ||
1126 | * | ||
1127 | * RETURN: New state object, null on failure | ||
1128 | * | ||
1129 | * DESCRIPTION: Create a "Package State" | ||
1130 | * | ||
1131 | ******************************************************************************/ | ||
1132 | |||
1133 | union acpi_generic_state * | ||
1134 | acpi_ut_create_pkg_state ( | ||
1135 | void *internal_object, | ||
1136 | void *external_object, | ||
1137 | u16 index) | ||
1138 | { | ||
1139 | union acpi_generic_state *state; | ||
1140 | |||
1141 | |||
1142 | ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); | ||
1143 | |||
1144 | |||
1145 | /* Create the generic state object */ | ||
1146 | |||
1147 | state = acpi_ut_create_generic_state (); | ||
1148 | if (!state) { | ||
1149 | return_PTR (NULL); | ||
1150 | } | ||
1151 | |||
1152 | /* Init fields specific to the update struct */ | ||
1153 | |||
1154 | state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; | ||
1155 | state->pkg.source_object = (union acpi_operand_object *) internal_object; | ||
1156 | state->pkg.dest_object = external_object; | ||
1157 | state->pkg.index = index; | ||
1158 | state->pkg.num_packages = 1; | ||
1159 | |||
1160 | return_PTR (state); | ||
1161 | } | ||
1162 | |||
1163 | |||
1164 | /******************************************************************************* | ||
1165 | * | ||
1166 | * FUNCTION: acpi_ut_create_control_state | ||
1167 | * | ||
1168 | * PARAMETERS: None | ||
1169 | * | ||
1170 | * RETURN: New state object, null on failure | ||
1171 | * | ||
1172 | * DESCRIPTION: Create a "Control State" - a flavor of the generic state used | ||
1173 | * to support nested IF/WHILE constructs in the AML. | ||
1174 | * | ||
1175 | ******************************************************************************/ | ||
1176 | |||
1177 | union acpi_generic_state * | ||
1178 | acpi_ut_create_control_state ( | ||
1179 | void) | ||
1180 | { | ||
1181 | union acpi_generic_state *state; | ||
1182 | |||
1183 | |||
1184 | ACPI_FUNCTION_TRACE ("ut_create_control_state"); | ||
1185 | |||
1186 | |||
1187 | /* Create the generic state object */ | ||
1188 | |||
1189 | state = acpi_ut_create_generic_state (); | ||
1190 | if (!state) { | ||
1191 | return_PTR (NULL); | ||
1192 | } | ||
1193 | |||
1194 | /* Init fields specific to the control struct */ | ||
1195 | |||
1196 | state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; | ||
1197 | state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; | ||
1198 | |||
1199 | return_PTR (state); | ||
1200 | } | ||
1201 | |||
1202 | |||
1203 | /******************************************************************************* | ||
1204 | * | ||
1205 | * FUNCTION: acpi_ut_delete_generic_state | ||
1206 | * | ||
1207 | * PARAMETERS: State - The state object to be deleted | ||
1208 | * | ||
1209 | * RETURN: None | ||
1210 | * | ||
1211 | * DESCRIPTION: Put a state object back into the global state cache. The object | ||
1212 | * is not actually freed at this time. | ||
1213 | * | ||
1214 | ******************************************************************************/ | ||
1215 | |||
1216 | void | ||
1217 | acpi_ut_delete_generic_state ( | ||
1218 | union acpi_generic_state *state) | ||
1219 | { | ||
1220 | ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); | ||
1221 | |||
1222 | |||
1223 | acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state); | ||
1224 | return_VOID; | ||
1225 | } | ||
1226 | |||
1227 | |||
1228 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
1229 | /******************************************************************************* | ||
1230 | * | ||
1231 | * FUNCTION: acpi_ut_delete_generic_state_cache | ||
1232 | * | ||
1233 | * PARAMETERS: None | ||
1234 | * | ||
1235 | * RETURN: None | ||
1236 | * | ||
1237 | * DESCRIPTION: Purge the global state object cache. Used during subsystem | ||
1238 | * termination. | ||
1239 | * | ||
1240 | ******************************************************************************/ | ||
1241 | |||
1242 | void | ||
1243 | acpi_ut_delete_generic_state_cache ( | ||
1244 | void) | ||
1245 | { | ||
1246 | ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache"); | ||
1247 | |||
1248 | |||
1249 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE); | ||
1250 | return_VOID; | ||
1251 | } | ||
1252 | #endif | ||
1253 | |||
1254 | |||
1255 | /******************************************************************************* | ||
1256 | * | ||
1257 | * FUNCTION: acpi_ut_walk_package_tree | 676 | * FUNCTION: acpi_ut_walk_package_tree |
1258 | * | 677 | * |
1259 | * PARAMETERS: source_object - The package to walk | 678 | * PARAMETERS: source_object - The package to walk |
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c new file mode 100644 index 000000000000..0699b6be62b6 --- /dev/null +++ b/drivers/acpi/utilities/utmutex.c | |||
@@ -0,0 +1,380 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: utmutex - local mutex support | ||
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 | |||
45 | #include <acpi/acpi.h> | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME ("utmutex") | ||
49 | |||
50 | /* Local prototypes */ | ||
51 | |||
52 | static acpi_status | ||
53 | acpi_ut_create_mutex ( | ||
54 | acpi_mutex_handle mutex_id); | ||
55 | |||
56 | static acpi_status | ||
57 | acpi_ut_delete_mutex ( | ||
58 | acpi_mutex_handle mutex_id); | ||
59 | |||
60 | |||
61 | /******************************************************************************* | ||
62 | * | ||
63 | * FUNCTION: acpi_ut_mutex_initialize | ||
64 | * | ||
65 | * PARAMETERS: None. | ||
66 | * | ||
67 | * RETURN: Status | ||
68 | * | ||
69 | * DESCRIPTION: Create the system mutex objects. | ||
70 | * | ||
71 | ******************************************************************************/ | ||
72 | |||
73 | acpi_status | ||
74 | acpi_ut_mutex_initialize ( | ||
75 | void) | ||
76 | { | ||
77 | u32 i; | ||
78 | acpi_status status; | ||
79 | |||
80 | |||
81 | ACPI_FUNCTION_TRACE ("ut_mutex_initialize"); | ||
82 | |||
83 | |||
84 | /* | ||
85 | * Create each of the predefined mutex objects | ||
86 | */ | ||
87 | for (i = 0; i < NUM_MUTEX; i++) { | ||
88 | status = acpi_ut_create_mutex (i); | ||
89 | if (ACPI_FAILURE (status)) { | ||
90 | return_ACPI_STATUS (status); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | status = acpi_os_create_lock (&acpi_gbl_gpe_lock); | ||
95 | return_ACPI_STATUS (status); | ||
96 | } | ||
97 | |||
98 | |||
99 | /******************************************************************************* | ||
100 | * | ||
101 | * FUNCTION: acpi_ut_mutex_terminate | ||
102 | * | ||
103 | * PARAMETERS: None. | ||
104 | * | ||
105 | * RETURN: None. | ||
106 | * | ||
107 | * DESCRIPTION: Delete all of the system mutex objects. | ||
108 | * | ||
109 | ******************************************************************************/ | ||
110 | |||
111 | void | ||
112 | acpi_ut_mutex_terminate ( | ||
113 | void) | ||
114 | { | ||
115 | u32 i; | ||
116 | |||
117 | |||
118 | ACPI_FUNCTION_TRACE ("ut_mutex_terminate"); | ||
119 | |||
120 | |||
121 | /* | ||
122 | * Delete each predefined mutex object | ||
123 | */ | ||
124 | for (i = 0; i < NUM_MUTEX; i++) { | ||
125 | (void) acpi_ut_delete_mutex (i); | ||
126 | } | ||
127 | |||
128 | acpi_os_delete_lock (acpi_gbl_gpe_lock); | ||
129 | return_VOID; | ||
130 | } | ||
131 | |||
132 | |||
133 | /******************************************************************************* | ||
134 | * | ||
135 | * FUNCTION: acpi_ut_create_mutex | ||
136 | * | ||
137 | * PARAMETERS: mutex_iD - ID of the mutex to be created | ||
138 | * | ||
139 | * RETURN: Status | ||
140 | * | ||
141 | * DESCRIPTION: Create a mutex object. | ||
142 | * | ||
143 | ******************************************************************************/ | ||
144 | |||
145 | static acpi_status | ||
146 | acpi_ut_create_mutex ( | ||
147 | acpi_mutex_handle mutex_id) | ||
148 | { | ||
149 | acpi_status status = AE_OK; | ||
150 | |||
151 | |||
152 | ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id); | ||
153 | |||
154 | |||
155 | if (mutex_id > MAX_MUTEX) { | ||
156 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
157 | } | ||
158 | |||
159 | if (!acpi_gbl_mutex_info[mutex_id].mutex) { | ||
160 | status = acpi_os_create_semaphore (1, 1, | ||
161 | &acpi_gbl_mutex_info[mutex_id].mutex); | ||
162 | acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
163 | acpi_gbl_mutex_info[mutex_id].use_count = 0; | ||
164 | } | ||
165 | |||
166 | return_ACPI_STATUS (status); | ||
167 | } | ||
168 | |||
169 | |||
170 | /******************************************************************************* | ||
171 | * | ||
172 | * FUNCTION: acpi_ut_delete_mutex | ||
173 | * | ||
174 | * PARAMETERS: mutex_iD - ID of the mutex to be deleted | ||
175 | * | ||
176 | * RETURN: Status | ||
177 | * | ||
178 | * DESCRIPTION: Delete a mutex object. | ||
179 | * | ||
180 | ******************************************************************************/ | ||
181 | |||
182 | static acpi_status | ||
183 | acpi_ut_delete_mutex ( | ||
184 | acpi_mutex_handle mutex_id) | ||
185 | { | ||
186 | acpi_status status; | ||
187 | |||
188 | |||
189 | ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id); | ||
190 | |||
191 | |||
192 | if (mutex_id > MAX_MUTEX) { | ||
193 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
194 | } | ||
195 | |||
196 | status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); | ||
197 | |||
198 | acpi_gbl_mutex_info[mutex_id].mutex = NULL; | ||
199 | acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
200 | |||
201 | return_ACPI_STATUS (status); | ||
202 | } | ||
203 | |||
204 | |||
205 | /******************************************************************************* | ||
206 | * | ||
207 | * FUNCTION: acpi_ut_acquire_mutex | ||
208 | * | ||
209 | * PARAMETERS: mutex_iD - ID of the mutex to be acquired | ||
210 | * | ||
211 | * RETURN: Status | ||
212 | * | ||
213 | * DESCRIPTION: Acquire a mutex object. | ||
214 | * | ||
215 | ******************************************************************************/ | ||
216 | |||
217 | acpi_status | ||
218 | acpi_ut_acquire_mutex ( | ||
219 | acpi_mutex_handle mutex_id) | ||
220 | { | ||
221 | acpi_status status; | ||
222 | u32 this_thread_id; | ||
223 | |||
224 | |||
225 | ACPI_FUNCTION_NAME ("ut_acquire_mutex"); | ||
226 | |||
227 | |||
228 | if (mutex_id > MAX_MUTEX) { | ||
229 | return (AE_BAD_PARAMETER); | ||
230 | } | ||
231 | |||
232 | this_thread_id = acpi_os_get_thread_id (); | ||
233 | |||
234 | #ifdef ACPI_MUTEX_DEBUG | ||
235 | { | ||
236 | u32 i; | ||
237 | /* | ||
238 | * Mutex debug code, for internal debugging only. | ||
239 | * | ||
240 | * Deadlock prevention. Check if this thread owns any mutexes of value | ||
241 | * greater than or equal to this one. If so, the thread has violated | ||
242 | * the mutex ordering rule. This indicates a coding error somewhere in | ||
243 | * the ACPI subsystem code. | ||
244 | */ | ||
245 | for (i = mutex_id; i < MAX_MUTEX; i++) { | ||
246 | if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { | ||
247 | if (i == mutex_id) { | ||
248 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
249 | "Mutex [%s] already acquired by this thread [%X]\n", | ||
250 | acpi_ut_get_mutex_name (mutex_id), this_thread_id)); | ||
251 | |||
252 | return (AE_ALREADY_ACQUIRED); | ||
253 | } | ||
254 | |||
255 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
256 | "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", | ||
257 | this_thread_id, acpi_ut_get_mutex_name (i), | ||
258 | acpi_ut_get_mutex_name (mutex_id))); | ||
259 | |||
260 | return (AE_ACQUIRE_DEADLOCK); | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | #endif | ||
265 | |||
266 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, | ||
267 | "Thread %X attempting to acquire Mutex [%s]\n", | ||
268 | this_thread_id, acpi_ut_get_mutex_name (mutex_id))); | ||
269 | |||
270 | status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, | ||
271 | 1, ACPI_WAIT_FOREVER); | ||
272 | if (ACPI_SUCCESS (status)) { | ||
273 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", | ||
274 | this_thread_id, acpi_ut_get_mutex_name (mutex_id))); | ||
275 | |||
276 | acpi_gbl_mutex_info[mutex_id].use_count++; | ||
277 | acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; | ||
278 | } | ||
279 | else { | ||
280 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
281 | "Thread %X could not acquire Mutex [%s] %s\n", | ||
282 | this_thread_id, acpi_ut_get_mutex_name (mutex_id), | ||
283 | acpi_format_exception (status))); | ||
284 | } | ||
285 | |||
286 | return (status); | ||
287 | } | ||
288 | |||
289 | |||
290 | /******************************************************************************* | ||
291 | * | ||
292 | * FUNCTION: acpi_ut_release_mutex | ||
293 | * | ||
294 | * PARAMETERS: mutex_iD - ID of the mutex to be released | ||
295 | * | ||
296 | * RETURN: Status | ||
297 | * | ||
298 | * DESCRIPTION: Release a mutex object. | ||
299 | * | ||
300 | ******************************************************************************/ | ||
301 | |||
302 | acpi_status | ||
303 | acpi_ut_release_mutex ( | ||
304 | acpi_mutex_handle mutex_id) | ||
305 | { | ||
306 | acpi_status status; | ||
307 | u32 this_thread_id; | ||
308 | |||
309 | |||
310 | ACPI_FUNCTION_NAME ("ut_release_mutex"); | ||
311 | |||
312 | |||
313 | this_thread_id = acpi_os_get_thread_id (); | ||
314 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, | ||
315 | "Thread %X releasing Mutex [%s]\n", this_thread_id, | ||
316 | acpi_ut_get_mutex_name (mutex_id))); | ||
317 | |||
318 | if (mutex_id > MAX_MUTEX) { | ||
319 | return (AE_BAD_PARAMETER); | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * Mutex must be acquired in order to release it! | ||
324 | */ | ||
325 | if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { | ||
326 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
327 | "Mutex [%s] is not acquired, cannot release\n", | ||
328 | acpi_ut_get_mutex_name (mutex_id))); | ||
329 | |||
330 | return (AE_NOT_ACQUIRED); | ||
331 | } | ||
332 | |||
333 | #ifdef ACPI_MUTEX_DEBUG | ||
334 | { | ||
335 | u32 i; | ||
336 | /* | ||
337 | * Mutex debug code, for internal debugging only. | ||
338 | * | ||
339 | * Deadlock prevention. Check if this thread owns any mutexes of value | ||
340 | * greater than this one. If so, the thread has violated the mutex | ||
341 | * ordering rule. This indicates a coding error somewhere in | ||
342 | * the ACPI subsystem code. | ||
343 | */ | ||
344 | for (i = mutex_id; i < MAX_MUTEX; i++) { | ||
345 | if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { | ||
346 | if (i == mutex_id) { | ||
347 | continue; | ||
348 | } | ||
349 | |||
350 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
351 | "Invalid release order: owns [%s], releasing [%s]\n", | ||
352 | acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); | ||
353 | |||
354 | return (AE_RELEASE_DEADLOCK); | ||
355 | } | ||
356 | } | ||
357 | } | ||
358 | #endif | ||
359 | |||
360 | /* Mark unlocked FIRST */ | ||
361 | |||
362 | acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
363 | |||
364 | status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); | ||
365 | |||
366 | if (ACPI_FAILURE (status)) { | ||
367 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, | ||
368 | "Thread %X could not release Mutex [%s] %s\n", | ||
369 | this_thread_id, acpi_ut_get_mutex_name (mutex_id), | ||
370 | acpi_format_exception (status))); | ||
371 | } | ||
372 | else { | ||
373 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", | ||
374 | this_thread_id, acpi_ut_get_mutex_name (mutex_id))); | ||
375 | } | ||
376 | |||
377 | return (status); | ||
378 | } | ||
379 | |||
380 | |||
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index cd3899b9cc5a..19178e142951 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c | |||
@@ -338,7 +338,7 @@ acpi_ut_allocate_object_desc_dbg ( | |||
338 | ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); | 338 | ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); |
339 | 339 | ||
340 | 340 | ||
341 | object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND); | 341 | object = acpi_os_acquire_object (acpi_gbl_operand_cache); |
342 | if (!object) { | 342 | if (!object) { |
343 | _ACPI_REPORT_ERROR (module_name, line_number, component_id, | 343 | _ACPI_REPORT_ERROR (module_name, line_number, component_id, |
344 | ("Could not allocate an object descriptor\n")); | 344 | ("Could not allocate an object descriptor\n")); |
@@ -347,7 +347,7 @@ acpi_ut_allocate_object_desc_dbg ( | |||
347 | } | 347 | } |
348 | 348 | ||
349 | /* Mark the descriptor type */ | 349 | /* Mark the descriptor type */ |
350 | 350 | memset(object, 0, sizeof(union acpi_operand_object)); | |
351 | ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); | 351 | ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); |
352 | 352 | ||
353 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", | 353 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", |
@@ -385,37 +385,9 @@ acpi_ut_delete_object_desc ( | |||
385 | return_VOID; | 385 | return_VOID; |
386 | } | 386 | } |
387 | 387 | ||
388 | acpi_ut_release_to_cache (ACPI_MEM_LIST_OPERAND, object); | 388 | (void) acpi_os_release_object (acpi_gbl_operand_cache, object); |
389 | |||
390 | return_VOID; | ||
391 | } | ||
392 | |||
393 | |||
394 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
395 | /******************************************************************************* | ||
396 | * | ||
397 | * FUNCTION: acpi_ut_delete_object_cache | ||
398 | * | ||
399 | * PARAMETERS: None | ||
400 | * | ||
401 | * RETURN: None | ||
402 | * | ||
403 | * DESCRIPTION: Purge the global state object cache. Used during subsystem | ||
404 | * termination. | ||
405 | * | ||
406 | ******************************************************************************/ | ||
407 | |||
408 | void | ||
409 | acpi_ut_delete_object_cache ( | ||
410 | void) | ||
411 | { | ||
412 | ACPI_FUNCTION_TRACE ("ut_delete_object_cache"); | ||
413 | |||
414 | |||
415 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND); | ||
416 | return_VOID; | 389 | return_VOID; |
417 | } | 390 | } |
418 | #endif | ||
419 | 391 | ||
420 | 392 | ||
421 | /******************************************************************************* | 393 | /******************************************************************************* |
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c new file mode 100644 index 000000000000..192e7ac95690 --- /dev/null +++ b/drivers/acpi/utilities/utstate.c | |||
@@ -0,0 +1,376 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: utstate - state object support procedures | ||
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 | |||
45 | #include <acpi/acpi.h> | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME ("utstate") | ||
49 | |||
50 | |||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_ut_create_pkg_state_and_push | ||
54 | * | ||
55 | * PARAMETERS: Object - Object to be added to the new state | ||
56 | * Action - Increment/Decrement | ||
57 | * state_list - List the state will be added to | ||
58 | * | ||
59 | * RETURN: Status | ||
60 | * | ||
61 | * DESCRIPTION: Create a new state and push it | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | |||
65 | acpi_status | ||
66 | acpi_ut_create_pkg_state_and_push ( | ||
67 | void *internal_object, | ||
68 | void *external_object, | ||
69 | u16 index, | ||
70 | union acpi_generic_state **state_list) | ||
71 | { | ||
72 | union acpi_generic_state *state; | ||
73 | |||
74 | |||
75 | ACPI_FUNCTION_ENTRY (); | ||
76 | |||
77 | |||
78 | state = acpi_ut_create_pkg_state (internal_object, external_object, index); | ||
79 | if (!state) { | ||
80 | return (AE_NO_MEMORY); | ||
81 | } | ||
82 | |||
83 | acpi_ut_push_generic_state (state_list, state); | ||
84 | return (AE_OK); | ||
85 | } | ||
86 | |||
87 | |||
88 | /******************************************************************************* | ||
89 | * | ||
90 | * FUNCTION: acpi_ut_push_generic_state | ||
91 | * | ||
92 | * PARAMETERS: list_head - Head of the state stack | ||
93 | * State - State object to push | ||
94 | * | ||
95 | * RETURN: None | ||
96 | * | ||
97 | * DESCRIPTION: Push a state object onto a state stack | ||
98 | * | ||
99 | ******************************************************************************/ | ||
100 | |||
101 | void | ||
102 | acpi_ut_push_generic_state ( | ||
103 | union acpi_generic_state **list_head, | ||
104 | union acpi_generic_state *state) | ||
105 | { | ||
106 | ACPI_FUNCTION_TRACE ("ut_push_generic_state"); | ||
107 | |||
108 | |||
109 | /* Push the state object onto the front of the list (stack) */ | ||
110 | |||
111 | state->common.next = *list_head; | ||
112 | *list_head = state; | ||
113 | |||
114 | return_VOID; | ||
115 | } | ||
116 | |||
117 | |||
118 | /******************************************************************************* | ||
119 | * | ||
120 | * FUNCTION: acpi_ut_pop_generic_state | ||
121 | * | ||
122 | * PARAMETERS: list_head - Head of the state stack | ||
123 | * | ||
124 | * RETURN: The popped state object | ||
125 | * | ||
126 | * DESCRIPTION: Pop a state object from a state stack | ||
127 | * | ||
128 | ******************************************************************************/ | ||
129 | |||
130 | union acpi_generic_state * | ||
131 | acpi_ut_pop_generic_state ( | ||
132 | union acpi_generic_state **list_head) | ||
133 | { | ||
134 | union acpi_generic_state *state; | ||
135 | |||
136 | |||
137 | ACPI_FUNCTION_TRACE ("ut_pop_generic_state"); | ||
138 | |||
139 | |||
140 | /* Remove the state object at the head of the list (stack) */ | ||
141 | |||
142 | state = *list_head; | ||
143 | if (state) { | ||
144 | /* Update the list head */ | ||
145 | |||
146 | *list_head = state->common.next; | ||
147 | } | ||
148 | |||
149 | return_PTR (state); | ||
150 | } | ||
151 | |||
152 | |||
153 | /******************************************************************************* | ||
154 | * | ||
155 | * FUNCTION: acpi_ut_create_generic_state | ||
156 | * | ||
157 | * PARAMETERS: None | ||
158 | * | ||
159 | * RETURN: The new state object. NULL on failure. | ||
160 | * | ||
161 | * DESCRIPTION: Create a generic state object. Attempt to obtain one from | ||
162 | * the global state cache; If none available, create a new one. | ||
163 | * | ||
164 | ******************************************************************************/ | ||
165 | |||
166 | union acpi_generic_state * | ||
167 | acpi_ut_create_generic_state ( | ||
168 | void) | ||
169 | { | ||
170 | union acpi_generic_state *state; | ||
171 | |||
172 | |||
173 | ACPI_FUNCTION_ENTRY (); | ||
174 | |||
175 | |||
176 | state = acpi_os_acquire_object (acpi_gbl_state_cache); | ||
177 | if (state) { | ||
178 | /* Initialize */ | ||
179 | memset(state, 0, sizeof(union acpi_generic_state)); | ||
180 | state->common.data_type = ACPI_DESC_TYPE_STATE; | ||
181 | } | ||
182 | |||
183 | return (state); | ||
184 | } | ||
185 | |||
186 | |||
187 | /******************************************************************************* | ||
188 | * | ||
189 | * FUNCTION: acpi_ut_create_thread_state | ||
190 | * | ||
191 | * PARAMETERS: None | ||
192 | * | ||
193 | * RETURN: New Thread State. NULL on failure | ||
194 | * | ||
195 | * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used | ||
196 | * to track per-thread info during method execution | ||
197 | * | ||
198 | ******************************************************************************/ | ||
199 | |||
200 | struct acpi_thread_state * | ||
201 | acpi_ut_create_thread_state ( | ||
202 | void) | ||
203 | { | ||
204 | union acpi_generic_state *state; | ||
205 | |||
206 | |||
207 | ACPI_FUNCTION_TRACE ("ut_create_thread_state"); | ||
208 | |||
209 | |||
210 | /* Create the generic state object */ | ||
211 | |||
212 | state = acpi_ut_create_generic_state (); | ||
213 | if (!state) { | ||
214 | return_PTR (NULL); | ||
215 | } | ||
216 | |||
217 | /* Init fields specific to the update struct */ | ||
218 | |||
219 | state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; | ||
220 | state->thread.thread_id = acpi_os_get_thread_id (); | ||
221 | |||
222 | return_PTR ((struct acpi_thread_state *) state); | ||
223 | } | ||
224 | |||
225 | |||
226 | /******************************************************************************* | ||
227 | * | ||
228 | * FUNCTION: acpi_ut_create_update_state | ||
229 | * | ||
230 | * PARAMETERS: Object - Initial Object to be installed in the state | ||
231 | * Action - Update action to be performed | ||
232 | * | ||
233 | * RETURN: New state object, null on failure | ||
234 | * | ||
235 | * DESCRIPTION: Create an "Update State" - a flavor of the generic state used | ||
236 | * to update reference counts and delete complex objects such | ||
237 | * as packages. | ||
238 | * | ||
239 | ******************************************************************************/ | ||
240 | |||
241 | union acpi_generic_state * | ||
242 | acpi_ut_create_update_state ( | ||
243 | union acpi_operand_object *object, | ||
244 | u16 action) | ||
245 | { | ||
246 | union acpi_generic_state *state; | ||
247 | |||
248 | |||
249 | ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object); | ||
250 | |||
251 | |||
252 | /* Create the generic state object */ | ||
253 | |||
254 | state = acpi_ut_create_generic_state (); | ||
255 | if (!state) { | ||
256 | return_PTR (NULL); | ||
257 | } | ||
258 | |||
259 | /* Init fields specific to the update struct */ | ||
260 | |||
261 | state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; | ||
262 | state->update.object = object; | ||
263 | state->update.value = action; | ||
264 | |||
265 | return_PTR (state); | ||
266 | } | ||
267 | |||
268 | |||
269 | /******************************************************************************* | ||
270 | * | ||
271 | * FUNCTION: acpi_ut_create_pkg_state | ||
272 | * | ||
273 | * PARAMETERS: Object - Initial Object to be installed in the state | ||
274 | * Action - Update action to be performed | ||
275 | * | ||
276 | * RETURN: New state object, null on failure | ||
277 | * | ||
278 | * DESCRIPTION: Create a "Package State" | ||
279 | * | ||
280 | ******************************************************************************/ | ||
281 | |||
282 | union acpi_generic_state * | ||
283 | acpi_ut_create_pkg_state ( | ||
284 | void *internal_object, | ||
285 | void *external_object, | ||
286 | u16 index) | ||
287 | { | ||
288 | union acpi_generic_state *state; | ||
289 | |||
290 | |||
291 | ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object); | ||
292 | |||
293 | |||
294 | /* Create the generic state object */ | ||
295 | |||
296 | state = acpi_ut_create_generic_state (); | ||
297 | if (!state) { | ||
298 | return_PTR (NULL); | ||
299 | } | ||
300 | |||
301 | /* Init fields specific to the update struct */ | ||
302 | |||
303 | state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; | ||
304 | state->pkg.source_object = (union acpi_operand_object *) internal_object; | ||
305 | state->pkg.dest_object = external_object; | ||
306 | state->pkg.index = index; | ||
307 | state->pkg.num_packages = 1; | ||
308 | |||
309 | return_PTR (state); | ||
310 | } | ||
311 | |||
312 | |||
313 | /******************************************************************************* | ||
314 | * | ||
315 | * FUNCTION: acpi_ut_create_control_state | ||
316 | * | ||
317 | * PARAMETERS: None | ||
318 | * | ||
319 | * RETURN: New state object, null on failure | ||
320 | * | ||
321 | * DESCRIPTION: Create a "Control State" - a flavor of the generic state used | ||
322 | * to support nested IF/WHILE constructs in the AML. | ||
323 | * | ||
324 | ******************************************************************************/ | ||
325 | |||
326 | union acpi_generic_state * | ||
327 | acpi_ut_create_control_state ( | ||
328 | void) | ||
329 | { | ||
330 | union acpi_generic_state *state; | ||
331 | |||
332 | |||
333 | ACPI_FUNCTION_TRACE ("ut_create_control_state"); | ||
334 | |||
335 | |||
336 | /* Create the generic state object */ | ||
337 | |||
338 | state = acpi_ut_create_generic_state (); | ||
339 | if (!state) { | ||
340 | return_PTR (NULL); | ||
341 | } | ||
342 | |||
343 | /* Init fields specific to the control struct */ | ||
344 | |||
345 | state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; | ||
346 | state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; | ||
347 | |||
348 | return_PTR (state); | ||
349 | } | ||
350 | |||
351 | |||
352 | /******************************************************************************* | ||
353 | * | ||
354 | * FUNCTION: acpi_ut_delete_generic_state | ||
355 | * | ||
356 | * PARAMETERS: State - The state object to be deleted | ||
357 | * | ||
358 | * RETURN: None | ||
359 | * | ||
360 | * DESCRIPTION: Put a state object back into the global state cache. The object | ||
361 | * is not actually freed at this time. | ||
362 | * | ||
363 | ******************************************************************************/ | ||
364 | |||
365 | void | ||
366 | acpi_ut_delete_generic_state ( | ||
367 | union acpi_generic_state *state) | ||
368 | { | ||
369 | ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); | ||
370 | |||
371 | |||
372 | (void) acpi_os_release_object (acpi_gbl_state_cache, state); | ||
373 | return_VOID; | ||
374 | } | ||
375 | |||
376 | |||
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index e8803d810656..850da6817423 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c | |||
@@ -46,8 +46,6 @@ | |||
46 | #include <acpi/acpi.h> | 46 | #include <acpi/acpi.h> |
47 | #include <acpi/acevents.h> | 47 | #include <acpi/acevents.h> |
48 | #include <acpi/acnamesp.h> | 48 | #include <acpi/acnamesp.h> |
49 | #include <acpi/acparser.h> | ||
50 | #include <acpi/acdispat.h> | ||
51 | #include <acpi/acdebug.h> | 49 | #include <acpi/acdebug.h> |
52 | 50 | ||
53 | #define _COMPONENT ACPI_UTILITIES | 51 | #define _COMPONENT ACPI_UTILITIES |
@@ -79,11 +77,6 @@ acpi_initialize_subsystem ( | |||
79 | 77 | ||
80 | ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); | 78 | ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); |
81 | 79 | ||
82 | |||
83 | /* Initialize all globals used by the subsystem */ | ||
84 | |||
85 | acpi_ut_init_globals (); | ||
86 | |||
87 | /* Initialize the OS-Dependent layer */ | 80 | /* Initialize the OS-Dependent layer */ |
88 | 81 | ||
89 | status = acpi_os_initialize (); | 82 | status = acpi_os_initialize (); |
@@ -93,6 +86,10 @@ acpi_initialize_subsystem ( | |||
93 | return_ACPI_STATUS (status); | 86 | return_ACPI_STATUS (status); |
94 | } | 87 | } |
95 | 88 | ||
89 | /* Initialize all globals used by the subsystem */ | ||
90 | |||
91 | acpi_ut_init_globals (); | ||
92 | |||
96 | /* Create the default mutex objects */ | 93 | /* Create the default mutex objects */ |
97 | 94 | ||
98 | status = acpi_ut_mutex_initialize (); | 95 | status = acpi_ut_mutex_initialize (); |
@@ -522,13 +519,9 @@ acpi_purge_cached_objects ( | |||
522 | { | 519 | { |
523 | ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); | 520 | ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); |
524 | 521 | ||
525 | 522 | (void) acpi_os_purge_cache (acpi_gbl_state_cache); | |
526 | #ifdef ACPI_ENABLE_OBJECT_CACHE | 523 | (void) acpi_os_purge_cache (acpi_gbl_operand_cache); |
527 | acpi_ut_delete_generic_state_cache (); | 524 | (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache); |
528 | acpi_ut_delete_object_cache (); | 525 | (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache); |
529 | acpi_ds_delete_walk_state_cache (); | ||
530 | acpi_ps_delete_parse_cache (); | ||
531 | #endif | ||
532 | |||
533 | return_ACPI_STATUS (AE_OK); | 526 | return_ACPI_STATUS (AE_OK); |
534 | } | 527 | } |