10174267aSFredrik Holmqvist /******************************************************************************
20174267aSFredrik Holmqvist *
30174267aSFredrik Holmqvist * Module Name: dswload - Dispatcher first pass namespace load callbacks
40174267aSFredrik Holmqvist *
50174267aSFredrik Holmqvist *****************************************************************************/
60174267aSFredrik Holmqvist
70174267aSFredrik Holmqvist /******************************************************************************
80174267aSFredrik Holmqvist *
90174267aSFredrik Holmqvist * 1. Copyright Notice
100174267aSFredrik Holmqvist *
11*6dde014fSPulkoMandy * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
120174267aSFredrik Holmqvist * All rights reserved.
130174267aSFredrik Holmqvist *
140174267aSFredrik Holmqvist * 2. License
150174267aSFredrik Holmqvist *
160174267aSFredrik Holmqvist * 2.1. This is your license from Intel Corp. under its intellectual property
170174267aSFredrik Holmqvist * rights. You may have additional license terms from the party that provided
180174267aSFredrik Holmqvist * you this software, covering your right to use that party's intellectual
190174267aSFredrik Holmqvist * property rights.
200174267aSFredrik Holmqvist *
210174267aSFredrik Holmqvist * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220174267aSFredrik Holmqvist * copy of the source code appearing in this file ("Covered Code") an
230174267aSFredrik Holmqvist * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240174267aSFredrik Holmqvist * base code distributed originally by Intel ("Original Intel Code") to copy,
250174267aSFredrik Holmqvist * make derivatives, distribute, use and display any portion of the Covered
260174267aSFredrik Holmqvist * Code in any form, with the right to sublicense such rights; and
270174267aSFredrik Holmqvist *
280174267aSFredrik Holmqvist * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290174267aSFredrik Holmqvist * license (with the right to sublicense), under only those claims of Intel
300174267aSFredrik Holmqvist * patents that are infringed by the Original Intel Code, to make, use, sell,
310174267aSFredrik Holmqvist * offer to sell, and import the Covered Code and derivative works thereof
320174267aSFredrik Holmqvist * solely to the minimum extent necessary to exercise the above copyright
330174267aSFredrik Holmqvist * license, and in no event shall the patent license extend to any additions
340174267aSFredrik Holmqvist * to or modifications of the Original Intel Code. No other license or right
350174267aSFredrik Holmqvist * is granted directly or by implication, estoppel or otherwise;
360174267aSFredrik Holmqvist *
370174267aSFredrik Holmqvist * The above copyright and patent license is granted only if the following
380174267aSFredrik Holmqvist * conditions are met:
390174267aSFredrik Holmqvist *
400174267aSFredrik Holmqvist * 3. Conditions
410174267aSFredrik Holmqvist *
420174267aSFredrik Holmqvist * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430174267aSFredrik Holmqvist * Redistribution of source code of any substantial portion of the Covered
440174267aSFredrik Holmqvist * Code or modification with rights to further distribute source must include
450174267aSFredrik Holmqvist * the above Copyright Notice, the above License, this list of Conditions,
460174267aSFredrik Holmqvist * and the following Disclaimer and Export Compliance provision. In addition,
470174267aSFredrik Holmqvist * Licensee must cause all Covered Code to which Licensee contributes to
480174267aSFredrik Holmqvist * contain a file documenting the changes Licensee made to create that Covered
490174267aSFredrik Holmqvist * Code and the date of any change. Licensee must include in that file the
500174267aSFredrik Holmqvist * documentation of any changes made by any predecessor Licensee. Licensee
510174267aSFredrik Holmqvist * must include a prominent statement that the modification is derived,
520174267aSFredrik Holmqvist * directly or indirectly, from Original Intel Code.
530174267aSFredrik Holmqvist *
540174267aSFredrik Holmqvist * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550174267aSFredrik Holmqvist * Redistribution of source code of any substantial portion of the Covered
560174267aSFredrik Holmqvist * Code or modification without rights to further distribute source must
570174267aSFredrik Holmqvist * include the following Disclaimer and Export Compliance provision in the
580174267aSFredrik Holmqvist * documentation and/or other materials provided with distribution. In
590174267aSFredrik Holmqvist * addition, Licensee may not authorize further sublicense of source of any
600174267aSFredrik Holmqvist * portion of the Covered Code, and must include terms to the effect that the
610174267aSFredrik Holmqvist * license from Licensee to its licensee is limited to the intellectual
620174267aSFredrik Holmqvist * property embodied in the software Licensee provides to its licensee, and
630174267aSFredrik Holmqvist * not to intellectual property embodied in modifications its licensee may
640174267aSFredrik Holmqvist * make.
650174267aSFredrik Holmqvist *
660174267aSFredrik Holmqvist * 3.3. Redistribution of Executable. Redistribution in executable form of any
670174267aSFredrik Holmqvist * substantial portion of the Covered Code or modification must reproduce the
680174267aSFredrik Holmqvist * above Copyright Notice, and the following Disclaimer and Export Compliance
690174267aSFredrik Holmqvist * provision in the documentation and/or other materials provided with the
700174267aSFredrik Holmqvist * distribution.
710174267aSFredrik Holmqvist *
720174267aSFredrik Holmqvist * 3.4. Intel retains all right, title, and interest in and to the Original
730174267aSFredrik Holmqvist * Intel Code.
740174267aSFredrik Holmqvist *
750174267aSFredrik Holmqvist * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760174267aSFredrik Holmqvist * Intel shall be used in advertising or otherwise to promote the sale, use or
770174267aSFredrik Holmqvist * other dealings in products derived from or relating to the Covered Code
780174267aSFredrik Holmqvist * without prior written authorization from Intel.
790174267aSFredrik Holmqvist *
800174267aSFredrik Holmqvist * 4. Disclaimer and Export Compliance
810174267aSFredrik Holmqvist *
820174267aSFredrik Holmqvist * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830174267aSFredrik Holmqvist * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840174267aSFredrik Holmqvist * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850174267aSFredrik Holmqvist * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860174267aSFredrik Holmqvist * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870174267aSFredrik Holmqvist * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880174267aSFredrik Holmqvist * PARTICULAR PURPOSE.
890174267aSFredrik Holmqvist *
900174267aSFredrik Holmqvist * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910174267aSFredrik Holmqvist * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920174267aSFredrik Holmqvist * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930174267aSFredrik Holmqvist * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940174267aSFredrik Holmqvist * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950174267aSFredrik Holmqvist * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960174267aSFredrik Holmqvist * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970174267aSFredrik Holmqvist * LIMITED REMEDY.
980174267aSFredrik Holmqvist *
990174267aSFredrik Holmqvist * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000174267aSFredrik Holmqvist * software or system incorporating such software without first obtaining any
1010174267aSFredrik Holmqvist * required license or other approval from the U. S. Department of Commerce or
1020174267aSFredrik Holmqvist * any other agency or department of the United States Government. In the
1030174267aSFredrik Holmqvist * event Licensee exports any such software from the United States or
1040174267aSFredrik Holmqvist * re-exports any such software from a foreign destination, Licensee shall
1050174267aSFredrik Holmqvist * ensure that the distribution and export/re-export of the software is in
1060174267aSFredrik Holmqvist * compliance with all laws, regulations, orders, or other restrictions of the
1070174267aSFredrik Holmqvist * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080174267aSFredrik Holmqvist * any of its subsidiaries will export/re-export any technical data, process,
1090174267aSFredrik Holmqvist * software, or service, directly or indirectly, to any country for which the
1100174267aSFredrik Holmqvist * United States government or any agency thereof requires an export license,
1110174267aSFredrik Holmqvist * other governmental approval, or letter of assurance, without first obtaining
1120174267aSFredrik Holmqvist * such license, approval or letter.
1130174267aSFredrik Holmqvist *
114ff2e2f81SFredrik Holmqvist *****************************************************************************
115ff2e2f81SFredrik Holmqvist *
116ff2e2f81SFredrik Holmqvist * Alternatively, you may choose to be licensed under the terms of the
117ff2e2f81SFredrik Holmqvist * following license:
118ff2e2f81SFredrik Holmqvist *
119ff2e2f81SFredrik Holmqvist * Redistribution and use in source and binary forms, with or without
120ff2e2f81SFredrik Holmqvist * modification, are permitted provided that the following conditions
121ff2e2f81SFredrik Holmqvist * are met:
122ff2e2f81SFredrik Holmqvist * 1. Redistributions of source code must retain the above copyright
123ff2e2f81SFredrik Holmqvist * notice, this list of conditions, and the following disclaimer,
124ff2e2f81SFredrik Holmqvist * without modification.
125ff2e2f81SFredrik Holmqvist * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126ff2e2f81SFredrik Holmqvist * substantially similar to the "NO WARRANTY" disclaimer below
127ff2e2f81SFredrik Holmqvist * ("Disclaimer") and any redistribution must be conditioned upon
128ff2e2f81SFredrik Holmqvist * including a substantially similar Disclaimer requirement for further
129ff2e2f81SFredrik Holmqvist * binary redistribution.
130ff2e2f81SFredrik Holmqvist * 3. Neither the names of the above-listed copyright holders nor the names
131ff2e2f81SFredrik Holmqvist * of any contributors may be used to endorse or promote products derived
132ff2e2f81SFredrik Holmqvist * from this software without specific prior written permission.
133ff2e2f81SFredrik Holmqvist *
134ff2e2f81SFredrik Holmqvist * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135ff2e2f81SFredrik Holmqvist * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136ff2e2f81SFredrik Holmqvist * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137ff2e2f81SFredrik Holmqvist * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138ff2e2f81SFredrik Holmqvist * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139ff2e2f81SFredrik Holmqvist * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140ff2e2f81SFredrik Holmqvist * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141ff2e2f81SFredrik Holmqvist * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142ff2e2f81SFredrik Holmqvist * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143ff2e2f81SFredrik Holmqvist * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144ff2e2f81SFredrik Holmqvist * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145ff2e2f81SFredrik Holmqvist *
146ff2e2f81SFredrik Holmqvist * Alternatively, you may choose to be licensed under the terms of the
147ff2e2f81SFredrik Holmqvist * GNU General Public License ("GPL") version 2 as published by the Free
148ff2e2f81SFredrik Holmqvist * Software Foundation.
149ff2e2f81SFredrik Holmqvist *
1500174267aSFredrik Holmqvist *****************************************************************************/
1510174267aSFredrik Holmqvist
1520174267aSFredrik Holmqvist #include "acpi.h"
1530174267aSFredrik Holmqvist #include "accommon.h"
1540174267aSFredrik Holmqvist #include "acparser.h"
1550174267aSFredrik Holmqvist #include "amlcode.h"
1560174267aSFredrik Holmqvist #include "acdispat.h"
1570174267aSFredrik Holmqvist #include "acinterp.h"
1580174267aSFredrik Holmqvist #include "acnamesp.h"
1590174267aSFredrik Holmqvist #ifdef ACPI_ASL_COMPILER
1600174267aSFredrik Holmqvist #include "acdisasm.h"
1610174267aSFredrik Holmqvist #endif
1620174267aSFredrik Holmqvist
1630174267aSFredrik Holmqvist #define _COMPONENT ACPI_DISPATCHER
1640174267aSFredrik Holmqvist ACPI_MODULE_NAME ("dswload")
1650174267aSFredrik Holmqvist
1660174267aSFredrik Holmqvist
1670174267aSFredrik Holmqvist /*******************************************************************************
1680174267aSFredrik Holmqvist *
1690174267aSFredrik Holmqvist * FUNCTION: AcpiDsInitCallbacks
1700174267aSFredrik Holmqvist *
1710174267aSFredrik Holmqvist * PARAMETERS: WalkState - Current state of the parse tree walk
1720174267aSFredrik Holmqvist * PassNumber - 1, 2, or 3
1730174267aSFredrik Holmqvist *
1740174267aSFredrik Holmqvist * RETURN: Status
1750174267aSFredrik Holmqvist *
1760174267aSFredrik Holmqvist * DESCRIPTION: Init walk state callbacks
1770174267aSFredrik Holmqvist *
1780174267aSFredrik Holmqvist ******************************************************************************/
1790174267aSFredrik Holmqvist
1800174267aSFredrik Holmqvist ACPI_STATUS
AcpiDsInitCallbacks(ACPI_WALK_STATE * WalkState,UINT32 PassNumber)1810174267aSFredrik Holmqvist AcpiDsInitCallbacks (
1820174267aSFredrik Holmqvist ACPI_WALK_STATE *WalkState,
1830174267aSFredrik Holmqvist UINT32 PassNumber)
1840174267aSFredrik Holmqvist {
1850174267aSFredrik Holmqvist
1860174267aSFredrik Holmqvist switch (PassNumber)
1870174267aSFredrik Holmqvist {
188ad5bbfb8SFredrik Holmqvist case 0:
189ad5bbfb8SFredrik Holmqvist
190ad5bbfb8SFredrik Holmqvist /* Parse only - caller will setup callbacks */
191ad5bbfb8SFredrik Holmqvist
192ad5bbfb8SFredrik Holmqvist WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 |
193ad5bbfb8SFredrik Holmqvist ACPI_PARSE_DELETE_TREE |
194ad5bbfb8SFredrik Holmqvist ACPI_PARSE_DISASSEMBLE;
195ad5bbfb8SFredrik Holmqvist WalkState->DescendingCallback = NULL;
196ad5bbfb8SFredrik Holmqvist WalkState->AscendingCallback = NULL;
197ad5bbfb8SFredrik Holmqvist break;
198ad5bbfb8SFredrik Holmqvist
1990174267aSFredrik Holmqvist case 1:
200c70258b7SJérôme Duval
201ad5bbfb8SFredrik Holmqvist /* Load pass 1 */
202ad5bbfb8SFredrik Holmqvist
2030174267aSFredrik Holmqvist WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 |
2040174267aSFredrik Holmqvist ACPI_PARSE_DELETE_TREE;
2050174267aSFredrik Holmqvist WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
2060174267aSFredrik Holmqvist WalkState->AscendingCallback = AcpiDsLoad1EndOp;
2070174267aSFredrik Holmqvist break;
2080174267aSFredrik Holmqvist
2090174267aSFredrik Holmqvist case 2:
210c70258b7SJérôme Duval
211ad5bbfb8SFredrik Holmqvist /* Load pass 2 */
212ad5bbfb8SFredrik Holmqvist
2130174267aSFredrik Holmqvist WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 |
2140174267aSFredrik Holmqvist ACPI_PARSE_DELETE_TREE;
2150174267aSFredrik Holmqvist WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
2160174267aSFredrik Holmqvist WalkState->AscendingCallback = AcpiDsLoad2EndOp;
2170174267aSFredrik Holmqvist break;
2180174267aSFredrik Holmqvist
2190174267aSFredrik Holmqvist case 3:
220c70258b7SJérôme Duval
221ad5bbfb8SFredrik Holmqvist /* Execution pass */
222ad5bbfb8SFredrik Holmqvist
2230174267aSFredrik Holmqvist WalkState->ParseFlags |= ACPI_PARSE_EXECUTE |
2240174267aSFredrik Holmqvist ACPI_PARSE_DELETE_TREE;
2250174267aSFredrik Holmqvist WalkState->DescendingCallback = AcpiDsExecBeginOp;
2260174267aSFredrik Holmqvist WalkState->AscendingCallback = AcpiDsExecEndOp;
2270174267aSFredrik Holmqvist break;
2280174267aSFredrik Holmqvist
2290174267aSFredrik Holmqvist default:
230c70258b7SJérôme Duval
2310174267aSFredrik Holmqvist return (AE_BAD_PARAMETER);
2320174267aSFredrik Holmqvist }
2330174267aSFredrik Holmqvist
2340174267aSFredrik Holmqvist return (AE_OK);
2350174267aSFredrik Holmqvist }
2360174267aSFredrik Holmqvist
2370174267aSFredrik Holmqvist
2380174267aSFredrik Holmqvist /*******************************************************************************
2390174267aSFredrik Holmqvist *
2400174267aSFredrik Holmqvist * FUNCTION: AcpiDsLoad1BeginOp
2410174267aSFredrik Holmqvist *
2420174267aSFredrik Holmqvist * PARAMETERS: WalkState - Current state of the parse tree walk
2430174267aSFredrik Holmqvist * OutOp - Where to return op if a new one is created
2440174267aSFredrik Holmqvist *
2450174267aSFredrik Holmqvist * RETURN: Status
2460174267aSFredrik Holmqvist *
2470174267aSFredrik Holmqvist * DESCRIPTION: Descending callback used during the loading of ACPI tables.
2480174267aSFredrik Holmqvist *
2490174267aSFredrik Holmqvist ******************************************************************************/
2500174267aSFredrik Holmqvist
2510174267aSFredrik Holmqvist ACPI_STATUS
AcpiDsLoad1BeginOp(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT ** OutOp)2520174267aSFredrik Holmqvist AcpiDsLoad1BeginOp (
2530174267aSFredrik Holmqvist ACPI_WALK_STATE *WalkState,
2540174267aSFredrik Holmqvist ACPI_PARSE_OBJECT **OutOp)
2550174267aSFredrik Holmqvist {
2560174267aSFredrik Holmqvist ACPI_PARSE_OBJECT *Op;
2570174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
2580174267aSFredrik Holmqvist ACPI_STATUS Status;
2590174267aSFredrik Holmqvist ACPI_OBJECT_TYPE ObjectType;
2600174267aSFredrik Holmqvist char *Path;
2610174267aSFredrik Holmqvist UINT32 Flags;
2620174267aSFredrik Holmqvist
2630174267aSFredrik Holmqvist
26408c9948cSFredrik Holmqvist ACPI_FUNCTION_TRACE_PTR (DsLoad1BeginOp, WalkState->Op);
2650174267aSFredrik Holmqvist
2660174267aSFredrik Holmqvist
2670174267aSFredrik Holmqvist Op = WalkState->Op;
2680174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
2690174267aSFredrik Holmqvist
2700174267aSFredrik Holmqvist /* We are only interested in opcodes that have an associated name */
2710174267aSFredrik Holmqvist
2720174267aSFredrik Holmqvist if (Op)
2730174267aSFredrik Holmqvist {
2740174267aSFredrik Holmqvist if (!(WalkState->OpInfo->Flags & AML_NAMED))
2750174267aSFredrik Holmqvist {
2760174267aSFredrik Holmqvist *OutOp = Op;
2770174267aSFredrik Holmqvist return_ACPI_STATUS (AE_OK);
2780174267aSFredrik Holmqvist }
2790174267aSFredrik Holmqvist
2800174267aSFredrik Holmqvist /* Check if this object has already been installed in the namespace */
2810174267aSFredrik Holmqvist
2820174267aSFredrik Holmqvist if (Op->Common.Node)
2830174267aSFredrik Holmqvist {
2840174267aSFredrik Holmqvist *OutOp = Op;
2850174267aSFredrik Holmqvist return_ACPI_STATUS (AE_OK);
2860174267aSFredrik Holmqvist }
2870174267aSFredrik Holmqvist }
2880174267aSFredrik Holmqvist
2890174267aSFredrik Holmqvist Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
2900174267aSFredrik Holmqvist
2910174267aSFredrik Holmqvist /* Map the raw opcode into an internal object type */
2920174267aSFredrik Holmqvist
2930174267aSFredrik Holmqvist ObjectType = WalkState->OpInfo->ObjectType;
2940174267aSFredrik Holmqvist
2950174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
296b64e8511SFredrik Holmqvist "State=%p Op=%p [%s]\n", WalkState, Op,
297b64e8511SFredrik Holmqvist AcpiUtGetTypeName (ObjectType)));
2980174267aSFredrik Holmqvist
2990174267aSFredrik Holmqvist switch (WalkState->Opcode)
3000174267aSFredrik Holmqvist {
3010174267aSFredrik Holmqvist case AML_SCOPE_OP:
3020174267aSFredrik Holmqvist /*
3030174267aSFredrik Holmqvist * The target name of the Scope() operator must exist at this point so
3040174267aSFredrik Holmqvist * that we can actually open the scope to enter new names underneath it.
3050174267aSFredrik Holmqvist * Allow search-to-root for single namesegs.
3060174267aSFredrik Holmqvist */
3070174267aSFredrik Holmqvist Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
3080174267aSFredrik Holmqvist ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
3090174267aSFredrik Holmqvist #ifdef ACPI_ASL_COMPILER
3100174267aSFredrik Holmqvist if (Status == AE_NOT_FOUND)
3110174267aSFredrik Holmqvist {
3120174267aSFredrik Holmqvist /*
3130174267aSFredrik Holmqvist * Table disassembly:
3140174267aSFredrik Holmqvist * Target of Scope() not found. Generate an External for it, and
3150174267aSFredrik Holmqvist * insert the name into the namespace.
3160174267aSFredrik Holmqvist */
317ad5bbfb8SFredrik Holmqvist AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0);
3180174267aSFredrik Holmqvist Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
3190174267aSFredrik Holmqvist ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
3200174267aSFredrik Holmqvist WalkState, &Node);
3210174267aSFredrik Holmqvist }
3220174267aSFredrik Holmqvist #endif
3230174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
3240174267aSFredrik Holmqvist {
325ff2e2f81SFredrik Holmqvist ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
3260174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
3270174267aSFredrik Holmqvist }
3280174267aSFredrik Holmqvist
3290174267aSFredrik Holmqvist /*
3300174267aSFredrik Holmqvist * Check to make sure that the target is
3310174267aSFredrik Holmqvist * one of the opcodes that actually opens a scope
3320174267aSFredrik Holmqvist */
3330174267aSFredrik Holmqvist switch (Node->Type)
3340174267aSFredrik Holmqvist {
3350174267aSFredrik Holmqvist case ACPI_TYPE_ANY:
3360174267aSFredrik Holmqvist case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
3370174267aSFredrik Holmqvist case ACPI_TYPE_DEVICE:
3380174267aSFredrik Holmqvist case ACPI_TYPE_POWER:
3390174267aSFredrik Holmqvist case ACPI_TYPE_PROCESSOR:
3400174267aSFredrik Holmqvist case ACPI_TYPE_THERMAL:
3410174267aSFredrik Holmqvist
3420174267aSFredrik Holmqvist /* These are acceptable types */
3430174267aSFredrik Holmqvist break;
3440174267aSFredrik Holmqvist
3450174267aSFredrik Holmqvist case ACPI_TYPE_INTEGER:
3460174267aSFredrik Holmqvist case ACPI_TYPE_STRING:
3470174267aSFredrik Holmqvist case ACPI_TYPE_BUFFER:
3480174267aSFredrik Holmqvist /*
3490174267aSFredrik Holmqvist * These types we will allow, but we will change the type.
3500174267aSFredrik Holmqvist * This enables some existing code of the form:
3510174267aSFredrik Holmqvist *
3520174267aSFredrik Holmqvist * Name (DEB, 0)
3530174267aSFredrik Holmqvist * Scope (DEB) { ... }
3540174267aSFredrik Holmqvist *
3550174267aSFredrik Holmqvist * Note: silently change the type here. On the second pass,
3560174267aSFredrik Holmqvist * we will report a warning
3570174267aSFredrik Holmqvist */
3580174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
3590174267aSFredrik Holmqvist "Type override - [%4.4s] had invalid type (%s) "
3600174267aSFredrik Holmqvist "for Scope operator, changed to type ANY\n",
3610174267aSFredrik Holmqvist AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
3620174267aSFredrik Holmqvist
3630174267aSFredrik Holmqvist Node->Type = ACPI_TYPE_ANY;
3640174267aSFredrik Holmqvist WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
3650174267aSFredrik Holmqvist break;
3669b0d045cSFredrik Holmqvist
3679b0d045cSFredrik Holmqvist case ACPI_TYPE_METHOD:
3689b0d045cSFredrik Holmqvist /*
3699b0d045cSFredrik Holmqvist * Allow scope change to root during execution of module-level
3709b0d045cSFredrik Holmqvist * code. Root is typed METHOD during this time.
3719b0d045cSFredrik Holmqvist */
3729b0d045cSFredrik Holmqvist if ((Node == AcpiGbl_RootNode) &&
3739b0d045cSFredrik Holmqvist (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
3749b0d045cSFredrik Holmqvist {
3759b0d045cSFredrik Holmqvist break;
3769b0d045cSFredrik Holmqvist }
3779b0d045cSFredrik Holmqvist
3780ffed378SFredrik Holmqvist ACPI_FALLTHROUGH;
3790174267aSFredrik Holmqvist
3800174267aSFredrik Holmqvist default:
3810174267aSFredrik Holmqvist
3820174267aSFredrik Holmqvist /* All other types are an error */
3830174267aSFredrik Holmqvist
3840174267aSFredrik Holmqvist ACPI_ERROR ((AE_INFO,
3850174267aSFredrik Holmqvist "Invalid type (%s) for target of "
3860174267aSFredrik Holmqvist "Scope operator [%4.4s] (Cannot override)",
3870174267aSFredrik Holmqvist AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
3880174267aSFredrik Holmqvist
3890174267aSFredrik Holmqvist return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
3900174267aSFredrik Holmqvist }
3910174267aSFredrik Holmqvist break;
3920174267aSFredrik Holmqvist
3930174267aSFredrik Holmqvist default:
3940174267aSFredrik Holmqvist /*
3950174267aSFredrik Holmqvist * For all other named opcodes, we will enter the name into
3960174267aSFredrik Holmqvist * the namespace.
3970174267aSFredrik Holmqvist *
3980174267aSFredrik Holmqvist * Setup the search flags.
3990174267aSFredrik Holmqvist * Since we are entering a name into the namespace, we do not want to
4000174267aSFredrik Holmqvist * enable the search-to-root upsearch.
4010174267aSFredrik Holmqvist *
4020174267aSFredrik Holmqvist * There are only two conditions where it is acceptable that the name
4030174267aSFredrik Holmqvist * already exists:
4040174267aSFredrik Holmqvist * 1) the Scope() operator can reopen a scoping object that was
4050174267aSFredrik Holmqvist * previously defined (Scope, Method, Device, etc.)
4060174267aSFredrik Holmqvist * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
4070174267aSFredrik Holmqvist * BufferField, or Package), the name of the object is already
4080174267aSFredrik Holmqvist * in the namespace.
4090174267aSFredrik Holmqvist */
4100174267aSFredrik Holmqvist if (WalkState->DeferredNode)
4110174267aSFredrik Holmqvist {
4120174267aSFredrik Holmqvist /* This name is already in the namespace, get the node */
4130174267aSFredrik Holmqvist
4140174267aSFredrik Holmqvist Node = WalkState->DeferredNode;
4150174267aSFredrik Holmqvist Status = AE_OK;
4160174267aSFredrik Holmqvist break;
4170174267aSFredrik Holmqvist }
4180174267aSFredrik Holmqvist
4190174267aSFredrik Holmqvist /*
4200174267aSFredrik Holmqvist * If we are executing a method, do not create any namespace objects
4210174267aSFredrik Holmqvist * during the load phase, only during execution.
4220174267aSFredrik Holmqvist */
4230174267aSFredrik Holmqvist if (WalkState->MethodNode)
4240174267aSFredrik Holmqvist {
4250174267aSFredrik Holmqvist Node = NULL;
4260174267aSFredrik Holmqvist Status = AE_OK;
4270174267aSFredrik Holmqvist break;
4280174267aSFredrik Holmqvist }
4290174267aSFredrik Holmqvist
4300174267aSFredrik Holmqvist Flags = ACPI_NS_NO_UPSEARCH;
4310174267aSFredrik Holmqvist if ((WalkState->Opcode != AML_SCOPE_OP) &&
4320174267aSFredrik Holmqvist (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
4330174267aSFredrik Holmqvist {
434e226d1d0SFredrik Holmqvist if (WalkState->NamespaceOverride)
435e226d1d0SFredrik Holmqvist {
436e226d1d0SFredrik Holmqvist Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
437e226d1d0SFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n",
438e226d1d0SFredrik Holmqvist AcpiUtGetTypeName (ObjectType)));
439e226d1d0SFredrik Holmqvist }
440e226d1d0SFredrik Holmqvist else
441e226d1d0SFredrik Holmqvist {
4420174267aSFredrik Holmqvist Flags |= ACPI_NS_ERROR_IF_FOUND;
4430174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
4440174267aSFredrik Holmqvist AcpiUtGetTypeName (ObjectType)));
4450174267aSFredrik Holmqvist }
446e226d1d0SFredrik Holmqvist }
4470174267aSFredrik Holmqvist else
4480174267aSFredrik Holmqvist {
4490174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
4500174267aSFredrik Holmqvist "[%s] Both Find or Create allowed\n",
4510174267aSFredrik Holmqvist AcpiUtGetTypeName (ObjectType)));
4520174267aSFredrik Holmqvist }
4530174267aSFredrik Holmqvist
4540174267aSFredrik Holmqvist /*
4550174267aSFredrik Holmqvist * Enter the named type into the internal namespace. We enter the name
4560174267aSFredrik Holmqvist * as we go downward in the parse tree. Any necessary subobjects that
4570174267aSFredrik Holmqvist * involve arguments to the opcode must be created as we go back up the
4580174267aSFredrik Holmqvist * parse tree later.
4590174267aSFredrik Holmqvist */
4600174267aSFredrik Holmqvist Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
4610174267aSFredrik Holmqvist ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
4620174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
4630174267aSFredrik Holmqvist {
4640174267aSFredrik Holmqvist if (Status == AE_ALREADY_EXISTS)
4650174267aSFredrik Holmqvist {
4660174267aSFredrik Holmqvist /* The name already exists in this scope */
4670174267aSFredrik Holmqvist
4680174267aSFredrik Holmqvist if (Node->Flags & ANOBJ_IS_EXTERNAL)
4690174267aSFredrik Holmqvist {
4700174267aSFredrik Holmqvist /*
4710174267aSFredrik Holmqvist * Allow one create on an object or segment that was
4720174267aSFredrik Holmqvist * previously declared External
4730174267aSFredrik Holmqvist */
4740174267aSFredrik Holmqvist Node->Flags &= ~ANOBJ_IS_EXTERNAL;
4750174267aSFredrik Holmqvist Node->Type = (UINT8) ObjectType;
4760174267aSFredrik Holmqvist
4770174267aSFredrik Holmqvist /* Just retyped a node, probably will need to open a scope */
4780174267aSFredrik Holmqvist
4790174267aSFredrik Holmqvist if (AcpiNsOpensScope (ObjectType))
4800174267aSFredrik Holmqvist {
481b64e8511SFredrik Holmqvist Status = AcpiDsScopeStackPush (
482b64e8511SFredrik Holmqvist Node, ObjectType, WalkState);
4830174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
4840174267aSFredrik Holmqvist {
4850174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
4860174267aSFredrik Holmqvist }
4870174267aSFredrik Holmqvist }
4880174267aSFredrik Holmqvist
4890174267aSFredrik Holmqvist Status = AE_OK;
4900174267aSFredrik Holmqvist }
4910174267aSFredrik Holmqvist }
4920174267aSFredrik Holmqvist
4930174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
4940174267aSFredrik Holmqvist {
495ff2e2f81SFredrik Holmqvist ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
4960174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
4970174267aSFredrik Holmqvist }
4980174267aSFredrik Holmqvist }
4990174267aSFredrik Holmqvist break;
5000174267aSFredrik Holmqvist }
5010174267aSFredrik Holmqvist
5020174267aSFredrik Holmqvist /* Common exit */
5030174267aSFredrik Holmqvist
5040174267aSFredrik Holmqvist if (!Op)
5050174267aSFredrik Holmqvist {
5060174267aSFredrik Holmqvist /* Create a new op */
5070174267aSFredrik Holmqvist
508e226d1d0SFredrik Holmqvist Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
5090174267aSFredrik Holmqvist if (!Op)
5100174267aSFredrik Holmqvist {
5110174267aSFredrik Holmqvist return_ACPI_STATUS (AE_NO_MEMORY);
5120174267aSFredrik Holmqvist }
5130174267aSFredrik Holmqvist }
5140174267aSFredrik Holmqvist
5150174267aSFredrik Holmqvist /* Initialize the op */
5160174267aSFredrik Holmqvist
51708c9948cSFredrik Holmqvist #ifdef ACPI_CONSTANT_EVAL_ONLY
518ff2e2f81SFredrik Holmqvist Op->Named.Path = Path;
5190174267aSFredrik Holmqvist #endif
5200174267aSFredrik Holmqvist
5210174267aSFredrik Holmqvist if (Node)
5220174267aSFredrik Holmqvist {
5230174267aSFredrik Holmqvist /*
5240174267aSFredrik Holmqvist * Put the Node in the "op" object that the parser uses, so we
5250174267aSFredrik Holmqvist * can get it again quickly when this scope is closed
5260174267aSFredrik Holmqvist */
5270174267aSFredrik Holmqvist Op->Common.Node = Node;
5280174267aSFredrik Holmqvist Op->Named.Name = Node->Name.Integer;
5290174267aSFredrik Holmqvist }
5300174267aSFredrik Holmqvist
5310174267aSFredrik Holmqvist AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
5320174267aSFredrik Holmqvist *OutOp = Op;
5330174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
5340174267aSFredrik Holmqvist }
5350174267aSFredrik Holmqvist
5360174267aSFredrik Holmqvist
5370174267aSFredrik Holmqvist /*******************************************************************************
5380174267aSFredrik Holmqvist *
5390174267aSFredrik Holmqvist * FUNCTION: AcpiDsLoad1EndOp
5400174267aSFredrik Holmqvist *
5410174267aSFredrik Holmqvist * PARAMETERS: WalkState - Current state of the parse tree walk
5420174267aSFredrik Holmqvist *
5430174267aSFredrik Holmqvist * RETURN: Status
5440174267aSFredrik Holmqvist *
5450174267aSFredrik Holmqvist * DESCRIPTION: Ascending callback used during the loading of the namespace,
5460174267aSFredrik Holmqvist * both control methods and everything else.
5470174267aSFredrik Holmqvist *
5480174267aSFredrik Holmqvist ******************************************************************************/
5490174267aSFredrik Holmqvist
5500174267aSFredrik Holmqvist ACPI_STATUS
AcpiDsLoad1EndOp(ACPI_WALK_STATE * WalkState)5510174267aSFredrik Holmqvist AcpiDsLoad1EndOp (
5520174267aSFredrik Holmqvist ACPI_WALK_STATE *WalkState)
5530174267aSFredrik Holmqvist {
5540174267aSFredrik Holmqvist ACPI_PARSE_OBJECT *Op;
5550174267aSFredrik Holmqvist ACPI_OBJECT_TYPE ObjectType;
5560174267aSFredrik Holmqvist ACPI_STATUS Status = AE_OK;
557ff2e2f81SFredrik Holmqvist #ifdef ACPI_ASL_COMPILER
558ff2e2f81SFredrik Holmqvist UINT8 ParamCount;
559ff2e2f81SFredrik Holmqvist #endif
560ff2e2f81SFredrik Holmqvist
5610174267aSFredrik Holmqvist
5620174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (DsLoad1EndOp);
5630174267aSFredrik Holmqvist
5640174267aSFredrik Holmqvist
5650174267aSFredrik Holmqvist Op = WalkState->Op;
5660174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
5670174267aSFredrik Holmqvist
5680ffed378SFredrik Holmqvist /*
5690ffed378SFredrik Holmqvist * Disassembler: handle create field operators here.
5700ffed378SFredrik Holmqvist *
5710ffed378SFredrik Holmqvist * CreateBufferField is a deferred op that is typically processed in load
5720ffed378SFredrik Holmqvist * pass 2. However, disassembly of control method contents walk the parse
5730ffed378SFredrik Holmqvist * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed
5740ffed378SFredrik Holmqvist * in a later walk. This is a problem when there is a control method that
5750ffed378SFredrik Holmqvist * has the same name as the AML_CREATE object. In this case, any use of the
5760ffed378SFredrik Holmqvist * name segment will be detected as a method call rather than a reference
5770ffed378SFredrik Holmqvist * to a buffer field.
5780ffed378SFredrik Holmqvist *
5790ffed378SFredrik Holmqvist * This earlier creation during disassembly solves this issue by inserting
5800ffed378SFredrik Holmqvist * the named object in the ACPI namespace so that references to this name
5810ffed378SFredrik Holmqvist * would be a name string rather than a method call.
5820ffed378SFredrik Holmqvist */
5830ffed378SFredrik Holmqvist if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) &&
5840ffed378SFredrik Holmqvist (WalkState->OpInfo->Flags & AML_CREATE))
5850ffed378SFredrik Holmqvist {
5860ffed378SFredrik Holmqvist Status = AcpiDsCreateBufferField (Op, WalkState);
5870ffed378SFredrik Holmqvist return_ACPI_STATUS (Status);
5880ffed378SFredrik Holmqvist }
5890ffed378SFredrik Holmqvist
5900174267aSFredrik Holmqvist /* We are only interested in opcodes that have an associated name */
5910174267aSFredrik Holmqvist
5920174267aSFredrik Holmqvist if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD)))
5930174267aSFredrik Holmqvist {
5940174267aSFredrik Holmqvist return_ACPI_STATUS (AE_OK);
5950174267aSFredrik Holmqvist }
5960174267aSFredrik Holmqvist
5970174267aSFredrik Holmqvist /* Get the object type to determine if we should pop the scope */
5980174267aSFredrik Holmqvist
5990174267aSFredrik Holmqvist ObjectType = WalkState->OpInfo->ObjectType;
6000174267aSFredrik Holmqvist
6010174267aSFredrik Holmqvist if (WalkState->OpInfo->Flags & AML_FIELD)
6020174267aSFredrik Holmqvist {
6030174267aSFredrik Holmqvist /*
6040174267aSFredrik Holmqvist * If we are executing a method, do not create any namespace objects
6050174267aSFredrik Holmqvist * during the load phase, only during execution.
6060174267aSFredrik Holmqvist */
6070174267aSFredrik Holmqvist if (!WalkState->MethodNode)
6080174267aSFredrik Holmqvist {
6090174267aSFredrik Holmqvist if (WalkState->Opcode == AML_FIELD_OP ||
6100174267aSFredrik Holmqvist WalkState->Opcode == AML_BANK_FIELD_OP ||
6110174267aSFredrik Holmqvist WalkState->Opcode == AML_INDEX_FIELD_OP)
6120174267aSFredrik Holmqvist {
6130174267aSFredrik Holmqvist Status = AcpiDsInitFieldObjects (Op, WalkState);
6140174267aSFredrik Holmqvist }
6150174267aSFredrik Holmqvist }
6160174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
6170174267aSFredrik Holmqvist }
6180174267aSFredrik Holmqvist
6190174267aSFredrik Holmqvist /*
6200174267aSFredrik Holmqvist * If we are executing a method, do not create any namespace objects
6210174267aSFredrik Holmqvist * during the load phase, only during execution.
6220174267aSFredrik Holmqvist */
6230174267aSFredrik Holmqvist if (!WalkState->MethodNode)
6240174267aSFredrik Holmqvist {
6250174267aSFredrik Holmqvist if (Op->Common.AmlOpcode == AML_REGION_OP)
6260174267aSFredrik Holmqvist {
6270174267aSFredrik Holmqvist Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
628b64e8511SFredrik Holmqvist (ACPI_ADR_SPACE_TYPE)
629b64e8511SFredrik Holmqvist ((Op->Common.Value.Arg)->Common.Value.Integer),
6300174267aSFredrik Holmqvist WalkState);
6310174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
6320174267aSFredrik Holmqvist {
6330174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
6340174267aSFredrik Holmqvist }
6350174267aSFredrik Holmqvist }
6360174267aSFredrik Holmqvist else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
6370174267aSFredrik Holmqvist {
6380174267aSFredrik Holmqvist Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
6390174267aSFredrik Holmqvist ACPI_ADR_SPACE_DATA_TABLE, WalkState);
6400174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
6410174267aSFredrik Holmqvist {
6420174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
6430174267aSFredrik Holmqvist }
6440174267aSFredrik Holmqvist }
6450174267aSFredrik Holmqvist }
6460174267aSFredrik Holmqvist
6470174267aSFredrik Holmqvist if (Op->Common.AmlOpcode == AML_NAME_OP)
6480174267aSFredrik Holmqvist {
6490174267aSFredrik Holmqvist /* For Name opcode, get the object type from the argument */
6500174267aSFredrik Holmqvist
6510174267aSFredrik Holmqvist if (Op->Common.Value.Arg)
6520174267aSFredrik Holmqvist {
6530174267aSFredrik Holmqvist ObjectType = (AcpiPsGetOpcodeInfo (
6540174267aSFredrik Holmqvist (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType;
6550174267aSFredrik Holmqvist
6560174267aSFredrik Holmqvist /* Set node type if we have a namespace node */
6570174267aSFredrik Holmqvist
6580174267aSFredrik Holmqvist if (Op->Common.Node)
6590174267aSFredrik Holmqvist {
6600174267aSFredrik Holmqvist Op->Common.Node->Type = (UINT8) ObjectType;
6610174267aSFredrik Holmqvist }
6620174267aSFredrik Holmqvist }
6630174267aSFredrik Holmqvist }
6640174267aSFredrik Holmqvist
665ff2e2f81SFredrik Holmqvist #ifdef ACPI_ASL_COMPILER
666ff2e2f81SFredrik Holmqvist /*
667ff2e2f81SFredrik Holmqvist * For external opcode, get the object type from the argument and
668ff2e2f81SFredrik Holmqvist * get the parameter count from the argument's next.
669ff2e2f81SFredrik Holmqvist */
670ff2e2f81SFredrik Holmqvist if (AcpiGbl_DisasmFlag &&
671ff2e2f81SFredrik Holmqvist Op->Common.Node &&
672ff2e2f81SFredrik Holmqvist Op->Common.AmlOpcode == AML_EXTERNAL_OP)
673ff2e2f81SFredrik Holmqvist {
674ff2e2f81SFredrik Holmqvist /*
675ff2e2f81SFredrik Holmqvist * Note, if this external is not a method
676ff2e2f81SFredrik Holmqvist * Op->Common.Value.Arg->Common.Next->Common.Value.Integer == 0
677ff2e2f81SFredrik Holmqvist * Therefore, ParamCount will be 0.
678ff2e2f81SFredrik Holmqvist */
679ff2e2f81SFredrik Holmqvist ParamCount = (UINT8) Op->Common.Value.Arg->Common.Next->Common.Value.Integer;
680ff2e2f81SFredrik Holmqvist ObjectType = (UINT8) Op->Common.Value.Arg->Common.Value.Integer;
681ff2e2f81SFredrik Holmqvist Op->Common.Node->Flags |= ANOBJ_IS_EXTERNAL;
682ff2e2f81SFredrik Holmqvist Op->Common.Node->Type = (UINT8) ObjectType;
683ff2e2f81SFredrik Holmqvist
684ff2e2f81SFredrik Holmqvist AcpiDmCreateSubobjectForExternal ((UINT8)ObjectType,
685ff2e2f81SFredrik Holmqvist &Op->Common.Node, ParamCount);
686ff2e2f81SFredrik Holmqvist
687ff2e2f81SFredrik Holmqvist /*
688ff2e2f81SFredrik Holmqvist * Add the external to the external list because we may be
689ff2e2f81SFredrik Holmqvist * emitting code based off of the items within the external list.
690ff2e2f81SFredrik Holmqvist */
691ff2e2f81SFredrik Holmqvist AcpiDmAddOpToExternalList (Op, Op->Named.Path, (UINT8)ObjectType, ParamCount,
692ff2e2f81SFredrik Holmqvist ACPI_EXT_ORIGIN_FROM_OPCODE | ACPI_EXT_RESOLVED_REFERENCE);
693ff2e2f81SFredrik Holmqvist }
694ff2e2f81SFredrik Holmqvist #endif
695ff2e2f81SFredrik Holmqvist
6960174267aSFredrik Holmqvist /*
6970174267aSFredrik Holmqvist * If we are executing a method, do not create any namespace objects
6980174267aSFredrik Holmqvist * during the load phase, only during execution.
6990174267aSFredrik Holmqvist */
7000174267aSFredrik Holmqvist if (!WalkState->MethodNode)
7010174267aSFredrik Holmqvist {
7020174267aSFredrik Holmqvist if (Op->Common.AmlOpcode == AML_METHOD_OP)
7030174267aSFredrik Holmqvist {
7040174267aSFredrik Holmqvist /*
7050174267aSFredrik Holmqvist * MethodOp PkgLength NameString MethodFlags TermList
7060174267aSFredrik Holmqvist *
7070174267aSFredrik Holmqvist * Note: We must create the method node/object pair as soon as we
7080174267aSFredrik Holmqvist * see the method declaration. This allows later pass1 parsing
7090174267aSFredrik Holmqvist * of invocations of the method (need to know the number of
7100174267aSFredrik Holmqvist * arguments.)
7110174267aSFredrik Holmqvist */
7120174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
7130174267aSFredrik Holmqvist "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
7140174267aSFredrik Holmqvist WalkState, Op, Op->Named.Node));
7150174267aSFredrik Holmqvist
7160174267aSFredrik Holmqvist if (!AcpiNsGetAttachedObject (Op->Named.Node))
7170174267aSFredrik Holmqvist {
7180174267aSFredrik Holmqvist WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
7190174267aSFredrik Holmqvist WalkState->NumOperands = 1;
7200174267aSFredrik Holmqvist
721b64e8511SFredrik Holmqvist Status = AcpiDsCreateOperands (
722b64e8511SFredrik Holmqvist WalkState, Op->Common.Value.Arg);
7230174267aSFredrik Holmqvist if (ACPI_SUCCESS (Status))
7240174267aSFredrik Holmqvist {
7250174267aSFredrik Holmqvist Status = AcpiExCreateMethod (Op->Named.Data,
7260174267aSFredrik Holmqvist Op->Named.Length, WalkState);
7270174267aSFredrik Holmqvist }
7280174267aSFredrik Holmqvist
7290174267aSFredrik Holmqvist WalkState->Operands[0] = NULL;
7300174267aSFredrik Holmqvist WalkState->NumOperands = 0;
7310174267aSFredrik Holmqvist
7320174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
7330174267aSFredrik Holmqvist {
7340174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
7350174267aSFredrik Holmqvist }
7360174267aSFredrik Holmqvist }
7370174267aSFredrik Holmqvist }
7380174267aSFredrik Holmqvist }
7390174267aSFredrik Holmqvist
7400174267aSFredrik Holmqvist /* Pop the scope stack (only if loading a table) */
7410174267aSFredrik Holmqvist
7420174267aSFredrik Holmqvist if (!WalkState->MethodNode &&
743ff2e2f81SFredrik Holmqvist Op->Common.AmlOpcode != AML_EXTERNAL_OP &&
7440174267aSFredrik Holmqvist AcpiNsOpensScope (ObjectType))
7450174267aSFredrik Holmqvist {
7460174267aSFredrik Holmqvist ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
7470174267aSFredrik Holmqvist AcpiUtGetTypeName (ObjectType), Op));
7480174267aSFredrik Holmqvist
7490174267aSFredrik Holmqvist Status = AcpiDsScopeStackPop (WalkState);
7500174267aSFredrik Holmqvist }
7510174267aSFredrik Holmqvist
7520174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
7530174267aSFredrik Holmqvist }
754