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

ACPICA: Parser: Allow method invocations as target operands

ACPICA commit a6cca7a4786cdbfd29cea67e84b5b01a8ae6ff1c

Method invocations as target operands are allowed as target
operands in the ASL grammar. This change implements support
for this. Method must return a reference for this to work
properly at runtime, however.

Link: https://github.com/acpica/acpica/commit/a6cca7a4Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 74e30f96
...@@ -269,23 +269,13 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, ...@@ -269,23 +269,13 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
*/ */
if (ACPI_SUCCESS(status) && if (ACPI_SUCCESS(status) &&
possible_method_call && (node->type == ACPI_TYPE_METHOD)) { possible_method_call && (node->type == ACPI_TYPE_METHOD)) {
if (walk_state->opcode == AML_UNLOAD_OP) {
/*
* acpi_ps_get_next_namestring has increased the AML pointer,
* so we need to restore the saved AML pointer for method call.
*/
walk_state->parser_state.aml = start;
walk_state->arg_count = 1;
acpi_ps_init_op(arg, AML_INT_METHODCALL_OP);
return_ACPI_STATUS(AE_OK);
}
/* This name is actually a control method invocation */ /* This name is actually a control method invocation */
method_desc = acpi_ns_get_attached_object(node); method_desc = acpi_ns_get_attached_object(node);
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"Control Method - %p Desc %p Path=%p\n", node, "Control Method invocation %4.4s - %p Desc %p Path=%p\n",
method_desc, path)); node->name.ascii, node, method_desc, path));
name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP, start); name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP, start);
if (!name_op) { if (!name_op) {
...@@ -719,6 +709,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, ...@@ -719,6 +709,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
ACPI_FUNCTION_TRACE_PTR(ps_get_next_arg, parser_state); ACPI_FUNCTION_TRACE_PTR(ps_get_next_arg, parser_state);
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"Expected argument type ARGP: %s (%2.2X)\n",
acpi_ut_get_argument_type_name(arg_type), arg_type));
switch (arg_type) { switch (arg_type) {
case ARGP_BYTEDATA: case ARGP_BYTEDATA:
case ARGP_WORDDATA: case ARGP_WORDDATA:
...@@ -796,11 +790,14 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, ...@@ -796,11 +790,14 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
} }
break; break;
case ARGP_TARGET:
case ARGP_SUPERNAME:
case ARGP_SIMPLENAME: case ARGP_SIMPLENAME:
case ARGP_NAME_OR_REF: case ARGP_NAME_OR_REF:
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"**** SimpleName/NameOrRef: %s (%2.2X)\n",
acpi_ut_get_argument_type_name(arg_type),
arg_type));
subop = acpi_ps_peek_opcode(parser_state); subop = acpi_ps_peek_opcode(parser_state);
if (subop == 0 || if (subop == 0 ||
acpi_ps_is_leading_char(subop) || acpi_ps_is_leading_char(subop) ||
...@@ -816,29 +813,41 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, ...@@ -816,29 +813,41 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
return_ACPI_STATUS(AE_NO_MEMORY); return_ACPI_STATUS(AE_NO_MEMORY);
} }
/* To support super_name arg of Unload */ status =
acpi_ps_get_next_namepath(walk_state, parser_state,
if (walk_state->opcode == AML_UNLOAD_OP) { arg,
status = ACPI_NOT_METHOD_CALL);
acpi_ps_get_next_namepath(walk_state, } else {
parser_state, arg, /* Single complex argument, nothing returned */
ACPI_POSSIBLE_METHOD_CALL);
walk_state->arg_count = 1;
/* }
* If the super_name argument is a method call, we have break;
* already restored the AML pointer, just free this Arg
*/ case ARGP_TARGET:
if (arg->common.aml_opcode == case ARGP_SUPERNAME:
AML_INT_METHODCALL_OP) {
acpi_ps_free_op(arg); ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
arg = NULL; "**** Target/Supername: %s (%2.2X)\n",
} acpi_ut_get_argument_type_name(arg_type),
} else { arg_type));
status =
acpi_ps_get_next_namepath(walk_state, subop = acpi_ps_peek_opcode(parser_state);
parser_state, arg, if (subop == 0) {
ACPI_NOT_METHOD_CALL);
/* NULL target (zero). Convert to a NULL namepath */
arg =
acpi_ps_alloc_op(AML_INT_NAMEPATH_OP,
parser_state->aml);
if (!arg) {
return_ACPI_STATUS(AE_NO_MEMORY);
} }
status =
acpi_ps_get_next_namepath(walk_state, parser_state,
arg,
ACPI_POSSIBLE_METHOD_CALL);
} else { } else {
/* Single complex argument, nothing returned */ /* Single complex argument, nothing returned */
...@@ -849,6 +858,11 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, ...@@ -849,6 +858,11 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
case ARGP_DATAOBJ: case ARGP_DATAOBJ:
case ARGP_TERMARG: case ARGP_TERMARG:
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"**** TermArg/DataObj: %s (%2.2X)\n",
acpi_ut_get_argument_type_name(arg_type),
arg_type));
/* Single complex argument, nothing returned */ /* Single complex argument, nothing returned */
walk_state->arg_count = 1; walk_state->arg_count = 1;
......
...@@ -92,6 +92,10 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state, ...@@ -92,6 +92,10 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state); ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
"Get arguments for opcode [%s]\n",
op->common.aml_op_name));
switch (op->common.aml_opcode) { switch (op->common.aml_opcode) {
case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
case AML_WORD_OP: /* AML_WORDDATA_ARG */ case AML_WORD_OP: /* AML_WORDDATA_ARG */
......
...@@ -348,7 +348,15 @@ acpi_ps_create_op(struct acpi_walk_state *walk_state, ...@@ -348,7 +348,15 @@ acpi_ps_create_op(struct acpi_walk_state *walk_state,
argument_count) { argument_count) {
op->common.flags |= ACPI_PARSEOP_TARGET; op->common.flags |= ACPI_PARSEOP_TARGET;
} }
} else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) { }
/*
* Special case for both Increment() and Decrement(), where
* the lone argument is both a source and a target.
*/
else if ((parent_scope->common.aml_opcode == AML_INCREMENT_OP)
|| (parent_scope->common.aml_opcode ==
AML_DECREMENT_OP)) {
op->common.flags |= ACPI_PARSEOP_TARGET; op->common.flags |= ACPI_PARSEOP_TARGET;
} }
} }
......
...@@ -129,10 +129,10 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) ...@@ -129,10 +129,10 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
union acpi_parse_object *prev_arg; union acpi_parse_object *prev_arg;
const struct acpi_opcode_info *op_info; const struct acpi_opcode_info *op_info;
ACPI_FUNCTION_ENTRY(); ACPI_FUNCTION_TRACE(ps_append_arg);
if (!op) { if (!op) {
return; return_VOID;
} }
/* Get the info structure for this opcode */ /* Get the info structure for this opcode */
...@@ -144,7 +144,7 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) ...@@ -144,7 +144,7 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X", ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
op->common.aml_opcode)); op->common.aml_opcode));
return; return_VOID;
} }
/* Check if this opcode requires argument sub-objects */ /* Check if this opcode requires argument sub-objects */
...@@ -153,7 +153,7 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) ...@@ -153,7 +153,7 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
/* Has no linked argument objects */ /* Has no linked argument objects */
return; return_VOID;
} }
/* Append the argument to the linked argument list */ /* Append the argument to the linked argument list */
...@@ -181,6 +181,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) ...@@ -181,6 +181,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
op->common.arg_list_length++; op->common.arg_list_length++;
} }
return_VOID;
} }
/******************************************************************************* /*******************************************************************************
......
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