xref: /freebsd/sys/contrib/dev/acpica/components/dispatcher/dswload.c (revision 90b566fde97e5f8b40250d6aadc0eba9f48058c2)
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  *
1132ac4016SJung-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         WalkState->ParseFlags        |= ACPI_PARSE_EXECUTE  |
225a159c266SJung-uk Kim                                         ACPI_PARSE_DELETE_TREE;
226a159c266SJung-uk Kim         WalkState->DescendingCallback = AcpiDsExecBeginOp;
227a159c266SJung-uk Kim         WalkState->AscendingCallback  = AcpiDsExecEndOp;
228a159c266SJung-uk Kim         break;
229a159c266SJung-uk Kim 
230a159c266SJung-uk Kim     default:
231a9d8d09cSJung-uk Kim 
232a159c266SJung-uk Kim         return (AE_BAD_PARAMETER);
233a159c266SJung-uk Kim     }
234a159c266SJung-uk Kim 
235a159c266SJung-uk Kim     return (AE_OK);
236a159c266SJung-uk Kim }
237a159c266SJung-uk Kim 
238a159c266SJung-uk Kim 
239a159c266SJung-uk Kim /*******************************************************************************
240a159c266SJung-uk Kim  *
241a159c266SJung-uk Kim  * FUNCTION:    AcpiDsLoad1BeginOp
242a159c266SJung-uk Kim  *
243a159c266SJung-uk Kim  * PARAMETERS:  WalkState       - Current state of the parse tree walk
244a159c266SJung-uk Kim  *              OutOp           - Where to return op if a new one is created
245a159c266SJung-uk Kim  *
246a159c266SJung-uk Kim  * RETURN:      Status
247a159c266SJung-uk Kim  *
248a159c266SJung-uk Kim  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
249a159c266SJung-uk Kim  *
250a159c266SJung-uk Kim  ******************************************************************************/
251a159c266SJung-uk Kim 
252a159c266SJung-uk Kim ACPI_STATUS
253a159c266SJung-uk Kim AcpiDsLoad1BeginOp (
254a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState,
255a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       **OutOp)
256a159c266SJung-uk Kim {
257a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op;
258a159c266SJung-uk Kim     ACPI_NAMESPACE_NODE     *Node;
259a159c266SJung-uk Kim     ACPI_STATUS             Status;
260a159c266SJung-uk Kim     ACPI_OBJECT_TYPE        ObjectType;
261a159c266SJung-uk Kim     char                    *Path;
262a159c266SJung-uk Kim     UINT32                  Flags;
263a159c266SJung-uk Kim 
264a159c266SJung-uk Kim 
265ff879b07SJung-uk Kim     ACPI_FUNCTION_TRACE_PTR (DsLoad1BeginOp, WalkState->Op);
266a159c266SJung-uk Kim 
267a159c266SJung-uk Kim 
268a159c266SJung-uk Kim     Op = WalkState->Op;
269a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
270a159c266SJung-uk Kim 
271a159c266SJung-uk Kim     /* We are only interested in opcodes that have an associated name */
272a159c266SJung-uk Kim 
273a159c266SJung-uk Kim     if (Op)
274a159c266SJung-uk Kim     {
275a159c266SJung-uk Kim         if (!(WalkState->OpInfo->Flags & AML_NAMED))
276a159c266SJung-uk Kim         {
277a159c266SJung-uk Kim             *OutOp = Op;
278a159c266SJung-uk Kim             return_ACPI_STATUS (AE_OK);
279a159c266SJung-uk Kim         }
280a159c266SJung-uk Kim 
281a159c266SJung-uk Kim         /* Check if this object has already been installed in the namespace */
282a159c266SJung-uk Kim 
283a159c266SJung-uk Kim         if (Op->Common.Node)
284a159c266SJung-uk Kim         {
285a159c266SJung-uk Kim             *OutOp = Op;
286a159c266SJung-uk Kim             return_ACPI_STATUS (AE_OK);
287a159c266SJung-uk Kim         }
288a159c266SJung-uk Kim     }
289a159c266SJung-uk Kim 
290a159c266SJung-uk Kim     Path = AcpiPsGetNextNamestring (&WalkState->ParserState);
291a159c266SJung-uk Kim 
292a159c266SJung-uk Kim     /* Map the raw opcode into an internal object type */
293a159c266SJung-uk Kim 
294a159c266SJung-uk Kim     ObjectType = WalkState->OpInfo->ObjectType;
295a159c266SJung-uk Kim 
296a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
297f8146b88SJung-uk Kim         "State=%p Op=%p [%s]\n", WalkState, Op,
298f8146b88SJung-uk Kim         AcpiUtGetTypeName (ObjectType)));
299a159c266SJung-uk Kim 
300a159c266SJung-uk Kim     switch (WalkState->Opcode)
301a159c266SJung-uk Kim     {
302a159c266SJung-uk Kim     case AML_SCOPE_OP:
303a159c266SJung-uk Kim         /*
304a159c266SJung-uk Kim          * The target name of the Scope() operator must exist at this point so
305a159c266SJung-uk Kim          * that we can actually open the scope to enter new names underneath it.
306a159c266SJung-uk Kim          * Allow search-to-root for single namesegs.
307a159c266SJung-uk Kim          */
308a159c266SJung-uk Kim         Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
309a159c266SJung-uk Kim             ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
310a159c266SJung-uk Kim #ifdef ACPI_ASL_COMPILER
311a159c266SJung-uk Kim         if (Status == AE_NOT_FOUND)
312a159c266SJung-uk Kim         {
313a159c266SJung-uk Kim             /*
314a159c266SJung-uk Kim              * Table disassembly:
315a159c266SJung-uk Kim              * Target of Scope() not found. Generate an External for it, and
316a159c266SJung-uk Kim              * insert the name into the namespace.
317a159c266SJung-uk Kim              */
318313a0c13SJung-uk Kim             AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0);
319a159c266SJung-uk Kim             Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
320a159c266SJung-uk Kim                ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
321a159c266SJung-uk Kim                WalkState, &Node);
322a159c266SJung-uk Kim         }
323a159c266SJung-uk Kim #endif
324a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
325a159c266SJung-uk Kim         {
326b7b7e711SJung-uk Kim             ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
327a159c266SJung-uk Kim             return_ACPI_STATUS (Status);
328a159c266SJung-uk Kim         }
329a159c266SJung-uk Kim 
330a159c266SJung-uk Kim         /*
331a159c266SJung-uk Kim          * Check to make sure that the target is
332a159c266SJung-uk Kim          * one of the opcodes that actually opens a scope
333a159c266SJung-uk Kim          */
334a159c266SJung-uk Kim         switch (Node->Type)
335a159c266SJung-uk Kim         {
336a159c266SJung-uk Kim         case ACPI_TYPE_ANY:
337a159c266SJung-uk Kim         case ACPI_TYPE_LOCAL_SCOPE:         /* Scope  */
338a159c266SJung-uk Kim         case ACPI_TYPE_DEVICE:
339a159c266SJung-uk Kim         case ACPI_TYPE_POWER:
340a159c266SJung-uk Kim         case ACPI_TYPE_PROCESSOR:
341a159c266SJung-uk Kim         case ACPI_TYPE_THERMAL:
342a159c266SJung-uk Kim 
343a159c266SJung-uk Kim             /* These are acceptable types */
344a159c266SJung-uk Kim             break;
345a159c266SJung-uk Kim 
346a159c266SJung-uk Kim         case ACPI_TYPE_INTEGER:
347a159c266SJung-uk Kim         case ACPI_TYPE_STRING:
348a159c266SJung-uk Kim         case ACPI_TYPE_BUFFER:
349a159c266SJung-uk Kim             /*
350a159c266SJung-uk Kim              * These types we will allow, but we will change the type.
351a159c266SJung-uk Kim              * This enables some existing code of the form:
352a159c266SJung-uk Kim              *
353a159c266SJung-uk Kim              *  Name (DEB, 0)
354a159c266SJung-uk Kim              *  Scope (DEB) { ... }
355a159c266SJung-uk Kim              *
356a159c266SJung-uk Kim              * Note: silently change the type here. On the second pass,
357a159c266SJung-uk Kim              * we will report a warning
358a159c266SJung-uk Kim              */
359a159c266SJung-uk Kim             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
360a159c266SJung-uk Kim                 "Type override - [%4.4s] had invalid type (%s) "
361a159c266SJung-uk Kim                 "for Scope operator, changed to type ANY\n",
362a159c266SJung-uk Kim                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
363a159c266SJung-uk Kim 
364a159c266SJung-uk Kim             Node->Type = ACPI_TYPE_ANY;
365a159c266SJung-uk Kim             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
366a159c266SJung-uk Kim             break;
367a159c266SJung-uk Kim 
3681df130f1SJung-uk Kim         case ACPI_TYPE_METHOD:
3691df130f1SJung-uk Kim             /*
3701df130f1SJung-uk Kim              * Allow scope change to root during execution of module-level
3711df130f1SJung-uk Kim              * code. Root is typed METHOD during this time.
3721df130f1SJung-uk Kim              */
3731df130f1SJung-uk Kim             if ((Node == AcpiGbl_RootNode) &&
3741df130f1SJung-uk Kim                 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
3751df130f1SJung-uk Kim             {
3761df130f1SJung-uk Kim                 break;
3771df130f1SJung-uk Kim             }
3781df130f1SJung-uk Kim 
3791df130f1SJung-uk Kim             /*lint -fallthrough */
3801df130f1SJung-uk Kim 
381a159c266SJung-uk Kim         default:
382a159c266SJung-uk Kim 
383a159c266SJung-uk Kim             /* All other types are an error */
384a159c266SJung-uk Kim 
385a159c266SJung-uk Kim             ACPI_ERROR ((AE_INFO,
386a159c266SJung-uk Kim                 "Invalid type (%s) for target of "
387a159c266SJung-uk Kim                 "Scope operator [%4.4s] (Cannot override)",
388a159c266SJung-uk Kim                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
389a159c266SJung-uk Kim 
390a159c266SJung-uk Kim             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
391a159c266SJung-uk Kim         }
392a159c266SJung-uk Kim         break;
393a159c266SJung-uk Kim 
394a159c266SJung-uk Kim     default:
395a159c266SJung-uk Kim         /*
396a159c266SJung-uk Kim          * For all other named opcodes, we will enter the name into
397a159c266SJung-uk Kim          * the namespace.
398a159c266SJung-uk Kim          *
399a159c266SJung-uk Kim          * Setup the search flags.
400a159c266SJung-uk Kim          * Since we are entering a name into the namespace, we do not want to
401a159c266SJung-uk Kim          * enable the search-to-root upsearch.
402a159c266SJung-uk Kim          *
403a159c266SJung-uk Kim          * There are only two conditions where it is acceptable that the name
404a159c266SJung-uk Kim          * already exists:
405a159c266SJung-uk Kim          *    1) the Scope() operator can reopen a scoping object that was
406a159c266SJung-uk Kim          *       previously defined (Scope, Method, Device, etc.)
407a159c266SJung-uk Kim          *    2) Whenever we are parsing a deferred opcode (OpRegion, Buffer,
408a159c266SJung-uk Kim          *       BufferField, or Package), the name of the object is already
409a159c266SJung-uk Kim          *       in the namespace.
410a159c266SJung-uk Kim          */
411a159c266SJung-uk Kim         if (WalkState->DeferredNode)
412a159c266SJung-uk Kim         {
413a159c266SJung-uk Kim             /* This name is already in the namespace, get the node */
414a159c266SJung-uk Kim 
415a159c266SJung-uk Kim             Node = WalkState->DeferredNode;
416a159c266SJung-uk Kim             Status = AE_OK;
417a159c266SJung-uk Kim             break;
418a159c266SJung-uk Kim         }
419a159c266SJung-uk Kim 
420a159c266SJung-uk Kim         /*
421a159c266SJung-uk Kim          * If we are executing a method, do not create any namespace objects
422a159c266SJung-uk Kim          * during the load phase, only during execution.
423a159c266SJung-uk Kim          */
424a159c266SJung-uk Kim         if (WalkState->MethodNode)
425a159c266SJung-uk Kim         {
426a159c266SJung-uk Kim             Node = NULL;
427a159c266SJung-uk Kim             Status = AE_OK;
428a159c266SJung-uk Kim             break;
429a159c266SJung-uk Kim         }
430a159c266SJung-uk Kim 
431a159c266SJung-uk Kim         Flags = ACPI_NS_NO_UPSEARCH;
432a159c266SJung-uk Kim         if ((WalkState->Opcode != AML_SCOPE_OP) &&
433a159c266SJung-uk Kim             (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
434a159c266SJung-uk Kim         {
4355ef50723SJung-uk Kim             if (WalkState->NamespaceOverride)
4365ef50723SJung-uk Kim             {
4375ef50723SJung-uk Kim                 Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
4385ef50723SJung-uk Kim                 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n",
4395ef50723SJung-uk Kim                     AcpiUtGetTypeName (ObjectType)));
4405ef50723SJung-uk Kim             }
4415ef50723SJung-uk Kim             else
4425ef50723SJung-uk Kim             {
443a159c266SJung-uk Kim                 Flags |= ACPI_NS_ERROR_IF_FOUND;
444a159c266SJung-uk Kim                 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
445a159c266SJung-uk Kim                     AcpiUtGetTypeName (ObjectType)));
446a159c266SJung-uk Kim             }
4475ef50723SJung-uk Kim         }
448a159c266SJung-uk Kim         else
449a159c266SJung-uk Kim         {
450a159c266SJung-uk Kim             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
451a159c266SJung-uk Kim                 "[%s] Both Find or Create allowed\n",
452a159c266SJung-uk Kim                 AcpiUtGetTypeName (ObjectType)));
453a159c266SJung-uk Kim         }
454a159c266SJung-uk Kim 
455a159c266SJung-uk Kim         /*
456a159c266SJung-uk Kim          * Enter the named type into the internal namespace. We enter the name
457a159c266SJung-uk Kim          * as we go downward in the parse tree. Any necessary subobjects that
458a159c266SJung-uk Kim          * involve arguments to the opcode must be created as we go back up the
459a159c266SJung-uk Kim          * parse tree later.
460a159c266SJung-uk Kim          */
461a159c266SJung-uk Kim         Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
462a159c266SJung-uk Kim             ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
463a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
464a159c266SJung-uk Kim         {
465a159c266SJung-uk Kim             if (Status == AE_ALREADY_EXISTS)
466a159c266SJung-uk Kim             {
467a159c266SJung-uk Kim                 /* The name already exists in this scope */
468a159c266SJung-uk Kim 
469a159c266SJung-uk Kim                 if (Node->Flags & ANOBJ_IS_EXTERNAL)
470a159c266SJung-uk Kim                 {
471a159c266SJung-uk Kim                     /*
472a159c266SJung-uk Kim                      * Allow one create on an object or segment that was
473a159c266SJung-uk Kim                      * previously declared External
474a159c266SJung-uk Kim                      */
475a159c266SJung-uk Kim                     Node->Flags &= ~ANOBJ_IS_EXTERNAL;
476a159c266SJung-uk Kim                     Node->Type = (UINT8) ObjectType;
477a159c266SJung-uk Kim 
478a159c266SJung-uk Kim                     /* Just retyped a node, probably will need to open a scope */
479a159c266SJung-uk Kim 
480a159c266SJung-uk Kim                     if (AcpiNsOpensScope (ObjectType))
481a159c266SJung-uk Kim                     {
482f8146b88SJung-uk Kim                         Status = AcpiDsScopeStackPush (
483f8146b88SJung-uk Kim                             Node, ObjectType, WalkState);
484a159c266SJung-uk Kim                         if (ACPI_FAILURE (Status))
485a159c266SJung-uk Kim                         {
486a159c266SJung-uk Kim                             return_ACPI_STATUS (Status);
487a159c266SJung-uk Kim                         }
488a159c266SJung-uk Kim                     }
489a159c266SJung-uk Kim 
490a159c266SJung-uk Kim                     Status = AE_OK;
491a159c266SJung-uk Kim                 }
492a159c266SJung-uk Kim             }
493a159c266SJung-uk Kim 
494a159c266SJung-uk Kim             if (ACPI_FAILURE (Status))
495a159c266SJung-uk Kim             {
496b7b7e711SJung-uk Kim                 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
497a159c266SJung-uk Kim                 return_ACPI_STATUS (Status);
498a159c266SJung-uk Kim             }
499a159c266SJung-uk Kim         }
500a159c266SJung-uk Kim         break;
501a159c266SJung-uk Kim     }
502a159c266SJung-uk Kim 
503a159c266SJung-uk Kim     /* Common exit */
504a159c266SJung-uk Kim 
505a159c266SJung-uk Kim     if (!Op)
506a159c266SJung-uk Kim     {
507a159c266SJung-uk Kim         /* Create a new op */
508a159c266SJung-uk Kim 
509fe0f0bbbSJung-uk Kim         Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml);
510a159c266SJung-uk Kim         if (!Op)
511a159c266SJung-uk Kim         {
512a159c266SJung-uk Kim             return_ACPI_STATUS (AE_NO_MEMORY);
513a159c266SJung-uk Kim         }
514a159c266SJung-uk Kim     }
515a159c266SJung-uk Kim 
516a159c266SJung-uk Kim     /* Initialize the op */
517a159c266SJung-uk Kim 
518*90b566fdSJung-uk Kim #ifdef ACPI_CONSTANT_EVAL_ONLY
519af051161SJung-uk Kim     Op->Named.Path = Path;
520a159c266SJung-uk Kim #endif
521a159c266SJung-uk Kim 
522a159c266SJung-uk Kim     if (Node)
523a159c266SJung-uk Kim     {
524a159c266SJung-uk Kim         /*
525a159c266SJung-uk Kim          * Put the Node in the "op" object that the parser uses, so we
526a159c266SJung-uk Kim          * can get it again quickly when this scope is closed
527a159c266SJung-uk Kim          */
528a159c266SJung-uk Kim         Op->Common.Node = Node;
529a159c266SJung-uk Kim         Op->Named.Name = Node->Name.Integer;
530a159c266SJung-uk Kim     }
531a159c266SJung-uk Kim 
532a159c266SJung-uk Kim     AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
533a159c266SJung-uk Kim     *OutOp = Op;
534a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
535a159c266SJung-uk Kim }
536a159c266SJung-uk Kim 
537a159c266SJung-uk Kim 
538a159c266SJung-uk Kim /*******************************************************************************
539a159c266SJung-uk Kim  *
540a159c266SJung-uk Kim  * FUNCTION:    AcpiDsLoad1EndOp
541a159c266SJung-uk Kim  *
542a159c266SJung-uk Kim  * PARAMETERS:  WalkState       - Current state of the parse tree walk
543a159c266SJung-uk Kim  *
544a159c266SJung-uk Kim  * RETURN:      Status
545a159c266SJung-uk Kim  *
546a159c266SJung-uk Kim  * DESCRIPTION: Ascending callback used during the loading of the namespace,
547a159c266SJung-uk Kim  *              both control methods and everything else.
548a159c266SJung-uk Kim  *
549a159c266SJung-uk Kim  ******************************************************************************/
550a159c266SJung-uk Kim 
551a159c266SJung-uk Kim ACPI_STATUS
552a159c266SJung-uk Kim AcpiDsLoad1EndOp (
553a159c266SJung-uk Kim     ACPI_WALK_STATE         *WalkState)
554a159c266SJung-uk Kim {
555a159c266SJung-uk Kim     ACPI_PARSE_OBJECT       *Op;
556a159c266SJung-uk Kim     ACPI_OBJECT_TYPE        ObjectType;
557a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_OK;
558a159c266SJung-uk Kim 
559af051161SJung-uk Kim #ifdef ACPI_ASL_COMPILER
560af051161SJung-uk Kim     UINT8                   ParamCount;
561af051161SJung-uk Kim #endif
562af051161SJung-uk Kim 
563a159c266SJung-uk Kim 
564a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (DsLoad1EndOp);
565a159c266SJung-uk Kim 
566a159c266SJung-uk Kim 
567a159c266SJung-uk Kim     Op = WalkState->Op;
568a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
569a159c266SJung-uk Kim 
570a159c266SJung-uk Kim     /* We are only interested in opcodes that have an associated name */
571a159c266SJung-uk Kim 
572a159c266SJung-uk Kim     if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD)))
573a159c266SJung-uk Kim     {
574a159c266SJung-uk Kim         return_ACPI_STATUS (AE_OK);
575a159c266SJung-uk Kim     }
576a159c266SJung-uk Kim 
577a159c266SJung-uk Kim     /* Get the object type to determine if we should pop the scope */
578a159c266SJung-uk Kim 
579a159c266SJung-uk Kim     ObjectType = WalkState->OpInfo->ObjectType;
580a159c266SJung-uk Kim 
581a159c266SJung-uk Kim     if (WalkState->OpInfo->Flags & AML_FIELD)
582a159c266SJung-uk Kim     {
583a159c266SJung-uk Kim         /*
584a159c266SJung-uk Kim          * If we are executing a method, do not create any namespace objects
585a159c266SJung-uk Kim          * during the load phase, only during execution.
586a159c266SJung-uk Kim          */
587a159c266SJung-uk Kim         if (!WalkState->MethodNode)
588a159c266SJung-uk Kim         {
589a159c266SJung-uk Kim             if (WalkState->Opcode == AML_FIELD_OP          ||
590a159c266SJung-uk Kim                 WalkState->Opcode == AML_BANK_FIELD_OP     ||
591a159c266SJung-uk Kim                 WalkState->Opcode == AML_INDEX_FIELD_OP)
592a159c266SJung-uk Kim             {
593a159c266SJung-uk Kim                 Status = AcpiDsInitFieldObjects (Op, WalkState);
594a159c266SJung-uk Kim             }
595a159c266SJung-uk Kim         }
596a159c266SJung-uk Kim         return_ACPI_STATUS (Status);
597a159c266SJung-uk Kim     }
598a159c266SJung-uk Kim 
599a159c266SJung-uk Kim     /*
600a159c266SJung-uk Kim      * If we are executing a method, do not create any namespace objects
601a159c266SJung-uk Kim      * during the load phase, only during execution.
602a159c266SJung-uk Kim      */
603a159c266SJung-uk Kim     if (!WalkState->MethodNode)
604a159c266SJung-uk Kim     {
605a159c266SJung-uk Kim         if (Op->Common.AmlOpcode == AML_REGION_OP)
606a159c266SJung-uk Kim         {
607a159c266SJung-uk Kim             Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
608f8146b88SJung-uk Kim                 (ACPI_ADR_SPACE_TYPE)
609f8146b88SJung-uk Kim                     ((Op->Common.Value.Arg)->Common.Value.Integer),
610a159c266SJung-uk Kim                 WalkState);
611a159c266SJung-uk Kim             if (ACPI_FAILURE (Status))
612a159c266SJung-uk Kim             {
613a159c266SJung-uk Kim                 return_ACPI_STATUS (Status);
614a159c266SJung-uk Kim             }
615a159c266SJung-uk Kim         }
616a159c266SJung-uk Kim         else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
617a159c266SJung-uk Kim         {
618a159c266SJung-uk Kim             Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
619a159c266SJung-uk Kim                 ACPI_ADR_SPACE_DATA_TABLE, WalkState);
620a159c266SJung-uk Kim             if (ACPI_FAILURE (Status))
621a159c266SJung-uk Kim             {
622a159c266SJung-uk Kim                 return_ACPI_STATUS (Status);
623a159c266SJung-uk Kim             }
624a159c266SJung-uk Kim         }
625a159c266SJung-uk Kim     }
626a159c266SJung-uk Kim 
627a159c266SJung-uk Kim     if (Op->Common.AmlOpcode == AML_NAME_OP)
628a159c266SJung-uk Kim     {
629a159c266SJung-uk Kim         /* For Name opcode, get the object type from the argument */
630a159c266SJung-uk Kim 
631a159c266SJung-uk Kim         if (Op->Common.Value.Arg)
632a159c266SJung-uk Kim         {
633a159c266SJung-uk Kim             ObjectType = (AcpiPsGetOpcodeInfo (
634a159c266SJung-uk Kim                 (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType;
635a159c266SJung-uk Kim 
636a159c266SJung-uk Kim             /* Set node type if we have a namespace node */
637a159c266SJung-uk Kim 
638a159c266SJung-uk Kim             if (Op->Common.Node)
639a159c266SJung-uk Kim             {
640a159c266SJung-uk Kim                 Op->Common.Node->Type = (UINT8) ObjectType;
641a159c266SJung-uk Kim             }
642a159c266SJung-uk Kim         }
643a159c266SJung-uk Kim     }
644a159c266SJung-uk Kim 
645af051161SJung-uk Kim #ifdef ACPI_ASL_COMPILER
646af051161SJung-uk Kim     /*
647af051161SJung-uk Kim      * For external opcode, get the object type from the argument and
648af051161SJung-uk Kim      * get the parameter count from the argument's next.
649af051161SJung-uk Kim      */
650af051161SJung-uk Kim     if (AcpiGbl_DisasmFlag &&
651af051161SJung-uk Kim         Op->Common.Node &&
652af051161SJung-uk Kim         Op->Common.AmlOpcode == AML_EXTERNAL_OP)
653af051161SJung-uk Kim     {
654af051161SJung-uk Kim         /*
655af051161SJung-uk Kim          * Note, if this external is not a method
656af051161SJung-uk Kim          * Op->Common.Value.Arg->Common.Next->Common.Value.Integer == 0
657af051161SJung-uk Kim          * Therefore, ParamCount will be 0.
658af051161SJung-uk Kim          */
659af051161SJung-uk Kim         ParamCount = (UINT8) Op->Common.Value.Arg->Common.Next->Common.Value.Integer;
660af051161SJung-uk Kim         ObjectType = (UINT8) Op->Common.Value.Arg->Common.Value.Integer;
661af051161SJung-uk Kim         Op->Common.Node->Flags |= ANOBJ_IS_EXTERNAL;
662af051161SJung-uk Kim         Op->Common.Node->Type = (UINT8) ObjectType;
663af051161SJung-uk Kim 
664af051161SJung-uk Kim         AcpiDmCreateSubobjectForExternal ((UINT8)ObjectType,
665af051161SJung-uk Kim             &Op->Common.Node, ParamCount);
666af051161SJung-uk Kim 
667af051161SJung-uk Kim         /*
668af051161SJung-uk Kim          * Add the external to the external list because we may be
669af051161SJung-uk Kim          * emitting code based off of the items within the external list.
670af051161SJung-uk Kim          */
671af051161SJung-uk Kim         AcpiDmAddOpToExternalList (Op, Op->Named.Path, (UINT8)ObjectType, ParamCount,
672af051161SJung-uk Kim            ACPI_EXT_ORIGIN_FROM_OPCODE | ACPI_EXT_RESOLVED_REFERENCE);
673af051161SJung-uk Kim     }
674af051161SJung-uk Kim #endif
675af051161SJung-uk Kim 
676a159c266SJung-uk Kim     /*
677a159c266SJung-uk Kim      * If we are executing a method, do not create any namespace objects
678a159c266SJung-uk Kim      * during the load phase, only during execution.
679a159c266SJung-uk Kim      */
680a159c266SJung-uk Kim     if (!WalkState->MethodNode)
681a159c266SJung-uk Kim     {
682a159c266SJung-uk Kim         if (Op->Common.AmlOpcode == AML_METHOD_OP)
683a159c266SJung-uk Kim         {
684a159c266SJung-uk Kim             /*
685a159c266SJung-uk Kim              * MethodOp PkgLength NameString MethodFlags TermList
686a159c266SJung-uk Kim              *
687a159c266SJung-uk Kim              * Note: We must create the method node/object pair as soon as we
688a159c266SJung-uk Kim              * see the method declaration. This allows later pass1 parsing
689a159c266SJung-uk Kim              * of invocations of the method (need to know the number of
690a159c266SJung-uk Kim              * arguments.)
691a159c266SJung-uk Kim              */
692a159c266SJung-uk Kim             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
693a159c266SJung-uk Kim                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
694a159c266SJung-uk Kim                 WalkState, Op, Op->Named.Node));
695a159c266SJung-uk Kim 
696a159c266SJung-uk Kim             if (!AcpiNsGetAttachedObject (Op->Named.Node))
697a159c266SJung-uk Kim             {
698a159c266SJung-uk Kim                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
699a159c266SJung-uk Kim                 WalkState->NumOperands = 1;
700a159c266SJung-uk Kim 
701f8146b88SJung-uk Kim                 Status = AcpiDsCreateOperands (
702f8146b88SJung-uk Kim                     WalkState, Op->Common.Value.Arg);
703a159c266SJung-uk Kim                 if (ACPI_SUCCESS (Status))
704a159c266SJung-uk Kim                 {
705a159c266SJung-uk Kim                     Status = AcpiExCreateMethod (Op->Named.Data,
706a159c266SJung-uk Kim                         Op->Named.Length, WalkState);
707a159c266SJung-uk Kim                 }
708a159c266SJung-uk Kim 
709a159c266SJung-uk Kim                 WalkState->Operands[0] = NULL;
710a159c266SJung-uk Kim                 WalkState->NumOperands = 0;
711a159c266SJung-uk Kim 
712a159c266SJung-uk Kim                 if (ACPI_FAILURE (Status))
713a159c266SJung-uk Kim                 {
714a159c266SJung-uk Kim                     return_ACPI_STATUS (Status);
715a159c266SJung-uk Kim                 }
716a159c266SJung-uk Kim             }
717a159c266SJung-uk Kim         }
718a159c266SJung-uk Kim     }
719a159c266SJung-uk Kim 
720a159c266SJung-uk Kim     /* Pop the scope stack (only if loading a table) */
721a159c266SJung-uk Kim 
722a159c266SJung-uk Kim     if (!WalkState->MethodNode &&
723af051161SJung-uk Kim         Op->Common.AmlOpcode != AML_EXTERNAL_OP &&
724a159c266SJung-uk Kim         AcpiNsOpensScope (ObjectType))
725a159c266SJung-uk Kim     {
726a159c266SJung-uk Kim         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
727a159c266SJung-uk Kim             AcpiUtGetTypeName (ObjectType), Op));
728a159c266SJung-uk Kim 
729a159c266SJung-uk Kim         Status = AcpiDsScopeStackPop (WalkState);
730a159c266SJung-uk Kim     }
731a159c266SJung-uk Kim 
732a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
733a159c266SJung-uk Kim }
734