Cleanup of invalid ACPI name handling and repair

Implemented a change/cleanup for the handling of invalid ACPI names.
 Names are now validated and repaired only when
 1) entering a new name into the namespace and
 2) disassembling a named AML opcode. A warning is only displayed in
    debug mode or when the interpreter is in "strict" mode, since some
    working machines do in fact contain invalid ACPI names.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Bob Moore 2012-10-31 02:24:51 +00:00 committed by Rafael J. Wysocki
parent 77b67063bb
commit 45dcd31547
4 changed files with 28 additions and 33 deletions

View File

@ -483,7 +483,7 @@ void acpi_ut_print_string(char *string, u8 max_length);
u8 acpi_ut_valid_acpi_name(u32 name);
acpi_name acpi_ut_repair_name(char *name);
void acpi_ut_repair_name(char *name);
u8 acpi_ut_valid_acpi_char(char character, u32 position);

View File

@ -209,14 +209,6 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
"Invalid ACPI Object Type 0x%08X", type));
}
if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
this_node->name.integer =
acpi_ut_repair_name(this_node->name.ascii);
ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
this_node->name.integer));
}
acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
}

View File

@ -314,23 +314,8 @@ acpi_ns_search_and_enter(u32 target_name,
* this problem, and we want to be able to enable ACPI support for them,
* even though there are a few bad names.
*/
if (!acpi_ut_valid_acpi_name(target_name)) {
target_name =
acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name));
/* Report warning only if in strict mode or debug mode */
if (!acpi_gbl_enable_interpreter_slack) {
ACPI_WARNING((AE_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
ACPI_CAST_PTR(char, &target_name)));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
ACPI_CAST_PTR(char, &target_name)));
}
}
/* Try to find the name in the namespace level specified by the caller */
*return_node = ACPI_ENTRY_NOT_FOUND;

View File

@ -642,25 +642,43 @@ u8 acpi_ut_valid_acpi_name(u32 name)
*
******************************************************************************/
acpi_name acpi_ut_repair_name(char *name)
void acpi_ut_repair_name(char *name)
{
u32 i;
char new_name[ACPI_NAME_SIZE];
u8 found_bad_char = FALSE;
ACPI_FUNCTION_NAME(ut_repair_name);
/* Check each character in the name */
for (i = 0; i < ACPI_NAME_SIZE; i++) {
new_name[i] = name[i];
if (acpi_ut_valid_acpi_char(name[i], i)) {
continue;
}
/*
* Replace a bad character with something printable, yet technically
* still invalid. This prevents any collisions with existing "good"
* names in the namespace.
*/
if (!acpi_ut_valid_acpi_char(name[i], i)) {
new_name[i] = '*';
}
name[i] = '*';
found_bad_char = TRUE;
}
return (*(u32 *) new_name);
if (found_bad_char) {
/* Report warning only if in strict mode or debug mode */
if (!acpi_gbl_enable_interpreter_slack) {
ACPI_WARNING((AE_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
name));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
name));
}
}
}
/*******************************************************************************