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: pswalk - Parser routines to walk parsed op tree(s)
|
|
|
|
*
|
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"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_PARSER
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("pswalk")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ps_delete_parse_tree
|
|
|
|
*
|
|
|
|
* PARAMETERS: subtree_root - Root of tree (or subtree) to delete
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Delete a portion of or an entire parse tree.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2018-06-02 03:06:41 +08:00
|
|
|
#include "amlcode.h"
|
2005-08-05 12:44:28 +08:00
|
|
|
void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_parse_object *op = subtree_root;
|
|
|
|
union acpi_parse_object *next = NULL;
|
|
|
|
union acpi_parse_object *parent = NULL;
|
2018-06-02 03:06:41 +08:00
|
|
|
u32 level = 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_PTR(ps_delete_parse_tree, subtree_root);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-06-02 03:06:41 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_PARSE_TREES, " root %p\n", subtree_root));
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Visit all nodes in the subtree */
|
|
|
|
|
|
|
|
while (op) {
|
|
|
|
if (op != parent) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2018-06-02 03:06:41 +08:00
|
|
|
/* This is the descending case */
|
|
|
|
|
|
|
|
if (ACPI_IS_DEBUG_ENABLED
|
|
|
|
(ACPI_LV_PARSE_TREES, _COMPONENT)) {
|
|
|
|
|
|
|
|
/* This debug option will print the entire parse tree */
|
|
|
|
|
|
|
|
acpi_os_printf(" %*.s%s %p", (level * 4),
|
|
|
|
" ",
|
|
|
|
acpi_ps_get_opcode_name(op->
|
|
|
|
common.
|
|
|
|
aml_opcode),
|
|
|
|
op);
|
|
|
|
|
|
|
|
if (op->named.aml_opcode == AML_INT_NAMEPATH_OP) {
|
|
|
|
acpi_os_printf(" %4.4s",
|
|
|
|
op->common.value.string);
|
|
|
|
}
|
|
|
|
if (op->named.aml_opcode == AML_STRING_OP) {
|
|
|
|
acpi_os_printf(" %s",
|
|
|
|
op->common.value.string);
|
|
|
|
}
|
|
|
|
acpi_os_printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Look for an argument or child of the current op */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
next = acpi_ps_get_arg(op, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (next) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Still going downward in tree (Op is not completed yet) */
|
|
|
|
|
|
|
|
op = next;
|
2018-06-02 03:06:41 +08:00
|
|
|
level++;
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/* No more children, this Op is complete. */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
next = op->common.next;
|
|
|
|
parent = op->common.parent;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ps_free_op(op);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/* If we are back to the starting point, the walk is complete. */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (op == subtree_root) {
|
|
|
|
return_VOID;
|
|
|
|
}
|
2015-12-29 13:54:36 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (next) {
|
|
|
|
op = next;
|
2005-08-05 12:44:28 +08:00
|
|
|
} else {
|
2018-06-02 03:06:41 +08:00
|
|
|
level--;
|
2005-04-17 06:20:36 +08:00
|
|
|
op = parent;
|
|
|
|
}
|
|
|
|
}
|
2005-04-19 10:49:35 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return_VOID;
|
|
|
|
}
|