aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r--drivers/acpi/utilities/utalloc.c59
-rw-r--r--drivers/acpi/utilities/utcopy.c29
-rw-r--r--drivers/acpi/utilities/utdelete.c25
-rw-r--r--drivers/acpi/utilities/utglobal.c52
-rw-r--r--drivers/acpi/utilities/utmisc.c9
-rw-r--r--drivers/acpi/utilities/utobject.c28
-rw-r--r--drivers/acpi/utilities/utxface.c7
7 files changed, 149 insertions, 60 deletions
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 3dfb8a442b26..241c535c1753 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -232,7 +232,7 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
232 * RETURN: Status 232 * RETURN: Status
233 * 233 *
234 * DESCRIPTION: Validate that the buffer is of the required length or 234 * DESCRIPTION: Validate that the buffer is of the required length or
235 * allocate a new buffer. Returned buffer is always zeroed. 235 * allocate a new buffer. Returned buffer is always zeroed.
236 * 236 *
237 ******************************************************************************/ 237 ******************************************************************************/
238 238
@@ -240,57 +240,66 @@ acpi_status
240acpi_ut_initialize_buffer(struct acpi_buffer * buffer, 240acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
241 acpi_size required_length) 241 acpi_size required_length)
242{ 242{
243 acpi_status status = AE_OK; 243 acpi_size input_buffer_length;
244 244
245 switch (buffer->length) { 245 /* Parameter validation */
246
247 if (!buffer || !required_length) {
248 return (AE_BAD_PARAMETER);
249 }
250
251 /*
252 * Buffer->Length is used as both an input and output parameter. Get the
253 * input actual length and set the output required buffer length.
254 */
255 input_buffer_length = buffer->length;
256 buffer->length = required_length;
257
258 /*
259 * The input buffer length contains the actual buffer length, or the type
260 * of buffer to be allocated by this routine.
261 */
262 switch (input_buffer_length) {
246 case ACPI_NO_BUFFER: 263 case ACPI_NO_BUFFER:
247 264
248 /* Set the exception and returned the required length */ 265 /* Return the exception (and the required buffer length) */
249 266
250 status = AE_BUFFER_OVERFLOW; 267 return (AE_BUFFER_OVERFLOW);
251 break;
252 268
253 case ACPI_ALLOCATE_BUFFER: 269 case ACPI_ALLOCATE_BUFFER:
254 270
255 /* Allocate a new buffer */ 271 /* Allocate a new buffer */
256 272
257 buffer->pointer = acpi_os_allocate(required_length); 273 buffer->pointer = acpi_os_allocate(required_length);
258 if (!buffer->pointer) {
259 return (AE_NO_MEMORY);
260 }
261
262 /* Clear the buffer */
263
264 ACPI_MEMSET(buffer->pointer, 0, required_length);
265 break; 274 break;
266 275
267 case ACPI_ALLOCATE_LOCAL_BUFFER: 276 case ACPI_ALLOCATE_LOCAL_BUFFER:
268 277
269 /* Allocate a new buffer with local interface to allow tracking */ 278 /* Allocate a new buffer with local interface to allow tracking */
270 279
271 buffer->pointer = ACPI_ALLOCATE_ZEROED(required_length); 280 buffer->pointer = ACPI_ALLOCATE(required_length);
272 if (!buffer->pointer) {
273 return (AE_NO_MEMORY);
274 }
275 break; 281 break;
276 282
277 default: 283 default:
278 284
279 /* Existing buffer: Validate the size of the buffer */ 285 /* Existing buffer: Validate the size of the buffer */
280 286
281 if (buffer->length < required_length) { 287 if (input_buffer_length < required_length) {
282 status = AE_BUFFER_OVERFLOW; 288 return (AE_BUFFER_OVERFLOW);
283 break;
284 } 289 }
290 break;
291 }
285 292
286 /* Clear the buffer */ 293 /* Validate allocation from above or input buffer pointer */
287 294
288 ACPI_MEMSET(buffer->pointer, 0, required_length); 295 if (!buffer->pointer) {
289 break; 296 return (AE_NO_MEMORY);
290 } 297 }
291 298
292 buffer->length = required_length; 299 /* Have a valid buffer, clear it */
293 return (status); 300
301 ACPI_MEMSET(buffer->pointer, 0, required_length);
302 return (AE_OK);
294} 303}
295 304
296#ifdef NOT_USED_BY_LINUX 305#ifdef NOT_USED_BY_LINUX
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 53499ac90988..5b2f7c27b705 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -42,7 +42,6 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48 47
@@ -176,20 +175,24 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
176 175
177 /* This is an object reference. */ 176 /* This is an object reference. */
178 177
179 switch (internal_object->reference.opcode) { 178 switch (internal_object->reference.class) {
180 case AML_INT_NAMEPATH_OP: 179 case ACPI_REFCLASS_NAME:
181
182 /* For namepath, return the object handle ("reference") */
183
184 default:
185
186 /* We are referring to the namespace node */
187 180
181 /*
182 * For namepath, return the object handle ("reference")
183 * We are referring to the namespace node
184 */
188 external_object->reference.handle = 185 external_object->reference.handle =
189 internal_object->reference.node; 186 internal_object->reference.node;
190 external_object->reference.actual_type = 187 external_object->reference.actual_type =
191 acpi_ns_get_type(internal_object->reference.node); 188 acpi_ns_get_type(internal_object->reference.node);
192 break; 189 break;
190
191 default:
192
193 /* All other reference types are unsupported */
194
195 return_ACPI_STATUS(AE_TYPE);
193 } 196 }
194 break; 197 break;
195 198
@@ -533,7 +536,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
533 536
534 /* TBD: should validate incoming handle */ 537 /* TBD: should validate incoming handle */
535 538
536 internal_object->reference.opcode = AML_INT_NAMEPATH_OP; 539 internal_object->reference.class = ACPI_REFCLASS_NAME;
537 internal_object->reference.node = 540 internal_object->reference.node =
538 external_object->reference.handle; 541 external_object->reference.handle;
539 break; 542 break;
@@ -743,11 +746,11 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
743 * We copied the reference object, so we now must add a reference 746 * We copied the reference object, so we now must add a reference
744 * to the object pointed to by the reference 747 * to the object pointed to by the reference
745 * 748 *
746 * DDBHandle reference (from Load/load_table is a special reference, 749 * DDBHandle reference (from Load/load_table) is a special reference,
747 * it's Reference.Object is the table index, so does not need to 750 * it does not have a Reference.Object, so does not need to
748 * increase the reference count 751 * increase the reference count
749 */ 752 */
750 if (source_desc->reference.opcode == AML_LOAD_OP) { 753 if (source_desc->reference.class == ACPI_REFCLASS_TABLE) {
751 break; 754 break;
752 } 755 }
753 756
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index c5c791a575c9..d197c6b29e17 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -45,7 +45,6 @@
45#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47#include <acpi/acevents.h> 47#include <acpi/acevents.h>
48#include <acpi/amlcode.h>
49 48
50#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utdelete") 50ACPI_MODULE_NAME("utdelete")
@@ -135,6 +134,10 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
135 obj_pointer = object->package.elements; 134 obj_pointer = object->package.elements;
136 break; 135 break;
137 136
137 /*
138 * These objects have a possible list of notify handlers.
139 * Device object also may have a GPE block.
140 */
138 case ACPI_TYPE_DEVICE: 141 case ACPI_TYPE_DEVICE:
139 142
140 if (object->device.gpe_block) { 143 if (object->device.gpe_block) {
@@ -142,9 +145,14 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
142 gpe_block); 145 gpe_block);
143 } 146 }
144 147
145 /* Walk the handler list for this device */ 148 /*lint -fallthrough */
149
150 case ACPI_TYPE_PROCESSOR:
151 case ACPI_TYPE_THERMAL:
152
153 /* Walk the notify handler list for this object */
146 154
147 handler_desc = object->device.handler; 155 handler_desc = object->common_notify.handler;
148 while (handler_desc) { 156 while (handler_desc) {
149 next_desc = handler_desc->address_space.next; 157 next_desc = handler_desc->address_space.next;
150 acpi_ut_remove_reference(handler_desc); 158 acpi_ut_remove_reference(handler_desc);
@@ -539,8 +547,8 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
539 * reference must track changes to the ref count of the index or 547 * reference must track changes to the ref count of the index or
540 * target object. 548 * target object.
541 */ 549 */
542 if ((object->reference.opcode == AML_INDEX_OP) || 550 if ((object->reference.class == ACPI_REFCLASS_INDEX) ||
543 (object->reference.opcode == AML_INT_NAMEPATH_OP)) { 551 (object->reference.class == ACPI_REFCLASS_NAME)) {
544 next_object = object->reference.object; 552 next_object = object->reference.object;
545 } 553 }
546 break; 554 break;
@@ -577,6 +585,13 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
577 ACPI_EXCEPTION((AE_INFO, status, 585 ACPI_EXCEPTION((AE_INFO, status,
578 "Could not update object reference count")); 586 "Could not update object reference count"));
579 587
588 /* Free any stacked Update State objects */
589
590 while (state_list) {
591 state = acpi_ut_pop_generic_state(&state_list);
592 acpi_ut_delete_generic_state(state);
593 }
594
580 return_ACPI_STATUS(status); 595 return_ACPI_STATUS(status);
581} 596}
582 597
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index a6e71b801d2d..670551b95e56 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -281,7 +281,6 @@ struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
281 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 281 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
282 ACPI_BITPOSITION_RT_CLOCK_ENABLE, 282 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
283 ACPI_BITMASK_RT_CLOCK_ENABLE}, 283 ACPI_BITMASK_RT_CLOCK_ENABLE},
284 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
285 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, 284 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
286 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, 285 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
287 ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 286 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
@@ -575,6 +574,47 @@ char *acpi_ut_get_descriptor_name(void *object)
575 574
576} 575}
577 576
577/*******************************************************************************
578 *
579 * FUNCTION: acpi_ut_get_reference_name
580 *
581 * PARAMETERS: Object - An ACPI reference object
582 *
583 * RETURN: Pointer to a string
584 *
585 * DESCRIPTION: Decode a reference object sub-type to a string.
586 *
587 ******************************************************************************/
588
589/* Printable names of reference object sub-types */
590
591static const char *acpi_gbl_ref_class_names[] = {
592 /* 00 */ "Local",
593 /* 01 */ "Argument",
594 /* 02 */ "RefOf",
595 /* 03 */ "Index",
596 /* 04 */ "DdbHandle",
597 /* 05 */ "Named Object",
598 /* 06 */ "Debug"
599};
600
601const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
602{
603 if (!object)
604 return "NULL Object";
605
606 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND)
607 return "Not an Operand object";
608
609 if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE)
610 return "Not a Reference object";
611
612 if (object->reference.class > ACPI_REFCLASS_MAX)
613 return "Unknown Reference class";
614
615 return acpi_gbl_ref_class_names[object->reference.class];
616}
617
578#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 618#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
579/* 619/*
580 * Strings and procedures used for debug only 620 * Strings and procedures used for debug only
@@ -677,14 +717,14 @@ u8 acpi_ut_valid_object_type(acpi_object_type type)
677 * 717 *
678 * PARAMETERS: None 718 * PARAMETERS: None
679 * 719 *
680 * RETURN: None 720 * RETURN: Status
681 * 721 *
682 * DESCRIPTION: Init library globals. All globals that require specific 722 * DESCRIPTION: Init library globals. All globals that require specific
683 * initialization should be initialized here! 723 * initialization should be initialized here!
684 * 724 *
685 ******************************************************************************/ 725 ******************************************************************************/
686 726
687void acpi_ut_init_globals(void) 727acpi_status acpi_ut_init_globals(void)
688{ 728{
689 acpi_status status; 729 acpi_status status;
690 u32 i; 730 u32 i;
@@ -695,7 +735,7 @@ void acpi_ut_init_globals(void)
695 735
696 status = acpi_ut_create_caches(); 736 status = acpi_ut_create_caches();
697 if (ACPI_FAILURE(status)) { 737 if (ACPI_FAILURE(status)) {
698 return; 738 return_ACPI_STATUS(status);
699 } 739 }
700 740
701 /* Mutex locked flags */ 741 /* Mutex locked flags */
@@ -772,8 +812,8 @@ void acpi_ut_init_globals(void)
772 acpi_gbl_display_final_mem_stats = FALSE; 812 acpi_gbl_display_final_mem_stats = FALSE;
773#endif 813#endif
774 814
775 return_VOID; 815 return_ACPI_STATUS(AE_OK);
776} 816}
777 817
778ACPI_EXPORT_SYMBOL(acpi_dbg_level) 818ACPI_EXPORT_SYMBOL(acpi_dbg_level)
779 ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 819ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index f34be6773556..9089a158a874 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -995,6 +995,15 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
995 state->pkg. 995 state->pkg.
996 this_target_obj, 0); 996 this_target_obj, 0);
997 if (!state) { 997 if (!state) {
998
999 /* Free any stacked Update State objects */
1000
1001 while (state_list) {
1002 state =
1003 acpi_ut_pop_generic_state
1004 (&state_list);
1005 acpi_ut_delete_generic_state(state);
1006 }
998 return_ACPI_STATUS(AE_NO_MEMORY); 1007 return_ACPI_STATUS(AE_NO_MEMORY);
999 } 1008 }
1000 } 1009 }
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index e25484495e65..c354e7a42bcd 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/amlcode.h>
47 46
48#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utobject") 48ACPI_MODULE_NAME("utobject")
@@ -425,6 +424,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
425 acpi_size * obj_length) 424 acpi_size * obj_length)
426{ 425{
427 acpi_size length; 426 acpi_size length;
427 acpi_size size;
428 acpi_status status = AE_OK; 428 acpi_status status = AE_OK;
429 429
430 ACPI_FUNCTION_TRACE_PTR(ut_get_simple_object_size, internal_object); 430 ACPI_FUNCTION_TRACE_PTR(ut_get_simple_object_size, internal_object);
@@ -477,17 +477,21 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
477 477
478 case ACPI_TYPE_LOCAL_REFERENCE: 478 case ACPI_TYPE_LOCAL_REFERENCE:
479 479
480 switch (internal_object->reference.opcode) { 480 switch (internal_object->reference.class) {
481 case AML_INT_NAMEPATH_OP: 481 case ACPI_REFCLASS_NAME:
482 482
483 /* 483 /*
484 * Get the actual length of the full pathname to this object. 484 * Get the actual length of the full pathname to this object.
485 * The reference will be converted to the pathname to the object 485 * The reference will be converted to the pathname to the object
486 */ 486 */
487 length += 487 size =
488 ACPI_ROUND_UP_TO_NATIVE_WORD 488 acpi_ns_get_pathname_length(internal_object->
489 (acpi_ns_get_pathname_length 489 reference.node);
490 (internal_object->reference.node)); 490 if (!size) {
491 return_ACPI_STATUS(AE_BAD_PARAMETER);
492 }
493
494 length += ACPI_ROUND_UP_TO_NATIVE_WORD(size);
491 break; 495 break;
492 496
493 default: 497 default:
@@ -498,8 +502,10 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
498 * required eventually. 502 * required eventually.
499 */ 503 */
500 ACPI_ERROR((AE_INFO, 504 ACPI_ERROR((AE_INFO,
501 "Unsupported Reference opcode=%X in object %p", 505 "Cannot convert to external object - "
502 internal_object->reference.opcode, 506 "unsupported Reference Class [%s] %X in object %p",
507 acpi_ut_get_reference_name(internal_object),
508 internal_object->reference.class,
503 internal_object)); 509 internal_object));
504 status = AE_TYPE; 510 status = AE_TYPE;
505 break; 511 break;
@@ -508,7 +514,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
508 514
509 default: 515 default:
510 516
511 ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p", 517 ACPI_ERROR((AE_INFO, "Cannot convert to external object - "
518 "unsupported type [%s] %X in object %p",
519 acpi_ut_get_object_type_name(internal_object),
512 ACPI_GET_OBJECT_TYPE(internal_object), 520 ACPI_GET_OBJECT_TYPE(internal_object),
513 internal_object)); 521 internal_object));
514 status = AE_TYPE; 522 status = AE_TYPE;
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index f8bdadf3c32f..c198a4d40583 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -81,7 +81,12 @@ acpi_status __init acpi_initialize_subsystem(void)
81 81
82 /* Initialize all globals used by the subsystem */ 82 /* Initialize all globals used by the subsystem */
83 83
84 acpi_ut_init_globals(); 84 status = acpi_ut_init_globals();
85 if (ACPI_FAILURE(status)) {
86 ACPI_EXCEPTION((AE_INFO, status,
87 "During initialization of globals"));
88 return_ACPI_STATUS(status);
89 }
85 90
86 /* Create the default mutex objects */ 91 /* Create the default mutex objects */
87 92