diff options
author | Bob Moore <robert.moore@intel.com> | 2013-04-11 20:24:22 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-04-12 07:29:46 -0400 |
commit | c34c82bc9634a099a2652889806c5997f2a3d56f (patch) | |
tree | f2b9505b179e7e1a069105037fb0a531aeebdb56 /drivers/acpi/acpica/nspredef.c | |
parent | f084dbb939070281be7c882db63a4a428c51fcf4 (diff) |
ACPICA: Predefine names: Add allowed argument types to master info table
This change adds the infrastructure to enable typechecking
on incoming arguments for the predefined methods/objects. It
does not actually contain the code that will fully utilize this
information. Also condenses some duplicate code for the predefined
names into a new module, utilities/utpredef.c
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/nspredef.c')
-rw-r--r-- | drivers/acpi/acpica/nspredef.c | 106 |
1 files changed, 6 insertions, 100 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 36f724085dca..8a52916148cb 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
@@ -76,22 +76,8 @@ 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); | ||
80 | |||
81 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); | 79 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); |
82 | 80 | ||
83 | /* | ||
84 | * Names for the types that can be returned by the predefined objects. | ||
85 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs | ||
86 | */ | ||
87 | static const char *acpi_rtype_names[] = { | ||
88 | "/Integer", | ||
89 | "/String", | ||
90 | "/Buffer", | ||
91 | "/Package", | ||
92 | "/Reference", | ||
93 | }; | ||
94 | |||
95 | /******************************************************************************* | 81 | /******************************************************************************* |
96 | * | 82 | * |
97 | * FUNCTION: acpi_ns_check_predefined_names | 83 | * FUNCTION: acpi_ns_check_predefined_names |
@@ -121,7 +107,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
121 | 107 | ||
122 | /* Match the name for this method/object against the predefined list */ | 108 | /* Match the name for this method/object against the predefined list */ |
123 | 109 | ||
124 | predefined = acpi_ns_check_for_predefined_name(node); | 110 | predefined = acpi_ut_match_predefined_method(node->name.ascii); |
125 | 111 | ||
126 | /* 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 */ |
127 | 113 | ||
@@ -292,8 +278,10 @@ acpi_ns_check_parameter_count(char *pathname, | |||
292 | * Validate the user-supplied parameter count. | 278 | * Validate the user-supplied parameter count. |
293 | * Allow two different legal argument counts (_SCP, etc.) | 279 | * Allow two different legal argument counts (_SCP, etc.) |
294 | */ | 280 | */ |
295 | required_params_current = predefined->info.param_count & 0x0F; | 281 | required_params_current = |
296 | 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; | ||
297 | 285 | ||
298 | if (user_param_count != ACPI_UINT32_MAX) { | 286 | if (user_param_count != ACPI_UINT32_MAX) { |
299 | if ((user_param_count != required_params_current) && | 287 | if ((user_param_count != required_params_current) && |
@@ -322,52 +310,6 @@ acpi_ns_check_parameter_count(char *pathname, | |||
322 | 310 | ||
323 | /******************************************************************************* | 311 | /******************************************************************************* |
324 | * | 312 | * |
325 | * FUNCTION: acpi_ns_check_for_predefined_name | ||
326 | * | ||
327 | * PARAMETERS: node - Namespace node for the method/object | ||
328 | * | ||
329 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. | ||
330 | * | ||
331 | * DESCRIPTION: Check an object name against the predefined object list. | ||
332 | * | ||
333 | ******************************************************************************/ | ||
334 | |||
335 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | ||
336 | acpi_namespace_node | ||
337 | *node) | ||
338 | { | ||
339 | const union acpi_predefined_info *this_name; | ||
340 | |||
341 | /* Quick check for a predefined name, first character must be underscore */ | ||
342 | |||
343 | if (node->name.ascii[0] != '_') { | ||
344 | return (NULL); | ||
345 | } | ||
346 | |||
347 | /* Search info table for a predefined method/object name */ | ||
348 | |||
349 | this_name = predefined_names; | ||
350 | while (this_name->info.name[0]) { | ||
351 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { | ||
352 | return (this_name); | ||
353 | } | ||
354 | |||
355 | /* | ||
356 | * Skip next entry in the table if this name returns a Package | ||
357 | * (next entry contains the package info) | ||
358 | */ | ||
359 | if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) { | ||
360 | this_name++; | ||
361 | } | ||
362 | |||
363 | this_name++; | ||
364 | } | ||
365 | |||
366 | return (NULL); /* Not found */ | ||
367 | } | ||
368 | |||
369 | /******************************************************************************* | ||
370 | * | ||
371 | * FUNCTION: acpi_ns_check_object_type | 313 | * FUNCTION: acpi_ns_check_object_type |
372 | * | 314 | * |
373 | * PARAMETERS: data - Pointer to validation data structure | 315 | * PARAMETERS: data - Pointer to validation data structure |
@@ -438,7 +380,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
438 | 380 | ||
439 | /* Create a string with all expected types for this predefined object */ | 381 | /* Create a string with all expected types for this predefined object */ |
440 | 382 | ||
441 | acpi_ns_get_expected_types(type_buffer, expected_btypes); | 383 | acpi_ut_get_expected_return_types(type_buffer, expected_btypes); |
442 | 384 | ||
443 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { | 385 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { |
444 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 386 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
@@ -548,39 +490,3 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) | |||
548 | 490 | ||
549 | return (return_btype); | 491 | return (return_btype); |
550 | } | 492 | } |
551 | |||
552 | /******************************************************************************* | ||
553 | * | ||
554 | * FUNCTION: acpi_ns_get_expected_types | ||
555 | * | ||
556 | * PARAMETERS: buffer - Pointer to where the string is returned | ||
557 | * expected_btypes - Bitmap of expected return type(s) | ||
558 | * | ||
559 | * RETURN: Buffer is populated with type names. | ||
560 | * | ||
561 | * DESCRIPTION: Translate the expected types bitmap into a string of ascii | ||
562 | * names of expected types, for use in warning messages. | ||
563 | * | ||
564 | ******************************************************************************/ | ||
565 | |||
566 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes) | ||
567 | { | ||
568 | u32 this_rtype; | ||
569 | u32 i; | ||
570 | u32 j; | ||
571 | |||
572 | j = 1; | ||
573 | buffer[0] = 0; | ||
574 | this_rtype = ACPI_RTYPE_INTEGER; | ||
575 | |||
576 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { | ||
577 | |||
578 | /* If one of the expected types, concatenate the name of this type */ | ||
579 | |||
580 | if (expected_btypes & this_rtype) { | ||
581 | ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]); | ||
582 | j = 0; /* Use name separator from now on */ | ||
583 | } | ||
584 | this_rtype <<= 1; /* Next Rtype */ | ||
585 | } | ||
586 | } | ||