Commit 9a1ae804 authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki

ACPICA: Fixes for acpiExec namespace init file

This is the result of squashing the following ACPICA commit ID's:
6803997e5b4f3635cea6610b51ff69e29d251de3
f31cdf8bfda22fe265c1a176d0e33d311c82a7f7

This change fixes several problems with the support for the
acpi_exec namespace init file (-fi option). Specifically, it
fixes AE_ALREADY_EXISTS errors, as well as various seg faults.

Link: https://github.com/acpica/acpica/commit/f31cdf8b
Link: https://github.com/acpica/acpica/commit/6803997eSigned-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarErik Kaneda <erik.kaneda@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 88055d8f
...@@ -256,6 +256,8 @@ u32 ...@@ -256,6 +256,8 @@ u32
acpi_ns_build_normalized_path(struct acpi_namespace_node *node, acpi_ns_build_normalized_path(struct acpi_namespace_node *node,
char *full_path, u32 path_size, u8 no_trailing); char *full_path, u32 path_size, u8 no_trailing);
void acpi_ns_normalize_pathname(char *original_path);
char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node, char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
u8 no_trailing); u8 no_trailing);
......
...@@ -468,16 +468,14 @@ char *acpi_db_get_next_token(char *string, ...@@ -468,16 +468,14 @@ char *acpi_db_get_next_token(char *string,
return (NULL); return (NULL);
} }
/* Remove any spaces at the beginning */ /* Remove any spaces at the beginning, ignore blank lines */
if (*string == ' ') { while (*string && isspace(*string)) {
while (*string && (*string == ' ')) { string++;
string++; }
}
if (!(*string)) { if (!(*string)) {
return (NULL); return (NULL);
}
} }
switch (*string) { switch (*string) {
...@@ -570,7 +568,7 @@ char *acpi_db_get_next_token(char *string, ...@@ -570,7 +568,7 @@ char *acpi_db_get_next_token(char *string,
/* Find end of token */ /* Find end of token */
while (*string && (*string != ' ')) { while (*string && !isspace(*string)) {
string++; string++;
} }
break; break;
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include "acinterp.h" #include "acinterp.h"
#include "acnamesp.h" #include "acnamesp.h"
#include "acdebug.h" #include "acdebug.h"
#ifdef ACPI_EXEC_APP
#include "aecommon.h"
#endif
#define _COMPONENT ACPI_DISPATCHER #define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME("dswexec") ACPI_MODULE_NAME("dswexec")
...@@ -329,6 +332,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) ...@@ -329,6 +332,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
u32 op_class; u32 op_class;
union acpi_parse_object *next_op; union acpi_parse_object *next_op;
union acpi_parse_object *first_arg; union acpi_parse_object *first_arg;
#ifdef ACPI_EXEC_APP
char *namepath;
union acpi_operand_object *obj_desc;
#endif
ACPI_FUNCTION_TRACE_PTR(ds_exec_end_op, walk_state); ACPI_FUNCTION_TRACE_PTR(ds_exec_end_op, walk_state);
...@@ -537,6 +544,32 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) ...@@ -537,6 +544,32 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
status = status =
acpi_ds_eval_buffer_field_operands(walk_state, op); acpi_ds_eval_buffer_field_operands(walk_state, op);
if (ACPI_FAILURE(status)) {
break;
}
#ifdef ACPI_EXEC_APP
/*
* acpi_exec support for namespace initialization file (initialize
* buffer_fields in this code.)
*/
namepath =
acpi_ns_get_external_pathname(op->common.node);
status = ae_lookup_init_file_entry(namepath, &obj_desc);
if (ACPI_SUCCESS(status)) {
status =
acpi_ex_write_data_to_field(obj_desc,
op->common.
node->object,
NULL);
if ACPI_FAILURE
(status) {
ACPI_EXCEPTION((AE_INFO, status,
"While writing to buffer field"));
}
}
ACPI_FREE(namepath);
status = AE_OK;
#endif
break; break;
case AML_TYPE_CREATE_OBJECT: case AML_TYPE_CREATE_OBJECT:
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "acdispat.h" #include "acdispat.h"
#include "acinterp.h" #include "acinterp.h"
#include "acnamesp.h" #include "acnamesp.h"
#ifdef ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
#include "acdisasm.h" #include "acdisasm.h"
#endif #endif
...@@ -399,7 +398,6 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) ...@@ -399,7 +398,6 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
union acpi_parse_object *op; union acpi_parse_object *op;
acpi_object_type object_type; acpi_object_type object_type;
acpi_status status = AE_OK; acpi_status status = AE_OK;
#ifdef ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
u8 param_count; u8 param_count;
#endif #endif
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "acinterp.h" #include "acinterp.h"
#include "acnamesp.h" #include "acnamesp.h"
#include "acevents.h" #include "acevents.h"
#ifdef ACPI_EXEC_APP
#include "aecommon.h"
#endif
#define _COMPONENT ACPI_DISPATCHER #define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME("dswload2") ACPI_MODULE_NAME("dswload2")
...@@ -373,6 +376,10 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) ...@@ -373,6 +376,10 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
struct acpi_namespace_node *new_node; struct acpi_namespace_node *new_node;
u32 i; u32 i;
u8 region_space; u8 region_space;
#ifdef ACPI_EXEC_APP
union acpi_operand_object *obj_desc;
char *namepath;
#endif
ACPI_FUNCTION_TRACE(ds_load2_end_op); ACPI_FUNCTION_TRACE(ds_load2_end_op);
...@@ -466,6 +473,11 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) ...@@ -466,6 +473,11 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
* be evaluated later during the execution phase * be evaluated later during the execution phase
*/ */
status = acpi_ds_create_buffer_field(op, walk_state); status = acpi_ds_create_buffer_field(op, walk_state);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
"CreateBufferField failure"));
goto cleanup;
}
break; break;
case AML_TYPE_NAMED_FIELD: case AML_TYPE_NAMED_FIELD:
...@@ -604,6 +616,29 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) ...@@ -604,6 +616,29 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
case AML_NAME_OP: case AML_NAME_OP:
status = acpi_ds_create_node(walk_state, node, op); status = acpi_ds_create_node(walk_state, node, op);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
#ifdef ACPI_EXEC_APP
/*
* acpi_exec support for namespace initialization file (initialize
* Name opcodes in this code.)
*/
namepath = acpi_ns_get_external_pathname(node);
status = ae_lookup_init_file_entry(namepath, &obj_desc);
if (ACPI_SUCCESS(status)) {
/* Detach any existing object, attach new object */
if (node->object) {
acpi_ns_detach_object(node);
}
acpi_ns_attach_object(node, obj_desc,
obj_desc->common.type);
}
ACPI_FREE(namepath);
status = AE_OK;
#endif
break; break;
case AML_METHOD_OP: case AML_METHOD_OP:
......
...@@ -13,9 +13,6 @@ ...@@ -13,9 +13,6 @@
#define _COMPONENT ACPI_NAMESPACE #define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsnames") ACPI_MODULE_NAME("nsnames")
/* Local Prototypes */
static void acpi_ns_normalize_pathname(char *original_path);
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_get_external_pathname * FUNCTION: acpi_ns_get_external_pathname
...@@ -30,7 +27,6 @@ static void acpi_ns_normalize_pathname(char *original_path); ...@@ -30,7 +27,6 @@ static void acpi_ns_normalize_pathname(char *original_path);
* for error and debug statements. * for error and debug statements.
* *
******************************************************************************/ ******************************************************************************/
char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
{ {
char *name_buffer; char *name_buffer;
...@@ -411,7 +407,7 @@ char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope, ...@@ -411,7 +407,7 @@ char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
* *
******************************************************************************/ ******************************************************************************/
static void acpi_ns_normalize_pathname(char *original_path) void acpi_ns_normalize_pathname(char *original_path)
{ {
char *input_path = original_path; char *input_path = original_path;
char *new_path_buffer; char *new_path_buffer;
......
...@@ -452,13 +452,13 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) ...@@ -452,13 +452,13 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
* *
* FUNCTION: acpi_ut_update_object_reference * FUNCTION: acpi_ut_update_object_reference
* *
* PARAMETERS: object - Increment ref count for this object * PARAMETERS: object - Increment or decrement the ref count for
* and all sub-objects * this object and all sub-objects
* action - Either REF_INCREMENT or REF_DECREMENT * action - Either REF_INCREMENT or REF_DECREMENT
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Increment the object reference count * DESCRIPTION: Increment or decrement the object reference count
* *
* Object references are incremented when: * Object references are incremented when:
* 1) An object is attached to a Node (namespace object) * 1) An object is attached to a Node (namespace object)
...@@ -492,7 +492,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -492,7 +492,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
} }
/* /*
* All sub-objects must have their reference count incremented * All sub-objects must have their reference count updated
* also. Different object types have different subobjects. * also. Different object types have different subobjects.
*/ */
switch (object->common.type) { switch (object->common.type) {
...@@ -559,6 +559,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -559,6 +559,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
break; break;
} }
} }
next_object = NULL; next_object = NULL;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment