126f3cdf0SGordon Ross /******************************************************************************
226f3cdf0SGordon Ross *
326f3cdf0SGordon Ross * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
426f3cdf0SGordon Ross *
526f3cdf0SGordon Ross *****************************************************************************/
626f3cdf0SGordon Ross
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi *
9*35786f68SRobert Mustacchi * 1. Copyright Notice
10*35786f68SRobert Mustacchi *
11*35786f68SRobert Mustacchi * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
1226f3cdf0SGordon Ross * All rights reserved.
1326f3cdf0SGordon Ross *
14*35786f68SRobert Mustacchi * 2. License
15*35786f68SRobert Mustacchi *
16*35786f68SRobert Mustacchi * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi * property rights.
20*35786f68SRobert Mustacchi *
21*35786f68SRobert Mustacchi * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi *
28*35786f68SRobert Mustacchi * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi *
37*35786f68SRobert Mustacchi * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi * conditions are met:
39*35786f68SRobert Mustacchi *
40*35786f68SRobert Mustacchi * 3. Conditions
41*35786f68SRobert Mustacchi *
42*35786f68SRobert Mustacchi * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi *
54*35786f68SRobert Mustacchi * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi * make.
65*35786f68SRobert Mustacchi *
66*35786f68SRobert Mustacchi * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi * distribution.
71*35786f68SRobert Mustacchi *
72*35786f68SRobert Mustacchi * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi * Intel Code.
74*35786f68SRobert Mustacchi *
75*35786f68SRobert Mustacchi * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi *
80*35786f68SRobert Mustacchi * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi *
82*35786f68SRobert Mustacchi * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi *
90*35786f68SRobert Mustacchi * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi * LIMITED REMEDY.
98*35786f68SRobert Mustacchi *
99*35786f68SRobert Mustacchi * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi * such license, approval or letter.
113*35786f68SRobert Mustacchi *
114*35786f68SRobert Mustacchi *****************************************************************************
115*35786f68SRobert Mustacchi *
116*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi * following license:
118*35786f68SRobert Mustacchi *
11926f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without
12026f3cdf0SGordon Ross * modification, are permitted provided that the following conditions
12126f3cdf0SGordon Ross * are met:
12226f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright
12326f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer,
12426f3cdf0SGordon Ross * without modification.
12526f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12626f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below
12726f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon
12826f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further
12926f3cdf0SGordon Ross * binary redistribution.
13026f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names
13126f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived
13226f3cdf0SGordon Ross * from this software without specific prior written permission.
13326f3cdf0SGordon Ross *
13426f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13526f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
13726f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi *
146*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi * Software Foundation.
149*35786f68SRobert Mustacchi *
150*35786f68SRobert Mustacchi *****************************************************************************/
15126f3cdf0SGordon Ross
15226f3cdf0SGordon Ross #include "acpi.h"
15326f3cdf0SGordon Ross #include "accommon.h"
15426f3cdf0SGordon Ross #include "acparser.h"
15526f3cdf0SGordon Ross #include "amlcode.h"
15626f3cdf0SGordon Ross #include "acdispat.h"
15726f3cdf0SGordon Ross #include "acinterp.h"
15826f3cdf0SGordon Ross #include "acnamesp.h"
15926f3cdf0SGordon Ross #include "acevents.h"
16026f3cdf0SGordon Ross
16126f3cdf0SGordon Ross #define _COMPONENT ACPI_DISPATCHER
16226f3cdf0SGordon Ross ACPI_MODULE_NAME ("dswload2")
16326f3cdf0SGordon Ross
16426f3cdf0SGordon Ross
16526f3cdf0SGordon Ross /*******************************************************************************
16626f3cdf0SGordon Ross *
16726f3cdf0SGordon Ross * FUNCTION: AcpiDsLoad2BeginOp
16826f3cdf0SGordon Ross *
16926f3cdf0SGordon Ross * PARAMETERS: WalkState - Current state of the parse tree walk
17026f3cdf0SGordon Ross * OutOp - Wher to return op if a new one is created
17126f3cdf0SGordon Ross *
17226f3cdf0SGordon Ross * RETURN: Status
17326f3cdf0SGordon Ross *
17426f3cdf0SGordon Ross * DESCRIPTION: Descending callback used during the loading of ACPI tables.
17526f3cdf0SGordon Ross *
17626f3cdf0SGordon Ross ******************************************************************************/
17726f3cdf0SGordon Ross
17826f3cdf0SGordon Ross ACPI_STATUS
AcpiDsLoad2BeginOp(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT ** OutOp)17926f3cdf0SGordon Ross AcpiDsLoad2BeginOp (
18026f3cdf0SGordon Ross ACPI_WALK_STATE *WalkState,
18126f3cdf0SGordon Ross ACPI_PARSE_OBJECT **OutOp)
18226f3cdf0SGordon Ross {
18326f3cdf0SGordon Ross ACPI_PARSE_OBJECT *Op;
18426f3cdf0SGordon Ross ACPI_NAMESPACE_NODE *Node;
18526f3cdf0SGordon Ross ACPI_STATUS Status;
18626f3cdf0SGordon Ross ACPI_OBJECT_TYPE ObjectType;
18726f3cdf0SGordon Ross char *BufferPtr;
18826f3cdf0SGordon Ross UINT32 Flags;
18926f3cdf0SGordon Ross
19026f3cdf0SGordon Ross
19126f3cdf0SGordon Ross ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
19226f3cdf0SGordon Ross
19326f3cdf0SGordon Ross
19426f3cdf0SGordon Ross Op = WalkState->Op;
19526f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
19626f3cdf0SGordon Ross
19726f3cdf0SGordon Ross if (Op)
19826f3cdf0SGordon Ross {
19926f3cdf0SGordon Ross if ((WalkState->ControlState) &&
20026f3cdf0SGordon Ross (WalkState->ControlState->Common.State ==
20126f3cdf0SGordon Ross ACPI_CONTROL_CONDITIONAL_EXECUTING))
20226f3cdf0SGordon Ross {
20326f3cdf0SGordon Ross /* We are executing a while loop outside of a method */
20426f3cdf0SGordon Ross
20526f3cdf0SGordon Ross Status = AcpiDsExecBeginOp (WalkState, OutOp);
20626f3cdf0SGordon Ross return_ACPI_STATUS (Status);
20726f3cdf0SGordon Ross }
20826f3cdf0SGordon Ross
20926f3cdf0SGordon Ross /* We only care about Namespace opcodes here */
21026f3cdf0SGordon Ross
21126f3cdf0SGordon Ross if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&
21226f3cdf0SGordon Ross (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
21326f3cdf0SGordon Ross (!(WalkState->OpInfo->Flags & AML_NAMED)))
21426f3cdf0SGordon Ross {
21526f3cdf0SGordon Ross return_ACPI_STATUS (AE_OK);
21626f3cdf0SGordon Ross }
21726f3cdf0SGordon Ross
21826f3cdf0SGordon Ross /* Get the name we are going to enter or lookup in the namespace */
21926f3cdf0SGordon Ross
22026f3cdf0SGordon Ross if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
22126f3cdf0SGordon Ross {
22226f3cdf0SGordon Ross /* For Namepath op, get the path string */
22326f3cdf0SGordon Ross
22426f3cdf0SGordon Ross BufferPtr = Op->Common.Value.String;
22526f3cdf0SGordon Ross if (!BufferPtr)
22626f3cdf0SGordon Ross {
22726f3cdf0SGordon Ross /* No name, just exit */
22826f3cdf0SGordon Ross
22926f3cdf0SGordon Ross return_ACPI_STATUS (AE_OK);
23026f3cdf0SGordon Ross }
23126f3cdf0SGordon Ross }
23226f3cdf0SGordon Ross else
23326f3cdf0SGordon Ross {
23426f3cdf0SGordon Ross /* Get name from the op */
23526f3cdf0SGordon Ross
23626f3cdf0SGordon Ross BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
23726f3cdf0SGordon Ross }
23826f3cdf0SGordon Ross }
23926f3cdf0SGordon Ross else
24026f3cdf0SGordon Ross {
24126f3cdf0SGordon Ross /* Get the namestring from the raw AML */
24226f3cdf0SGordon Ross
24326f3cdf0SGordon Ross BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
24426f3cdf0SGordon Ross }
24526f3cdf0SGordon Ross
24626f3cdf0SGordon Ross /* Map the opcode into an internal object type */
24726f3cdf0SGordon Ross
24826f3cdf0SGordon Ross ObjectType = WalkState->OpInfo->ObjectType;
24926f3cdf0SGordon Ross
25026f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
25126f3cdf0SGordon Ross "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
25226f3cdf0SGordon Ross
25326f3cdf0SGordon Ross switch (WalkState->Opcode)
25426f3cdf0SGordon Ross {
25526f3cdf0SGordon Ross case AML_FIELD_OP:
25626f3cdf0SGordon Ross case AML_BANK_FIELD_OP:
25726f3cdf0SGordon Ross case AML_INDEX_FIELD_OP:
25826f3cdf0SGordon Ross
25926f3cdf0SGordon Ross Node = NULL;
26026f3cdf0SGordon Ross Status = AE_OK;
26126f3cdf0SGordon Ross break;
26226f3cdf0SGordon Ross
26326f3cdf0SGordon Ross case AML_INT_NAMEPATH_OP:
26426f3cdf0SGordon Ross /*
26526f3cdf0SGordon Ross * The NamePath is an object reference to an existing object.
26626f3cdf0SGordon Ross * Don't enter the name into the namespace, but look it up
26726f3cdf0SGordon Ross * for use later.
26826f3cdf0SGordon Ross */
26926f3cdf0SGordon Ross Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
2707b1019a6SJerry Jelinek ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
2717b1019a6SJerry Jelinek WalkState, &(Node));
27226f3cdf0SGordon Ross break;
27326f3cdf0SGordon Ross
27426f3cdf0SGordon Ross case AML_SCOPE_OP:
27526f3cdf0SGordon Ross
27626f3cdf0SGordon Ross /* Special case for Scope(\) -> refers to the Root node */
27726f3cdf0SGordon Ross
27826f3cdf0SGordon Ross if (Op && (Op->Named.Node == AcpiGbl_RootNode))
27926f3cdf0SGordon Ross {
28026f3cdf0SGordon Ross Node = Op->Named.Node;
28126f3cdf0SGordon Ross
28226f3cdf0SGordon Ross Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
28326f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
28426f3cdf0SGordon Ross {
28526f3cdf0SGordon Ross return_ACPI_STATUS (Status);
28626f3cdf0SGordon Ross }
28726f3cdf0SGordon Ross }
28826f3cdf0SGordon Ross else
28926f3cdf0SGordon Ross {
29026f3cdf0SGordon Ross /*
29126f3cdf0SGordon Ross * The Path is an object reference to an existing object.
29226f3cdf0SGordon Ross * Don't enter the name into the namespace, but look it up
29326f3cdf0SGordon Ross * for use later.
29426f3cdf0SGordon Ross */
29526f3cdf0SGordon Ross Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
2967b1019a6SJerry Jelinek ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
2977b1019a6SJerry Jelinek WalkState, &(Node));
29826f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
29926f3cdf0SGordon Ross {
30026f3cdf0SGordon Ross #ifdef ACPI_ASL_COMPILER
30126f3cdf0SGordon Ross if (Status == AE_NOT_FOUND)
30226f3cdf0SGordon Ross {
30326f3cdf0SGordon Ross Status = AE_OK;
30426f3cdf0SGordon Ross }
30526f3cdf0SGordon Ross else
30626f3cdf0SGordon Ross {
307*35786f68SRobert Mustacchi ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
308*35786f68SRobert Mustacchi BufferPtr, Status);
30926f3cdf0SGordon Ross }
31026f3cdf0SGordon Ross #else
311*35786f68SRobert Mustacchi ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
312*35786f68SRobert Mustacchi BufferPtr, Status);
31326f3cdf0SGordon Ross #endif
31426f3cdf0SGordon Ross return_ACPI_STATUS (Status);
31526f3cdf0SGordon Ross }
31626f3cdf0SGordon Ross }
31726f3cdf0SGordon Ross
31826f3cdf0SGordon Ross /*
31926f3cdf0SGordon Ross * We must check to make sure that the target is
32026f3cdf0SGordon Ross * one of the opcodes that actually opens a scope
32126f3cdf0SGordon Ross */
32226f3cdf0SGordon Ross switch (Node->Type)
32326f3cdf0SGordon Ross {
32426f3cdf0SGordon Ross case ACPI_TYPE_ANY:
32526f3cdf0SGordon Ross case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
32626f3cdf0SGordon Ross case ACPI_TYPE_DEVICE:
32726f3cdf0SGordon Ross case ACPI_TYPE_POWER:
32826f3cdf0SGordon Ross case ACPI_TYPE_PROCESSOR:
32926f3cdf0SGordon Ross case ACPI_TYPE_THERMAL:
33026f3cdf0SGordon Ross
33126f3cdf0SGordon Ross /* These are acceptable types */
33226f3cdf0SGordon Ross break;
33326f3cdf0SGordon Ross
33426f3cdf0SGordon Ross case ACPI_TYPE_INTEGER:
33526f3cdf0SGordon Ross case ACPI_TYPE_STRING:
33626f3cdf0SGordon Ross case ACPI_TYPE_BUFFER:
33726f3cdf0SGordon Ross
33826f3cdf0SGordon Ross /*
33926f3cdf0SGordon Ross * These types we will allow, but we will change the type.
34026f3cdf0SGordon Ross * This enables some existing code of the form:
34126f3cdf0SGordon Ross *
34226f3cdf0SGordon Ross * Name (DEB, 0)
34326f3cdf0SGordon Ross * Scope (DEB) { ... }
34426f3cdf0SGordon Ross */
34526f3cdf0SGordon Ross ACPI_WARNING ((AE_INFO,
34626f3cdf0SGordon Ross "Type override - [%4.4s] had invalid type (%s) "
3477b1019a6SJerry Jelinek "for Scope operator, changed to type ANY",
34826f3cdf0SGordon Ross AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
34926f3cdf0SGordon Ross
35026f3cdf0SGordon Ross Node->Type = ACPI_TYPE_ANY;
35126f3cdf0SGordon Ross WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
35226f3cdf0SGordon Ross break;
35326f3cdf0SGordon Ross
3547b1019a6SJerry Jelinek case ACPI_TYPE_METHOD:
3557b1019a6SJerry Jelinek
3567b1019a6SJerry Jelinek /*
3577b1019a6SJerry Jelinek * Allow scope change to root during execution of module-level
3587b1019a6SJerry Jelinek * code. Root is typed METHOD during this time.
3597b1019a6SJerry Jelinek */
3607b1019a6SJerry Jelinek if ((Node == AcpiGbl_RootNode) &&
3617b1019a6SJerry Jelinek (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
3627b1019a6SJerry Jelinek {
3637b1019a6SJerry Jelinek break;
3647b1019a6SJerry Jelinek }
3657b1019a6SJerry Jelinek
3667b1019a6SJerry Jelinek /*lint -fallthrough */
3677b1019a6SJerry Jelinek
36826f3cdf0SGordon Ross default:
36926f3cdf0SGordon Ross
37026f3cdf0SGordon Ross /* All other types are an error */
37126f3cdf0SGordon Ross
37226f3cdf0SGordon Ross ACPI_ERROR ((AE_INFO,
37326f3cdf0SGordon Ross "Invalid type (%s) for target of "
37426f3cdf0SGordon Ross "Scope operator [%4.4s] (Cannot override)",
37526f3cdf0SGordon Ross AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
37626f3cdf0SGordon Ross
3777b1019a6SJerry Jelinek return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
37826f3cdf0SGordon Ross }
37926f3cdf0SGordon Ross break;
38026f3cdf0SGordon Ross
38126f3cdf0SGordon Ross default:
38226f3cdf0SGordon Ross
38326f3cdf0SGordon Ross /* All other opcodes */
38426f3cdf0SGordon Ross
38526f3cdf0SGordon Ross if (Op && Op->Common.Node)
38626f3cdf0SGordon Ross {
38726f3cdf0SGordon Ross /* This op/node was previously entered into the namespace */
38826f3cdf0SGordon Ross
38926f3cdf0SGordon Ross Node = Op->Common.Node;
39026f3cdf0SGordon Ross
39126f3cdf0SGordon Ross if (AcpiNsOpensScope (ObjectType))
39226f3cdf0SGordon Ross {
39326f3cdf0SGordon Ross Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
39426f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
39526f3cdf0SGordon Ross {
39626f3cdf0SGordon Ross return_ACPI_STATUS (Status);
39726f3cdf0SGordon Ross }
39826f3cdf0SGordon Ross }
39926f3cdf0SGordon Ross
40026f3cdf0SGordon Ross return_ACPI_STATUS (AE_OK);
40126f3cdf0SGordon Ross }
40226f3cdf0SGordon Ross
40326f3cdf0SGordon Ross /*
40426f3cdf0SGordon Ross * Enter the named type into the internal namespace. We enter the name
40526f3cdf0SGordon Ross * as we go downward in the parse tree. Any necessary subobjects that
40626f3cdf0SGordon Ross * involve arguments to the opcode must be created as we go back up the
40726f3cdf0SGordon Ross * parse tree later.
40826f3cdf0SGordon Ross *
40926f3cdf0SGordon Ross * Note: Name may already exist if we are executing a deferred opcode.
41026f3cdf0SGordon Ross */
41126f3cdf0SGordon Ross if (WalkState->DeferredNode)
41226f3cdf0SGordon Ross {
41326f3cdf0SGordon Ross /* This name is already in the namespace, get the node */
41426f3cdf0SGordon Ross
41526f3cdf0SGordon Ross Node = WalkState->DeferredNode;
41626f3cdf0SGordon Ross Status = AE_OK;
41726f3cdf0SGordon Ross break;
41826f3cdf0SGordon Ross }
41926f3cdf0SGordon Ross
42026f3cdf0SGordon Ross Flags = ACPI_NS_NO_UPSEARCH;
42126f3cdf0SGordon Ross if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
42226f3cdf0SGordon Ross {
42326f3cdf0SGordon Ross /* Execution mode, node cannot already exist, node is temporary */
42426f3cdf0SGordon Ross
42526f3cdf0SGordon Ross Flags |= ACPI_NS_ERROR_IF_FOUND;
42626f3cdf0SGordon Ross
42726f3cdf0SGordon Ross if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
42826f3cdf0SGordon Ross {
42926f3cdf0SGordon Ross Flags |= ACPI_NS_TEMPORARY;
43026f3cdf0SGordon Ross }
43126f3cdf0SGordon Ross }
43226f3cdf0SGordon Ross
433*35786f68SRobert Mustacchi #ifdef ACPI_ASL_COMPILER
434*35786f68SRobert Mustacchi
435*35786f68SRobert Mustacchi /*
436*35786f68SRobert Mustacchi * Do not open a scope for AML_EXTERNAL_OP
437*35786f68SRobert Mustacchi * AcpiNsLookup can open a new scope based on the object type
438*35786f68SRobert Mustacchi * of this op. AML_EXTERNAL_OP is a declaration rather than a
439*35786f68SRobert Mustacchi * definition. In the case that this external is a method object,
440*35786f68SRobert Mustacchi * AcpiNsLookup will open a new scope. However, an AML_EXTERNAL_OP
441*35786f68SRobert Mustacchi * associated with the ACPI_TYPE_METHOD is a declaration, rather than
442*35786f68SRobert Mustacchi * a definition. Flags is set to avoid opening a scope for any
443*35786f68SRobert Mustacchi * AML_EXTERNAL_OP.
444*35786f68SRobert Mustacchi */
445*35786f68SRobert Mustacchi if (WalkState->Opcode == AML_EXTERNAL_OP)
446*35786f68SRobert Mustacchi {
447*35786f68SRobert Mustacchi Flags |= ACPI_NS_DONT_OPEN_SCOPE;
448*35786f68SRobert Mustacchi }
449*35786f68SRobert Mustacchi #endif
450*35786f68SRobert Mustacchi
45126f3cdf0SGordon Ross /* Add new entry or lookup existing entry */
45226f3cdf0SGordon Ross
45326f3cdf0SGordon Ross Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
4547b1019a6SJerry Jelinek ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
45526f3cdf0SGordon Ross
45626f3cdf0SGordon Ross if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
45726f3cdf0SGordon Ross {
45826f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
45926f3cdf0SGordon Ross "***New Node [%4.4s] %p is temporary\n",
46026f3cdf0SGordon Ross AcpiUtGetNodeName (Node), Node));
46126f3cdf0SGordon Ross }
46226f3cdf0SGordon Ross break;
46326f3cdf0SGordon Ross }
46426f3cdf0SGordon Ross
46526f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
46626f3cdf0SGordon Ross {
467*35786f68SRobert Mustacchi ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
468*35786f68SRobert Mustacchi BufferPtr, Status);
46926f3cdf0SGordon Ross return_ACPI_STATUS (Status);
47026f3cdf0SGordon Ross }
47126f3cdf0SGordon Ross
47226f3cdf0SGordon Ross if (!Op)
47326f3cdf0SGordon Ross {
47426f3cdf0SGordon Ross /* Create a new op */
47526f3cdf0SGordon Ross
4767b1019a6SJerry Jelinek Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
47726f3cdf0SGordon Ross if (!Op)
47826f3cdf0SGordon Ross {
47926f3cdf0SGordon Ross return_ACPI_STATUS (AE_NO_MEMORY);
48026f3cdf0SGordon Ross }
48126f3cdf0SGordon Ross
48226f3cdf0SGordon Ross /* Initialize the new op */
48326f3cdf0SGordon Ross
48426f3cdf0SGordon Ross if (Node)
48526f3cdf0SGordon Ross {
48626f3cdf0SGordon Ross Op->Named.Name = Node->Name.Integer;
48726f3cdf0SGordon Ross }
48826f3cdf0SGordon Ross *OutOp = Op;
48926f3cdf0SGordon Ross }
49026f3cdf0SGordon Ross
49126f3cdf0SGordon Ross /*
49226f3cdf0SGordon Ross * Put the Node in the "op" object that the parser uses, so we
49326f3cdf0SGordon Ross * can get it again quickly when this scope is closed
49426f3cdf0SGordon Ross */
49526f3cdf0SGordon Ross Op->Common.Node = Node;
49626f3cdf0SGordon Ross return_ACPI_STATUS (Status);
49726f3cdf0SGordon Ross }
49826f3cdf0SGordon Ross
49926f3cdf0SGordon Ross
50026f3cdf0SGordon Ross /*******************************************************************************
50126f3cdf0SGordon Ross *
50226f3cdf0SGordon Ross * FUNCTION: AcpiDsLoad2EndOp
50326f3cdf0SGordon Ross *
50426f3cdf0SGordon Ross * PARAMETERS: WalkState - Current state of the parse tree walk
50526f3cdf0SGordon Ross *
50626f3cdf0SGordon Ross * RETURN: Status
50726f3cdf0SGordon Ross *
50826f3cdf0SGordon Ross * DESCRIPTION: Ascending callback used during the loading of the namespace,
50926f3cdf0SGordon Ross * both control methods and everything else.
51026f3cdf0SGordon Ross *
51126f3cdf0SGordon Ross ******************************************************************************/
51226f3cdf0SGordon Ross
51326f3cdf0SGordon Ross ACPI_STATUS
AcpiDsLoad2EndOp(ACPI_WALK_STATE * WalkState)51426f3cdf0SGordon Ross AcpiDsLoad2EndOp (
51526f3cdf0SGordon Ross ACPI_WALK_STATE *WalkState)
51626f3cdf0SGordon Ross {
51726f3cdf0SGordon Ross ACPI_PARSE_OBJECT *Op;
51826f3cdf0SGordon Ross ACPI_STATUS Status = AE_OK;
51926f3cdf0SGordon Ross ACPI_OBJECT_TYPE ObjectType;
52026f3cdf0SGordon Ross ACPI_NAMESPACE_NODE *Node;
52126f3cdf0SGordon Ross ACPI_PARSE_OBJECT *Arg;
52226f3cdf0SGordon Ross ACPI_NAMESPACE_NODE *NewNode;
52326f3cdf0SGordon Ross #ifndef ACPI_NO_METHOD_EXECUTION
52426f3cdf0SGordon Ross UINT32 i;
52526f3cdf0SGordon Ross UINT8 RegionSpace;
52626f3cdf0SGordon Ross #endif
52726f3cdf0SGordon Ross
52826f3cdf0SGordon Ross
52926f3cdf0SGordon Ross ACPI_FUNCTION_TRACE (DsLoad2EndOp);
53026f3cdf0SGordon Ross
53126f3cdf0SGordon Ross Op = WalkState->Op;
53226f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
5337b1019a6SJerry Jelinek WalkState->OpInfo->Name, Op, WalkState));
53426f3cdf0SGordon Ross
53526f3cdf0SGordon Ross /* Check if opcode had an associated namespace object */
53626f3cdf0SGordon Ross
53726f3cdf0SGordon Ross if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
53826f3cdf0SGordon Ross {
53926f3cdf0SGordon Ross return_ACPI_STATUS (AE_OK);
54026f3cdf0SGordon Ross }
54126f3cdf0SGordon Ross
54226f3cdf0SGordon Ross if (Op->Common.AmlOpcode == AML_SCOPE_OP)
54326f3cdf0SGordon Ross {
54426f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
54526f3cdf0SGordon Ross "Ending scope Op=%p State=%p\n", Op, WalkState));
54626f3cdf0SGordon Ross }
54726f3cdf0SGordon Ross
54826f3cdf0SGordon Ross ObjectType = WalkState->OpInfo->ObjectType;
54926f3cdf0SGordon Ross
55026f3cdf0SGordon Ross /*
55126f3cdf0SGordon Ross * Get the Node/name from the earlier lookup
55226f3cdf0SGordon Ross * (It was saved in the *op structure)
55326f3cdf0SGordon Ross */
55426f3cdf0SGordon Ross Node = Op->Common.Node;
55526f3cdf0SGordon Ross
55626f3cdf0SGordon Ross /*
55726f3cdf0SGordon Ross * Put the Node on the object stack (Contains the ACPI Name of
55826f3cdf0SGordon Ross * this object)
55926f3cdf0SGordon Ross */
56026f3cdf0SGordon Ross WalkState->Operands[0] = (void *) Node;
56126f3cdf0SGordon Ross WalkState->NumOperands = 1;
56226f3cdf0SGordon Ross
56326f3cdf0SGordon Ross /* Pop the scope stack */
56426f3cdf0SGordon Ross
56526f3cdf0SGordon Ross if (AcpiNsOpensScope (ObjectType) &&
56626f3cdf0SGordon Ross (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
56726f3cdf0SGordon Ross {
56826f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
56926f3cdf0SGordon Ross AcpiUtGetTypeName (ObjectType), Op));
57026f3cdf0SGordon Ross
57126f3cdf0SGordon Ross Status = AcpiDsScopeStackPop (WalkState);
57226f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
57326f3cdf0SGordon Ross {
57426f3cdf0SGordon Ross goto Cleanup;
57526f3cdf0SGordon Ross }
57626f3cdf0SGordon Ross }
57726f3cdf0SGordon Ross
57826f3cdf0SGordon Ross /*
57926f3cdf0SGordon Ross * Named operations are as follows:
58026f3cdf0SGordon Ross *
58126f3cdf0SGordon Ross * AML_ALIAS
58226f3cdf0SGordon Ross * AML_BANKFIELD
58326f3cdf0SGordon Ross * AML_CREATEBITFIELD
58426f3cdf0SGordon Ross * AML_CREATEBYTEFIELD
58526f3cdf0SGordon Ross * AML_CREATEDWORDFIELD
58626f3cdf0SGordon Ross * AML_CREATEFIELD
58726f3cdf0SGordon Ross * AML_CREATEQWORDFIELD
58826f3cdf0SGordon Ross * AML_CREATEWORDFIELD
58926f3cdf0SGordon Ross * AML_DATA_REGION
59026f3cdf0SGordon Ross * AML_DEVICE
59126f3cdf0SGordon Ross * AML_EVENT
59226f3cdf0SGordon Ross * AML_FIELD
59326f3cdf0SGordon Ross * AML_INDEXFIELD
59426f3cdf0SGordon Ross * AML_METHOD
59526f3cdf0SGordon Ross * AML_METHODCALL
59626f3cdf0SGordon Ross * AML_MUTEX
59726f3cdf0SGordon Ross * AML_NAME
59826f3cdf0SGordon Ross * AML_NAMEDFIELD
59926f3cdf0SGordon Ross * AML_OPREGION
60026f3cdf0SGordon Ross * AML_POWERRES
60126f3cdf0SGordon Ross * AML_PROCESSOR
60226f3cdf0SGordon Ross * AML_SCOPE
60326f3cdf0SGordon Ross * AML_THERMALZONE
60426f3cdf0SGordon Ross */
60526f3cdf0SGordon Ross
60626f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
60726f3cdf0SGordon Ross "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
60826f3cdf0SGordon Ross AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
60926f3cdf0SGordon Ross
61026f3cdf0SGordon Ross /* Decode the opcode */
61126f3cdf0SGordon Ross
61226f3cdf0SGordon Ross Arg = Op->Common.Value.Arg;
61326f3cdf0SGordon Ross
61426f3cdf0SGordon Ross switch (WalkState->OpInfo->Type)
61526f3cdf0SGordon Ross {
61626f3cdf0SGordon Ross #ifndef ACPI_NO_METHOD_EXECUTION
61726f3cdf0SGordon Ross
61826f3cdf0SGordon Ross case AML_TYPE_CREATE_FIELD:
61926f3cdf0SGordon Ross /*
62026f3cdf0SGordon Ross * Create the field object, but the field buffer and index must
62126f3cdf0SGordon Ross * be evaluated later during the execution phase
62226f3cdf0SGordon Ross */
62326f3cdf0SGordon Ross Status = AcpiDsCreateBufferField (Op, WalkState);
62426f3cdf0SGordon Ross break;
62526f3cdf0SGordon Ross
62626f3cdf0SGordon Ross case AML_TYPE_NAMED_FIELD:
62726f3cdf0SGordon Ross /*
62826f3cdf0SGordon Ross * If we are executing a method, initialize the field
62926f3cdf0SGordon Ross */
63026f3cdf0SGordon Ross if (WalkState->MethodNode)
63126f3cdf0SGordon Ross {
63226f3cdf0SGordon Ross Status = AcpiDsInitFieldObjects (Op, WalkState);
63326f3cdf0SGordon Ross }
63426f3cdf0SGordon Ross
63526f3cdf0SGordon Ross switch (Op->Common.AmlOpcode)
63626f3cdf0SGordon Ross {
63726f3cdf0SGordon Ross case AML_INDEX_FIELD_OP:
63826f3cdf0SGordon Ross
6397b1019a6SJerry Jelinek Status = AcpiDsCreateIndexField (
6407b1019a6SJerry Jelinek Op, (ACPI_HANDLE) Arg->Common.Node, WalkState);
64126f3cdf0SGordon Ross break;
64226f3cdf0SGordon Ross
64326f3cdf0SGordon Ross case AML_BANK_FIELD_OP:
64426f3cdf0SGordon Ross
64526f3cdf0SGordon Ross Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
64626f3cdf0SGordon Ross break;
64726f3cdf0SGordon Ross
64826f3cdf0SGordon Ross case AML_FIELD_OP:
64926f3cdf0SGordon Ross
65026f3cdf0SGordon Ross Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
65126f3cdf0SGordon Ross break;
65226f3cdf0SGordon Ross
65326f3cdf0SGordon Ross default:
6547b1019a6SJerry Jelinek
65526f3cdf0SGordon Ross /* All NAMED_FIELD opcodes must be handled above */
65626f3cdf0SGordon Ross break;
65726f3cdf0SGordon Ross }
65826f3cdf0SGordon Ross break;
65926f3cdf0SGordon Ross
66026f3cdf0SGordon Ross case AML_TYPE_NAMED_SIMPLE:
66126f3cdf0SGordon Ross
66226f3cdf0SGordon Ross Status = AcpiDsCreateOperands (WalkState, Arg);
66326f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
66426f3cdf0SGordon Ross {
66526f3cdf0SGordon Ross goto Cleanup;
66626f3cdf0SGordon Ross }
66726f3cdf0SGordon Ross
66826f3cdf0SGordon Ross switch (Op->Common.AmlOpcode)
66926f3cdf0SGordon Ross {
67026f3cdf0SGordon Ross case AML_PROCESSOR_OP:
67126f3cdf0SGordon Ross
67226f3cdf0SGordon Ross Status = AcpiExCreateProcessor (WalkState);
67326f3cdf0SGordon Ross break;
67426f3cdf0SGordon Ross
675*35786f68SRobert Mustacchi case AML_POWER_RESOURCE_OP:
67626f3cdf0SGordon Ross
67726f3cdf0SGordon Ross Status = AcpiExCreatePowerResource (WalkState);
67826f3cdf0SGordon Ross break;
67926f3cdf0SGordon Ross
68026f3cdf0SGordon Ross case AML_MUTEX_OP:
68126f3cdf0SGordon Ross
68226f3cdf0SGordon Ross Status = AcpiExCreateMutex (WalkState);
68326f3cdf0SGordon Ross break;
68426f3cdf0SGordon Ross
68526f3cdf0SGordon Ross case AML_EVENT_OP:
68626f3cdf0SGordon Ross
68726f3cdf0SGordon Ross Status = AcpiExCreateEvent (WalkState);
68826f3cdf0SGordon Ross break;
68926f3cdf0SGordon Ross
69026f3cdf0SGordon Ross case AML_ALIAS_OP:
69126f3cdf0SGordon Ross
69226f3cdf0SGordon Ross Status = AcpiExCreateAlias (WalkState);
69326f3cdf0SGordon Ross break;
69426f3cdf0SGordon Ross
69526f3cdf0SGordon Ross default:
6967b1019a6SJerry Jelinek
69726f3cdf0SGordon Ross /* Unknown opcode */
69826f3cdf0SGordon Ross
69926f3cdf0SGordon Ross Status = AE_OK;
70026f3cdf0SGordon Ross goto Cleanup;
70126f3cdf0SGordon Ross }
70226f3cdf0SGordon Ross
70326f3cdf0SGordon Ross /* Delete operands */
70426f3cdf0SGordon Ross
70526f3cdf0SGordon Ross for (i = 1; i < WalkState->NumOperands; i++)
70626f3cdf0SGordon Ross {
70726f3cdf0SGordon Ross AcpiUtRemoveReference (WalkState->Operands[i]);
70826f3cdf0SGordon Ross WalkState->Operands[i] = NULL;
70926f3cdf0SGordon Ross }
71026f3cdf0SGordon Ross
71126f3cdf0SGordon Ross break;
71226f3cdf0SGordon Ross #endif /* ACPI_NO_METHOD_EXECUTION */
71326f3cdf0SGordon Ross
71426f3cdf0SGordon Ross case AML_TYPE_NAMED_COMPLEX:
71526f3cdf0SGordon Ross
71626f3cdf0SGordon Ross switch (Op->Common.AmlOpcode)
71726f3cdf0SGordon Ross {
71826f3cdf0SGordon Ross #ifndef ACPI_NO_METHOD_EXECUTION
71926f3cdf0SGordon Ross case AML_REGION_OP:
72026f3cdf0SGordon Ross case AML_DATA_REGION_OP:
72126f3cdf0SGordon Ross
72226f3cdf0SGordon Ross if (Op->Common.AmlOpcode == AML_REGION_OP)
72326f3cdf0SGordon Ross {
72426f3cdf0SGordon Ross RegionSpace = (ACPI_ADR_SPACE_TYPE)
7257b1019a6SJerry Jelinek ((Op->Common.Value.Arg)->Common.Value.Integer);
72626f3cdf0SGordon Ross }
72726f3cdf0SGordon Ross else
72826f3cdf0SGordon Ross {
72926f3cdf0SGordon Ross RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;
73026f3cdf0SGordon Ross }
73126f3cdf0SGordon Ross
73226f3cdf0SGordon Ross /*
73326f3cdf0SGordon Ross * The OpRegion is not fully parsed at this time. The only valid
73426f3cdf0SGordon Ross * argument is the SpaceId. (We must save the address of the
73526f3cdf0SGordon Ross * AML of the address and length operands)
73626f3cdf0SGordon Ross *
73726f3cdf0SGordon Ross * If we have a valid region, initialize it. The namespace is
73826f3cdf0SGordon Ross * unlocked at this point.
73926f3cdf0SGordon Ross *
74026f3cdf0SGordon Ross * Need to unlock interpreter if it is locked (if we are running
74126f3cdf0SGordon Ross * a control method), in order to allow _REG methods to be run
74226f3cdf0SGordon Ross * during AcpiEvInitializeRegion.
74326f3cdf0SGordon Ross */
74426f3cdf0SGordon Ross if (WalkState->MethodNode)
74526f3cdf0SGordon Ross {
74626f3cdf0SGordon Ross /*
74726f3cdf0SGordon Ross * Executing a method: initialize the region and unlock
74826f3cdf0SGordon Ross * the interpreter
74926f3cdf0SGordon Ross */
7507b1019a6SJerry Jelinek Status = AcpiExCreateRegion (Op->Named.Data,
7517b1019a6SJerry Jelinek Op->Named.Length, RegionSpace, WalkState);
75226f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
75326f3cdf0SGordon Ross {
7547b1019a6SJerry Jelinek return_ACPI_STATUS (Status);
75526f3cdf0SGordon Ross }
75626f3cdf0SGordon Ross }
75726f3cdf0SGordon Ross
7587b1019a6SJerry Jelinek Status = AcpiEvInitializeRegion (
759*35786f68SRobert Mustacchi AcpiNsGetAttachedObject (Node));
76026f3cdf0SGordon Ross break;
76126f3cdf0SGordon Ross
76226f3cdf0SGordon Ross case AML_NAME_OP:
76326f3cdf0SGordon Ross
76426f3cdf0SGordon Ross Status = AcpiDsCreateNode (WalkState, Node, Op);
76526f3cdf0SGordon Ross break;
76626f3cdf0SGordon Ross
76726f3cdf0SGordon Ross case AML_METHOD_OP:
76826f3cdf0SGordon Ross /*
76926f3cdf0SGordon Ross * MethodOp PkgLength NameString MethodFlags TermList
77026f3cdf0SGordon Ross *
77126f3cdf0SGordon Ross * Note: We must create the method node/object pair as soon as we
77226f3cdf0SGordon Ross * see the method declaration. This allows later pass1 parsing
77326f3cdf0SGordon Ross * of invocations of the method (need to know the number of
77426f3cdf0SGordon Ross * arguments.)
77526f3cdf0SGordon Ross */
77626f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
77726f3cdf0SGordon Ross "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
77826f3cdf0SGordon Ross WalkState, Op, Op->Named.Node));
77926f3cdf0SGordon Ross
78026f3cdf0SGordon Ross if (!AcpiNsGetAttachedObject (Op->Named.Node))
78126f3cdf0SGordon Ross {
78226f3cdf0SGordon Ross WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
78326f3cdf0SGordon Ross WalkState->NumOperands = 1;
78426f3cdf0SGordon Ross
7857b1019a6SJerry Jelinek Status = AcpiDsCreateOperands (
7867b1019a6SJerry Jelinek WalkState, Op->Common.Value.Arg);
78726f3cdf0SGordon Ross if (ACPI_SUCCESS (Status))
78826f3cdf0SGordon Ross {
7897b1019a6SJerry Jelinek Status = AcpiExCreateMethod (
7907b1019a6SJerry Jelinek Op->Named.Data, Op->Named.Length, WalkState);
79126f3cdf0SGordon Ross }
7927b1019a6SJerry Jelinek
79326f3cdf0SGordon Ross WalkState->Operands[0] = NULL;
79426f3cdf0SGordon Ross WalkState->NumOperands = 0;
79526f3cdf0SGordon Ross
79626f3cdf0SGordon Ross if (ACPI_FAILURE (Status))
79726f3cdf0SGordon Ross {
79826f3cdf0SGordon Ross return_ACPI_STATUS (Status);
79926f3cdf0SGordon Ross }
80026f3cdf0SGordon Ross }
80126f3cdf0SGordon Ross break;
80226f3cdf0SGordon Ross
80326f3cdf0SGordon Ross #endif /* ACPI_NO_METHOD_EXECUTION */
80426f3cdf0SGordon Ross
80526f3cdf0SGordon Ross default:
8067b1019a6SJerry Jelinek
80726f3cdf0SGordon Ross /* All NAMED_COMPLEX opcodes must be handled above */
80826f3cdf0SGordon Ross break;
80926f3cdf0SGordon Ross }
81026f3cdf0SGordon Ross break;
81126f3cdf0SGordon Ross
81226f3cdf0SGordon Ross case AML_CLASS_INTERNAL:
81326f3cdf0SGordon Ross
81426f3cdf0SGordon Ross /* case AML_INT_NAMEPATH_OP: */
81526f3cdf0SGordon Ross break;
81626f3cdf0SGordon Ross
81726f3cdf0SGordon Ross case AML_CLASS_METHOD_CALL:
81826f3cdf0SGordon Ross
81926f3cdf0SGordon Ross ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
82026f3cdf0SGordon Ross "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
82126f3cdf0SGordon Ross WalkState, Op, Node));
82226f3cdf0SGordon Ross
82326f3cdf0SGordon Ross /*
82426f3cdf0SGordon Ross * Lookup the method name and save the Node
82526f3cdf0SGordon Ross */
82626f3cdf0SGordon Ross Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
8277b1019a6SJerry Jelinek ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
8287b1019a6SJerry Jelinek ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
8297b1019a6SJerry Jelinek WalkState, &(NewNode));
83026f3cdf0SGordon Ross if (ACPI_SUCCESS (Status))
83126f3cdf0SGordon Ross {
83226f3cdf0SGordon Ross /*
83326f3cdf0SGordon Ross * Make sure that what we found is indeed a method
83426f3cdf0SGordon Ross * We didn't search for a method on purpose, to see if the name
83526f3cdf0SGordon Ross * would resolve
83626f3cdf0SGordon Ross */
83726f3cdf0SGordon Ross if (NewNode->Type != ACPI_TYPE_METHOD)
83826f3cdf0SGordon Ross {
83926f3cdf0SGordon Ross Status = AE_AML_OPERAND_TYPE;
84026f3cdf0SGordon Ross }
84126f3cdf0SGordon Ross
84226f3cdf0SGordon Ross /* We could put the returned object (Node) on the object stack for
84326f3cdf0SGordon Ross * later, but for now, we will put it in the "op" object that the
84426f3cdf0SGordon Ross * parser uses, so we can get it again at the end of this scope
84526f3cdf0SGordon Ross */
84626f3cdf0SGordon Ross Op->Common.Node = NewNode;
84726f3cdf0SGordon Ross }
84826f3cdf0SGordon Ross else
84926f3cdf0SGordon Ross {
850*35786f68SRobert Mustacchi ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
851*35786f68SRobert Mustacchi Arg->Common.Value.String, Status);
85226f3cdf0SGordon Ross }
85326f3cdf0SGordon Ross break;
85426f3cdf0SGordon Ross
85526f3cdf0SGordon Ross
85626f3cdf0SGordon Ross default:
8577b1019a6SJerry Jelinek
85826f3cdf0SGordon Ross break;
85926f3cdf0SGordon Ross }
86026f3cdf0SGordon Ross
86126f3cdf0SGordon Ross Cleanup:
86226f3cdf0SGordon Ross
86326f3cdf0SGordon Ross /* Remove the Node pushed at the very beginning */
86426f3cdf0SGordon Ross
86526f3cdf0SGordon Ross WalkState->Operands[0] = NULL;
86626f3cdf0SGordon Ross WalkState->NumOperands = 0;
86726f3cdf0SGordon Ross return_ACPI_STATUS (Status);
86826f3cdf0SGordon Ross }
869