2018-03-15 07:13:07 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: exoparg1 - AML execution - opcodes with 1 argument
|
|
|
|
*
|
2019-01-15 01:55:25 +08:00
|
|
|
* Copyright (C) 2000 - 2019, Intel Corp.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2018-03-15 07:13:07 +08:00
|
|
|
*****************************************************************************/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 13:30:03 +08:00
|
|
|
#include "accommon.h"
|
|
|
|
#include "acparser.h"
|
|
|
|
#include "acdispat.h"
|
|
|
|
#include "acinterp.h"
|
|
|
|
#include "amlcode.h"
|
|
|
|
#include "acnamesp.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_EXECUTER
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("exoparg1")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Naming convention for AML interpreter execution routines.
|
|
|
|
*
|
|
|
|
* The routines that begin execution of AML opcodes are named with a common
|
|
|
|
* convention based upon the number of arguments, the number of target operands,
|
|
|
|
* and whether or not a value is returned:
|
|
|
|
*
|
|
|
|
* AcpiExOpcode_xA_yT_zR
|
|
|
|
*
|
|
|
|
* Where:
|
|
|
|
*
|
|
|
|
* xA - ARGUMENTS: The number of arguments (input operands) that are
|
|
|
|
* required for this opcode type (0 through 6 args).
|
|
|
|
* yT - TARGETS: The number of targets (output operands) that are required
|
|
|
|
* for this opcode type (0, 1, or 2 targets).
|
|
|
|
* zR - RETURN VALUE: Indicates whether this opcode type returns a value
|
|
|
|
* as the function return (0 or 1).
|
|
|
|
*
|
|
|
|
* The AcpiExOpcode* functions are called via the Dispatcher component with
|
|
|
|
* fully resolved operands.
|
|
|
|
!*/
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_opcode_0A_0T_1R
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current state (contains AML opcode)
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Execute operator with no operands, one return value
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status = AE_OK;
|
|
|
|
union acpi_operand_object *return_desc = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE_STR(ex_opcode_0A_0T_1R,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ps_get_opcode_name(walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Examine the AML opcode */
|
|
|
|
|
|
|
|
switch (walk_state->opcode) {
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_TIMER_OP: /* Timer () */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Create a return object of type Integer */
|
|
|
|
|
2009-11-12 09:52:45 +08:00
|
|
|
return_desc =
|
|
|
|
acpi_ut_create_integer_object(acpi_os_get_timer());
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
default: /* Unknown opcode */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-05 17:56:40 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
|
2006-01-28 05:43:00 +08:00
|
|
|
walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_BAD_OPCODE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-29 09:30:02 +08:00
|
|
|
cleanup:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Delete return object on error */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if ((ACPI_FAILURE(status)) || walk_state->result_obj) {
|
|
|
|
acpi_ut_remove_reference(return_desc);
|
2008-04-10 23:06:37 +08:00
|
|
|
walk_state->result_obj = NULL;
|
2005-08-05 12:44:28 +08:00
|
|
|
} else {
|
2005-05-26 12:00:00 +08:00
|
|
|
/* Save the return value */
|
|
|
|
|
|
|
|
walk_state->result_obj = return_desc;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_opcode_1A_0T_0R
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current state (contains AML opcode)
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
|
|
|
|
* object stack
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_operand_object **operand = &walk_state->operands[0];
|
|
|
|
acpi_status status = AE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_0R,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ps_get_opcode_name(walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Examine the AML opcode */
|
|
|
|
|
|
|
|
switch (walk_state->opcode) {
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_RELEASE_OP: /* Release (mutex_object) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_release_mutex(operand[0], walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_RESET_OP: /* Reset (event_object) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_system_reset_event(operand[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_SIGNAL_OP: /* Signal (event_object) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_system_signal_event(operand[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_SLEEP_OP: /* Sleep (msec_time) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-27 11:48:02 +08:00
|
|
|
status = acpi_ex_system_do_sleep(operand[0]->integer.value);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_STALL_OP: /* Stall (usec_time) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_system_do_stall((u32) operand[0]->integer.value);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_UNLOAD_OP: /* Unload (Handle) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_unload_table(operand[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
default: /* Unknown opcode */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-05 17:56:40 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
|
2006-01-28 05:43:00 +08:00
|
|
|
walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_BAD_OPCODE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_opcode_1A_1T_0R
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current state (contains AML opcode)
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Execute opcode with one argument, one target, and no
|
|
|
|
* return value.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status = AE_OK;
|
|
|
|
union acpi_operand_object **operand = &walk_state->operands[0];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_0R,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ps_get_opcode_name(walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Examine the AML opcode */
|
|
|
|
|
|
|
|
switch (walk_state->opcode) {
|
|
|
|
case AML_LOAD_OP:
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_load_op(operand[0], operand[1], walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
default: /* Unknown opcode */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-05 17:56:40 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
|
2006-01-28 05:43:00 +08:00
|
|
|
walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_BAD_OPCODE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-10-29 09:30:02 +08:00
|
|
|
cleanup:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_opcode_1A_1T_1R
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current state (contains AML opcode)
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Execute opcode with one argument, one target, and a
|
|
|
|
* return value.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status = AE_OK;
|
|
|
|
union acpi_operand_object **operand = &walk_state->operands[0];
|
|
|
|
union acpi_operand_object *return_desc = NULL;
|
|
|
|
union acpi_operand_object *return_desc2 = NULL;
|
|
|
|
u32 temp32;
|
|
|
|
u32 i;
|
2010-01-21 10:06:32 +08:00
|
|
|
u64 power_of_ten;
|
|
|
|
u64 digit;
|
2005-08-05 12:44:28 +08:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ps_get_opcode_name(walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Examine the AML opcode */
|
|
|
|
|
|
|
|
switch (walk_state->opcode) {
|
|
|
|
case AML_BIT_NOT_OP:
|
|
|
|
case AML_FIND_SET_LEFT_BIT_OP:
|
|
|
|
case AML_FIND_SET_RIGHT_BIT_OP:
|
|
|
|
case AML_FROM_BCD_OP:
|
|
|
|
case AML_TO_BCD_OP:
|
2017-04-26 16:18:40 +08:00
|
|
|
case AML_CONDITIONAL_REF_OF_OP:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Create a return object of type Integer for these opcodes */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (walk_state->opcode) {
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_BIT_NOT_OP: /* Not (Operand, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return_desc->integer.value = ~operand[0]->integer.value;
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_FIND_SET_LEFT_BIT_OP: /* find_set_left_bit (Operand, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return_desc->integer.value = operand[0]->integer.value;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Acpi specification describes Integer type as a little
|
|
|
|
* endian unsigned value, so this boundary condition is valid.
|
|
|
|
*/
|
|
|
|
for (temp32 = 0; return_desc->integer.value &&
|
2005-08-05 12:44:28 +08:00
|
|
|
temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return_desc->integer.value >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_desc->integer.value = temp32;
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_FIND_SET_RIGHT_BIT_OP: /* find_set_right_bit (Operand, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return_desc->integer.value = operand[0]->integer.value;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Acpi specification describes Integer type as a little
|
|
|
|
* endian unsigned value, so this boundary condition is valid.
|
|
|
|
*/
|
|
|
|
for (temp32 = 0; return_desc->integer.value &&
|
2005-08-05 12:44:28 +08:00
|
|
|
temp32 < ACPI_INTEGER_BIT_SIZE; ++temp32) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return_desc->integer.value <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Since the bit position is one-based, subtract from 33 (65) */
|
|
|
|
|
2006-06-09 04:29:00 +08:00
|
|
|
return_desc->integer.value =
|
|
|
|
temp32 ==
|
|
|
|
0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - temp32;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* The 64-bit ACPI integer can hold 16 4-bit BCD characters
|
|
|
|
* (if table is 32-bit, integer can hold 8 BCD characters)
|
|
|
|
* Convert each 4-bit BCD value
|
|
|
|
*/
|
|
|
|
power_of_ten = 1;
|
|
|
|
return_desc->integer.value = 0;
|
|
|
|
digit = operand[0]->integer.value;
|
|
|
|
|
|
|
|
/* Convert each BCD digit (each is one nybble wide) */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
for (i = 0;
|
|
|
|
(i < acpi_gbl_integer_nybble_width) && (digit > 0);
|
|
|
|
i++) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Get the least significant 4-bit BCD digit */
|
|
|
|
|
|
|
|
temp32 = ((u32) digit) & 0xF;
|
|
|
|
|
|
|
|
/* Check the range of the digit */
|
|
|
|
|
|
|
|
if (temp32 > 9) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"BCD digit too large (not decimal): 0x%X",
|
|
|
|
temp32));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
status = AE_AML_NUMERIC_OVERFLOW;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sum the digit into the result with the current power of 10 */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc->integer.value +=
|
2010-01-21 10:06:32 +08:00
|
|
|
(((u64) temp32) * power_of_ten);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Shift to next BCD digit */
|
|
|
|
|
|
|
|
digit >>= 4;
|
|
|
|
|
|
|
|
/* Next power of 10 */
|
|
|
|
|
|
|
|
power_of_ten *= 10;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_TO_BCD_OP: /* to_bcd (Operand, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return_desc->integer.value = 0;
|
|
|
|
digit = operand[0]->integer.value;
|
|
|
|
|
|
|
|
/* Each BCD digit is one nybble wide */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
for (i = 0;
|
|
|
|
(i < acpi_gbl_integer_nybble_width) && (digit > 0);
|
|
|
|
i++) {
|
|
|
|
(void)acpi_ut_short_divide(digit, 10, &digit,
|
|
|
|
&temp32);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/*
|
|
|
|
* Insert the BCD digit that resides in the
|
|
|
|
* remainder from above
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc->integer.value |=
|
2010-01-21 10:06:32 +08:00
|
|
|
(((u64) temp32) << ACPI_MUL_4(i));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Overflow if there is any data left in Digit */
|
|
|
|
|
|
|
|
if (digit > 0) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 17:56:40 +08:00
|
|
|
"Integer too large to convert to BCD: 0x%8.8X%8.8X",
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_FORMAT_UINT64(operand[0]->
|
|
|
|
integer.value)));
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_NUMERIC_OVERFLOW;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-04-26 16:18:40 +08:00
|
|
|
case AML_CONDITIONAL_REF_OF_OP: /* cond_ref_of (source_object, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This op is a little strange because the internal return value is
|
|
|
|
* different than the return value stored in the result descriptor
|
|
|
|
* (There are really two return values)
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
if ((struct acpi_namespace_node *)operand[0] ==
|
|
|
|
acpi_gbl_root_node) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This means that the object does not exist in the namespace,
|
|
|
|
* return FALSE
|
|
|
|
*/
|
|
|
|
return_desc->integer.value = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the object reference, store it, and remove our reference */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_get_object_reference(operand[0],
|
|
|
|
&return_desc2,
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_store(return_desc2, operand[1], walk_state);
|
|
|
|
acpi_ut_remove_reference(return_desc2);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* The object exists in the namespace, return TRUE */
|
|
|
|
|
2010-01-21 10:06:32 +08:00
|
|
|
return_desc->integer.value = ACPI_UINT64_MAX;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
default:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* No other opcodes get here */
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_STORE_OP: /* Store (Source, Target) */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* A store operand is typically a number, string, buffer or lvalue
|
|
|
|
* Be careful about deleting the source object,
|
|
|
|
* since the object itself may have been stored.
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_store(operand[0], operand[1], walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* It is possible that the Store already produced a return object */
|
|
|
|
|
|
|
|
if (!walk_state->result_obj) {
|
|
|
|
/*
|
2005-04-19 10:49:35 +08:00
|
|
|
* Normally, we would remove a reference on the Operand[0]
|
|
|
|
* parameter; But since it is being used as the internal return
|
|
|
|
* object (meaning we would normally increment it), the two
|
|
|
|
* cancel out, and we simply don't do anything.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
walk_state->result_obj = operand[0];
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->operands[0] = NULL; /* Prevent deletion */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
/*
|
|
|
|
* ACPI 2.0 Opcodes
|
|
|
|
*/
|
2017-04-26 16:18:40 +08:00
|
|
|
case AML_COPY_OBJECT_OP: /* copy_object (Source, Target) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ut_copy_iobject_to_iobject(operand[0], &return_desc,
|
|
|
|
walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2017-04-26 16:18:40 +08:00
|
|
|
case AML_TO_DECIMAL_STRING_OP: /* to_decimal_string (Data, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-12-29 13:54:36 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_convert_to_string(operand[0], &return_desc,
|
|
|
|
ACPI_EXPLICIT_CONVERT_DECIMAL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (return_desc == operand[0]) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* No conversion performed, add ref to handle return value */
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_add_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-04-26 16:18:40 +08:00
|
|
|
case AML_TO_HEX_STRING_OP: /* to_hex_string (Data, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-12-29 13:54:36 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_convert_to_string(operand[0], &return_desc,
|
|
|
|
ACPI_EXPLICIT_CONVERT_HEX);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (return_desc == operand[0]) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* No conversion performed, add ref to handle return value */
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_add_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_TO_BUFFER_OP: /* to_buffer (Data, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_convert_to_buffer(operand[0], &return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (return_desc == operand[0]) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* No conversion performed, add ref to handle return value */
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_add_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_TO_INTEGER_OP: /* to_integer (Data, Result) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-09-07 14:14:30 +08:00
|
|
|
/* Perform "explicit" conversion */
|
|
|
|
|
2015-12-29 13:54:36 +08:00
|
|
|
status =
|
2016-09-07 14:14:30 +08:00
|
|
|
acpi_ex_convert_to_integer(operand[0], &return_desc, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (return_desc == operand[0]) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* No conversion performed, add ref to handle return value */
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_add_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
|
|
|
|
case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/* These are two obsolete opcodes */
|
|
|
|
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"%s is obsolete and not implemented",
|
|
|
|
acpi_ps_get_opcode_name(walk_state->opcode)));
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_SUPPORT;
|
|
|
|
goto cleanup;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
default: /* Unknown opcode */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-05 17:56:40 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
|
2006-01-28 05:43:00 +08:00
|
|
|
walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_BAD_OPCODE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_SUCCESS(status)) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/* Store the return value computed above into the target object */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_store(return_desc, operand[1], walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-10-29 09:30:02 +08:00
|
|
|
cleanup:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Delete return object on error */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
acpi_ut_remove_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
/* Save return object on success */
|
|
|
|
|
|
|
|
else if (!walk_state->result_obj) {
|
|
|
|
walk_state->result_obj = return_desc;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_opcode_1A_0T_1R
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current state (contains AML opcode)
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Execute opcode with one argument, no target, and a return value
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_operand_object **operand = &walk_state->operands[0];
|
|
|
|
union acpi_operand_object *temp_desc;
|
|
|
|
union acpi_operand_object *return_desc = NULL;
|
|
|
|
acpi_status status = AE_OK;
|
|
|
|
u32 type;
|
2010-01-21 10:06:32 +08:00
|
|
|
u64 value;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R,
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ps_get_opcode_name(walk_state->opcode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Examine the AML opcode */
|
|
|
|
|
|
|
|
switch (walk_state->opcode) {
|
2017-04-26 16:18:40 +08:00
|
|
|
case AML_LOGICAL_NOT_OP: /* LNot (Operand) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-11-12 09:52:45 +08:00
|
|
|
return_desc = acpi_ut_create_integer_object((u64) 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-10-31 10:26:55 +08:00
|
|
|
* Set result to ONES (TRUE) if Value == 0. Note:
|
2005-04-17 06:20:36 +08:00
|
|
|
* return_desc->Integer.Value is initially == 0 (FALSE) from above.
|
|
|
|
*/
|
|
|
|
if (!operand[0]->integer.value) {
|
2010-01-21 10:06:32 +08:00
|
|
|
return_desc->integer.value = ACPI_UINT64_MAX;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_DECREMENT_OP: /* Decrement (Operand) */
|
|
|
|
case AML_INCREMENT_OP: /* Increment (Operand) */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2012-10-31 10:26:55 +08:00
|
|
|
* Create a new integer. Can't just get the base integer and
|
2005-04-17 06:20:36 +08:00
|
|
|
* increment it because it may be an Arg or Field.
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we are expecting a Reference operand, it can be either a
|
|
|
|
* NS Node or an internal object.
|
|
|
|
*/
|
|
|
|
temp_desc = operand[0];
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_GET_DESCRIPTOR_TYPE(temp_desc) ==
|
|
|
|
ACPI_DESC_TYPE_OPERAND) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Internal reference object - prevent deletion */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_add_reference(temp_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert the Reference operand to an Integer (This removes a
|
|
|
|
* reference on the Operand[0] object)
|
|
|
|
*
|
|
|
|
* NOTE: We use LNOT_OP here in order to force resolution of the
|
|
|
|
* reference operand to an actual integer.
|
|
|
|
*/
|
2017-04-26 16:18:40 +08:00
|
|
|
status = acpi_ex_resolve_operands(AML_LOGICAL_NOT_OP,
|
|
|
|
&temp_desc, walk_state);
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"While resolving operands for [%s]",
|
|
|
|
acpi_ps_get_opcode_name(walk_state->
|
|
|
|
opcode)));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* temp_desc is now guaranteed to be an Integer object --
|
|
|
|
* Perform the actual increment or decrement
|
|
|
|
*/
|
|
|
|
if (walk_state->opcode == AML_INCREMENT_OP) {
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc->integer.value =
|
|
|
|
temp_desc->integer.value + 1;
|
|
|
|
} else {
|
|
|
|
return_desc->integer.value =
|
|
|
|
temp_desc->integer.value - 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Finished with this Integer object */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_remove_reference(temp_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Store the result back (indirectly) through the original
|
|
|
|
* Reference object
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ex_store(return_desc, operand[0], walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2015-12-29 14:00:28 +08:00
|
|
|
case AML_OBJECT_TYPE_OP: /* object_type (source_object) */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Note: The operand is not resolved at this point because we want to
|
2012-10-31 10:26:55 +08:00
|
|
|
* get the associated object, not its value. For example, we don't
|
2005-04-19 10:49:35 +08:00
|
|
|
* want to resolve a field_unit to its value, we want the actual
|
|
|
|
* field_unit object.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get the type of the base object */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_resolve_multiple(walk_state, operand[0], &type,
|
|
|
|
NULL);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-06-09 04:29:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Allocate a descriptor to hold the type. */
|
|
|
|
|
2009-11-12 09:52:45 +08:00
|
|
|
return_desc = acpi_ut_create_integer_object((u64) type);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_SIZE_OF_OP: /* size_of (source_object) */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Note: The operand is not resolved at this point because we want to
|
|
|
|
* get the associated object, not its value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get the base object */
|
|
|
|
|
2015-12-29 13:54:36 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_resolve_multiple(walk_state, operand[0], &type,
|
|
|
|
&temp_desc);
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The type of the base object must be integer, buffer, string, or
|
2012-10-31 10:26:55 +08:00
|
|
|
* package. All others are not supported.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* NOTE: Integer is not specifically supported by the ACPI spec,
|
|
|
|
* but is supported implicitly via implicit operand conversion.
|
|
|
|
* rather than bother with conversion, we just use the byte width
|
|
|
|
* global (4 or 8 bytes).
|
|
|
|
*/
|
|
|
|
switch (type) {
|
|
|
|
case ACPI_TYPE_INTEGER:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
value = acpi_gbl_integer_byte_width;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_STRING:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
value = temp_desc->string.length;
|
|
|
|
break;
|
|
|
|
|
2008-04-10 23:06:41 +08:00
|
|
|
case ACPI_TYPE_BUFFER:
|
|
|
|
|
|
|
|
/* Buffer arguments may not be evaluated at this point */
|
|
|
|
|
|
|
|
status = acpi_ds_get_buffer_arguments(temp_desc);
|
|
|
|
value = temp_desc->buffer.length;
|
|
|
|
break;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
case ACPI_TYPE_PACKAGE:
|
2008-04-10 23:06:41 +08:00
|
|
|
|
|
|
|
/* Package arguments may not be evaluated at this point */
|
|
|
|
|
|
|
|
status = acpi_ds_get_package_arguments(temp_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
value = temp_desc->package.count;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2015-12-29 13:54:36 +08:00
|
|
|
"Operand must be Buffer/Integer/String/Package"
|
|
|
|
" - found type %s",
|
2006-01-28 05:43:00 +08:00
|
|
|
acpi_ut_get_type_name(type)));
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_OPERAND_TYPE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-04-10 23:06:41 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Now that we have the size of the object, create a result
|
|
|
|
* object to hold the value
|
|
|
|
*/
|
2009-11-12 09:52:45 +08:00
|
|
|
return_desc = acpi_ut_create_integer_object(value);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_REF_OF_OP: /* ref_of (source_object) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_get_object_reference(operand[0], &return_desc,
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
case AML_DEREF_OF_OP: /* deref_of (obj_reference | String) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Check for a method local or argument, or standalone String */
|
|
|
|
|
2006-10-02 12:00:00 +08:00
|
|
|
if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) ==
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DESC_TYPE_NAMED) {
|
2006-10-02 12:00:00 +08:00
|
|
|
temp_desc =
|
|
|
|
acpi_ns_get_attached_object((struct
|
|
|
|
acpi_namespace_node *)
|
|
|
|
operand[0]);
|
|
|
|
if (temp_desc
|
2009-02-18 14:44:03 +08:00
|
|
|
&& ((temp_desc->common.type == ACPI_TYPE_STRING)
|
|
|
|
|| (temp_desc->common.type ==
|
|
|
|
ACPI_TYPE_LOCAL_REFERENCE))) {
|
2006-10-02 12:00:00 +08:00
|
|
|
operand[0] = temp_desc;
|
|
|
|
acpi_ut_add_reference(temp_desc);
|
|
|
|
} else {
|
|
|
|
status = AE_AML_OPERAND_TYPE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else {
|
2009-02-18 14:44:03 +08:00
|
|
|
switch ((operand[0])->common.type) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case ACPI_TYPE_LOCAL_REFERENCE:
|
|
|
|
/*
|
|
|
|
* This is a deref_of (local_x | arg_x)
|
|
|
|
*
|
|
|
|
* Must resolve/dereference the local/arg reference first
|
|
|
|
*/
|
2008-09-27 11:08:41 +08:00
|
|
|
switch (operand[0]->reference.class) {
|
|
|
|
case ACPI_REFCLASS_LOCAL:
|
|
|
|
case ACPI_REFCLASS_ARG:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Set Operand[0] to the value of the local/arg */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ds_method_data_get_value
|
2008-09-27 11:08:41 +08:00
|
|
|
(operand[0]->reference.class,
|
|
|
|
operand[0]->reference.value,
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state, &temp_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete our reference to the input object and
|
|
|
|
* point to the object just retrieved
|
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_remove_reference(operand[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
operand[0] = temp_desc;
|
|
|
|
break;
|
|
|
|
|
2008-09-27 11:08:41 +08:00
|
|
|
case ACPI_REFCLASS_REFOF:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Get the object to which the reference refers */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
temp_desc =
|
|
|
|
operand[0]->reference.object;
|
|
|
|
acpi_ut_remove_reference(operand[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
operand[0] = temp_desc;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Must be an Index op - handled below */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_STRING:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2006-10-02 12:00:00 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-02 12:00:00 +08:00
|
|
|
default:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2006-10-02 12:00:00 +08:00
|
|
|
status = AE_AML_OPERAND_TYPE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) !=
|
|
|
|
ACPI_DESC_TYPE_NAMED) {
|
2009-02-18 14:44:03 +08:00
|
|
|
if ((operand[0])->common.type == ACPI_TYPE_STRING) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-04-19 10:49:35 +08:00
|
|
|
* This is a deref_of (String). The string is a reference
|
|
|
|
* to a named ACPI object.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* 1) Find the owning Node
|
2006-10-02 12:00:00 +08:00
|
|
|
* 2) Dereference the node to an actual object. Could be a
|
2005-04-19 10:49:35 +08:00
|
|
|
* Field, so we need to resolve the node to a value.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
ACPICA: Namespace: Fix dynamic table loading issues
ACPICA commit 767ee53354e0c4b7e8e7c57c6dd7bf569f0d52bb
There are issues related to the namespace/interpreter locks, which causes
several ACPI functionalities not specification compliant. The lock issues
were detectec when we were trying to fix the functionalities (please see
Link # [1] for the details).
What's the lock issues? Let's first look into the namespace/interpreter
lock usages inside of the object evaluation and the table loading which are
the key AML interpretion code paths:
Table loading:
acpi_ns_load_table
L(Namespace)
acpi_ns_parse_table
acpi_ns_one_complete_parse(LOAD_PASS1/LOAD_PASS2)
acpi_ds_load1_begion_op
acpi_ds_load1_end_op
acpi_ds_load2_begion_op
acpi_ds_load2_end_op
U(Namespace)
Object evaluation:
acpi_ns_evaluate
L(Interpreter)
acpi_ps_execute_method
acpi_ds_exec_begin_op
acpi_ds_exec_end_op
U(Interpreter)
acpi_ns_load_table
L(Namespace)
U(Namespace)
acpi_ev_initialize_region
L(Namespace)
U(Namespace)
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
L(Interpreter)
U(Interpreter)
L(Interpreter)
acpi_ex_resolve_node_to_value
U(Interpreter)
acpi_ns_check_return_value
Where:
1. L(Interpreter) means acquire(MTX_INTERPRETER);
2. U(Interpreter) means release(MTX_INTERPRETER);
3. L(Namespace) means acquire(MTX_NAMESPACE);
4. U(Namespace) means release(MTX_NAMESPACE);
We can see that acpi_ns_exec_module_code() (which invokes acpi_ns_evaluate) is
implemented in a deferred way just in order to avoid to reacquire the
namespace lock. This is in fact the root cause of many other ACPICA issues:
1. We now know for sure that the module code should be executed right in
place by the Windows AML interpreter. So in the current design, if
the region initializations/accesses or the table loadings (where the
namespace surely should be locked again) happening during the table
loading period, dead lock could happen because ACPICA never unlocks the
namespace during the AML interpretion.
2. ACPICA interpreter just ensures that all static namespace nodes (named
objects created during the acpi_load_tables()) are created
(acpi_ns_lookup()) with the correct lock held, but doesn't ensure that
the named objects created by the control method are created with the
same correct lock held. It requires the control methods to be executed
in a serial way after "loading a table", that's why ACPICA requires
method auto serialization.
This patch fixes these software design issues by extending interpreter
enter/exit APIs to hold both interpreter/namespace locks to ensure the lock
order correctness, so that we can get these code paths:
Table loading:
acpi_ns_load_table
E(Interpreter)
acpi_ns_parse_table
acpi_ns_one_complete_parse
acpi_ns_execute_table
X(Interpreter)
acpi_ns_load_table
acpi_ev_initialize_region
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
E(Interpreter)
X(Interpreter)
Object evaluation:
acpi_ns_evaluate
E(Interpreter)
acpi_ps_execute_method
X(Interpreter)
acpi_ns_load_table
acpi_ev_initialize_region
address_space.Setup
address_space.Handler
acpi_os_wait_semaphore
acpi_os_acquire_mutex
acpi_os_sleep
E(Interpreter)
X(Interpreter)
Where:
1. E(Interpreter) means acquire(MTX_INTERPRETER, MTX_NAMESPACE);
2. X(Interpreter) means release(MTX_NAMESPACE, MTX_INTERPRETER);
After this change, we can see:
1. All namespace nodes creations are locked by the namespace lock.
2. All namespace nodes referencing are locked with the same lock.
3. But we also can notice a defact that, all namespace nodes deletions
could be affected by this change. As a consequence,
acpi_ns_delete_namespace_subtree() may delete a static namespace node that
is still referenced by the interpreter (for example, the parser scopes).
Currently, we needn't worry about the last defact because in ACPICA, table
unloading is not fully functioning, its design strictly relies on the fact
that when the namespace deletion happens, either the AML table or the OSPMs
should have been notified and thus either the AML table or the OSPMs
shouldn't reference deletion-related namespace nodes during the namespace
deletion. And this change still works with the above restrictions applied.
While making this a-step-forward helps us to correct the wrong grammar to
pull many things back to the correct rail. And pulling things back to the
correct rail in return makes it possible for us to support fully
functioning table unloading after doing many cleanups.
While this patch is generated, all namespace locks are examined to ensure
that they can meet either of the following pattens:
1. L(Namespace)
U(Namespace)
2. E(Interpreter)
X(Interpreter)
3. E(Interpreter)
X(Interpreter)
L(Namespace)
U(Namespace)
E(Interpreter)
X(Interpreter)
We ensure this by adding X(Interpreter)/E(Interpreter) or removing
U(Namespace)/L(Namespace) for those currently are executed in the following
order:
E(Interpreter)
L(Namespace)
U(Namespace)
X(Interpreter)
And adding E(Interpreter)/X(Interpreter) for those currently are executed
in the following order:
X(Interpreter)
E(Interpreter)
Originally, the interpreter lock is held for the execution AML opcodes, the
namespace lock is held for the named object creation AML opcodes. Since
they are actually same in MS interpreter (can all be executed during the
table loading), we can combine the 2 locks and tune the locking code better
in this way. Lv Zheng.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=153541 # [1]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=121701 # [1]
Link: https://bugs.acpica.org/show_bug.cgi?id=1323
Link: https://github.com/acpica/acpica/commit/767ee533
Reported-and-tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reported-and-tested-by: Greg White <gwhite@kupulau.com>
Reported-and-tested-by: Dutch Guy <lucht_piloot@gmx.net>
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>
2016-09-07 14:07:10 +08:00
|
|
|
acpi_ns_get_node_unlocked(walk_state->
|
|
|
|
scope_info->scope.
|
|
|
|
node,
|
|
|
|
operand[0]->
|
|
|
|
string.pointer,
|
|
|
|
ACPI_NS_SEARCH_PARENT,
|
|
|
|
ACPI_CAST_INDIRECT_PTR
|
|
|
|
(struct
|
|
|
|
acpi_namespace_node,
|
|
|
|
&return_desc));
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ex_resolve_node_to_value
|
|
|
|
(ACPI_CAST_INDIRECT_PTR
|
|
|
|
(struct acpi_namespace_node, &return_desc),
|
|
|
|
walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Operand[0] may have changed from the code above */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) ==
|
|
|
|
ACPI_DESC_TYPE_NAMED) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This is a deref_of (object_reference)
|
|
|
|
* Get the actual object from the Node (This is the dereference).
|
2005-04-19 10:49:35 +08:00
|
|
|
* This case may only happen when a local_x or arg_x is
|
2017-06-05 16:41:18 +08:00
|
|
|
* dereferenced above, or for references to device and
|
|
|
|
* thermal objects.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2017-06-05 16:41:18 +08:00
|
|
|
switch (((struct acpi_namespace_node *)operand[0])->
|
|
|
|
type) {
|
|
|
|
case ACPI_TYPE_DEVICE:
|
|
|
|
case ACPI_TYPE_THERMAL:
|
|
|
|
|
|
|
|
/* These types have no node subobject, return the NS node */
|
|
|
|
|
|
|
|
return_desc = operand[0];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* For most types, get the object attached to the node */
|
|
|
|
|
|
|
|
return_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *)operand[0]);
|
|
|
|
acpi_ut_add_reference(return_desc);
|
|
|
|
break;
|
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-04-19 10:49:35 +08:00
|
|
|
* This must be a reference object produced by either the
|
|
|
|
* Index() or ref_of() operator
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2008-09-27 11:08:41 +08:00
|
|
|
switch (operand[0]->reference.class) {
|
|
|
|
case ACPI_REFCLASS_INDEX:
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* The target type for the Index operator must be
|
|
|
|
* either a Buffer or a Package
|
|
|
|
*/
|
|
|
|
switch (operand[0]->reference.target_type) {
|
|
|
|
case ACPI_TYPE_BUFFER_FIELD:
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
temp_desc =
|
|
|
|
operand[0]->reference.object;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a new object that contains one element of the
|
|
|
|
* buffer -- the element pointed to by the index.
|
|
|
|
*
|
|
|
|
* NOTE: index into a buffer is NOT a pointer to a
|
|
|
|
* sub-buffer of the main buffer, it is only a pointer to a
|
|
|
|
* single element (byte) of the buffer!
|
2009-11-12 09:52:45 +08:00
|
|
|
*
|
|
|
|
* Since we are returning the value of the buffer at the
|
|
|
|
* indexed location, we don't need to add an additional
|
|
|
|
* reference to the buffer itself.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc =
|
2009-11-12 09:52:45 +08:00
|
|
|
acpi_ut_create_integer_object((u64)
|
2012-12-19 13:37:15 +08:00
|
|
|
temp_desc->buffer.pointer[operand[0]->reference.value]);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
status = AE_NO_MEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_PACKAGE:
|
|
|
|
/*
|
2012-10-31 10:26:55 +08:00
|
|
|
* Return the referenced element of the package. We must
|
2005-04-19 10:49:35 +08:00
|
|
|
* add another reference to the referenced object, however.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-08-05 12:44:28 +08:00
|
|
|
return_desc =
|
|
|
|
*(operand[0]->reference.where);
|
2013-08-08 15:29:58 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
/*
|
|
|
|
* Element is NULL, do not allow the dereference.
|
|
|
|
* This provides compatibility with other ACPI
|
|
|
|
* implementations.
|
|
|
|
*/
|
|
|
|
return_ACPI_STATUS
|
|
|
|
(AE_AML_UNINITIALIZED_ELEMENT);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2013-08-08 15:29:58 +08:00
|
|
|
|
|
|
|
acpi_ut_add_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 17:56:40 +08:00
|
|
|
"Unknown Index TargetType 0x%X in reference object %p",
|
2006-01-28 05:43:00 +08:00
|
|
|
operand[0]->reference.
|
|
|
|
target_type, operand[0]));
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_OPERAND_TYPE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-09-27 11:08:41 +08:00
|
|
|
case ACPI_REFCLASS_REFOF:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return_desc = operand[0]->reference.object;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_GET_DESCRIPTOR_TYPE(return_desc) ==
|
|
|
|
ACPI_DESC_TYPE_NAMED) {
|
|
|
|
return_desc =
|
|
|
|
acpi_ns_get_attached_object((struct
|
|
|
|
acpi_namespace_node
|
|
|
|
*)
|
|
|
|
return_desc);
|
2013-08-08 15:29:32 +08:00
|
|
|
if (!return_desc) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* June 2013:
|
|
|
|
* buffer_fields/field_units require additional resolution
|
|
|
|
*/
|
|
|
|
switch (return_desc->common.type) {
|
|
|
|
case ACPI_TYPE_BUFFER_FIELD:
|
|
|
|
case ACPI_TYPE_LOCAL_REGION_FIELD:
|
|
|
|
case ACPI_TYPE_LOCAL_BANK_FIELD:
|
|
|
|
case ACPI_TYPE_LOCAL_INDEX_FIELD:
|
|
|
|
|
|
|
|
status =
|
|
|
|
acpi_ex_read_data_from_field
|
|
|
|
(walk_state, return_desc,
|
|
|
|
&temp_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-08 15:29:32 +08:00
|
|
|
return_desc = temp_desc;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-08 15:29:32 +08:00
|
|
|
default:
|
|
|
|
|
|
|
|
/* Add another reference to the object */
|
|
|
|
|
|
|
|
acpi_ut_add_reference
|
|
|
|
(return_desc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 17:56:40 +08:00
|
|
|
"Unknown class in reference(%p) - 0x%2.2X",
|
2006-01-28 05:43:00 +08:00
|
|
|
operand[0],
|
2008-09-27 11:08:41 +08:00
|
|
|
operand[0]->reference.class));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
status = AE_TYPE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
2010-03-05 17:56:40 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
|
2006-01-28 05:43:00 +08:00
|
|
|
walk_state->opcode));
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
status = AE_AML_BAD_OPCODE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-10-29 09:30:02 +08:00
|
|
|
cleanup:
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Delete return object on error */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
acpi_ut_remove_reference(return_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
/* Save return object on success */
|
|
|
|
|
|
|
|
else {
|
|
|
|
walk_state->result_obj = return_desc;
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|