]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ACPICA: Dispatcher: Cleanup union acpi_operand_object's AML address assignments
authorLv Zheng <lv.zheng@intel.com>
Thu, 23 Jul 2015 04:52:24 +0000 (12:52 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 23 Jul 2015 21:09:06 +0000 (23:09 +0200)
ACPICA commit afb52611dbe7403551f93504d3798534f5c343f4

This patch cleans up the code of assigning the AML address to the
union acpi_operand_object.

The idea behind this cleanup is:
The AML address of the union acpi_operand_object should always be determined at
the point where the object is encountered. It should be started from the
first byte of the object. For example, the opcode of the object, the name
string of the user_term object, or the first byte of the packaged object
(where a pkg_length is prefixed). So it's not cleaner to have it assigned
here and there in the entire ACPICA source tree.

There are some special cases for the internal opcodes, before cleaning up
the internal opcodes, we should also determine the rules for the AML
addresses of the internal opcodes:
1. INT_NAMEPATH_OP: the address of the first byte for the name_string.
2. INT_METHODCALL_OP: the address of the first byte for the name_string.
3. INT_BYTELIST_OP: the address of the first byte for the byte_data list.
4. INT_EVAL_SUBTREE_OP: the address of the first byte for the
                        Region/Package/Buffer/bank_field/Field arguments.
5. INT_NAMEDFIELD_OP: the address to the name_seg.
6. INT_RESERVEDFIELD_OP: the address to the 0x00 prefix.
7. INT_ACCESSFIELD_OP: the address to the 0x01 prefix.
8. INT_CONNECTION_OP: the address to the 0x02 prefix.
9: INT_EXTACCESSFIELD_OP: the address to the 0x03 prefix.
10.INT_RETURN_VALUE_OP: the address of the replaced operand.
11.computational_data: the address to the
                      Byte/Word/Dword/Qword/string_prefix.

Before cleaning up the internal root scope of the aml_walk, turning it into
the term_list, we need to remember the aml_start address as the "Aml"
attribute for the union acpi_operand_object created by acpi_ps_create_scope_op().

Finally, we can delete some redundant AML address assignment in psloop.c.

Link: https://github.com/acpica/acpica/commit/afb52611
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
12 files changed:
drivers/acpi/acpica/acparser.h
drivers/acpi/acpica/dsargs.c
drivers/acpi/acpica/dsmethod.c
drivers/acpi/acpica/dswload.c
drivers/acpi/acpica/dswload2.c
drivers/acpi/acpica/nsparse.c
drivers/acpi/acpica/psargs.c
drivers/acpi/acpica/psloop.c
drivers/acpi/acpica/psobject.c
drivers/acpi/acpica/psparse.c
drivers/acpi/acpica/psutils.c
drivers/acpi/acpica/psxface.c

index 0cdd2fce493a9c15e34139b633b54ac8e531a151..6021ccfb0b1c8cad1e80bd350355a2698f085320 100644 (file)
@@ -225,11 +225,11 @@ void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
 /*
  * psutils - parser utilities
  */
-union acpi_parse_object *acpi_ps_create_scope_op(void);
+union acpi_parse_object *acpi_ps_create_scope_op(u8 *aml);
 
 void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
 
-union acpi_parse_object *acpi_ps_alloc_op(u16 opcode);
+union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml);
 
 void acpi_ps_free_op(union acpi_parse_object *op);
 
index 3e6989738e85f8d24577fd01b2ca084c7184b3ed..e2ab59e39162763e38121d027882cd925dd7ec2f 100644 (file)
@@ -86,7 +86,7 @@ acpi_ds_execute_arguments(struct acpi_namespace_node *node,
 
        /* Allocate a new parser op to be the root of the parsed tree */
 
-       op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
+       op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP, aml_start);
        if (!op) {
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
@@ -129,7 +129,7 @@ acpi_ds_execute_arguments(struct acpi_namespace_node *node,
 
        /* Evaluate the deferred arguments */
 
-       op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
+       op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP, aml_start);
        if (!op) {
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
index bf8c16e379fbd57090b4d1e702ae0d4aeb738e7a..4abc2425de4bab89ad9389e9e104a80549b43b31 100644 (file)
@@ -103,7 +103,7 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node,
 
        /* Create/Init a root op for the method parse tree */
 
-       op = acpi_ps_alloc_op(AML_METHOD_OP);
+       op = acpi_ps_alloc_op(AML_METHOD_OP, obj_desc->method.aml_start);
        if (!op) {
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
index 845ff44919c3713f8725f08daff16d9b9679e338..097188a6b1c1bb23d5ede8f940254cc93309d443 100644 (file)
@@ -388,7 +388,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
 
                /* Create a new op */
 
-               op = acpi_ps_alloc_op(walk_state->opcode);
+               op = acpi_ps_alloc_op(walk_state->opcode, walk_state->aml);
                if (!op) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
index fcaa30c611fb186a0418d343b77501328a7d3647..e2c08cd79aca7a64bcf6b7c8107c8ed0d4d601a5 100644 (file)
@@ -335,7 +335,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
 
                /* Create a new op */
 
-               op = acpi_ps_alloc_op(walk_state->opcode);
+               op = acpi_ps_alloc_op(walk_state->opcode, walk_state->aml);
                if (!op) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
index 9926a67ca6d71186de4a0ec9488a1f6b2c04405f..3736d43b18b94aaf45bf5f7dddcc9d2f4ec570c4 100644 (file)
@@ -78,6 +78,20 @@ acpi_ns_one_complete_parse(u32 pass_number,
 
        ACPI_FUNCTION_TRACE(ns_one_complete_parse);
 
+       status = acpi_get_table_by_index(table_index, &table);
+       if (ACPI_FAILURE(status)) {
+               return_ACPI_STATUS(status);
+       }
+
+       /* Table must consist of at least a complete header */
+
+       if (table->length < sizeof(struct acpi_table_header)) {
+               return_ACPI_STATUS(AE_BAD_HEADER);
+       }
+
+       aml_start = (u8 *)table + sizeof(struct acpi_table_header);
+       aml_length = table->length - sizeof(struct acpi_table_header);
+
        status = acpi_tb_get_owner_id(table_index, &owner_id);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
@@ -85,7 +99,7 @@ acpi_ns_one_complete_parse(u32 pass_number,
 
        /* Create and init a Root Node */
 
-       parse_root = acpi_ps_create_scope_op();
+       parse_root = acpi_ps_create_scope_op(aml_start);
        if (!parse_root) {
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
@@ -98,23 +112,12 @@ acpi_ns_one_complete_parse(u32 pass_number,
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
 
-       status = acpi_get_table_by_index(table_index, &table);
+       status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
+                                      aml_start, aml_length, NULL,
+                                      (u8)pass_number);
        if (ACPI_FAILURE(status)) {
                acpi_ds_delete_walk_state(walk_state);
-               acpi_ps_free_op(parse_root);
-               return_ACPI_STATUS(status);
-       }
-
-       /* Table must consist of at least a complete header */
-
-       if (table->length < sizeof(struct acpi_table_header)) {
-               status = AE_BAD_HEADER;
-       } else {
-               aml_start = (u8 *)table + sizeof(struct acpi_table_header);
-               aml_length = table->length - sizeof(struct acpi_table_header);
-               status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
-                                              aml_start, aml_length, NULL,
-                                              (u8)pass_number);
+               goto cleanup;
        }
 
        /* Found OSDT table, enable the namespace override feature */
@@ -124,11 +127,6 @@ acpi_ns_one_complete_parse(u32 pass_number,
                walk_state->namespace_override = TRUE;
        }
 
-       if (ACPI_FAILURE(status)) {
-               acpi_ds_delete_walk_state(walk_state);
-               goto cleanup;
-       }
-
        /* start_node is the default location to load the table */
 
        if (start_node && start_node != acpi_gbl_root_node) {
index 0bee9466d1498e7aeb6e7ba2e59ed9ef8710791f..29d8b7b01dca74ad55169e5de786b1b7dc0f476b 100644 (file)
@@ -287,7 +287,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
                                  "Control Method - %p Desc %p Path=%p\n", node,
                                  method_desc, path));
 
-               name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
+               name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP, start);
                if (!name_op) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
@@ -535,13 +535,11 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 
        /* Allocate a new field op */
 
-       field = acpi_ps_alloc_op(opcode);
+       field = acpi_ps_alloc_op(opcode, aml);
        if (!field) {
                return_PTR(NULL);
        }
 
-       field->common.aml = aml;
-
        /* Decode the field type */
 
        switch (opcode) {
@@ -603,6 +601,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
                 * Argument for Connection operator can be either a Buffer
                 * (resource descriptor), or a name_string.
                 */
+               aml = parser_state->aml;
                if (ACPI_GET8(parser_state->aml) == AML_BUFFER_OP) {
                        parser_state->aml++;
 
@@ -615,7 +614,8 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 
                                /* Non-empty list */
 
-                               arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP);
+                               arg =
+                                   acpi_ps_alloc_op(AML_INT_BYTELIST_OP, aml);
                                if (!arg) {
                                        acpi_ps_free_op(field);
                                        return_PTR(NULL);
@@ -664,7 +664,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
 
                        parser_state->aml = pkg_end;
                } else {
-                       arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
+                       arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP, aml);
                        if (!arg) {
                                acpi_ps_free_op(field);
                                return_PTR(NULL);
@@ -729,7 +729,7 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
 
                /* Constants, strings, and namestrings are all the same size */
 
-               arg = acpi_ps_alloc_op(AML_BYTE_OP);
+               arg = acpi_ps_alloc_op(AML_BYTE_OP, parser_state->aml);
                if (!arg) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
@@ -776,7 +776,8 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
 
                        /* Non-empty list */
 
-                       arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP);
+                       arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP,
+                                              parser_state->aml);
                        if (!arg) {
                                return_ACPI_STATUS(AE_NO_MEMORY);
                        }
@@ -806,7 +807,9 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
 
                        /* null_name or name_string */
 
-                       arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
+                       arg =
+                           acpi_ps_alloc_op(AML_INT_NAMEPATH_OP,
+                                            parser_state->aml);
                        if (!arg) {
                                return_ACPI_STATUS(AE_NO_MEMORY);
                        }
index d5843830fef809d9ec58d499828bf01633cc4cd5..49c60c2671ef595d4aada0d90c99492bf572233c 100644 (file)
@@ -137,7 +137,6 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
                        }
 
                        if (arg) {
-                               arg->common.aml = walk_state->aml;
                                acpi_ps_append_arg(op, arg);
                        }
 
@@ -491,8 +490,6 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
                                continue;
                        }
 
-                       op->common.aml = walk_state->aml;
-
                        if (walk_state->op_info) {
                                ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
                                                  "Opcode %4.4X [%s] Op %p Aml %p\n",
index 6ba3bb7402a951780eb07543d3d7fc684c040365..e54bc2aa7a880305b873ead6c3f9c918ff7d1334 100644 (file)
@@ -297,7 +297,7 @@ acpi_ps_create_op(struct acpi_walk_state *walk_state,
        /* Create Op structure and append to parent's argument list */
 
        walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
-       op = acpi_ps_alloc_op(walk_state->opcode);
+       op = acpi_ps_alloc_op(walk_state->opcode, aml_op_start);
        if (!op) {
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
index a555f7f7b9a215d2a899f0e656faae857f3fcf76..b857ad58022af4f83cdfd31d76294259d0ab601a 100644 (file)
@@ -185,7 +185,8 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
                         * op must be replaced by a placeholder return op
                         */
                        replacement_op =
-                           acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
+                           acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP,
+                                            op->common.aml);
                        if (!replacement_op) {
                                status = AE_NO_MEMORY;
                        }
@@ -209,7 +210,8 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
                            || (op->common.parent->common.aml_opcode ==
                                AML_VAR_PACKAGE_OP)) {
                                replacement_op =
-                                   acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
+                                   acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP,
+                                                    op->common.aml);
                                if (!replacement_op) {
                                        status = AE_NO_MEMORY;
                                }
@@ -224,7 +226,8 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
                                        AML_VAR_PACKAGE_OP)) {
                                        replacement_op =
                                            acpi_ps_alloc_op(op->common.
-                                                            aml_opcode);
+                                                            aml_opcode,
+                                                            op->common.aml);
                                        if (!replacement_op) {
                                                status = AE_NO_MEMORY;
                                        } else {
@@ -240,7 +243,8 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
                default:
 
                        replacement_op =
-                           acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
+                           acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP,
+                                            op->common.aml);
                        if (!replacement_op) {
                                status = AE_NO_MEMORY;
                        }
index 32440912023a7d4a8ab65bf84de8df7beb37d633..183cc1efbc5182d990dacaa88b5bff1471d2ee8b 100644 (file)
@@ -60,11 +60,11 @@ ACPI_MODULE_NAME("psutils")
  * DESCRIPTION: Create a Scope and associated namepath op with the root name
  *
  ******************************************************************************/
-union acpi_parse_object *acpi_ps_create_scope_op(void)
+union acpi_parse_object *acpi_ps_create_scope_op(u8 *aml)
 {
        union acpi_parse_object *scope_op;
 
-       scope_op = acpi_ps_alloc_op(AML_SCOPE_OP);
+       scope_op = acpi_ps_alloc_op(AML_SCOPE_OP, aml);
        if (!scope_op) {
                return (NULL);
        }
@@ -103,6 +103,7 @@ void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode)
  * FUNCTION:    acpi_ps_alloc_op
  *
  * PARAMETERS:  opcode          - Opcode that will be stored in the new Op
+ *              aml             - Address of the opcode
  *
  * RETURN:      Pointer to the new Op, null on failure
  *
@@ -112,7 +113,7 @@ void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode)
  *
  ******************************************************************************/
 
-union acpi_parse_object *acpi_ps_alloc_op(u16 opcode)
+union acpi_parse_object *acpi_ps_alloc_op(u16 opcode, u8 *aml)
 {
        union acpi_parse_object *op;
        const struct acpi_opcode_info *op_info;
@@ -149,6 +150,7 @@ union acpi_parse_object *acpi_ps_alloc_op(u16 opcode)
 
        if (op) {
                acpi_ps_init_op(op, opcode);
+               op->common.aml = aml;
                op->common.flags = flags;
        }
 
index 841a5ea0609425ed5c2e97aa72af0118302289ff..1f3f46d44312ed93c6ea85f8fc2777c3b8196f83 100644 (file)
@@ -256,7 +256,7 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
 
        /* Create and init a Root Node */
 
-       op = acpi_ps_create_scope_op();
+       op = acpi_ps_create_scope_op(info->obj_desc->method.aml_start);
        if (!op) {
                status = AE_NO_MEMORY;
                goto cleanup;