1
0
Fork 0

ACPICA: Enhance error messages from namespace create/lookup operations

ACPICA commit b09c8d7bdc8c5a3db0a8d38bfd6182c023885e12

1) Emit the full pathname (scope+name) instead of just the name
2) For AE_ALREADY_EXISTS and AE_NOT_FOUND, use the "firmware error"
string to point to the true problem.

Link: https://github.com/acpica/acpica/commit/b09c8d7b
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
hifive-unleashed-5.1
Bob Moore 2017-11-17 15:42:22 -08:00 committed by Rafael J. Wysocki
parent 4b9b1de798
commit 16ccf82920
12 changed files with 270 additions and 25 deletions

View File

@ -455,7 +455,7 @@
* the plist contains a set of parens to allow variable-length lists.
* These macros are used for both the debug and non-debug versions of the code.
*/
#define ACPI_ERROR_NAMESPACE(s, e) acpi_ut_namespace_error (AE_INFO, s, e);
#define ACPI_ERROR_NAMESPACE(s, p, e) acpi_ut_prefixed_namespace_error (AE_INFO, s, p, e);
#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ut_method_error (AE_INFO, s, n, p, e);
#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist
#define ACPI_INFO_PREDEFINED(plist) acpi_ut_predefined_info plist

View File

@ -289,6 +289,9 @@ acpi_ns_build_normalized_path(struct acpi_namespace_node *node,
char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
u8 no_trailing);
char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
const char *internal_path);
char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
acpi_status

View File

@ -126,10 +126,10 @@ extern const char *acpi_gbl_ptyp_decode[];
#endif
#ifndef ACPI_MSG_BIOS_ERROR
#define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): "
#define ACPI_MSG_BIOS_ERROR "Firmware Error (ACPI): "
#endif
#ifndef ACPI_MSG_BIOS_WARNING
#define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): "
#define ACPI_MSG_BIOS_WARNING "Firmware Warning (ACPI): "
#endif
/*
@ -734,9 +734,11 @@ acpi_ut_predefined_bios_error(const char *module_name,
u8 node_flags, const char *format, ...);
void
acpi_ut_namespace_error(const char *module_name,
u32 line_number,
const char *internal_name, acpi_status lookup_status);
acpi_ut_prefixed_namespace_error(const char *module_name,
u32 line_number,
union acpi_generic_state *prefix_scope,
const char *internal_name,
acpi_status lookup_status);
void
acpi_ut_method_error(const char *module_name,

View File

@ -209,7 +209,8 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
ACPI_IMODE_LOAD_PASS1, flags,
walk_state, &node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.string, status);
return_ACPI_STATUS(status);
}
}
@ -383,7 +384,9 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
walk_state,
&info->connection_node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(child->common.
ACPI_ERROR_NAMESPACE(walk_state->
scope_info,
child->common.
value.name,
status);
return_ACPI_STATUS(status);
@ -402,7 +405,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
ACPI_NS_DONT_OPEN_SCOPE,
walk_state, &info->field_node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
(char *)&arg->named.name,
status);
return_ACPI_STATUS(status);
} else {
@ -498,7 +502,8 @@ acpi_ds_create_field(union acpi_parse_object *op,
&region_node);
#endif
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.name, status);
return_ACPI_STATUS(status);
}
}
@ -618,7 +623,8 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
ACPI_IMODE_LOAD_PASS1, flags,
walk_state, &node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
(char *)&arg->named.name,
status);
if (status != AE_ALREADY_EXISTS) {
return_ACPI_STATUS(status);
@ -681,7 +687,8 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
&region_node);
#endif
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.name, status);
return_ACPI_STATUS(status);
}
}
@ -695,7 +702,8 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
ACPI_NS_SEARCH_PARENT, walk_state,
&info.register_node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.string, status);
return_ACPI_STATUS(status);
}
@ -765,7 +773,8 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
ACPI_NS_SEARCH_PARENT, walk_state,
&info.register_node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.string, status);
return_ACPI_STATUS(status);
}
@ -778,7 +787,8 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
ACPI_NS_SEARCH_PARENT, walk_state,
&info.data_register_node);
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.string, status);
return_ACPI_STATUS(status);
}

View File

@ -112,7 +112,9 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
acpi_namespace_node,
&(op->common.node)));
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(op->common.value.
ACPI_ERROR_NAMESPACE(walk_state->
scope_info,
op->common.value.
string, status);
return_ACPI_STATUS(status);
}

View File

@ -583,7 +583,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
}
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(name_string, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
name_string, status);
}
}

View File

@ -207,7 +207,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
}
#endif
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(path, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info, path,
status);
return_ACPI_STATUS(status);
}
@ -375,7 +376,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
}
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(path, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
path, status);
return_ACPI_STATUS(status);
}
}

View File

@ -184,11 +184,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
if (status == AE_NOT_FOUND) {
status = AE_OK;
} else {
ACPI_ERROR_NAMESPACE(buffer_ptr,
ACPI_ERROR_NAMESPACE(walk_state->
scope_info,
buffer_ptr,
status);
}
#else
ACPI_ERROR_NAMESPACE(buffer_ptr, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
buffer_ptr, status);
#endif
return_ACPI_STATUS(status);
}
@ -343,7 +346,8 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
}
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(buffer_ptr, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
buffer_ptr, status);
return_ACPI_STATUS(status);
}
@ -719,7 +723,8 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
*/
op->common.node = new_node;
} else {
ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info,
arg->common.value.string, status);
}
break;

View File

@ -495,7 +495,8 @@ acpi_ns_convert_to_reference(struct acpi_namespace_node *scope,
/* Check if we are resolving a named reference within a package */
ACPI_ERROR_NAMESPACE(original_object->string.pointer, status);
ACPI_ERROR_NAMESPACE(&scope_info,
original_object->string.pointer, status);
goto error_exit;
}

View File

@ -49,6 +49,9 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsnames")
/* Local Prototypes */
static void acpi_ns_normalize_pathname(char *original_path);
/*******************************************************************************
*
* FUNCTION: acpi_ns_get_external_pathname
@ -63,6 +66,7 @@ ACPI_MODULE_NAME("nsnames")
* for error and debug statements.
*
******************************************************************************/
char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
{
char *name_buffer;
@ -352,3 +356,145 @@ char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
return_PTR(name_buffer);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_build_prefixed_pathname
*
* PARAMETERS: prefix_scope - Scope/Path that prefixes the internal path
* internal_path - Name or path of the namespace node
*
* RETURN: None
*
* DESCRIPTION: Construct a fully qualified pathname from a concatenation of:
* 1) Path associated with the prefix_scope namespace node
* 2) External path representation of the Internal path
*
******************************************************************************/
char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
const char *internal_path)
{
acpi_status status;
char *full_path = NULL;
char *external_path;
char *prefix_path = NULL;
u32 prefix_path_length = 0;
/* If there is a prefix, get the pathname to it */
if (prefix_scope && prefix_scope->scope.node) {
prefix_path =
acpi_ns_get_normalized_pathname(prefix_scope->scope.node,
TRUE);
if (prefix_path) {
prefix_path_length = strlen(prefix_path);
}
}
status = acpi_ns_externalize_name(ACPI_UINT32_MAX, internal_path,
NULL, &external_path);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/* Merge the prefix path and the path. 2 is for one dot and trailing null */
full_path =
ACPI_ALLOCATE_ZEROED(prefix_path_length + strlen(external_path) +
2);
if (!full_path) {
goto cleanup;
}
/* Don't merge if the External path is already fully qualified */
if (prefix_path && (*external_path != '\\') && (*external_path != '^')) {
strcat(full_path, prefix_path);
if (prefix_path[1]) {
strcat(full_path, ".");
}
}
acpi_ns_normalize_pathname(external_path);
strcat(full_path, external_path);
cleanup:
if (prefix_path) {
ACPI_FREE(prefix_path);
}
return (full_path);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_normalize_pathname
*
* PARAMETERS: original_path - Path to be normalized, in External format
*
* RETURN: The original path is processed in-place
*
* DESCRIPTION: Remove trailing underscores from each element of a path.
*
* For example: \A___.B___.C___ becomes \A.B.C
*
******************************************************************************/
static void acpi_ns_normalize_pathname(char *original_path)
{
char *input_path = original_path;
char *new_path_buffer;
char *new_path;
u32 i;
/* Allocate a temp buffer in which to construct the new path */
new_path_buffer = ACPI_ALLOCATE_ZEROED(strlen(input_path) + 1);
new_path = new_path_buffer;
if (!new_path_buffer) {
return;
}
/* Special characters may appear at the beginning of the path */
if (*input_path == '\\') {
*new_path = *input_path;
new_path++;
input_path++;
}
while (*input_path == '^') {
*new_path = *input_path;
new_path++;
input_path++;
}
/* Remainder of the path */
while (*input_path) {
/* Do one nameseg at a time */
for (i = 0; (i < ACPI_NAME_SIZE) && *input_path; i++) {
if ((i == 0) || (*input_path != '_')) { /* First char is allowed to be underscore */
*new_path = *input_path;
new_path++;
}
input_path++;
}
/* Dot means that there are more namesegs to come */
if (*input_path == '.') {
*new_path = *input_path;
new_path++;
input_path++;
}
}
*new_path = 0;
strcpy(original_path, new_path_buffer);
ACPI_FREE(new_path_buffer);
}

View File

@ -361,7 +361,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
/* Final exception check (may have been changed from code above) */
if (ACPI_FAILURE(status)) {
ACPI_ERROR_NAMESPACE(path, status);
ACPI_ERROR_NAMESPACE(walk_state->scope_info, path, status);
if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
ACPI_PARSE_EXECUTE) {

View File

@ -180,6 +180,78 @@ acpi_ut_predefined_bios_error(const char *module_name,
va_end(arg_list);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_prefixed_namespace_error
*
* PARAMETERS: module_name - Caller's module name (for error output)
* line_number - Caller's line number (for error output)
* prefix_scope - Scope/Path that prefixes the internal path
* internal_path - Name or path of the namespace node
* lookup_status - Exception code from NS lookup
*
* RETURN: None
*
* DESCRIPTION: Print error message with the full pathname constructed this way:
*
* prefix_scope_node_full_path.externalized_internal_path
*
* NOTE: 10/2017: Treat the major ns_lookup errors as firmware errors
*
******************************************************************************/
void
acpi_ut_prefixed_namespace_error(const char *module_name,
u32 line_number,
union acpi_generic_state *prefix_scope,
const char *internal_path,
acpi_status lookup_status)
{
char *full_path;
const char *message;
/*
* Main cases:
* 1) Object creation, object must not already exist
* 2) Object lookup, object must exist
*/
switch (lookup_status) {
case AE_ALREADY_EXISTS:
acpi_os_printf(ACPI_MSG_BIOS_ERROR);
message = "Failure creating";
break;
case AE_NOT_FOUND:
acpi_os_printf(ACPI_MSG_BIOS_ERROR);
message = "Failure looking up";
break;
default:
acpi_os_printf(ACPI_MSG_ERROR);
message = "Failure looking up";
break;
}
/* Concatenate the prefix path and the internal path */
full_path =
acpi_ns_build_prefixed_pathname(prefix_scope, internal_path);
acpi_os_printf("%s [%s], %s", message,
full_path ? full_path : "Could not get pathname",
acpi_format_exception(lookup_status));
if (full_path) {
ACPI_FREE(full_path);
}
ACPI_MSG_SUFFIX;
}
#ifdef __OBSOLETE_FUNCTION
/*******************************************************************************
*
* FUNCTION: acpi_ut_namespace_error
@ -240,6 +312,7 @@ acpi_ut_namespace_error(const char *module_name,
ACPI_MSG_SUFFIX;
ACPI_MSG_REDIRECT_END;
}
#endif
/*******************************************************************************
*