153289f6aSNate Lawson /****************************************************************************** 253289f6aSNate Lawson * 353289f6aSNate Lawson * Module Name: dswload - Dispatcher namespace load callbacks 453289f6aSNate Lawson * 553289f6aSNate Lawson *****************************************************************************/ 653289f6aSNate Lawson 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. 1253289f6aSNate Lawson * All rights reserved. 1353289f6aSNate Lawson * 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 * 119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions 121d244b227SJung-uk Kim * are met: 122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124d244b227SJung-uk Kim * without modification. 125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129d244b227SJung-uk Kim * binary redistribution. 130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132d244b227SJung-uk Kim * from this software without specific prior written permission. 13353289f6aSNate Lawson * 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 147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148d244b227SJung-uk Kim * Software Foundation. 14953289f6aSNate Lawson * 1500d84335fSJung-uk Kim *****************************************************************************/ 15153289f6aSNate Lawson 152ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 153ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h> 154ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h> 155ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 156835b56bfSJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 15753289f6aSNate Lawson #include "aslcompiler.y.h" 15853289f6aSNate Lawson 159835b56bfSJung-uk Kim 16053289f6aSNate Lawson #define _COMPONENT ACPI_COMPILER 16153289f6aSNate Lawson ACPI_MODULE_NAME ("aslload") 16253289f6aSNate Lawson 163fba7fc7eSJung-uk Kim /* Local prototypes */ 164fba7fc7eSJung-uk Kim 165fba7fc7eSJung-uk Kim static ACPI_STATUS 166fba7fc7eSJung-uk Kim LdLoadFieldElements ( 167fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 168fba7fc7eSJung-uk Kim ACPI_WALK_STATE *WalkState); 169fba7fc7eSJung-uk Kim 170fba7fc7eSJung-uk Kim static ACPI_STATUS 171fba7fc7eSJung-uk Kim LdLoadResourceElements ( 172fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 173fba7fc7eSJung-uk Kim ACPI_WALK_STATE *WalkState); 174fba7fc7eSJung-uk Kim 175fba7fc7eSJung-uk Kim static ACPI_STATUS 176fba7fc7eSJung-uk Kim LdNamespace1Begin ( 177fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 178fba7fc7eSJung-uk Kim UINT32 Level, 179fba7fc7eSJung-uk Kim void *Context); 180fba7fc7eSJung-uk Kim 181fba7fc7eSJung-uk Kim static ACPI_STATUS 182a9f12690SJung-uk Kim LdNamespace2Begin ( 183a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Op, 184a9f12690SJung-uk Kim UINT32 Level, 185a9f12690SJung-uk Kim void *Context); 186a9f12690SJung-uk Kim 187a9f12690SJung-uk Kim static ACPI_STATUS 188a9f12690SJung-uk Kim LdCommonNamespaceEnd ( 189fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 190fba7fc7eSJung-uk Kim UINT32 Level, 191fba7fc7eSJung-uk Kim void *Context); 192fba7fc7eSJung-uk Kim 19353289f6aSNate Lawson 19453289f6aSNate Lawson /******************************************************************************* 19553289f6aSNate Lawson * 19653289f6aSNate Lawson * FUNCTION: LdLoadNamespace 19753289f6aSNate Lawson * 198fba7fc7eSJung-uk Kim * PARAMETERS: RootOp - Root of the parse tree 19953289f6aSNate Lawson * 20053289f6aSNate Lawson * RETURN: Status 20153289f6aSNate Lawson * 20253289f6aSNate Lawson * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the 20353289f6aSNate Lawson * named ASL/AML objects into the namespace. The namespace is 20453289f6aSNate Lawson * constructed in order to resolve named references and references 20553289f6aSNate Lawson * to named fields within resource templates/descriptors. 20653289f6aSNate Lawson * 20753289f6aSNate Lawson ******************************************************************************/ 20853289f6aSNate Lawson 20953289f6aSNate Lawson ACPI_STATUS 21053289f6aSNate Lawson LdLoadNamespace ( 21153289f6aSNate Lawson ACPI_PARSE_OBJECT *RootOp) 21253289f6aSNate Lawson { 21353289f6aSNate Lawson ACPI_WALK_STATE *WalkState; 21453289f6aSNate Lawson 21553289f6aSNate Lawson 21653289f6aSNate Lawson /* Create a new walk state */ 21753289f6aSNate Lawson 21853289f6aSNate Lawson WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 21953289f6aSNate Lawson if (!WalkState) 22053289f6aSNate Lawson { 2218ef1a331SJung-uk Kim return (AE_NO_MEMORY); 22253289f6aSNate Lawson } 22353289f6aSNate Lawson 224a9f12690SJung-uk Kim /* Walk the entire parse tree, first pass */ 22553289f6aSNate Lawson 22653289f6aSNate Lawson TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, 227a9f12690SJung-uk Kim LdCommonNamespaceEnd, WalkState); 228a9f12690SJung-uk Kim 229a9f12690SJung-uk Kim /* Second pass to handle forward references */ 230a9f12690SJung-uk Kim 231a9f12690SJung-uk Kim TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace2Begin, 232a9f12690SJung-uk Kim LdCommonNamespaceEnd, WalkState); 23353289f6aSNate Lawson 23453289f6aSNate Lawson /* Dump the namespace if debug is enabled */ 23553289f6aSNate Lawson 236*3d90091dSJung-uk Kim if (AcpiDbgLevel & ACPI_LV_TABLES) 237*3d90091dSJung-uk Kim { 23853289f6aSNate Lawson AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); 239*3d90091dSJung-uk Kim } 240*3d90091dSJung-uk Kim 241313a0c13SJung-uk Kim ACPI_FREE (WalkState); 2428ef1a331SJung-uk Kim return (AE_OK); 24353289f6aSNate Lawson } 24453289f6aSNate Lawson 24553289f6aSNate Lawson 24653289f6aSNate Lawson /******************************************************************************* 24753289f6aSNate Lawson * 24853289f6aSNate Lawson * FUNCTION: LdLoadFieldElements 24953289f6aSNate Lawson * 25053289f6aSNate Lawson * PARAMETERS: Op - Parent node (Field) 25153289f6aSNate Lawson * WalkState - Current walk state 25253289f6aSNate Lawson * 25353289f6aSNate Lawson * RETURN: Status 25453289f6aSNate Lawson * 25553289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the field (children of the parent) 25653289f6aSNate Lawson * into the namespace. 25753289f6aSNate Lawson * 25853289f6aSNate Lawson ******************************************************************************/ 25953289f6aSNate Lawson 260fba7fc7eSJung-uk Kim static ACPI_STATUS 26153289f6aSNate Lawson LdLoadFieldElements ( 26253289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 26353289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 26453289f6aSNate Lawson { 26553289f6aSNate Lawson ACPI_PARSE_OBJECT *Child = NULL; 26653289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 26753289f6aSNate Lawson ACPI_STATUS Status; 26853289f6aSNate Lawson 26953289f6aSNate Lawson 27053289f6aSNate Lawson /* Get the first named field element */ 27153289f6aSNate Lawson 27253289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 27353289f6aSNate Lawson { 27453289f6aSNate Lawson case AML_BANK_FIELD_OP: 27553289f6aSNate Lawson 27653289f6aSNate Lawson Child = UtGetArg (Op, 6); 27753289f6aSNate Lawson break; 27853289f6aSNate Lawson 27953289f6aSNate Lawson case AML_INDEX_FIELD_OP: 28053289f6aSNate Lawson 28153289f6aSNate Lawson Child = UtGetArg (Op, 5); 28253289f6aSNate Lawson break; 28353289f6aSNate Lawson 28453289f6aSNate Lawson case AML_FIELD_OP: 28553289f6aSNate Lawson 28653289f6aSNate Lawson Child = UtGetArg (Op, 4); 28753289f6aSNate Lawson break; 28853289f6aSNate Lawson 28953289f6aSNate Lawson default: 290a9d8d09cSJung-uk Kim 29153289f6aSNate Lawson /* No other opcodes should arrive here */ 292a9d8d09cSJung-uk Kim 29353289f6aSNate Lawson return (AE_BAD_PARAMETER); 29453289f6aSNate Lawson } 29553289f6aSNate Lawson 29653289f6aSNate Lawson /* Enter all elements into the namespace */ 29753289f6aSNate Lawson 29853289f6aSNate Lawson while (Child) 29953289f6aSNate Lawson { 30053289f6aSNate Lawson switch (Child->Asl.AmlOpcode) 30153289f6aSNate Lawson { 30253289f6aSNate Lawson case AML_INT_RESERVEDFIELD_OP: 30353289f6aSNate Lawson case AML_INT_ACCESSFIELD_OP: 3043f0275a0SJung-uk Kim case AML_INT_CONNECTION_OP: 30553289f6aSNate Lawson break; 30653289f6aSNate Lawson 30753289f6aSNate Lawson default: 30853289f6aSNate Lawson 309fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, 310fba7fc7eSJung-uk Kim Child->Asl.Value.String, 311fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_REGION_FIELD, 312fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 313fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 314f8146b88SJung-uk Kim ACPI_NS_ERROR_IF_FOUND, NULL, &Node); 31553289f6aSNate Lawson if (ACPI_FAILURE (Status)) 31653289f6aSNate Lawson { 31753289f6aSNate Lawson if (Status != AE_ALREADY_EXISTS) 31853289f6aSNate Lawson { 319fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child, 320fba7fc7eSJung-uk Kim Child->Asl.Value.String); 32153289f6aSNate Lawson return (Status); 32253289f6aSNate Lawson } 323af051161SJung-uk Kim else if (Status == AE_ALREADY_EXISTS && 3245f9b24faSJung-uk Kim (Node->Flags & ANOBJ_IS_EXTERNAL) && 3255f9b24faSJung-uk Kim Node->OwnerId != WalkState->OwnerId) 326af051161SJung-uk Kim { 327af051161SJung-uk Kim Node->Type = (UINT8) ACPI_TYPE_LOCAL_REGION_FIELD; 328af051161SJung-uk Kim } 329af051161SJung-uk Kim else 330af051161SJung-uk Kim { 33153289f6aSNate Lawson /* 33253289f6aSNate Lawson * The name already exists in this scope 33353289f6aSNate Lawson * But continue processing the elements 33453289f6aSNate Lawson */ 335ff879b07SJung-uk Kim AslDualParseOpError (ASL_WARNING, ASL_MSG_EXTERN_COLLISION, Child, 336ff879b07SJung-uk Kim Child->Asl.Value.String, ASL_MSG_EXTERN_FOUND_HERE, Node->Op, 33767d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 33853289f6aSNate Lawson } 339af051161SJung-uk Kim } 34053289f6aSNate Lawson else 34153289f6aSNate Lawson { 34253289f6aSNate Lawson Child->Asl.Node = Node; 343fba7fc7eSJung-uk Kim Node->Op = Child; 34453289f6aSNate Lawson } 34553289f6aSNate Lawson break; 34653289f6aSNate Lawson } 3473f0275a0SJung-uk Kim 34853289f6aSNate Lawson Child = Child->Asl.Next; 34953289f6aSNate Lawson } 3503f0275a0SJung-uk Kim 35153289f6aSNate Lawson return (AE_OK); 35253289f6aSNate Lawson } 35353289f6aSNate Lawson 35453289f6aSNate Lawson 35553289f6aSNate Lawson /******************************************************************************* 35653289f6aSNate Lawson * 35753289f6aSNate Lawson * FUNCTION: LdLoadResourceElements 35853289f6aSNate Lawson * 35953289f6aSNate Lawson * PARAMETERS: Op - Parent node (Resource Descriptor) 36053289f6aSNate Lawson * WalkState - Current walk state 36153289f6aSNate Lawson * 36253289f6aSNate Lawson * RETURN: Status 36353289f6aSNate Lawson * 36453289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the resource descriptor (children 36553289f6aSNate Lawson * of the parent) into the namespace. 36653289f6aSNate Lawson * 36753289f6aSNate Lawson * NOTE: In the real AML namespace, these named elements never exist. But 36853289f6aSNate Lawson * we simply use the namespace here as a symbol table so we can look 36953289f6aSNate Lawson * them up as they are referenced. 37053289f6aSNate Lawson * 37153289f6aSNate Lawson ******************************************************************************/ 37253289f6aSNate Lawson 373fba7fc7eSJung-uk Kim static ACPI_STATUS 37453289f6aSNate Lawson LdLoadResourceElements ( 37553289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 37653289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 37753289f6aSNate Lawson { 37853289f6aSNate Lawson ACPI_PARSE_OBJECT *InitializerOp = NULL; 37953289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 38053289f6aSNate Lawson ACPI_STATUS Status; 38153289f6aSNate Lawson 38253289f6aSNate Lawson 38353289f6aSNate Lawson /* 384fba7fc7eSJung-uk Kim * Enter the resource name into the namespace. Name must not already exist. 385fba7fc7eSJung-uk Kim * This opens a scope, so later field names are guaranteed to be new/unique. 38653289f6aSNate Lawson */ 38753289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, 388fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, 389fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, 39053289f6aSNate Lawson WalkState, &Node); 39153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 39253289f6aSNate Lawson { 393fba7fc7eSJung-uk Kim if (Status == AE_ALREADY_EXISTS) 394fba7fc7eSJung-uk Kim { 395fba7fc7eSJung-uk Kim /* Actual node causing the error was saved in ParentMethod */ 396fba7fc7eSJung-uk Kim 39767d9aa44SJung-uk Kim AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, 39867d9aa44SJung-uk Kim (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, 39967d9aa44SJung-uk Kim Op->Asl.Namepath, ASL_MSG_FOUND_HERE, Node->Op, 40067d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 401fba7fc7eSJung-uk Kim return (AE_OK); 402fba7fc7eSJung-uk Kim } 40353289f6aSNate Lawson return (Status); 40453289f6aSNate Lawson } 40553289f6aSNate Lawson 4061a39cfb0SJung-uk Kim Node->Value = (UINT32) Op->Asl.Value.Integer; 4071a39cfb0SJung-uk Kim Node->Op = Op; 408d6dd1baeSJung-uk Kim Op->Asl.Node = Node; 4091a39cfb0SJung-uk Kim 41053289f6aSNate Lawson /* 41153289f6aSNate Lawson * Now enter the predefined fields, for easy lookup when referenced 41253289f6aSNate Lawson * by the source ASL 41353289f6aSNate Lawson */ 41453289f6aSNate Lawson InitializerOp = ASL_GET_CHILD_NODE (Op); 41553289f6aSNate Lawson while (InitializerOp) 41653289f6aSNate Lawson { 41753289f6aSNate Lawson if (InitializerOp->Asl.ExternalName) 41853289f6aSNate Lawson { 41953289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, 42053289f6aSNate Lawson InitializerOp->Asl.ExternalName, 42153289f6aSNate Lawson ACPI_TYPE_LOCAL_RESOURCE_FIELD, 422fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 423fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, 42453289f6aSNate Lawson NULL, &Node); 42553289f6aSNate Lawson if (ACPI_FAILURE (Status)) 42653289f6aSNate Lawson { 42753289f6aSNate Lawson return (Status); 42853289f6aSNate Lawson } 42953289f6aSNate Lawson 43053289f6aSNate Lawson /* 4313f0275a0SJung-uk Kim * Store the field offset and length in the namespace node 4323f0275a0SJung-uk Kim * so it can be used when the field is referenced 43353289f6aSNate Lawson */ 4343f0275a0SJung-uk Kim Node->Value = InitializerOp->Asl.Value.Tag.BitOffset; 4353f0275a0SJung-uk Kim Node->Length = InitializerOp->Asl.Value.Tag.BitLength; 43653289f6aSNate Lawson InitializerOp->Asl.Node = Node; 437fba7fc7eSJung-uk Kim Node->Op = InitializerOp; 43853289f6aSNate Lawson } 4393f0275a0SJung-uk Kim 44053289f6aSNate Lawson InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 44153289f6aSNate Lawson } 44253289f6aSNate Lawson 44353289f6aSNate Lawson return (AE_OK); 44453289f6aSNate Lawson } 44553289f6aSNate Lawson 44653289f6aSNate Lawson 44753289f6aSNate Lawson /******************************************************************************* 44853289f6aSNate Lawson * 44953289f6aSNate Lawson * FUNCTION: LdNamespace1Begin 45053289f6aSNate Lawson * 45153289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 45253289f6aSNate Lawson * 45353289f6aSNate Lawson * RETURN: Status 45453289f6aSNate Lawson * 45553289f6aSNate Lawson * DESCRIPTION: Descending callback used during the parse tree walk. If this 45653289f6aSNate Lawson * is a named AML opcode, enter into the namespace 45753289f6aSNate Lawson * 45853289f6aSNate Lawson ******************************************************************************/ 45953289f6aSNate Lawson 460fba7fc7eSJung-uk Kim static ACPI_STATUS 46153289f6aSNate Lawson LdNamespace1Begin ( 46253289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 46353289f6aSNate Lawson UINT32 Level, 46453289f6aSNate Lawson void *Context) 46553289f6aSNate Lawson { 46653289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 46753289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 468f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *MethodOp; 46953289f6aSNate Lawson ACPI_STATUS Status; 47053289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 47153289f6aSNate Lawson ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; 47253289f6aSNate Lawson char *Path; 47353289f6aSNate Lawson UINT32 Flags = ACPI_NS_NO_UPSEARCH; 47453289f6aSNate Lawson ACPI_PARSE_OBJECT *Arg; 47553289f6aSNate Lawson UINT32 i; 4761a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 477af051161SJung-uk Kim ACPI_OWNER_ID OwnerId = 0; 478835b56bfSJung-uk Kim const ACPI_OPCODE_INFO *OpInfo; 479835b56bfSJung-uk Kim ACPI_PARSE_OBJECT *ParentOp; 48053289f6aSNate Lawson 48153289f6aSNate Lawson 4821a39cfb0SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace1Begin); 483835b56bfSJung-uk Kim 484835b56bfSJung-uk Kim 48553289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 48653289f6aSNate Lawson Op, Op->Asl.ParseOpName)); 48753289f6aSNate Lawson 488af051161SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) 489af051161SJung-uk Kim { 490af051161SJung-uk Kim /* 491af051161SJung-uk Kim * Allocate an OwnerId for this block. This helps identify the owners 492af051161SJung-uk Kim * of each namespace node. This is used in determining whether if 493af051161SJung-uk Kim * certain external declarations cause redefinition errors. 494af051161SJung-uk Kim */ 495af051161SJung-uk Kim Status = AcpiUtAllocateOwnerId (&OwnerId); 496af051161SJung-uk Kim WalkState->OwnerId = OwnerId; 497af051161SJung-uk Kim if (ACPI_FAILURE (Status)) 498af051161SJung-uk Kim { 499af051161SJung-uk Kim AslCoreSubsystemError (Op, Status, 500af051161SJung-uk Kim "Failure to allocate owner ID to this definition block.", FALSE); 501af051161SJung-uk Kim return_ACPI_STATUS (Status); 502af051161SJung-uk Kim } 503af051161SJung-uk Kim } 504af051161SJung-uk Kim 50553289f6aSNate Lawson /* 50653289f6aSNate Lawson * We are only interested in opcodes that have an associated name 50753289f6aSNate Lawson * (or multiple names) 50853289f6aSNate Lawson */ 50953289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 51053289f6aSNate Lawson { 51153289f6aSNate Lawson case AML_BANK_FIELD_OP: 51253289f6aSNate Lawson case AML_INDEX_FIELD_OP: 51353289f6aSNate Lawson case AML_FIELD_OP: 51453289f6aSNate Lawson 51553289f6aSNate Lawson Status = LdLoadFieldElements (Op, WalkState); 51653289f6aSNate Lawson return (Status); 51753289f6aSNate Lawson 518313a0c13SJung-uk Kim case AML_INT_CONNECTION_OP: 519313a0c13SJung-uk Kim 520313a0c13SJung-uk Kim 521313a0c13SJung-uk Kim if (Op->Asl.Child->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) 522313a0c13SJung-uk Kim { 523313a0c13SJung-uk Kim break; 524313a0c13SJung-uk Kim } 525313a0c13SJung-uk Kim Arg = Op->Asl.Child; 526313a0c13SJung-uk Kim 527313a0c13SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Asl.ExternalName, 528313a0c13SJung-uk Kim ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 529313a0c13SJung-uk Kim WalkState, &Node); 530313a0c13SJung-uk Kim if (ACPI_FAILURE (Status)) 531313a0c13SJung-uk Kim { 532313a0c13SJung-uk Kim break; 533313a0c13SJung-uk Kim } 534313a0c13SJung-uk Kim 535313a0c13SJung-uk Kim if (Node->Type == ACPI_TYPE_BUFFER) 536313a0c13SJung-uk Kim { 537313a0c13SJung-uk Kim Arg->Asl.Node = Node; 538313a0c13SJung-uk Kim 539313a0c13SJung-uk Kim Arg = Node->Op->Asl.Child; /* Get namepath */ 540313a0c13SJung-uk Kim Arg = Arg->Asl.Next; /* Get actual buffer */ 541313a0c13SJung-uk Kim Arg = Arg->Asl.Child; /* Buffer length */ 542313a0c13SJung-uk Kim Arg = Arg->Asl.Next; /* RAW_DATA buffer */ 543313a0c13SJung-uk Kim } 544313a0c13SJung-uk Kim break; 545313a0c13SJung-uk Kim 54653289f6aSNate Lawson default: 54753289f6aSNate Lawson 54853289f6aSNate Lawson /* All other opcodes go below */ 549a9d8d09cSJung-uk Kim 55053289f6aSNate Lawson break; 55153289f6aSNate Lawson } 55253289f6aSNate Lawson 55353289f6aSNate Lawson /* Check if this object has already been installed in the namespace */ 55453289f6aSNate Lawson 55553289f6aSNate Lawson if (Op->Asl.Node) 55653289f6aSNate Lawson { 55753289f6aSNate Lawson return (AE_OK); 55853289f6aSNate Lawson } 55953289f6aSNate Lawson 560835b56bfSJung-uk Kim /* Check for a possible illegal forward reference */ 561835b56bfSJung-uk Kim 562835b56bfSJung-uk Kim if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || 563835b56bfSJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) 564835b56bfSJung-uk Kim { 565835b56bfSJung-uk Kim /* 566835b56bfSJung-uk Kim * Op->Asl.Namepath will be NULL for these opcodes. 567835b56bfSJung-uk Kim * These opcodes are guaranteed to have a parent. 568835b56bfSJung-uk Kim * Examine the parent opcode. 569835b56bfSJung-uk Kim */ 570835b56bfSJung-uk Kim Status = AE_OK; 571835b56bfSJung-uk Kim ParentOp = Op->Asl.Parent; 572835b56bfSJung-uk Kim OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Asl.AmlOpcode); 573835b56bfSJung-uk Kim 574835b56bfSJung-uk Kim /* 575835b56bfSJung-uk Kim * Exclude all operators that actually declare a new name: 576835b56bfSJung-uk Kim * Name (ABCD, 1) -> Ignore (AML_CLASS_NAMED_OBJECT) 577835b56bfSJung-uk Kim * We only want references to named objects: 578835b56bfSJung-uk Kim * Store (2, WXYZ) -> Attempt to resolve the name 579835b56bfSJung-uk Kim */ 580835b56bfSJung-uk Kim if (OpInfo->Class == AML_CLASS_NAMED_OBJECT) 581835b56bfSJung-uk Kim { 582835b56bfSJung-uk Kim return (AE_OK); 583835b56bfSJung-uk Kim } 584835b56bfSJung-uk Kim 585835b56bfSJung-uk Kim /* 586835b56bfSJung-uk Kim * Check if the referenced object exists at this point during 587835b56bfSJung-uk Kim * the load: 588835b56bfSJung-uk Kim * 1) If it exists, then this cannot be a forward reference. 589835b56bfSJung-uk Kim * 2) If it does not exist, it could be a forward reference or 590835b56bfSJung-uk Kim * it truly does not exist (and no external declaration). 591835b56bfSJung-uk Kim */ 592835b56bfSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, 593835b56bfSJung-uk Kim Op->Asl.Value.Name, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 594835b56bfSJung-uk Kim ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 595835b56bfSJung-uk Kim WalkState, &Node); 596835b56bfSJung-uk Kim if (Status == AE_NOT_FOUND) 597835b56bfSJung-uk Kim { 598835b56bfSJung-uk Kim /* 599835b56bfSJung-uk Kim * This is either a foward reference or the object truly 600835b56bfSJung-uk Kim * does not exist. The two cases can only be differentiated 601835b56bfSJung-uk Kim * during the cross-reference stage later. Mark the Op/Name 602835b56bfSJung-uk Kim * as not-found for now to indicate the need for further 603835b56bfSJung-uk Kim * processing. 604835b56bfSJung-uk Kim * 605835b56bfSJung-uk Kim * Special case: Allow forward references from elements of 606835b56bfSJung-uk Kim * Package objects. This provides compatibility with other 607835b56bfSJung-uk Kim * ACPI implementations. To correctly implement this, the 608835b56bfSJung-uk Kim * ACPICA table load defers package resolution until the entire 609835b56bfSJung-uk Kim * namespace has been loaded. 610835b56bfSJung-uk Kim */ 611835b56bfSJung-uk Kim if ((ParentOp->Asl.ParseOpcode != PARSEOP_PACKAGE) && 612835b56bfSJung-uk Kim (ParentOp->Asl.ParseOpcode != PARSEOP_VAR_PACKAGE)) 613835b56bfSJung-uk Kim { 614835b56bfSJung-uk Kim Op->Asl.CompileFlags |= OP_NOT_FOUND_DURING_LOAD; 615835b56bfSJung-uk Kim } 616835b56bfSJung-uk Kim 617835b56bfSJung-uk Kim return (AE_OK); 618835b56bfSJung-uk Kim } 619835b56bfSJung-uk Kim 620835b56bfSJung-uk Kim return (Status); 621835b56bfSJung-uk Kim } 622835b56bfSJung-uk Kim 62353289f6aSNate Lawson Path = Op->Asl.Namepath; 62453289f6aSNate Lawson if (!Path) 62553289f6aSNate Lawson { 62653289f6aSNate Lawson return (AE_OK); 62753289f6aSNate Lawson } 62853289f6aSNate Lawson 62953289f6aSNate Lawson /* Map the raw opcode into an internal object type */ 63053289f6aSNate Lawson 63153289f6aSNate Lawson switch (Op->Asl.ParseOpcode) 63253289f6aSNate Lawson { 63353289f6aSNate Lawson case PARSEOP_NAME: 63453289f6aSNate Lawson 63553289f6aSNate Lawson Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ 63653289f6aSNate Lawson Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ 63753289f6aSNate Lawson 6381a39cfb0SJung-uk Kim /* 6391a39cfb0SJung-uk Kim * If this name refers to a ResourceTemplate, we will need to open 6401a39cfb0SJung-uk Kim * a new scope so that the resource subfield names can be entered into 6411a39cfb0SJung-uk Kim * the namespace underneath this name 6421a39cfb0SJung-uk Kim */ 6435f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 6441a39cfb0SJung-uk Kim { 6451a39cfb0SJung-uk Kim ForceNewScope = TRUE; 6461a39cfb0SJung-uk Kim } 6471a39cfb0SJung-uk Kim 64853289f6aSNate Lawson /* Get the data type associated with the named object, not the name itself */ 64953289f6aSNate Lawson 65053289f6aSNate Lawson /* Log2 loop to convert from Btype (binary) to Etype (encoded) */ 65153289f6aSNate Lawson 65253289f6aSNate Lawson ObjectType = 1; 65353289f6aSNate Lawson for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2) 65453289f6aSNate Lawson { 65553289f6aSNate Lawson ObjectType++; 65653289f6aSNate Lawson } 65753289f6aSNate Lawson break; 65853289f6aSNate Lawson 65953289f6aSNate Lawson case PARSEOP_EXTERNAL: 66053289f6aSNate Lawson /* 66153289f6aSNate Lawson * "External" simply enters a name and type into the namespace. 66253289f6aSNate Lawson * We must be careful to not open a new scope, however, no matter 66353289f6aSNate Lawson * what type the external name refers to (e.g., a method) 66453289f6aSNate Lawson * 66553289f6aSNate Lawson * first child is name, next child is ObjectType 66653289f6aSNate Lawson */ 66753289f6aSNate Lawson ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; 66853289f6aSNate Lawson ObjectType = ACPI_TYPE_ANY; 66953289f6aSNate Lawson 6701a39cfb0SJung-uk Kim /* 6711a39cfb0SJung-uk Kim * We will mark every new node along the path as "External". This 6721a39cfb0SJung-uk Kim * allows some or all of the nodes to be created later in the ASL 6731a39cfb0SJung-uk Kim * code. Handles cases like this: 6741a39cfb0SJung-uk Kim * 6751a39cfb0SJung-uk Kim * External (\_SB_.PCI0.ABCD, IntObj) 6761a39cfb0SJung-uk Kim * Scope (_SB_) 6771a39cfb0SJung-uk Kim * { 6781a39cfb0SJung-uk Kim * Device (PCI0) 6791a39cfb0SJung-uk Kim * { 6801a39cfb0SJung-uk Kim * } 6811a39cfb0SJung-uk Kim * } 6821a39cfb0SJung-uk Kim * Method (X) 6831a39cfb0SJung-uk Kim * { 6841a39cfb0SJung-uk Kim * Store (\_SB_.PCI0.ABCD, Local0) 6851a39cfb0SJung-uk Kim * } 6861a39cfb0SJung-uk Kim */ 6871a39cfb0SJung-uk Kim Flags |= ACPI_NS_EXTERNAL; 6881a39cfb0SJung-uk Kim break; 68953289f6aSNate Lawson 69053289f6aSNate Lawson case PARSEOP_DEFAULT_ARG: 69153289f6aSNate Lawson 6925f9b24faSJung-uk Kim if (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC) 69353289f6aSNate Lawson { 69453289f6aSNate Lawson Status = LdLoadResourceElements (Op, WalkState); 6959a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 69653289f6aSNate Lawson } 69753289f6aSNate Lawson 69853289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 69953289f6aSNate Lawson break; 70053289f6aSNate Lawson 70153289f6aSNate Lawson case PARSEOP_SCOPE: 70253289f6aSNate Lawson /* 70353289f6aSNate Lawson * The name referenced by Scope(Name) must already exist at this point. 70453289f6aSNate Lawson * In other words, forward references for Scope() are not supported. 70553289f6aSNate Lawson * The only real reason for this is that the MS interpreter cannot 70653289f6aSNate Lawson * handle this case. Perhaps someday this case can go away. 70753289f6aSNate Lawson */ 70853289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 709fba7fc7eSJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 710fba7fc7eSJung-uk Kim WalkState, &(Node)); 71153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 71253289f6aSNate Lawson { 71353289f6aSNate Lawson if (Status == AE_NOT_FOUND) 71453289f6aSNate Lawson { 71553289f6aSNate Lawson /* The name was not found, go ahead and create it */ 71653289f6aSNate Lawson 717fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 718fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_SCOPE, 719fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, 720fba7fc7eSJung-uk Kim WalkState, &(Node)); 72179c6d946SJung-uk Kim if (ACPI_FAILURE (Status)) 72279c6d946SJung-uk Kim { 72379c6d946SJung-uk Kim return_ACPI_STATUS (Status); 72479c6d946SJung-uk Kim } 72553289f6aSNate Lawson 72653289f6aSNate Lawson /* 72753289f6aSNate Lawson * However, this is an error -- primarily because the MS 72853289f6aSNate Lawson * interpreter can't handle a forward reference from the 72953289f6aSNate Lawson * Scope() operator. 73053289f6aSNate Lawson */ 731fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 732fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 733fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, 734fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 73553289f6aSNate Lawson goto FinishNode; 73653289f6aSNate Lawson } 73753289f6aSNate Lawson 738f556842eSJung-uk Kim AslCoreSubsystemError (Op, Status, 739f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 740f556842eSJung-uk Kim 7419a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 74253289f6aSNate Lawson } 743f8146b88SJung-uk Kim else /* Status AE_OK */ 744f8146b88SJung-uk Kim { 745f8146b88SJung-uk Kim /* 746f8146b88SJung-uk Kim * Do not allow references to external scopes from the DSDT. 747f8146b88SJung-uk Kim * This is because the DSDT is always loaded first, and the 748f8146b88SJung-uk Kim * external reference cannot be resolved -- causing a runtime 749f8146b88SJung-uk Kim * error because Scope() must be resolved immediately. 750f8146b88SJung-uk Kim * 10/2015. 751f8146b88SJung-uk Kim */ 752f8146b88SJung-uk Kim if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 753f8146b88SJung-uk Kim (ACPI_COMPARE_NAME (Gbl_TableSignature, "DSDT"))) 754f8146b88SJung-uk Kim { 755f8146b88SJung-uk Kim /* However, allowed if the reference is within a method */ 756f8146b88SJung-uk Kim 757f8146b88SJung-uk Kim MethodOp = Op->Asl.Parent; 758f8146b88SJung-uk Kim while (MethodOp && 759f8146b88SJung-uk Kim (MethodOp->Asl.ParseOpcode != PARSEOP_METHOD)) 760f8146b88SJung-uk Kim { 761f8146b88SJung-uk Kim MethodOp = MethodOp->Asl.Parent; 762f8146b88SJung-uk Kim } 763f8146b88SJung-uk Kim 764f8146b88SJung-uk Kim if (!MethodOp) 765f8146b88SJung-uk Kim { 766f8146b88SJung-uk Kim /* Not in a control method, error */ 767f8146b88SJung-uk Kim 768f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_CROSS_TABLE_SCOPE, Op, NULL); 769f8146b88SJung-uk Kim } 770f8146b88SJung-uk Kim } 771f8146b88SJung-uk Kim } 77253289f6aSNate Lawson 77353289f6aSNate Lawson /* We found a node with this name, now check the type */ 77453289f6aSNate Lawson 77553289f6aSNate Lawson switch (Node->Type) 77653289f6aSNate Lawson { 77753289f6aSNate Lawson case ACPI_TYPE_LOCAL_SCOPE: 77853289f6aSNate Lawson case ACPI_TYPE_DEVICE: 77953289f6aSNate Lawson case ACPI_TYPE_POWER: 78053289f6aSNate Lawson case ACPI_TYPE_PROCESSOR: 78153289f6aSNate Lawson case ACPI_TYPE_THERMAL: 78253289f6aSNate Lawson 78353289f6aSNate Lawson /* These are acceptable types - they all open a new scope */ 78453289f6aSNate Lawson break; 78553289f6aSNate Lawson 78653289f6aSNate Lawson case ACPI_TYPE_INTEGER: 78753289f6aSNate Lawson case ACPI_TYPE_STRING: 78853289f6aSNate Lawson case ACPI_TYPE_BUFFER: 78953289f6aSNate Lawson /* 790fba7fc7eSJung-uk Kim * These types we will allow, but we will change the type. 791fba7fc7eSJung-uk Kim * This enables some existing code of the form: 79253289f6aSNate Lawson * 79353289f6aSNate Lawson * Name (DEB, 0) 79453289f6aSNate Lawson * Scope (DEB) { ... } 79553289f6aSNate Lawson * 79653289f6aSNate Lawson * Which is used to workaround the fact that the MS interpreter 79753289f6aSNate Lawson * does not allow Scope() forward references. 79853289f6aSNate Lawson */ 799e0ef747bSNate Lawson sprintf (MsgBuffer, "%s [%s], changing type to [Scope]", 80053289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 80153289f6aSNate Lawson AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 80253289f6aSNate Lawson 803fba7fc7eSJung-uk Kim /* Switch the type to scope, open the new scope */ 804fba7fc7eSJung-uk Kim 805e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 806fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 807fba7fc7eSJung-uk Kim WalkState); 808e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 809e0ef747bSNate Lawson { 810e0ef747bSNate Lawson return_ACPI_STATUS (Status); 811e0ef747bSNate Lawson } 81253289f6aSNate Lawson break; 81353289f6aSNate Lawson 81453289f6aSNate Lawson default: 81553289f6aSNate Lawson 816fba7fc7eSJung-uk Kim /* All other types are an error */ 817fba7fc7eSJung-uk Kim 818fba7fc7eSJung-uk Kim sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 819fba7fc7eSJung-uk Kim AcpiUtGetTypeName (Node->Type)); 82053289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 82153289f6aSNate Lawson 82253289f6aSNate Lawson /* 82353289f6aSNate Lawson * However, switch the type to be an actual scope so 82453289f6aSNate Lawson * that compilation can continue without generating a whole 825e0ef747bSNate Lawson * cascade of additional errors. Open the new scope. 82653289f6aSNate Lawson */ 827e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 828fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 829fba7fc7eSJung-uk Kim WalkState); 830e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 831e0ef747bSNate Lawson { 832e0ef747bSNate Lawson return_ACPI_STATUS (Status); 833e0ef747bSNate Lawson } 83453289f6aSNate Lawson break; 83553289f6aSNate Lawson } 83653289f6aSNate Lawson 83753289f6aSNate Lawson Status = AE_OK; 83853289f6aSNate Lawson goto FinishNode; 83953289f6aSNate Lawson 84053289f6aSNate Lawson default: 84153289f6aSNate Lawson 84253289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 84353289f6aSNate Lawson break; 84453289f6aSNate Lawson } 84553289f6aSNate Lawson 84653289f6aSNate Lawson 84753289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", 84853289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); 84953289f6aSNate Lawson 85053289f6aSNate Lawson /* The name must not already exist */ 85153289f6aSNate Lawson 85253289f6aSNate Lawson Flags |= ACPI_NS_ERROR_IF_FOUND; 85353289f6aSNate Lawson 85453289f6aSNate Lawson /* 85553289f6aSNate Lawson * Enter the named type into the internal namespace. We enter the name 856fba7fc7eSJung-uk Kim * as we go downward in the parse tree. Any necessary subobjects that 857fba7fc7eSJung-uk Kim * involve arguments to the opcode must be created as we go back up the 858fba7fc7eSJung-uk Kim * parse tree later. 85953289f6aSNate Lawson */ 86053289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 8611a39cfb0SJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 86253289f6aSNate Lawson if (ACPI_FAILURE (Status)) 86353289f6aSNate Lawson { 86453289f6aSNate Lawson if (Status == AE_ALREADY_EXISTS) 86553289f6aSNate Lawson { 86653289f6aSNate Lawson /* The name already exists in this scope */ 86753289f6aSNate Lawson 86853289f6aSNate Lawson if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 86953289f6aSNate Lawson { 8701a39cfb0SJung-uk Kim /* Allow multiple references to the same scope */ 8711a39cfb0SJung-uk Kim 87253289f6aSNate Lawson Node->Type = (UINT8) ObjectType; 87353289f6aSNate Lawson Status = AE_OK; 87453289f6aSNate Lawson } 875a9f12690SJung-uk Kim else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 876a9f12690SJung-uk Kim (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) 8771a39cfb0SJung-uk Kim { 8781a39cfb0SJung-uk Kim /* 8791a39cfb0SJung-uk Kim * Allow one create on an object or segment that was 880af051161SJung-uk Kim * previously declared External only if WalkState->OwnerId and 88167d9aa44SJung-uk Kim * Node->OwnerId are different (meaning that the current WalkState 88267d9aa44SJung-uk Kim * and the Node are in different tables). 8831a39cfb0SJung-uk Kim */ 8841a39cfb0SJung-uk Kim Node->Flags &= ~ANOBJ_IS_EXTERNAL; 8851a39cfb0SJung-uk Kim Node->Type = (UINT8) ObjectType; 8861a39cfb0SJung-uk Kim 8871a39cfb0SJung-uk Kim /* Just retyped a node, probably will need to open a scope */ 8881a39cfb0SJung-uk Kim 8891a39cfb0SJung-uk Kim if (AcpiNsOpensScope (ObjectType)) 8901a39cfb0SJung-uk Kim { 8911a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 8921a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 8931a39cfb0SJung-uk Kim { 8941a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 8951a39cfb0SJung-uk Kim } 8961a39cfb0SJung-uk Kim } 897f8146b88SJung-uk Kim 8981a39cfb0SJung-uk Kim Status = AE_OK; 899af051161SJung-uk Kim 9005f9b24faSJung-uk Kim if (Node->OwnerId == WalkState->OwnerId && 9015f9b24faSJung-uk Kim !(Node->Flags & IMPLICIT_EXTERNAL)) 902af051161SJung-uk Kim { 903ff879b07SJung-uk Kim AslDualParseOpError (ASL_WARNING, ASL_MSG_EXTERN_COLLISION, Op, 904ff879b07SJung-uk Kim Op->Asl.ExternalName, ASL_MSG_EXTERN_FOUND_HERE, Node->Op, 90567d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 906af051161SJung-uk Kim } 9075f9b24faSJung-uk Kim if (Node->Flags & IMPLICIT_EXTERNAL) 9085f9b24faSJung-uk Kim { 9095f9b24faSJung-uk Kim Node->Flags &= ~IMPLICIT_EXTERNAL; 9105f9b24faSJung-uk Kim } 9111a39cfb0SJung-uk Kim } 912f8146b88SJung-uk Kim else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && 913f8146b88SJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) 914f8146b88SJung-uk Kim { 915f8146b88SJung-uk Kim /* 916f8146b88SJung-uk Kim * Allow externals in same scope as the definition of the 917f8146b88SJung-uk Kim * actual object. Similar to C. Allows multiple definition 918af051161SJung-uk Kim * blocks that refer to each other in the same file. However, 919af051161SJung-uk Kim * do not allow name declaration and an external declaration 920af051161SJung-uk Kim * within the same table. This is considered a re-declaration. 921f8146b88SJung-uk Kim */ 922f8146b88SJung-uk Kim Status = AE_OK; 923af051161SJung-uk Kim 924af051161SJung-uk Kim if (Node->OwnerId == WalkState->OwnerId) 925af051161SJung-uk Kim { 926ff879b07SJung-uk Kim AslDualParseOpError (ASL_WARNING, ASL_MSG_EXTERN_COLLISION, Op, 927ff879b07SJung-uk Kim Op->Asl.ExternalName, ASL_MSG_EXTERN_FOUND_HERE, Node->Op, 92867d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 929af051161SJung-uk Kim } 930f8146b88SJung-uk Kim } 931f8146b88SJung-uk Kim else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 932f8146b88SJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && 933f8146b88SJung-uk Kim (ObjectType == ACPI_TYPE_ANY)) 934f8146b88SJung-uk Kim { 935af051161SJung-uk Kim /* 936af051161SJung-uk Kim * Allow update of externals of unknown type. 937af051161SJung-uk Kim * In the case that multiple definition blocks are being 938af051161SJung-uk Kim * parsed, updating the OwnerId allows enables subsequent calls 939af051161SJung-uk Kim * of this method to understand which table the most recent 940af051161SJung-uk Kim * external declaration was seen. Without this OwnerId update, 941af051161SJung-uk Kim * code like the following is allowed to compile: 942af051161SJung-uk Kim * 943af051161SJung-uk Kim * DefinitionBlock("externtest.aml", "DSDT", 0x02, "Intel", "Many", 0x00000001) 944af051161SJung-uk Kim * { 945af051161SJung-uk Kim * External(ERRS,methodobj) 946af051161SJung-uk Kim * Method (MAIN) 947af051161SJung-uk Kim * { 948af051161SJung-uk Kim * Name(NUM2, 0) 949af051161SJung-uk Kim * ERRS(1,2,3) 950af051161SJung-uk Kim * } 951af051161SJung-uk Kim * } 952af051161SJung-uk Kim * 953af051161SJung-uk Kim * DefinitionBlock("externtest.aml", "SSDT", 0x02, "Intel", "Many", 0x00000001) 954af051161SJung-uk Kim * { 955af051161SJung-uk Kim * if (0) 956af051161SJung-uk Kim * { 957af051161SJung-uk Kim * External(ERRS,methodobj) 958af051161SJung-uk Kim * } 959af051161SJung-uk Kim * Method (ERRS,3) 960af051161SJung-uk Kim * {} 961af051161SJung-uk Kim * 962af051161SJung-uk Kim * } 963af051161SJung-uk Kim */ 964af051161SJung-uk Kim Node->OwnerId = WalkState->OwnerId; 965f8146b88SJung-uk Kim 966f8146b88SJung-uk Kim if (AcpiNsOpensScope (ActualObjectType)) 967f8146b88SJung-uk Kim { 968f8146b88SJung-uk Kim Node->Type = (UINT8) ActualObjectType; 969f8146b88SJung-uk Kim Status = AE_OK; 970f8146b88SJung-uk Kim } 971f8146b88SJung-uk Kim else 972f8146b88SJung-uk Kim { 973f8146b88SJung-uk Kim sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 974f8146b88SJung-uk Kim AcpiUtGetTypeName (Node->Type)); 975f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 976f8146b88SJung-uk Kim return_ACPI_STATUS (AE_OK); 977f8146b88SJung-uk Kim } 978f8146b88SJung-uk Kim } 97953289f6aSNate Lawson else 98053289f6aSNate Lawson { 9811a39cfb0SJung-uk Kim /* Valid error, object already exists */ 9821a39cfb0SJung-uk Kim 98367d9aa44SJung-uk Kim AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, 98467d9aa44SJung-uk Kim Op->Asl.ExternalName, ASL_MSG_FOUND_HERE, Node->Op, 98567d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 9869a179dd8SJung-uk Kim return_ACPI_STATUS (AE_OK); 98753289f6aSNate Lawson } 98853289f6aSNate Lawson } 98953289f6aSNate Lawson else 99053289f6aSNate Lawson { 991fba7fc7eSJung-uk Kim AslCoreSubsystemError (Op, Status, 992f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 9939a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 99453289f6aSNate Lawson } 99553289f6aSNate Lawson } 99653289f6aSNate Lawson 9971a39cfb0SJung-uk Kim if (ForceNewScope) 9981a39cfb0SJung-uk Kim { 9991a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 10001a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 10011a39cfb0SJung-uk Kim { 10021a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 10031a39cfb0SJung-uk Kim } 10041a39cfb0SJung-uk Kim } 100553289f6aSNate Lawson 100653289f6aSNate Lawson FinishNode: 100753289f6aSNate Lawson /* 100853289f6aSNate Lawson * Point the parse node to the new namespace node, and point 100953289f6aSNate Lawson * the Node back to the original Parse node 101053289f6aSNate Lawson */ 101153289f6aSNate Lawson Op->Asl.Node = Node; 1012fba7fc7eSJung-uk Kim Node->Op = Op; 101353289f6aSNate Lawson 101453289f6aSNate Lawson /* Set the actual data type if appropriate (EXTERNAL term only) */ 101553289f6aSNate Lawson 101653289f6aSNate Lawson if (ActualObjectType != ACPI_TYPE_ANY) 101753289f6aSNate Lawson { 101853289f6aSNate Lawson Node->Type = (UINT8) ActualObjectType; 1019fba7fc7eSJung-uk Kim Node->Value = ASL_EXTERNAL_METHOD; 102053289f6aSNate Lawson } 102153289f6aSNate Lawson 102253289f6aSNate Lawson if (Op->Asl.ParseOpcode == PARSEOP_METHOD) 102353289f6aSNate Lawson { 102453289f6aSNate Lawson /* 1025fba7fc7eSJung-uk Kim * Get the method argument count from "Extra" and save 1026fba7fc7eSJung-uk Kim * it in the namespace node 102753289f6aSNate Lawson */ 1028fba7fc7eSJung-uk Kim Node->Value = (UINT32) Op->Asl.Extra; 102953289f6aSNate Lawson } 103053289f6aSNate Lawson 10319a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 103253289f6aSNate Lawson } 103353289f6aSNate Lawson 103453289f6aSNate Lawson 103553289f6aSNate Lawson /******************************************************************************* 103653289f6aSNate Lawson * 1037a9f12690SJung-uk Kim * FUNCTION: LdNamespace2Begin 1038a9f12690SJung-uk Kim * 1039a9f12690SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 1040a9f12690SJung-uk Kim * 1041a9f12690SJung-uk Kim * RETURN: Status 1042a9f12690SJung-uk Kim * 1043a9f12690SJung-uk Kim * DESCRIPTION: Descending callback used during the pass 2 parse tree walk. 1044a9f12690SJung-uk Kim * Second pass resolves some forward references. 1045a9f12690SJung-uk Kim * 1046a9f12690SJung-uk Kim * Notes: 1047a9f12690SJung-uk Kim * Currently only needs to handle the Alias operator. 1048a9f12690SJung-uk Kim * Could be used to allow forward references from the Scope() operator, but 1049a9f12690SJung-uk Kim * the MS interpreter does not allow this, so this compiler does not either. 1050a9f12690SJung-uk Kim * 1051a9f12690SJung-uk Kim ******************************************************************************/ 1052a9f12690SJung-uk Kim 1053a9f12690SJung-uk Kim static ACPI_STATUS 1054a9f12690SJung-uk Kim LdNamespace2Begin ( 1055a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Op, 1056a9f12690SJung-uk Kim UINT32 Level, 1057a9f12690SJung-uk Kim void *Context) 1058a9f12690SJung-uk Kim { 1059a9f12690SJung-uk Kim ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 1060a9f12690SJung-uk Kim ACPI_STATUS Status; 1061a9f12690SJung-uk Kim ACPI_NAMESPACE_NODE *Node; 1062a9f12690SJung-uk Kim ACPI_OBJECT_TYPE ObjectType; 1063a9f12690SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 1064a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Arg; 1065a9f12690SJung-uk Kim char *Path; 1066a9f12690SJung-uk Kim ACPI_NAMESPACE_NODE *TargetNode; 1067a9f12690SJung-uk Kim 1068a9f12690SJung-uk Kim 1069a9f12690SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace2Begin); 1070a9f12690SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 1071a9f12690SJung-uk Kim Op, Op->Asl.ParseOpName)); 1072a9f12690SJung-uk Kim 1073a9f12690SJung-uk Kim 1074a9f12690SJung-uk Kim /* Ignore Ops with no namespace node */ 1075a9f12690SJung-uk Kim 1076a9f12690SJung-uk Kim Node = Op->Asl.Node; 1077a9f12690SJung-uk Kim if (!Node) 1078a9f12690SJung-uk Kim { 1079a9f12690SJung-uk Kim return (AE_OK); 1080a9f12690SJung-uk Kim } 1081a9f12690SJung-uk Kim 1082a9f12690SJung-uk Kim /* Get the type to determine if we should push the scope */ 1083a9f12690SJung-uk Kim 1084a9f12690SJung-uk Kim if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 10855f9b24faSJung-uk Kim (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC)) 1086a9f12690SJung-uk Kim { 1087a9f12690SJung-uk Kim ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 1088a9f12690SJung-uk Kim } 1089a9f12690SJung-uk Kim else 1090a9f12690SJung-uk Kim { 1091a9f12690SJung-uk Kim ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 1092a9f12690SJung-uk Kim } 1093a9f12690SJung-uk Kim 1094a9f12690SJung-uk Kim /* Push scope for Resource Templates */ 1095a9f12690SJung-uk Kim 1096a9f12690SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 1097a9f12690SJung-uk Kim { 10985f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 1099a9f12690SJung-uk Kim { 1100a9f12690SJung-uk Kim ForceNewScope = TRUE; 1101a9f12690SJung-uk Kim } 1102a9f12690SJung-uk Kim } 1103a9f12690SJung-uk Kim 1104a9f12690SJung-uk Kim /* Push the scope stack */ 1105a9f12690SJung-uk Kim 1106a9f12690SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 1107a9f12690SJung-uk Kim { 1108a9f12690SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 1109a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 1110a9f12690SJung-uk Kim { 1111a9f12690SJung-uk Kim return_ACPI_STATUS (Status); 1112a9f12690SJung-uk Kim } 1113a9f12690SJung-uk Kim } 1114a9f12690SJung-uk Kim 1115a9f12690SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_ALIAS) 1116a9f12690SJung-uk Kim { 1117a9f12690SJung-uk Kim /* Complete the alias node by getting and saving the target node */ 1118a9f12690SJung-uk Kim 1119a9f12690SJung-uk Kim /* First child is the alias target */ 1120a9f12690SJung-uk Kim 1121a9f12690SJung-uk Kim Arg = Op->Asl.Child; 1122a9f12690SJung-uk Kim 1123a9f12690SJung-uk Kim /* Get the target pathname */ 1124a9f12690SJung-uk Kim 1125a9f12690SJung-uk Kim Path = Arg->Asl.Namepath; 1126a9f12690SJung-uk Kim if (!Path) 1127a9f12690SJung-uk Kim { 1128a9f12690SJung-uk Kim Status = UtInternalizeName (Arg->Asl.ExternalName, &Path); 1129a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 1130a9f12690SJung-uk Kim { 1131a9f12690SJung-uk Kim return (Status); 1132a9f12690SJung-uk Kim } 1133a9f12690SJung-uk Kim } 1134a9f12690SJung-uk Kim 1135a9f12690SJung-uk Kim /* Get the NS node associated with the target. It must exist. */ 1136a9f12690SJung-uk Kim 1137a9f12690SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 1138a9f12690SJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 1139a9f12690SJung-uk Kim WalkState, &TargetNode); 1140a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 1141a9f12690SJung-uk Kim { 1142a9f12690SJung-uk Kim if (Status == AE_NOT_FOUND) 1143a9f12690SJung-uk Kim { 1144a9f12690SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 1145a9f12690SJung-uk Kim Op->Asl.ExternalName); 1146a9f12690SJung-uk Kim 1147a9f12690SJung-uk Kim /* 1148a9f12690SJung-uk Kim * The name was not found, go ahead and create it. 1149a9f12690SJung-uk Kim * This prevents more errors later. 1150a9f12690SJung-uk Kim */ 1151a9f12690SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 1152a9f12690SJung-uk Kim ACPI_TYPE_ANY, 1153a9f12690SJung-uk Kim ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, 1154a9f12690SJung-uk Kim WalkState, &(Node)); 1155a9f12690SJung-uk Kim return (AE_OK); 1156a9f12690SJung-uk Kim } 1157a9f12690SJung-uk Kim 1158f556842eSJung-uk Kim AslCoreSubsystemError (Op, Status, 1159f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 1160a9f12690SJung-uk Kim return (AE_OK); 1161a9f12690SJung-uk Kim } 1162a9f12690SJung-uk Kim 1163a9f12690SJung-uk Kim /* Save the target node within the alias node */ 1164a9f12690SJung-uk Kim 1165a9f12690SJung-uk Kim Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 1166a9f12690SJung-uk Kim } 1167a9f12690SJung-uk Kim 1168a9f12690SJung-uk Kim return (AE_OK); 1169a9f12690SJung-uk Kim } 1170a9f12690SJung-uk Kim 1171a9f12690SJung-uk Kim 1172a9f12690SJung-uk Kim /******************************************************************************* 1173a9f12690SJung-uk Kim * 1174a9f12690SJung-uk Kim * FUNCTION: LdCommonNamespaceEnd 117553289f6aSNate Lawson * 117653289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 117753289f6aSNate Lawson * 117853289f6aSNate Lawson * RETURN: Status 117953289f6aSNate Lawson * 118053289f6aSNate Lawson * DESCRIPTION: Ascending callback used during the loading of the namespace, 118153289f6aSNate Lawson * We only need to worry about managing the scope stack here. 118253289f6aSNate Lawson * 118353289f6aSNate Lawson ******************************************************************************/ 118453289f6aSNate Lawson 1185fba7fc7eSJung-uk Kim static ACPI_STATUS 1186a9f12690SJung-uk Kim LdCommonNamespaceEnd ( 118753289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 118853289f6aSNate Lawson UINT32 Level, 118953289f6aSNate Lawson void *Context) 119053289f6aSNate Lawson { 119153289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 119253289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 11931a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 119453289f6aSNate Lawson 119553289f6aSNate Lawson 1196a9f12690SJung-uk Kim ACPI_FUNCTION_NAME (LdCommonNamespaceEnd); 119753289f6aSNate Lawson 119853289f6aSNate Lawson 119953289f6aSNate Lawson /* We are only interested in opcodes that have an associated name */ 120053289f6aSNate Lawson 120153289f6aSNate Lawson if (!Op->Asl.Namepath) 120253289f6aSNate Lawson { 120353289f6aSNate Lawson return (AE_OK); 120453289f6aSNate Lawson } 120553289f6aSNate Lawson 120653289f6aSNate Lawson /* Get the type to determine if we should pop the scope */ 120753289f6aSNate Lawson 120853289f6aSNate Lawson if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 12095f9b24faSJung-uk Kim (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC)) 121053289f6aSNate Lawson { 121153289f6aSNate Lawson /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */ 121253289f6aSNate Lawson 121353289f6aSNate Lawson ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 121453289f6aSNate Lawson } 121553289f6aSNate Lawson else 121653289f6aSNate Lawson { 121753289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 121853289f6aSNate Lawson } 121953289f6aSNate Lawson 12201a39cfb0SJung-uk Kim /* Pop scope that was pushed for Resource Templates */ 12211a39cfb0SJung-uk Kim 12221a39cfb0SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 12231a39cfb0SJung-uk Kim { 12245f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 12251a39cfb0SJung-uk Kim { 12261a39cfb0SJung-uk Kim ForceNewScope = TRUE; 12271a39cfb0SJung-uk Kim } 12281a39cfb0SJung-uk Kim } 12291a39cfb0SJung-uk Kim 123053289f6aSNate Lawson /* Pop the scope stack */ 123153289f6aSNate Lawson 12321a39cfb0SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 123353289f6aSNate Lawson { 123453289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 123553289f6aSNate Lawson "(%s): Popping scope for Op [%s] %p\n", 123653289f6aSNate Lawson AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); 123753289f6aSNate Lawson 1238fba7fc7eSJung-uk Kim (void) AcpiDsScopeStackPop (WalkState); 123953289f6aSNate Lawson } 124053289f6aSNate Lawson 124153289f6aSNate Lawson return (AE_OK); 124253289f6aSNate Lawson } 1243