xref: /freebsd/sys/contrib/dev/acpica/components/dispatcher/dswload.c (revision 32ac401671be7ee8af824460a11661e32df0e194)
1a159c266SJung-uk Kim /******************************************************************************
2a159c266SJung-uk Kim  *
3a159c266SJung-uk Kim  * Module Name: dswload - Dispatcher first pass namespace load callbacks
4a159c266SJung-uk Kim  *
5a159c266SJung-uk Kim  *****************************************************************************/
6a159c266SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11*32ac4016SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12a159c266SJung-uk Kim  * All rights reserved.
13a159c266SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119a159c266SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120a159c266SJung-uk Kim  * modification, are permitted provided that the following conditions
121a159c266SJung-uk Kim  * are met:
122a159c266SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123a159c266SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124a159c266SJung-uk Kim  *    without modification.
125a159c266SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126a159c266SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127a159c266SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128a159c266SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129a159c266SJung-uk Kim  *    binary redistribution.
130a159c266SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131a159c266SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132a159c266SJung-uk Kim  *    from this software without specific prior written permission.
133a159c266SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147a159c266SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148a159c266SJung-uk Kim  * Software Foundation.
149a159c266SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151a159c266SJung-uk Kim 
152a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
153a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
154a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h>
155a159c266SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h>
156a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h>
157a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acinterp.h>
158a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
159a159c266SJung-uk Kim 
160a159c266SJung-uk Kim #ifdef ACPI_ASL_COMPILER
161a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h>
162a159c266SJung-uk Kim #endif
163a159c266SJung-uk Kim 
164a159c266SJung-uk Kim #define _COMPONENT          ACPI_DISPATCHER
165a159c266SJung-uk Kim         ACPI_MODULE_NAME    ("dswload")
166a159c266SJung-uk Kim 
167a159c266SJung-uk Kim 
168a159c266SJung-uk Kim /*******************************************************************************
169a159c266SJung-uk Kim  *
170a159c266SJung-uk Kim  * FUNCTION:    AcpiDsInitCallbacks
171a159c266SJung-uk Kim  *
172a159c266SJung-uk Kim  * PARAMETERS:  WalkState       - Current state of the parse tree walk
173a159c266SJung-uk Kim  *              PassNumber      - 1, 2, or 3
174a159c266SJung-uk Kim  *
175a159c266SJung-uk Kim  * RETURN:      Status
176a159c266SJung-uk Kim  *
177a159c266SJung-uk Kim  * DESCRIPTION: Init walk state callbacks
178a159c266SJung-uk Kim  *
179a159c266SJung-uk Kim  ******************************************************************************/
180a159c266SJung-uk Kim 
181a159c266SJung-uk Kim ACPI_STATUS
182a159c266SJung-uk Kim AcpiDsInitCallbacks (
183a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState,
184a159c266SJung-uk Kim     UINT32                  PassNumber)
185a159c266SJung-uk Kim {
186a159c266SJung-uk Kim 
187a159c266SJung-uk Kim     switch (PassNumber)
188a159c266SJung-uk Kim     {
189313a0c13SJung-uk Kim     case 0:
190313a0c13SJung-uk Kim 
191313a0c13SJung-uk Kim         /* Parse only - caller will setup callbacks */
192313a0c13SJung-uk Kim 
193313a0c13SJung-uk Kim         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
194313a0c13SJung-uk Kim                                         ACPI_PARSE_DELETE_TREE |
195313a0c13SJung-uk Kim                                         ACPI_PARSE_DISASSEMBLE;
196313a0c13SJung-uk Kim         WalkState->DescendingCallback = NULL;
197313a0c13SJung-uk Kim         WalkState->AscendingCallback  = NULL;
198313a0c13SJung-uk Kim         break;
199313a0c13SJung-uk Kim 
200a159c266SJung-uk Kim     case 1:
201a9d8d09cSJung-uk Kim 
202313a0c13SJung-uk Kim         /* Load pass 1 */
203313a0c13SJung-uk Kim 
204a159c266SJung-uk Kim         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
205a159c266SJung-uk Kim                                         ACPI_PARSE_DELETE_TREE;
206a159c266SJung-uk Kim         WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
207a159c266SJung-uk Kim         WalkState->AscendingCallback  = AcpiDsLoad1EndOp;
208a159c266SJung-uk Kim         break;
209a159c266SJung-uk Kim 
210a159c266SJung-uk Kim     case 2:
211a9d8d09cSJung-uk Kim 
212313a0c13SJung-uk Kim         /* Load pass 2 */
213313a0c13SJung-uk Kim 
214a159c266SJung-uk Kim         WalkState->ParseFlags         = ACPI_PARSE_LOAD_PASS1 |
215a159c266SJung-uk Kim                                         ACPI_PARSE_DELETE_TREE;
216a159c266SJung-uk Kim         WalkState->DescendingCallback = AcpiDsLoad2BeginOp;
217a159c266SJung-uk Kim         WalkState->AscendingCallback  = AcpiDsLoad2EndOp;
218a159c266SJung-uk Kim         break;
219a159c266SJung-uk Kim 
220a159c266SJung-uk Kim     case 3:
221a9d8d09cSJung-uk Kim 
222313a0c13SJung-uk Kim         /* Execution pass */
223313a0c13SJung-uk Kim 
224a159c266SJung-uk Kim #ifndef ACPI_NO_METHOD_EXECUTION
225a159c266SJung-uk Kim         WalkState->ParseFlags        |= ACPI_PARSE_EXECUTE  |
226a159c266SJung-uk Kim                                         ACPI_PARSE_DELETE_TREE;
227a159c266SJung-uk Kim         WalkState->DescendingCallback = AcpiDsExecBeginOp;
228a159c266SJung-uk Kim         WalkState->AscendingCallback  = AcpiDsExecEndOp;
229a159c266SJung-uk Kim #endif
230a159c266SJung-uk Kim         break;
231a159c266SJung-uk Kim 
232a159c266SJung-uk Kim     default:
233a9d8d09cSJung-uk Kim 
234a159c266SJung-uk Kim         return (AE_BAD_PARAMETER);
235a159c266SJung-uk Kim     }
236a159c266SJung-uk Kim 
237a159c266SJung-uk Kim     return (AE_OK);
238a159c266SJung-uk Kim }
239a159c266SJung-uk Kim 
240a159c266SJung-uk Kim 
241a159c266SJung-uk Kim /*******************************************************************************
242a159c266SJung-uk Kim  *
243a159c266SJung-uk Kim  * FUNCTION:    AcpiDsLoad1BeginOp
244a159c266SJung-uk Kim  *
245a159c266SJung-uk Kim  * PARAMETERS:  WalkState       - Current state of the parse tree walk
246a159c266SJung-uk Kim  *              OutOp           - Where to return op if a new one is created
247a159c266SJung-uk Kim  *
248a159c266SJung-uk Kim  * RETURN:      Status
249a159c266SJung-uk Kim  *
250a159c266SJung-uk Kim  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
251a159c266SJung-uk Kim  *
252a159c266SJung-uk Kim  ******************************************************************************/
253a159c266SJung-uk Kim 
254a159c266SJung-uk Kim ACPI_STATUS
255a159c266SJung-uk Kim AcpiDsLoad1BeginOp (
256a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState,
257a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       **OutOp)
258a159c266SJung-uk Kim {
259a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op;
260a159c266SJung-uk Kim     ACPI_NAMESPACE_NODE     *Node;
261a159c266SJung-uk Kim     ACPI_STATUS             Status;
262a159c266SJung-uk Kim     ACPI_OBJECT_TYPE        ObjectType;
263a159c266SJung-uk Kim     char                    *Path;
264a159c266SJung-uk Kim     UINT32                  Flags;
265a159c266SJung-uk Kim 
266a159c266SJung-uk Kim 
267a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (DsLoad1BeginOp);
268a159c266SJung-uk Kim 
269a159c266SJung-uk Kim 
270a159c266SJung-uk Kim     Op = WalkState->Op;
271a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
272a159c266SJung-uk Kim 
273a159c266SJung-uk Kim     /* We are only interested in opcodes that have an associated name */
274a159c266SJung-uk Kim 
275a159c266SJung-uk Kim     if (Op)
276a159c266SJung-uk Kim     {
277a159c266SJung-uk Kim         if (!(WalkState->OpInfo->Flags & AML_NAMED))
278a159c266SJung-uk Kim         {
279a159c266SJung-uk Kim             *OutOp = Op;
280a159c266SJung-uk Kim             return_ACPI_STATUS (AE_OK);
281a159c266SJung-uk Kim         }
282a159c266SJung-uk Kim 
283a159c266SJung-uk Kim         /* Check if this object has already been installed in the namespace */
284a159c266SJung-uk Kim 
285a159c266SJung-uk Kim         if (Op->Common.Node)
286a159c266SJung-uk Kim         {
287a159c266SJung-uk Kim             *OutOp = Op;
288a159c266SJung-uk Kim             return_ACPI_STATUS (AE_OK);
289a159c266SJung-uk Kim         }
290a159c266SJung-uk Kim     }
291a159c266SJung-uk Kim 
292a159c266SJung-uk Kim     Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
293a159c266SJung-uk Kim 
294a159c266SJung-uk Kim     /* Map the raw opcode into an internal object type */
295a159c266SJung-uk Kim 
296a159c266SJung-uk Kim     ObjectType = WalkState->OpInfo->ObjectType;
297a159c266SJung-uk Kim 
298a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
299f8146b88SJung-uk Kim         "State=%p Op=%p [%s]\n", WalkState, Op,
300f8146b88SJung-uk Kim         AcpiUtGetTypeName (ObjectType)));
301a159c266SJung-uk Kim 
302a159c266SJung-uk Kim     switch (WalkState->Opcode)
303a159c266SJung-uk Kim     {
304a159c266SJung-uk Kim     case AML_SCOPE_OP:
305a159c266SJung-uk Kim         /*
306a159c266SJung-uk Kim          * The target name of the Scope() operator must exist at this point so
307a159c266SJung-uk Kim          * that we can actually open the scope to enter new names underneath it.
308a159c266SJung-uk Kim          * Allow search-to-root for single namesegs.
309a159c266SJung-uk Kim          */
310a159c266SJung-uk Kim         Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
311a159c266SJung-uk Kim             ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
312a159c266SJung-uk Kim #ifdef ACPI_ASL_COMPILER
313a159c266SJung-uk Kim         if (Status == AE_NOT_FOUND)
314a159c266SJung-uk Kim         {
315a159c266SJung-uk Kim             /*
316a159c266SJung-uk Kim              * Table disassembly:
317a159c266SJung-uk Kim              * Target of Scope() not found. Generate an External for it, and
318a159c266SJung-uk Kim              * insert the name into the namespace.
319a159c266SJung-uk Kim              */
320313a0c13SJung-uk Kim             AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0);
321a159c266SJung-uk Kim             Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
322a159c266SJung-uk Kim                ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
323a159c266SJung-uk Kim                WalkState, &Node);
324a159c266SJung-uk Kim         }
325a159c266SJung-uk Kim #endif
326a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
327a159c266SJung-uk Kim         {
328b7b7e711SJung-uk Kim             ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
329a159c266SJung-uk Kim             return_ACPI_STATUS (Status);
330a159c266SJung-uk Kim         }
331a159c266SJung-uk Kim 
332a159c266SJung-uk Kim         /*
333a159c266SJung-uk Kim          * Check to make sure that the target is
334a159c266SJung-uk Kim          * one of the opcodes that actually opens a scope
335a159c266SJung-uk Kim          */
336a159c266SJung-uk Kim         switch (Node->Type)
337a159c266SJung-uk Kim         {
338a159c266SJung-uk Kim         case ACPI_TYPE_ANY:
339a159c266SJung-uk Kim         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope  */
340a159c266SJung-uk Kim         case ACPI_TYPE_DEVICE:
341a159c266SJung-uk Kim         case ACPI_TYPE_POWER:
342a159c266SJung-uk Kim         case ACPI_TYPE_PROCESSOR:
343a159c266SJung-uk Kim         case ACPI_TYPE_THERMAL:
344a159c266SJung-uk Kim 
345a159c266SJung-uk Kim             /* These are acceptable types */
346a159c266SJung-uk Kim             break;
347a159c266SJung-uk Kim 
348a159c266SJung-uk Kim         case ACPI_TYPE_INTEGER:
349a159c266SJung-uk Kim         case ACPI_TYPE_STRING:
350a159c266SJung-uk Kim         case ACPI_TYPE_BUFFER:
351a159c266SJung-uk Kim             /*
352a159c266SJung-uk Kim              * These types we will allow, but we will change the type.
353a159c266SJung-uk Kim              * This enables some existing code of the form:
354a159c266SJung-uk Kim              *
355a159c266SJung-uk Kim              *  Name (DEB, 0)
356a159c266SJung-uk Kim              *  Scope (DEB) { ... }
357a159c266SJung-uk Kim              *
358a159c266SJung-uk Kim              * Note: silently change the type here. On the second pass,
359a159c266SJung-uk Kim              * we will report a warning
360a159c266SJung-uk Kim              */
361a159c266SJung-uk Kim             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
362a159c266SJung-uk Kim                 "Type override - [%4.4s] had invalid type (%s) "
363a159c266SJung-uk Kim                 "for Scope operator, changed to type ANY\n",
364a159c266SJung-uk Kim                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
365a159c266SJung-uk Kim 
366a159c266SJung-uk Kim             Node->Type = ACPI_TYPE_ANY;
367a159c266SJung-uk Kim             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
368a159c266SJung-uk Kim             break;
369a159c266SJung-uk Kim 
3701df130f1SJung-uk Kim         case ACPI_TYPE_METHOD:
3711df130f1SJung-uk Kim             /*
3721df130f1SJung-uk Kim              * Allow scope change to root during execution of module-level
3731df130f1SJung-uk Kim              * code. Root is typed METHOD during this time.
3741df130f1SJung-uk Kim              */
3751df130f1SJung-uk Kim             if ((Node == AcpiGbl_RootNode) &&
3761df130f1SJung-uk Kim                 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
3771df130f1SJung-uk Kim             {
3781df130f1SJung-uk Kim                 break;
3791df130f1SJung-uk Kim             }
3801df130f1SJung-uk Kim 
3811df130f1SJung-uk Kim             /*lint -fallthrough */
3821df130f1SJung-uk Kim 
383a159c266SJung-uk Kim         default:
384a159c266SJung-uk Kim 
385a159c266SJung-uk Kim             /* All other types are an error */
386a159c266SJung-uk Kim 
387a159c266SJung-uk Kim             ACPI_ERROR ((AE_INFO,
388a159c266SJung-uk Kim                 "Invalid type (%s) for target of "
389a159c266SJung-uk Kim                 "Scope operator [%4.4s] (Cannot override)",
390a159c266SJung-uk Kim                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
391a159c266SJung-uk Kim 
392a159c266SJung-uk Kim             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
393a159c266SJung-uk Kim         }
394a159c266SJung-uk Kim         break;
395a159c266SJung-uk Kim 
396a159c266SJung-uk Kim     default:
397a159c266SJung-uk Kim         /*
398a159c266SJung-uk Kim          * For all other named opcodes, we will enter the name into
399a159c266SJung-uk Kim          * the namespace.
400a159c266SJung-uk Kim          *
401a159c266SJung-uk Kim          * Setup the search flags.
402a159c266SJung-uk Kim          * Since we are entering a name into the namespace, we do not want to
403a159c266SJung-uk Kim          * enable the search-to-root upsearch.
404a159c266SJung-uk Kim          *
405a159c266SJung-uk Kim          * There are only two conditions where it is acceptable that the name
406a159c266SJung-uk Kim          * already exists:
407a159c266SJung-uk Kim          *    1) the Scope() operator can reopen a scoping object that was
408a159c266SJung-uk Kim          *       previously defined (Scope, Method, Device, etc.)
409a159c266SJung-uk Kim          *    2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
410a159c266SJung-uk Kim          *       BufferField, or Package), the name of the object is already
411a159c266SJung-uk Kim          *       in the namespace.
412a159c266SJung-uk Kim          */
413a159c266SJung-uk Kim         if (WalkState->DeferredNode)
414a159c266SJung-uk Kim         {
415a159c266SJung-uk Kim             /* This name is already in the namespace, get the node */
416a159c266SJung-uk Kim 
417a159c266SJung-uk Kim             Node = WalkState->DeferredNode;
418a159c266SJung-uk Kim             Status = AE_OK;
419a159c266SJung-uk Kim             break;
420a159c266SJung-uk Kim         }
421a159c266SJung-uk Kim 
422a159c266SJung-uk Kim         /*
423a159c266SJung-uk Kim          * If we are executing a method, do not create any namespace objects
424a159c266SJung-uk Kim          * during the load phase, only during execution.
425a159c266SJung-uk Kim          */
426a159c266SJung-uk Kim         if (WalkState->MethodNode)
427a159c266SJung-uk Kim         {
428a159c266SJung-uk Kim             Node = NULL;
429a159c266SJung-uk Kim             Status = AE_OK;
430a159c266SJung-uk Kim             break;
431a159c266SJung-uk Kim         }
432a159c266SJung-uk Kim 
433a159c266SJung-uk Kim         Flags = ACPI_NS_NO_UPSEARCH;
434a159c266SJung-uk Kim         if ((WalkState->Opcode != AML_SCOPE_OP) &&
435a159c266SJung-uk Kim             (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
436a159c266SJung-uk Kim         {
4375ef50723SJung-uk Kim             if (WalkState->NamespaceOverride)
4385ef50723SJung-uk Kim             {
4395ef50723SJung-uk Kim                 Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
4405ef50723SJung-uk Kim                 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n",
4415ef50723SJung-uk Kim                     AcpiUtGetTypeName (ObjectType)));
4425ef50723SJung-uk Kim             }
4435ef50723SJung-uk Kim             else
4445ef50723SJung-uk Kim             {
445a159c266SJung-uk Kim                 Flags |= ACPI_NS_ERROR_IF_FOUND;
446a159c266SJung-uk Kim                 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
447a159c266SJung-uk Kim                     AcpiUtGetTypeName (ObjectType)));
448a159c266SJung-uk Kim             }
4495ef50723SJung-uk Kim         }
450a159c266SJung-uk Kim         else
451a159c266SJung-uk Kim         {
452a159c266SJung-uk Kim             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
453a159c266SJung-uk Kim                 "[%s] Both Find or Create allowed\n",
454a159c266SJung-uk Kim                 AcpiUtGetTypeName (ObjectType)));
455a159c266SJung-uk Kim         }
456a159c266SJung-uk Kim 
457a159c266SJung-uk Kim         /*
458a159c266SJung-uk Kim          * Enter the named type into the internal namespace. We enter the name
459a159c266SJung-uk Kim          * as we go downward in the parse tree. Any necessary subobjects that
460a159c266SJung-uk Kim          * involve arguments to the opcode must be created as we go back up the
461a159c266SJung-uk Kim          * parse tree later.
462a159c266SJung-uk Kim          */
463a159c266SJung-uk Kim         Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
464a159c266SJung-uk Kim             ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
465a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
466a159c266SJung-uk Kim         {
467a159c266SJung-uk Kim             if (Status == AE_ALREADY_EXISTS)
468a159c266SJung-uk Kim             {
469a159c266SJung-uk Kim                 /* The name already exists in this scope */
470a159c266SJung-uk Kim 
471a159c266SJung-uk Kim                 if (Node->Flags & ANOBJ_IS_EXTERNAL)
472a159c266SJung-uk Kim                 {
473a159c266SJung-uk Kim                     /*
474a159c266SJung-uk Kim                      * Allow one create on an object or segment that was
475a159c266SJung-uk Kim                      * previously declared External
476a159c266SJung-uk Kim                      */
477a159c266SJung-uk Kim                     Node->Flags &= ~ANOBJ_IS_EXTERNAL;
478a159c266SJung-uk Kim                     Node->Type = (UINT8) ObjectType;
479a159c266SJung-uk Kim 
480a159c266SJung-uk Kim                     /* Just retyped a node, probably will need to open a scope */
481a159c266SJung-uk Kim 
482a159c266SJung-uk Kim                     if (AcpiNsOpensScope (ObjectType))
483a159c266SJung-uk Kim                     {
484f8146b88SJung-uk Kim                         Status = AcpiDsScopeStackPush (
485f8146b88SJung-uk Kim                             Node, ObjectType, WalkState);
486a159c266SJung-uk Kim                         if (ACPI_FAILURE (Status))
487a159c266SJung-uk Kim                         {
488a159c266SJung-uk Kim                             return_ACPI_STATUS (Status);
489a159c266SJung-uk Kim                         }
490a159c266SJung-uk Kim                     }
491a159c266SJung-uk Kim 
492a159c266SJung-uk Kim                     Status = AE_OK;
493a159c266SJung-uk Kim                 }
494a159c266SJung-uk Kim             }
495a159c266SJung-uk Kim 
496a159c266SJung-uk Kim             if (ACPI_FAILURE (Status))
497a159c266SJung-uk Kim             {
498b7b7e711SJung-uk Kim                 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
499a159c266SJung-uk Kim                 return_ACPI_STATUS (Status);
500a159c266SJung-uk Kim             }
501a159c266SJung-uk Kim         }
502a159c266SJung-uk Kim         break;
503a159c266SJung-uk Kim     }
504a159c266SJung-uk Kim 
505a159c266SJung-uk Kim     /* Common exit */
506a159c266SJung-uk Kim 
507a159c266SJung-uk Kim     if (!Op)
508a159c266SJung-uk Kim     {
509a159c266SJung-uk Kim         /* Create a new op */
510a159c266SJung-uk Kim 
511fe0f0bbbSJung-uk Kim         Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
512a159c266SJung-uk Kim         if (!Op)
513a159c266SJung-uk Kim         {
514a159c266SJung-uk Kim             return_ACPI_STATUS (AE_NO_MEMORY);
515a159c266SJung-uk Kim         }
516a159c266SJung-uk Kim     }
517a159c266SJung-uk Kim 
518a159c266SJung-uk Kim     /* Initialize the op */
519a159c266SJung-uk Kim 
520a159c266SJung-uk Kim #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
521af051161SJung-uk Kim     Op->Named.Path = Path;
522a159c266SJung-uk Kim #endif
523a159c266SJung-uk Kim 
524a159c266SJung-uk Kim     if (Node)
525a159c266SJung-uk Kim     {
526a159c266SJung-uk Kim         /*
527a159c266SJung-uk Kim          * Put the Node in the "op" object that the parser uses, so we
528a159c266SJung-uk Kim          * can get it again quickly when this scope is closed
529a159c266SJung-uk Kim          */
530a159c266SJung-uk Kim         Op->Common.Node = Node;
531a159c266SJung-uk Kim         Op->Named.Name = Node->Name.Integer;
532a159c266SJung-uk Kim     }
533a159c266SJung-uk Kim 
534a159c266SJung-uk Kim     AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
535a159c266SJung-uk Kim     *OutOp = Op;
536a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
537a159c266SJung-uk Kim }
538a159c266SJung-uk Kim 
539a159c266SJung-uk Kim 
540a159c266SJung-uk Kim /*******************************************************************************
541a159c266SJung-uk Kim  *
542a159c266SJung-uk Kim  * FUNCTION:    AcpiDsLoad1EndOp
543a159c266SJung-uk Kim  *
544a159c266SJung-uk Kim  * PARAMETERS:  WalkState       - Current state of the parse tree walk
545a159c266SJung-uk Kim  *
546a159c266SJung-uk Kim  * RETURN:      Status
547a159c266SJung-uk Kim  *
548a159c266SJung-uk Kim  * DESCRIPTION: Ascending callback used during the loading of the namespace,
549a159c266SJung-uk Kim  *              both control methods and everything else.
550a159c266SJung-uk Kim  *
551a159c266SJung-uk Kim  ******************************************************************************/
552a159c266SJung-uk Kim 
553a159c266SJung-uk Kim ACPI_STATUS
554a159c266SJung-uk Kim AcpiDsLoad1EndOp (
555a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState)
556a159c266SJung-uk Kim {
557a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op;
558a159c266SJung-uk Kim     ACPI_OBJECT_TYPE        ObjectType;
559a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_OK;
560a159c266SJung-uk Kim 
561af051161SJung-uk Kim #ifdef ACPI_ASL_COMPILER
562af051161SJung-uk Kim     UINT8                   ParamCount;
563af051161SJung-uk Kim #endif
564af051161SJung-uk Kim 
565a159c266SJung-uk Kim 
566a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (DsLoad1EndOp);
567a159c266SJung-uk Kim 
568a159c266SJung-uk Kim 
569a159c266SJung-uk Kim     Op = WalkState->Op;
570a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
571a159c266SJung-uk Kim 
572a159c266SJung-uk Kim     /* We are only interested in opcodes that have an associated name */
573a159c266SJung-uk Kim 
574a159c266SJung-uk Kim     if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD)))
575a159c266SJung-uk Kim     {
576a159c266SJung-uk Kim         return_ACPI_STATUS (AE_OK);
577a159c266SJung-uk Kim     }
578a159c266SJung-uk Kim 
579a159c266SJung-uk Kim     /* Get the object type to determine if we should pop the scope */
580a159c266SJung-uk Kim 
581a159c266SJung-uk Kim     ObjectType = WalkState->OpInfo->ObjectType;
582a159c266SJung-uk Kim 
583a159c266SJung-uk Kim #ifndef ACPI_NO_METHOD_EXECUTION
584a159c266SJung-uk Kim     if (WalkState->OpInfo->Flags & AML_FIELD)
585a159c266SJung-uk Kim     {
586a159c266SJung-uk Kim         /*
587a159c266SJung-uk Kim          * If we are executing a method, do not create any namespace objects
588a159c266SJung-uk Kim          * during the load phase, only during execution.
589a159c266SJung-uk Kim          */
590a159c266SJung-uk Kim         if (!WalkState->MethodNode)
591a159c266SJung-uk Kim         {
592a159c266SJung-uk Kim             if (WalkState->Opcode == AML_FIELD_OP          ||
593a159c266SJung-uk Kim                 WalkState->Opcode == AML_BANK_FIELD_OP     ||
594a159c266SJung-uk Kim                 WalkState->Opcode == AML_INDEX_FIELD_OP)
595a159c266SJung-uk Kim             {
596a159c266SJung-uk Kim                 Status = AcpiDsInitFieldObjects (Op, WalkState);
597a159c266SJung-uk Kim             }
598a159c266SJung-uk Kim         }
599a159c266SJung-uk Kim         return_ACPI_STATUS (Status);
600a159c266SJung-uk Kim     }
601a159c266SJung-uk Kim 
602a159c266SJung-uk Kim     /*
603a159c266SJung-uk Kim      * If we are executing a method, do not create any namespace objects
604a159c266SJung-uk Kim      * during the load phase, only during execution.
605a159c266SJung-uk Kim      */
606a159c266SJung-uk Kim     if (!WalkState->MethodNode)
607a159c266SJung-uk Kim     {
608a159c266SJung-uk Kim         if (Op->Common.AmlOpcode == AML_REGION_OP)
609a159c266SJung-uk Kim         {
610a159c266SJung-uk Kim             Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
611f8146b88SJung-uk Kim                 (ACPI_ADR_SPACE_TYPE)
612f8146b88SJung-uk Kim                     ((Op->Common.Value.Arg)->Common.Value.Integer),
613a159c266SJung-uk Kim                 WalkState);
614a159c266SJung-uk Kim             if (ACPI_FAILURE (Status))
615a159c266SJung-uk Kim             {
616a159c266SJung-uk Kim                 return_ACPI_STATUS (Status);
617a159c266SJung-uk Kim             }
618a159c266SJung-uk Kim         }
619a159c266SJung-uk Kim         else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
620a159c266SJung-uk Kim         {
621a159c266SJung-uk Kim             Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
622a159c266SJung-uk Kim                 ACPI_ADR_SPACE_DATA_TABLE, WalkState);
623a159c266SJung-uk Kim             if (ACPI_FAILURE (Status))
624a159c266SJung-uk Kim             {
625a159c266SJung-uk Kim                 return_ACPI_STATUS (Status);
626a159c266SJung-uk Kim             }
627a159c266SJung-uk Kim         }
628a159c266SJung-uk Kim     }
629a159c266SJung-uk Kim #endif
630a159c266SJung-uk Kim 
631a159c266SJung-uk Kim     if (Op->Common.AmlOpcode == AML_NAME_OP)
632a159c266SJung-uk Kim     {
633a159c266SJung-uk Kim         /* For Name opcode, get the object type from the argument */
634a159c266SJung-uk Kim 
635a159c266SJung-uk Kim         if (Op->Common.Value.Arg)
636a159c266SJung-uk Kim         {
637a159c266SJung-uk Kim             ObjectType = (AcpiPsGetOpcodeInfo (
638a159c266SJung-uk Kim                 (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType;
639a159c266SJung-uk Kim 
640a159c266SJung-uk Kim             /* Set node type if we have a namespace node */
641a159c266SJung-uk Kim 
642a159c266SJung-uk Kim             if (Op->Common.Node)
643a159c266SJung-uk Kim             {
644a159c266SJung-uk Kim                 Op->Common.Node->Type = (UINT8) ObjectType;
645a159c266SJung-uk Kim             }
646a159c266SJung-uk Kim         }
647a159c266SJung-uk Kim     }
648a159c266SJung-uk Kim 
649af051161SJung-uk Kim #ifdef ACPI_ASL_COMPILER
650af051161SJung-uk Kim     /*
651af051161SJung-uk Kim      * For external opcode, get the object type from the argument and
652af051161SJung-uk Kim      * get the parameter count from the argument's next.
653af051161SJung-uk Kim      */
654af051161SJung-uk Kim     if (AcpiGbl_DisasmFlag &&
655af051161SJung-uk Kim         Op->Common.Node &&
656af051161SJung-uk Kim         Op->Common.AmlOpcode == AML_EXTERNAL_OP)
657af051161SJung-uk Kim     {
658af051161SJung-uk Kim         /*
659af051161SJung-uk Kim          * Note, if this external is not a method
660af051161SJung-uk Kim          * Op->Common.Value.Arg->Common.Next->Common.Value.Integer == 0
661af051161SJung-uk Kim          * Therefore, ParamCount will be 0.
662af051161SJung-uk Kim          */
663af051161SJung-uk Kim         ParamCount = (UINT8) Op->Common.Value.Arg->Common.Next->Common.Value.Integer;
664af051161SJung-uk Kim         ObjectType = (UINT8) Op->Common.Value.Arg->Common.Value.Integer;
665af051161SJung-uk Kim         Op->Common.Node->Flags |= ANOBJ_IS_EXTERNAL;
666af051161SJung-uk Kim         Op->Common.Node->Type = (UINT8) ObjectType;
667af051161SJung-uk Kim 
668af051161SJung-uk Kim         AcpiDmCreateSubobjectForExternal ((UINT8)ObjectType,
669af051161SJung-uk Kim             &Op->Common.Node, ParamCount);
670af051161SJung-uk Kim 
671af051161SJung-uk Kim         /*
672af051161SJung-uk Kim          * Add the external to the external list because we may be
673af051161SJung-uk Kim          * emitting code based off of the items within the external list.
674af051161SJung-uk Kim          */
675af051161SJung-uk Kim         AcpiDmAddOpToExternalList (Op, Op->Named.Path, (UINT8)ObjectType, ParamCount,
676af051161SJung-uk Kim            ACPI_EXT_ORIGIN_FROM_OPCODE | ACPI_EXT_RESOLVED_REFERENCE);
677af051161SJung-uk Kim     }
678af051161SJung-uk Kim #endif
679af051161SJung-uk Kim 
680a159c266SJung-uk Kim     /*
681a159c266SJung-uk Kim      * If we are executing a method, do not create any namespace objects
682a159c266SJung-uk Kim      * during the load phase, only during execution.
683a159c266SJung-uk Kim      */
684a159c266SJung-uk Kim     if (!WalkState->MethodNode)
685a159c266SJung-uk Kim     {
686a159c266SJung-uk Kim         if (Op->Common.AmlOpcode == AML_METHOD_OP)
687a159c266SJung-uk Kim         {
688a159c266SJung-uk Kim             /*
689a159c266SJung-uk Kim              * MethodOp PkgLength NameString MethodFlags TermList
690a159c266SJung-uk Kim              *
691a159c266SJung-uk Kim              * Note: We must create the method node/object pair as soon as we
692a159c266SJung-uk Kim              * see the method declaration. This allows later pass1 parsing
693a159c266SJung-uk Kim              * of invocations of the method (need to know the number of
694a159c266SJung-uk Kim              * arguments.)
695a159c266SJung-uk Kim              */
696a159c266SJung-uk Kim             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
697a159c266SJung-uk Kim                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
698a159c266SJung-uk Kim                 WalkState, Op, Op->Named.Node));
699a159c266SJung-uk Kim 
700a159c266SJung-uk Kim             if (!AcpiNsGetAttachedObject (Op->Named.Node))
701a159c266SJung-uk Kim             {
702a159c266SJung-uk Kim                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
703a159c266SJung-uk Kim                 WalkState->NumOperands = 1;
704a159c266SJung-uk Kim 
705f8146b88SJung-uk Kim                 Status = AcpiDsCreateOperands (
706f8146b88SJung-uk Kim                     WalkState, Op->Common.Value.Arg);
707a159c266SJung-uk Kim                 if (ACPI_SUCCESS (Status))
708a159c266SJung-uk Kim                 {
709a159c266SJung-uk Kim                     Status = AcpiExCreateMethod (Op->Named.Data,
710a159c266SJung-uk Kim                         Op->Named.Length, WalkState);
711a159c266SJung-uk Kim                 }
712a159c266SJung-uk Kim 
713a159c266SJung-uk Kim                 WalkState->Operands[0] = NULL;
714a159c266SJung-uk Kim                 WalkState->NumOperands = 0;
715a159c266SJung-uk Kim 
716a159c266SJung-uk Kim                 if (ACPI_FAILURE (Status))
717a159c266SJung-uk Kim                 {
718a159c266SJung-uk Kim                     return_ACPI_STATUS (Status);
719a159c266SJung-uk Kim                 }
720a159c266SJung-uk Kim             }
721a159c266SJung-uk Kim         }
722a159c266SJung-uk Kim     }
723a159c266SJung-uk Kim 
724a159c266SJung-uk Kim     /* Pop the scope stack (only if loading a table) */
725a159c266SJung-uk Kim 
726a159c266SJung-uk Kim     if (!WalkState->MethodNode &&
727af051161SJung-uk Kim         Op->Common.AmlOpcode != AML_EXTERNAL_OP &&
728a159c266SJung-uk Kim         AcpiNsOpensScope (ObjectType))
729a159c266SJung-uk Kim     {
730a159c266SJung-uk Kim         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
731a159c266SJung-uk Kim             AcpiUtGetTypeName (ObjectType), Op));
732a159c266SJung-uk Kim 
733a159c266SJung-uk Kim         Status = AcpiDsScopeStackPop (WalkState);
734a159c266SJung-uk Kim     }
735a159c266SJung-uk Kim 
736a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
737a159c266SJung-uk Kim }
738