diff options
Diffstat (limited to 'drivers/acpi/acpica/nspredef.c')
-rw-r--r-- | drivers/acpi/acpica/nspredef.c | 213 |
1 files changed, 56 insertions, 157 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 224c30053401..8a52916148cb 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
@@ -76,19 +76,7 @@ static acpi_status | |||
76 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 76 | acpi_ns_check_reference(struct acpi_predefined_data *data, |
77 | union acpi_operand_object *return_object); | 77 | union acpi_operand_object *return_object); |
78 | 78 | ||
79 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); | 79 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); |
80 | |||
81 | /* | ||
82 | * Names for the types that can be returned by the predefined objects. | ||
83 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs | ||
84 | */ | ||
85 | static const char *acpi_rtype_names[] = { | ||
86 | "/Integer", | ||
87 | "/String", | ||
88 | "/Buffer", | ||
89 | "/Package", | ||
90 | "/Reference", | ||
91 | }; | ||
92 | 80 | ||
93 | /******************************************************************************* | 81 | /******************************************************************************* |
94 | * | 82 | * |
@@ -112,7 +100,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
112 | acpi_status return_status, | 100 | acpi_status return_status, |
113 | union acpi_operand_object **return_object_ptr) | 101 | union acpi_operand_object **return_object_ptr) |
114 | { | 102 | { |
115 | union acpi_operand_object *return_object = *return_object_ptr; | ||
116 | acpi_status status = AE_OK; | 103 | acpi_status status = AE_OK; |
117 | const union acpi_predefined_info *predefined; | 104 | const union acpi_predefined_info *predefined; |
118 | char *pathname; | 105 | char *pathname; |
@@ -120,7 +107,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
120 | 107 | ||
121 | /* Match the name for this method/object against the predefined list */ | 108 | /* Match the name for this method/object against the predefined list */ |
122 | 109 | ||
123 | predefined = acpi_ns_check_for_predefined_name(node); | 110 | predefined = acpi_ut_match_predefined_method(node->name.ascii); |
124 | 111 | ||
125 | /* Get the full pathname to the object, for use in warning messages */ | 112 | /* Get the full pathname to the object, for use in warning messages */ |
126 | 113 | ||
@@ -152,25 +139,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
152 | } | 139 | } |
153 | 140 | ||
154 | /* | 141 | /* |
155 | * If there is no return value, check if we require a return value for | ||
156 | * this predefined name. Either one return value is expected, or none, | ||
157 | * for both methods and other objects. | ||
158 | * | ||
159 | * Exit now if there is no return object. Warning if one was expected. | ||
160 | */ | ||
161 | if (!return_object) { | ||
162 | if ((predefined->info.expected_btypes) && | ||
163 | (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { | ||
164 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
165 | ACPI_WARN_ALWAYS, | ||
166 | "Missing expected return value")); | ||
167 | |||
168 | status = AE_AML_NO_RETURN_VALUE; | ||
169 | } | ||
170 | goto cleanup; | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Return value validation and possible repair. | 142 | * Return value validation and possible repair. |
175 | * | 143 | * |
176 | * 1) Don't perform return value validation/repair if this feature | 144 | * 1) Don't perform return value validation/repair if this feature |
@@ -310,8 +278,10 @@ acpi_ns_check_parameter_count(char *pathname, | |||
310 | * Validate the user-supplied parameter count. | 278 | * Validate the user-supplied parameter count. |
311 | * Allow two different legal argument counts (_SCP, etc.) | 279 | * Allow two different legal argument counts (_SCP, etc.) |
312 | */ | 280 | */ |
313 | required_params_current = predefined->info.param_count & 0x0F; | 281 | required_params_current = |
314 | required_params_old = predefined->info.param_count >> 4; | 282 | predefined->info.argument_list & METHOD_ARG_MASK; |
283 | required_params_old = | ||
284 | predefined->info.argument_list >> METHOD_ARG_BIT_WIDTH; | ||
315 | 285 | ||
316 | if (user_param_count != ACPI_UINT32_MAX) { | 286 | if (user_param_count != ACPI_UINT32_MAX) { |
317 | if ((user_param_count != required_params_current) && | 287 | if ((user_param_count != required_params_current) && |
@@ -340,52 +310,6 @@ acpi_ns_check_parameter_count(char *pathname, | |||
340 | 310 | ||
341 | /******************************************************************************* | 311 | /******************************************************************************* |
342 | * | 312 | * |
343 | * FUNCTION: acpi_ns_check_for_predefined_name | ||
344 | * | ||
345 | * PARAMETERS: node - Namespace node for the method/object | ||
346 | * | ||
347 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. | ||
348 | * | ||
349 | * DESCRIPTION: Check an object name against the predefined object list. | ||
350 | * | ||
351 | ******************************************************************************/ | ||
352 | |||
353 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | ||
354 | acpi_namespace_node | ||
355 | *node) | ||
356 | { | ||
357 | const union acpi_predefined_info *this_name; | ||
358 | |||
359 | /* Quick check for a predefined name, first character must be underscore */ | ||
360 | |||
361 | if (node->name.ascii[0] != '_') { | ||
362 | return (NULL); | ||
363 | } | ||
364 | |||
365 | /* Search info table for a predefined method/object name */ | ||
366 | |||
367 | this_name = predefined_names; | ||
368 | while (this_name->info.name[0]) { | ||
369 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { | ||
370 | return (this_name); | ||
371 | } | ||
372 | |||
373 | /* | ||
374 | * Skip next entry in the table if this name returns a Package | ||
375 | * (next entry contains the package info) | ||
376 | */ | ||
377 | if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) { | ||
378 | this_name++; | ||
379 | } | ||
380 | |||
381 | this_name++; | ||
382 | } | ||
383 | |||
384 | return (NULL); /* Not found */ | ||
385 | } | ||
386 | |||
387 | /******************************************************************************* | ||
388 | * | ||
389 | * FUNCTION: acpi_ns_check_object_type | 313 | * FUNCTION: acpi_ns_check_object_type |
390 | * | 314 | * |
391 | * PARAMETERS: data - Pointer to validation data structure | 315 | * PARAMETERS: data - Pointer to validation data structure |
@@ -410,28 +334,12 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
410 | { | 334 | { |
411 | union acpi_operand_object *return_object = *return_object_ptr; | 335 | union acpi_operand_object *return_object = *return_object_ptr; |
412 | acpi_status status = AE_OK; | 336 | acpi_status status = AE_OK; |
413 | u32 return_btype; | ||
414 | char type_buffer[48]; /* Room for 5 types */ | 337 | char type_buffer[48]; /* Room for 5 types */ |
415 | 338 | ||
416 | /* | ||
417 | * If we get a NULL return_object here, it is a NULL package element. | ||
418 | * Since all extraneous NULL package elements were removed earlier by a | ||
419 | * call to acpi_ns_remove_null_elements, this is an unexpected NULL element. | ||
420 | * We will attempt to repair it. | ||
421 | */ | ||
422 | if (!return_object) { | ||
423 | status = acpi_ns_repair_null_element(data, expected_btypes, | ||
424 | package_index, | ||
425 | return_object_ptr); | ||
426 | if (ACPI_SUCCESS(status)) { | ||
427 | return (AE_OK); /* Repair was successful */ | ||
428 | } | ||
429 | goto type_error_exit; | ||
430 | } | ||
431 | |||
432 | /* A Namespace node should not get here, but make sure */ | 339 | /* A Namespace node should not get here, but make sure */ |
433 | 340 | ||
434 | if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | 341 | if (return_object && |
342 | ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | ||
435 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 343 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
436 | "Invalid return type - Found a Namespace node [%4.4s] type %s", | 344 | "Invalid return type - Found a Namespace node [%4.4s] type %s", |
437 | return_object->node.name.ascii, | 345 | return_object->node.name.ascii, |
@@ -448,59 +356,31 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
448 | * from all of the predefined names (including elements of returned | 356 | * from all of the predefined names (including elements of returned |
449 | * packages) | 357 | * packages) |
450 | */ | 358 | */ |
451 | switch (return_object->common.type) { | 359 | data->return_btype = acpi_ns_get_bitmapped_type(return_object); |
452 | case ACPI_TYPE_INTEGER: | 360 | if (data->return_btype == ACPI_RTYPE_ANY) { |
453 | return_btype = ACPI_RTYPE_INTEGER; | ||
454 | break; | ||
455 | |||
456 | case ACPI_TYPE_BUFFER: | ||
457 | return_btype = ACPI_RTYPE_BUFFER; | ||
458 | break; | ||
459 | |||
460 | case ACPI_TYPE_STRING: | ||
461 | return_btype = ACPI_RTYPE_STRING; | ||
462 | break; | ||
463 | 361 | ||
464 | case ACPI_TYPE_PACKAGE: | ||
465 | return_btype = ACPI_RTYPE_PACKAGE; | ||
466 | break; | ||
467 | |||
468 | case ACPI_TYPE_LOCAL_REFERENCE: | ||
469 | return_btype = ACPI_RTYPE_REFERENCE; | ||
470 | break; | ||
471 | |||
472 | default: | ||
473 | /* Not one of the supported objects, must be incorrect */ | 362 | /* Not one of the supported objects, must be incorrect */ |
474 | |||
475 | goto type_error_exit; | 363 | goto type_error_exit; |
476 | } | 364 | } |
477 | 365 | ||
478 | /* Is the object one of the expected types? */ | 366 | /* For reference objects, check that the reference type is correct */ |
479 | |||
480 | if (return_btype & expected_btypes) { | ||
481 | |||
482 | /* For reference objects, check that the reference type is correct */ | ||
483 | |||
484 | if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { | ||
485 | status = acpi_ns_check_reference(data, return_object); | ||
486 | } | ||
487 | 367 | ||
368 | if ((data->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) { | ||
369 | status = acpi_ns_check_reference(data, return_object); | ||
488 | return (status); | 370 | return (status); |
489 | } | 371 | } |
490 | 372 | ||
491 | /* Type mismatch -- attempt repair of the returned object */ | 373 | /* Attempt simple repair of the returned object if necessary */ |
492 | 374 | ||
493 | status = acpi_ns_repair_object(data, expected_btypes, | 375 | status = acpi_ns_simple_repair(data, expected_btypes, |
494 | package_index, return_object_ptr); | 376 | package_index, return_object_ptr); |
495 | if (ACPI_SUCCESS(status)) { | 377 | return (status); |
496 | return (AE_OK); /* Repair was successful */ | ||
497 | } | ||
498 | 378 | ||
499 | type_error_exit: | 379 | type_error_exit: |
500 | 380 | ||
501 | /* Create a string with all expected types for this predefined object */ | 381 | /* Create a string with all expected types for this predefined object */ |
502 | 382 | ||
503 | acpi_ns_get_expected_types(type_buffer, expected_btypes); | 383 | acpi_ut_get_expected_return_types(type_buffer, expected_btypes); |
504 | 384 | ||
505 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { | 385 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { |
506 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 386 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
@@ -558,36 +438,55 @@ acpi_ns_check_reference(struct acpi_predefined_data *data, | |||
558 | 438 | ||
559 | /******************************************************************************* | 439 | /******************************************************************************* |
560 | * | 440 | * |
561 | * FUNCTION: acpi_ns_get_expected_types | 441 | * FUNCTION: acpi_ns_get_bitmapped_type |
562 | * | 442 | * |
563 | * PARAMETERS: buffer - Pointer to where the string is returned | 443 | * PARAMETERS: return_object - Object returned from method/obj evaluation |
564 | * expected_btypes - Bitmap of expected return type(s) | ||
565 | * | 444 | * |
566 | * RETURN: Buffer is populated with type names. | 445 | * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object |
446 | * type is not supported. ACPI_RTYPE_NONE indicates that no | ||
447 | * object was returned (return_object is NULL). | ||
567 | * | 448 | * |
568 | * DESCRIPTION: Translate the expected types bitmap into a string of ascii | 449 | * DESCRIPTION: Convert object type into a bitmapped object return type. |
569 | * names of expected types, for use in warning messages. | ||
570 | * | 450 | * |
571 | ******************************************************************************/ | 451 | ******************************************************************************/ |
572 | 452 | ||
573 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes) | 453 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) |
574 | { | 454 | { |
575 | u32 this_rtype; | 455 | u32 return_btype; |
576 | u32 i; | ||
577 | u32 j; | ||
578 | 456 | ||
579 | j = 1; | 457 | if (!return_object) { |
580 | buffer[0] = 0; | 458 | return (ACPI_RTYPE_NONE); |
581 | this_rtype = ACPI_RTYPE_INTEGER; | 459 | } |
582 | 460 | ||
583 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { | 461 | /* Map acpi_object_type to internal bitmapped type */ |
584 | 462 | ||
585 | /* If one of the expected types, concatenate the name of this type */ | 463 | switch (return_object->common.type) { |
464 | case ACPI_TYPE_INTEGER: | ||
465 | return_btype = ACPI_RTYPE_INTEGER; | ||
466 | break; | ||
586 | 467 | ||
587 | if (expected_btypes & this_rtype) { | 468 | case ACPI_TYPE_BUFFER: |
588 | ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]); | 469 | return_btype = ACPI_RTYPE_BUFFER; |
589 | j = 0; /* Use name separator from now on */ | 470 | break; |
590 | } | 471 | |
591 | this_rtype <<= 1; /* Next Rtype */ | 472 | case ACPI_TYPE_STRING: |
473 | return_btype = ACPI_RTYPE_STRING; | ||
474 | break; | ||
475 | |||
476 | case ACPI_TYPE_PACKAGE: | ||
477 | return_btype = ACPI_RTYPE_PACKAGE; | ||
478 | break; | ||
479 | |||
480 | case ACPI_TYPE_LOCAL_REFERENCE: | ||
481 | return_btype = ACPI_RTYPE_REFERENCE; | ||
482 | break; | ||
483 | |||
484 | default: | ||
485 | /* Not one of the supported objects, must be incorrect */ | ||
486 | |||
487 | return_btype = ACPI_RTYPE_ANY; | ||
488 | break; | ||
592 | } | 489 | } |
490 | |||
491 | return (return_btype); | ||
593 | } | 492 | } |