Skip to content

Commit 9a1ae80

Browse files
acpibobrafaeljw
authored andcommitted
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: acpica/acpica@f31cdf8b Link: acpica/acpica@6803997e Signed-off-by: Bob Moore <[email protected]> Signed-off-by: Erik Kaneda <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 88055d8 commit 9a1ae80

File tree

7 files changed

+83
-20
lines changed

7 files changed

+83
-20
lines changed

drivers/acpi/acpica/acnamesp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ u32
256256
acpi_ns_build_normalized_path(struct acpi_namespace_node *node,
257257
char *full_path, u32 path_size, u8 no_trailing);
258258

259+
void acpi_ns_normalize_pathname(char *original_path);
260+
259261
char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
260262
u8 no_trailing);
261263

drivers/acpi/acpica/dbinput.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -468,16 +468,14 @@ char *acpi_db_get_next_token(char *string,
468468
return (NULL);
469469
}
470470

471-
/* Remove any spaces at the beginning */
471+
/* Remove any spaces at the beginning, ignore blank lines */
472472

473-
if (*string == ' ') {
474-
while (*string && (*string == ' ')) {
475-
string++;
476-
}
473+
while (*string && isspace(*string)) {
474+
string++;
475+
}
477476

478-
if (!(*string)) {
479-
return (NULL);
480-
}
477+
if (!(*string)) {
478+
return (NULL);
481479
}
482480

483481
switch (*string) {
@@ -570,7 +568,7 @@ char *acpi_db_get_next_token(char *string,
570568

571569
/* Find end of token */
572570

573-
while (*string && (*string != ' ')) {
571+
while (*string && !isspace(*string)) {
574572
string++;
575573
}
576574
break;

drivers/acpi/acpica/dswexec.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "acinterp.h"
1717
#include "acnamesp.h"
1818
#include "acdebug.h"
19+
#ifdef ACPI_EXEC_APP
20+
#include "aecommon.h"
21+
#endif
1922

2023
#define _COMPONENT ACPI_DISPATCHER
2124
ACPI_MODULE_NAME("dswexec")
@@ -329,6 +332,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
329332
u32 op_class;
330333
union acpi_parse_object *next_op;
331334
union acpi_parse_object *first_arg;
335+
#ifdef ACPI_EXEC_APP
336+
char *namepath;
337+
union acpi_operand_object *obj_desc;
338+
#endif
332339

333340
ACPI_FUNCTION_TRACE_PTR(ds_exec_end_op, walk_state);
334341

@@ -537,6 +544,32 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
537544

538545
status =
539546
acpi_ds_eval_buffer_field_operands(walk_state, op);
547+
if (ACPI_FAILURE(status)) {
548+
break;
549+
}
550+
#ifdef ACPI_EXEC_APP
551+
/*
552+
* acpi_exec support for namespace initialization file (initialize
553+
* buffer_fields in this code.)
554+
*/
555+
namepath =
556+
acpi_ns_get_external_pathname(op->common.node);
557+
status = ae_lookup_init_file_entry(namepath, &obj_desc);
558+
if (ACPI_SUCCESS(status)) {
559+
status =
560+
acpi_ex_write_data_to_field(obj_desc,
561+
op->common.
562+
node->object,
563+
NULL);
564+
if ACPI_FAILURE
565+
(status) {
566+
ACPI_EXCEPTION((AE_INFO, status,
567+
"While writing to buffer field"));
568+
}
569+
}
570+
ACPI_FREE(namepath);
571+
status = AE_OK;
572+
#endif
540573
break;
541574

542575
case AML_TYPE_CREATE_OBJECT:

drivers/acpi/acpica/dswload.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "acdispat.h"
1515
#include "acinterp.h"
1616
#include "acnamesp.h"
17-
1817
#ifdef ACPI_ASL_COMPILER
1918
#include "acdisasm.h"
2019
#endif
@@ -399,7 +398,6 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
399398
union acpi_parse_object *op;
400399
acpi_object_type object_type;
401400
acpi_status status = AE_OK;
402-
403401
#ifdef ACPI_ASL_COMPILER
404402
u8 param_count;
405403
#endif

drivers/acpi/acpica/dswload2.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "acinterp.h"
1616
#include "acnamesp.h"
1717
#include "acevents.h"
18+
#ifdef ACPI_EXEC_APP
19+
#include "aecommon.h"
20+
#endif
1821

1922
#define _COMPONENT ACPI_DISPATCHER
2023
ACPI_MODULE_NAME("dswload2")
@@ -373,6 +376,10 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
373376
struct acpi_namespace_node *new_node;
374377
u32 i;
375378
u8 region_space;
379+
#ifdef ACPI_EXEC_APP
380+
union acpi_operand_object *obj_desc;
381+
char *namepath;
382+
#endif
376383

377384
ACPI_FUNCTION_TRACE(ds_load2_end_op);
378385

@@ -466,6 +473,11 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
466473
* be evaluated later during the execution phase
467474
*/
468475
status = acpi_ds_create_buffer_field(op, walk_state);
476+
if (ACPI_FAILURE(status)) {
477+
ACPI_EXCEPTION((AE_INFO, status,
478+
"CreateBufferField failure"));
479+
goto cleanup;
480+
}
469481
break;
470482

471483
case AML_TYPE_NAMED_FIELD:
@@ -604,6 +616,29 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
604616
case AML_NAME_OP:
605617

606618
status = acpi_ds_create_node(walk_state, node, op);
619+
if (ACPI_FAILURE(status)) {
620+
goto cleanup;
621+
}
622+
#ifdef ACPI_EXEC_APP
623+
/*
624+
* acpi_exec support for namespace initialization file (initialize
625+
* Name opcodes in this code.)
626+
*/
627+
namepath = acpi_ns_get_external_pathname(node);
628+
status = ae_lookup_init_file_entry(namepath, &obj_desc);
629+
if (ACPI_SUCCESS(status)) {
630+
631+
/* Detach any existing object, attach new object */
632+
633+
if (node->object) {
634+
acpi_ns_detach_object(node);
635+
}
636+
acpi_ns_attach_object(node, obj_desc,
637+
obj_desc->common.type);
638+
}
639+
ACPI_FREE(namepath);
640+
status = AE_OK;
641+
#endif
607642
break;
608643

609644
case AML_METHOD_OP:

drivers/acpi/acpica/nsnames.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#define _COMPONENT ACPI_NAMESPACE
1414
ACPI_MODULE_NAME("nsnames")
1515

16-
/* Local Prototypes */
17-
static void acpi_ns_normalize_pathname(char *original_path);
18-
1916
/*******************************************************************************
2017
*
2118
* FUNCTION: acpi_ns_get_external_pathname
@@ -30,7 +27,6 @@ static void acpi_ns_normalize_pathname(char *original_path);
3027
* for error and debug statements.
3128
*
3229
******************************************************************************/
33-
3430
char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
3531
{
3632
char *name_buffer;
@@ -411,7 +407,7 @@ char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
411407
*
412408
******************************************************************************/
413409

414-
static void acpi_ns_normalize_pathname(char *original_path)
410+
void acpi_ns_normalize_pathname(char *original_path)
415411
{
416412
char *input_path = original_path;
417413
char *new_path_buffer;

drivers/acpi/acpica/utdelete.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,13 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
452452
*
453453
* FUNCTION: acpi_ut_update_object_reference
454454
*
455-
* PARAMETERS: object - Increment ref count for this object
456-
* and all sub-objects
455+
* PARAMETERS: object - Increment or decrement the ref count for
456+
* this object and all sub-objects
457457
* action - Either REF_INCREMENT or REF_DECREMENT
458458
*
459459
* RETURN: Status
460460
*
461-
* DESCRIPTION: Increment the object reference count
461+
* DESCRIPTION: Increment or decrement the object reference count
462462
*
463463
* Object references are incremented when:
464464
* 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)
492492
}
493493

494494
/*
495-
* All sub-objects must have their reference count incremented
495+
* All sub-objects must have their reference count updated
496496
* also. Different object types have different subobjects.
497497
*/
498498
switch (object->common.type) {
@@ -559,6 +559,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
559559
break;
560560
}
561561
}
562+
562563
next_object = NULL;
563564
break;
564565

0 commit comments

Comments
 (0)