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> 156*835b56bfSJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 15753289f6aSNate Lawson #include "aslcompiler.y.h" 15853289f6aSNate Lawson 159*835b56bfSJung-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 23653289f6aSNate Lawson AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); 237313a0c13SJung-uk Kim ACPI_FREE (WalkState); 2388ef1a331SJung-uk Kim return (AE_OK); 23953289f6aSNate Lawson } 24053289f6aSNate Lawson 24153289f6aSNate Lawson 24253289f6aSNate Lawson /******************************************************************************* 24353289f6aSNate Lawson * 24453289f6aSNate Lawson * FUNCTION: LdLoadFieldElements 24553289f6aSNate Lawson * 24653289f6aSNate Lawson * PARAMETERS: Op - Parent node (Field) 24753289f6aSNate Lawson * WalkState - Current walk state 24853289f6aSNate Lawson * 24953289f6aSNate Lawson * RETURN: Status 25053289f6aSNate Lawson * 25153289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the field (children of the parent) 25253289f6aSNate Lawson * into the namespace. 25353289f6aSNate Lawson * 25453289f6aSNate Lawson ******************************************************************************/ 25553289f6aSNate Lawson 256fba7fc7eSJung-uk Kim static ACPI_STATUS 25753289f6aSNate Lawson LdLoadFieldElements ( 25853289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 25953289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 26053289f6aSNate Lawson { 26153289f6aSNate Lawson ACPI_PARSE_OBJECT *Child = NULL; 26253289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 26353289f6aSNate Lawson ACPI_STATUS Status; 26453289f6aSNate Lawson 26553289f6aSNate Lawson 26653289f6aSNate Lawson /* Get the first named field element */ 26753289f6aSNate Lawson 26853289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 26953289f6aSNate Lawson { 27053289f6aSNate Lawson case AML_BANK_FIELD_OP: 27153289f6aSNate Lawson 27253289f6aSNate Lawson Child = UtGetArg (Op, 6); 27353289f6aSNate Lawson break; 27453289f6aSNate Lawson 27553289f6aSNate Lawson case AML_INDEX_FIELD_OP: 27653289f6aSNate Lawson 27753289f6aSNate Lawson Child = UtGetArg (Op, 5); 27853289f6aSNate Lawson break; 27953289f6aSNate Lawson 28053289f6aSNate Lawson case AML_FIELD_OP: 28153289f6aSNate Lawson 28253289f6aSNate Lawson Child = UtGetArg (Op, 4); 28353289f6aSNate Lawson break; 28453289f6aSNate Lawson 28553289f6aSNate Lawson default: 286a9d8d09cSJung-uk Kim 28753289f6aSNate Lawson /* No other opcodes should arrive here */ 288a9d8d09cSJung-uk Kim 28953289f6aSNate Lawson return (AE_BAD_PARAMETER); 29053289f6aSNate Lawson } 29153289f6aSNate Lawson 29253289f6aSNate Lawson /* Enter all elements into the namespace */ 29353289f6aSNate Lawson 29453289f6aSNate Lawson while (Child) 29553289f6aSNate Lawson { 29653289f6aSNate Lawson switch (Child->Asl.AmlOpcode) 29753289f6aSNate Lawson { 29853289f6aSNate Lawson case AML_INT_RESERVEDFIELD_OP: 29953289f6aSNate Lawson case AML_INT_ACCESSFIELD_OP: 3003f0275a0SJung-uk Kim case AML_INT_CONNECTION_OP: 30153289f6aSNate Lawson break; 30253289f6aSNate Lawson 30353289f6aSNate Lawson default: 30453289f6aSNate Lawson 305fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, 306fba7fc7eSJung-uk Kim Child->Asl.Value.String, 307fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_REGION_FIELD, 308fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 309fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 310f8146b88SJung-uk Kim ACPI_NS_ERROR_IF_FOUND, NULL, &Node); 31153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 31253289f6aSNate Lawson { 31353289f6aSNate Lawson if (Status != AE_ALREADY_EXISTS) 31453289f6aSNate Lawson { 315fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child, 316fba7fc7eSJung-uk Kim Child->Asl.Value.String); 31753289f6aSNate Lawson return (Status); 31853289f6aSNate Lawson } 319af051161SJung-uk Kim else if (Status == AE_ALREADY_EXISTS && 3205f9b24faSJung-uk Kim (Node->Flags & ANOBJ_IS_EXTERNAL) && 3215f9b24faSJung-uk Kim Node->OwnerId != WalkState->OwnerId) 322af051161SJung-uk Kim { 323af051161SJung-uk Kim Node->Type = (UINT8) ACPI_TYPE_LOCAL_REGION_FIELD; 324af051161SJung-uk Kim } 325af051161SJung-uk Kim else 326af051161SJung-uk Kim { 32753289f6aSNate Lawson /* 32853289f6aSNate Lawson * The name already exists in this scope 32953289f6aSNate Lawson * But continue processing the elements 33053289f6aSNate Lawson */ 331ff879b07SJung-uk Kim AslDualParseOpError (ASL_WARNING, ASL_MSG_EXTERN_COLLISION, Child, 332ff879b07SJung-uk Kim Child->Asl.Value.String, ASL_MSG_EXTERN_FOUND_HERE, Node->Op, 33367d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 33453289f6aSNate Lawson } 335af051161SJung-uk Kim } 33653289f6aSNate Lawson else 33753289f6aSNate Lawson { 33853289f6aSNate Lawson Child->Asl.Node = Node; 339fba7fc7eSJung-uk Kim Node->Op = Child; 34053289f6aSNate Lawson } 34153289f6aSNate Lawson break; 34253289f6aSNate Lawson } 3433f0275a0SJung-uk Kim 34453289f6aSNate Lawson Child = Child->Asl.Next; 34553289f6aSNate Lawson } 3463f0275a0SJung-uk Kim 34753289f6aSNate Lawson return (AE_OK); 34853289f6aSNate Lawson } 34953289f6aSNate Lawson 35053289f6aSNate Lawson 35153289f6aSNate Lawson /******************************************************************************* 35253289f6aSNate Lawson * 35353289f6aSNate Lawson * FUNCTION: LdLoadResourceElements 35453289f6aSNate Lawson * 35553289f6aSNate Lawson * PARAMETERS: Op - Parent node (Resource Descriptor) 35653289f6aSNate Lawson * WalkState - Current walk state 35753289f6aSNate Lawson * 35853289f6aSNate Lawson * RETURN: Status 35953289f6aSNate Lawson * 36053289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the resource descriptor (children 36153289f6aSNate Lawson * of the parent) into the namespace. 36253289f6aSNate Lawson * 36353289f6aSNate Lawson * NOTE: In the real AML namespace, these named elements never exist. But 36453289f6aSNate Lawson * we simply use the namespace here as a symbol table so we can look 36553289f6aSNate Lawson * them up as they are referenced. 36653289f6aSNate Lawson * 36753289f6aSNate Lawson ******************************************************************************/ 36853289f6aSNate Lawson 369fba7fc7eSJung-uk Kim static ACPI_STATUS 37053289f6aSNate Lawson LdLoadResourceElements ( 37153289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 37253289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 37353289f6aSNate Lawson { 37453289f6aSNate Lawson ACPI_PARSE_OBJECT *InitializerOp = NULL; 37553289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 37653289f6aSNate Lawson ACPI_STATUS Status; 37753289f6aSNate Lawson 37853289f6aSNate Lawson 37953289f6aSNate Lawson /* 380fba7fc7eSJung-uk Kim * Enter the resource name into the namespace. Name must not already exist. 381fba7fc7eSJung-uk Kim * This opens a scope, so later field names are guaranteed to be new/unique. 38253289f6aSNate Lawson */ 38353289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, 384fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, 385fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, 38653289f6aSNate Lawson WalkState, &Node); 38753289f6aSNate Lawson if (ACPI_FAILURE (Status)) 38853289f6aSNate Lawson { 389fba7fc7eSJung-uk Kim if (Status == AE_ALREADY_EXISTS) 390fba7fc7eSJung-uk Kim { 391fba7fc7eSJung-uk Kim /* Actual node causing the error was saved in ParentMethod */ 392fba7fc7eSJung-uk Kim 39367d9aa44SJung-uk Kim AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, 39467d9aa44SJung-uk Kim (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, 39567d9aa44SJung-uk Kim Op->Asl.Namepath, ASL_MSG_FOUND_HERE, Node->Op, 39667d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 397fba7fc7eSJung-uk Kim return (AE_OK); 398fba7fc7eSJung-uk Kim } 39953289f6aSNate Lawson return (Status); 40053289f6aSNate Lawson } 40153289f6aSNate Lawson 4021a39cfb0SJung-uk Kim Node->Value = (UINT32) Op->Asl.Value.Integer; 4031a39cfb0SJung-uk Kim Node->Op = Op; 404d6dd1baeSJung-uk Kim Op->Asl.Node = Node; 4051a39cfb0SJung-uk Kim 40653289f6aSNate Lawson /* 40753289f6aSNate Lawson * Now enter the predefined fields, for easy lookup when referenced 40853289f6aSNate Lawson * by the source ASL 40953289f6aSNate Lawson */ 41053289f6aSNate Lawson InitializerOp = ASL_GET_CHILD_NODE (Op); 41153289f6aSNate Lawson while (InitializerOp) 41253289f6aSNate Lawson { 41353289f6aSNate Lawson if (InitializerOp->Asl.ExternalName) 41453289f6aSNate Lawson { 41553289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, 41653289f6aSNate Lawson InitializerOp->Asl.ExternalName, 41753289f6aSNate Lawson ACPI_TYPE_LOCAL_RESOURCE_FIELD, 418fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 419fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, 42053289f6aSNate Lawson NULL, &Node); 42153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 42253289f6aSNate Lawson { 42353289f6aSNate Lawson return (Status); 42453289f6aSNate Lawson } 42553289f6aSNate Lawson 42653289f6aSNate Lawson /* 4273f0275a0SJung-uk Kim * Store the field offset and length in the namespace node 4283f0275a0SJung-uk Kim * so it can be used when the field is referenced 42953289f6aSNate Lawson */ 4303f0275a0SJung-uk Kim Node->Value = InitializerOp->Asl.Value.Tag.BitOffset; 4313f0275a0SJung-uk Kim Node->Length = InitializerOp->Asl.Value.Tag.BitLength; 43253289f6aSNate Lawson InitializerOp->Asl.Node = Node; 433fba7fc7eSJung-uk Kim Node->Op = InitializerOp; 43453289f6aSNate Lawson } 4353f0275a0SJung-uk Kim 43653289f6aSNate Lawson InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 43753289f6aSNate Lawson } 43853289f6aSNate Lawson 43953289f6aSNate Lawson return (AE_OK); 44053289f6aSNate Lawson } 44153289f6aSNate Lawson 44253289f6aSNate Lawson 44353289f6aSNate Lawson /******************************************************************************* 44453289f6aSNate Lawson * 44553289f6aSNate Lawson * FUNCTION: LdNamespace1Begin 44653289f6aSNate Lawson * 44753289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 44853289f6aSNate Lawson * 44953289f6aSNate Lawson * RETURN: Status 45053289f6aSNate Lawson * 45153289f6aSNate Lawson * DESCRIPTION: Descending callback used during the parse tree walk. If this 45253289f6aSNate Lawson * is a named AML opcode, enter into the namespace 45353289f6aSNate Lawson * 45453289f6aSNate Lawson ******************************************************************************/ 45553289f6aSNate Lawson 456fba7fc7eSJung-uk Kim static ACPI_STATUS 45753289f6aSNate Lawson LdNamespace1Begin ( 45853289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 45953289f6aSNate Lawson UINT32 Level, 46053289f6aSNate Lawson void *Context) 46153289f6aSNate Lawson { 46253289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 46353289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 464f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *MethodOp; 46553289f6aSNate Lawson ACPI_STATUS Status; 46653289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 46753289f6aSNate Lawson ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; 46853289f6aSNate Lawson char *Path; 46953289f6aSNate Lawson UINT32 Flags = ACPI_NS_NO_UPSEARCH; 47053289f6aSNate Lawson ACPI_PARSE_OBJECT *Arg; 47153289f6aSNate Lawson UINT32 i; 4721a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 473af051161SJung-uk Kim ACPI_OWNER_ID OwnerId = 0; 474*835b56bfSJung-uk Kim const ACPI_OPCODE_INFO *OpInfo; 475*835b56bfSJung-uk Kim ACPI_PARSE_OBJECT *ParentOp; 47653289f6aSNate Lawson 47753289f6aSNate Lawson 4781a39cfb0SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace1Begin); 479*835b56bfSJung-uk Kim 480*835b56bfSJung-uk Kim 48153289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 48253289f6aSNate Lawson Op, Op->Asl.ParseOpName)); 48353289f6aSNate Lawson 484af051161SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) 485af051161SJung-uk Kim { 486af051161SJung-uk Kim /* 487af051161SJung-uk Kim * Allocate an OwnerId for this block. This helps identify the owners 488af051161SJung-uk Kim * of each namespace node. This is used in determining whether if 489af051161SJung-uk Kim * certain external declarations cause redefinition errors. 490af051161SJung-uk Kim */ 491af051161SJung-uk Kim Status = AcpiUtAllocateOwnerId (&OwnerId); 492af051161SJung-uk Kim WalkState->OwnerId = OwnerId; 493af051161SJung-uk Kim if (ACPI_FAILURE (Status)) 494af051161SJung-uk Kim { 495af051161SJung-uk Kim AslCoreSubsystemError (Op, Status, 496af051161SJung-uk Kim "Failure to allocate owner ID to this definition block.", FALSE); 497af051161SJung-uk Kim return_ACPI_STATUS (Status); 498af051161SJung-uk Kim } 499af051161SJung-uk Kim } 500af051161SJung-uk Kim 50153289f6aSNate Lawson /* 50253289f6aSNate Lawson * We are only interested in opcodes that have an associated name 50353289f6aSNate Lawson * (or multiple names) 50453289f6aSNate Lawson */ 50553289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 50653289f6aSNate Lawson { 50753289f6aSNate Lawson case AML_BANK_FIELD_OP: 50853289f6aSNate Lawson case AML_INDEX_FIELD_OP: 50953289f6aSNate Lawson case AML_FIELD_OP: 51053289f6aSNate Lawson 51153289f6aSNate Lawson Status = LdLoadFieldElements (Op, WalkState); 51253289f6aSNate Lawson return (Status); 51353289f6aSNate Lawson 514313a0c13SJung-uk Kim case AML_INT_CONNECTION_OP: 515313a0c13SJung-uk Kim 516313a0c13SJung-uk Kim 517313a0c13SJung-uk Kim if (Op->Asl.Child->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) 518313a0c13SJung-uk Kim { 519313a0c13SJung-uk Kim break; 520313a0c13SJung-uk Kim } 521313a0c13SJung-uk Kim Arg = Op->Asl.Child; 522313a0c13SJung-uk Kim 523313a0c13SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Asl.ExternalName, 524313a0c13SJung-uk Kim ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 525313a0c13SJung-uk Kim WalkState, &Node); 526313a0c13SJung-uk Kim if (ACPI_FAILURE (Status)) 527313a0c13SJung-uk Kim { 528313a0c13SJung-uk Kim break; 529313a0c13SJung-uk Kim } 530313a0c13SJung-uk Kim 531313a0c13SJung-uk Kim if (Node->Type == ACPI_TYPE_BUFFER) 532313a0c13SJung-uk Kim { 533313a0c13SJung-uk Kim Arg->Asl.Node = Node; 534313a0c13SJung-uk Kim 535313a0c13SJung-uk Kim Arg = Node->Op->Asl.Child; /* Get namepath */ 536313a0c13SJung-uk Kim Arg = Arg->Asl.Next; /* Get actual buffer */ 537313a0c13SJung-uk Kim Arg = Arg->Asl.Child; /* Buffer length */ 538313a0c13SJung-uk Kim Arg = Arg->Asl.Next; /* RAW_DATA buffer */ 539313a0c13SJung-uk Kim } 540313a0c13SJung-uk Kim break; 541313a0c13SJung-uk Kim 54253289f6aSNate Lawson default: 54353289f6aSNate Lawson 54453289f6aSNate Lawson /* All other opcodes go below */ 545a9d8d09cSJung-uk Kim 54653289f6aSNate Lawson break; 54753289f6aSNate Lawson } 54853289f6aSNate Lawson 54953289f6aSNate Lawson /* Check if this object has already been installed in the namespace */ 55053289f6aSNate Lawson 55153289f6aSNate Lawson if (Op->Asl.Node) 55253289f6aSNate Lawson { 55353289f6aSNate Lawson return (AE_OK); 55453289f6aSNate Lawson } 55553289f6aSNate Lawson 556*835b56bfSJung-uk Kim /* Check for a possible illegal forward reference */ 557*835b56bfSJung-uk Kim 558*835b56bfSJung-uk Kim if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || 559*835b56bfSJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) 560*835b56bfSJung-uk Kim { 561*835b56bfSJung-uk Kim /* 562*835b56bfSJung-uk Kim * Op->Asl.Namepath will be NULL for these opcodes. 563*835b56bfSJung-uk Kim * These opcodes are guaranteed to have a parent. 564*835b56bfSJung-uk Kim * Examine the parent opcode. 565*835b56bfSJung-uk Kim */ 566*835b56bfSJung-uk Kim Status = AE_OK; 567*835b56bfSJung-uk Kim ParentOp = Op->Asl.Parent; 568*835b56bfSJung-uk Kim OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Asl.AmlOpcode); 569*835b56bfSJung-uk Kim 570*835b56bfSJung-uk Kim /* 571*835b56bfSJung-uk Kim * Exclude all operators that actually declare a new name: 572*835b56bfSJung-uk Kim * Name (ABCD, 1) -> Ignore (AML_CLASS_NAMED_OBJECT) 573*835b56bfSJung-uk Kim * We only want references to named objects: 574*835b56bfSJung-uk Kim * Store (2, WXYZ) -> Attempt to resolve the name 575*835b56bfSJung-uk Kim */ 576*835b56bfSJung-uk Kim if (OpInfo->Class == AML_CLASS_NAMED_OBJECT) 577*835b56bfSJung-uk Kim { 578*835b56bfSJung-uk Kim return (AE_OK); 579*835b56bfSJung-uk Kim } 580*835b56bfSJung-uk Kim 581*835b56bfSJung-uk Kim /* 582*835b56bfSJung-uk Kim * Check if the referenced object exists at this point during 583*835b56bfSJung-uk Kim * the load: 584*835b56bfSJung-uk Kim * 1) If it exists, then this cannot be a forward reference. 585*835b56bfSJung-uk Kim * 2) If it does not exist, it could be a forward reference or 586*835b56bfSJung-uk Kim * it truly does not exist (and no external declaration). 587*835b56bfSJung-uk Kim */ 588*835b56bfSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, 589*835b56bfSJung-uk Kim Op->Asl.Value.Name, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 590*835b56bfSJung-uk Kim ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 591*835b56bfSJung-uk Kim WalkState, &Node); 592*835b56bfSJung-uk Kim if (Status == AE_NOT_FOUND) 593*835b56bfSJung-uk Kim { 594*835b56bfSJung-uk Kim /* 595*835b56bfSJung-uk Kim * This is either a foward reference or the object truly 596*835b56bfSJung-uk Kim * does not exist. The two cases can only be differentiated 597*835b56bfSJung-uk Kim * during the cross-reference stage later. Mark the Op/Name 598*835b56bfSJung-uk Kim * as not-found for now to indicate the need for further 599*835b56bfSJung-uk Kim * processing. 600*835b56bfSJung-uk Kim * 601*835b56bfSJung-uk Kim * Special case: Allow forward references from elements of 602*835b56bfSJung-uk Kim * Package objects. This provides compatibility with other 603*835b56bfSJung-uk Kim * ACPI implementations. To correctly implement this, the 604*835b56bfSJung-uk Kim * ACPICA table load defers package resolution until the entire 605*835b56bfSJung-uk Kim * namespace has been loaded. 606*835b56bfSJung-uk Kim */ 607*835b56bfSJung-uk Kim if ((ParentOp->Asl.ParseOpcode != PARSEOP_PACKAGE) && 608*835b56bfSJung-uk Kim (ParentOp->Asl.ParseOpcode != PARSEOP_VAR_PACKAGE)) 609*835b56bfSJung-uk Kim { 610*835b56bfSJung-uk Kim Op->Asl.CompileFlags |= OP_NOT_FOUND_DURING_LOAD; 611*835b56bfSJung-uk Kim } 612*835b56bfSJung-uk Kim 613*835b56bfSJung-uk Kim return (AE_OK); 614*835b56bfSJung-uk Kim } 615*835b56bfSJung-uk Kim 616*835b56bfSJung-uk Kim return (Status); 617*835b56bfSJung-uk Kim } 618*835b56bfSJung-uk Kim 61953289f6aSNate Lawson Path = Op->Asl.Namepath; 62053289f6aSNate Lawson if (!Path) 62153289f6aSNate Lawson { 62253289f6aSNate Lawson return (AE_OK); 62353289f6aSNate Lawson } 62453289f6aSNate Lawson 62553289f6aSNate Lawson /* Map the raw opcode into an internal object type */ 62653289f6aSNate Lawson 62753289f6aSNate Lawson switch (Op->Asl.ParseOpcode) 62853289f6aSNate Lawson { 62953289f6aSNate Lawson case PARSEOP_NAME: 63053289f6aSNate Lawson 63153289f6aSNate Lawson Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ 63253289f6aSNate Lawson Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ 63353289f6aSNate Lawson 6341a39cfb0SJung-uk Kim /* 6351a39cfb0SJung-uk Kim * If this name refers to a ResourceTemplate, we will need to open 6361a39cfb0SJung-uk Kim * a new scope so that the resource subfield names can be entered into 6371a39cfb0SJung-uk Kim * the namespace underneath this name 6381a39cfb0SJung-uk Kim */ 6395f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 6401a39cfb0SJung-uk Kim { 6411a39cfb0SJung-uk Kim ForceNewScope = TRUE; 6421a39cfb0SJung-uk Kim } 6431a39cfb0SJung-uk Kim 64453289f6aSNate Lawson /* Get the data type associated with the named object, not the name itself */ 64553289f6aSNate Lawson 64653289f6aSNate Lawson /* Log2 loop to convert from Btype (binary) to Etype (encoded) */ 64753289f6aSNate Lawson 64853289f6aSNate Lawson ObjectType = 1; 64953289f6aSNate Lawson for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2) 65053289f6aSNate Lawson { 65153289f6aSNate Lawson ObjectType++; 65253289f6aSNate Lawson } 65353289f6aSNate Lawson break; 65453289f6aSNate Lawson 65553289f6aSNate Lawson case PARSEOP_EXTERNAL: 65653289f6aSNate Lawson /* 65753289f6aSNate Lawson * "External" simply enters a name and type into the namespace. 65853289f6aSNate Lawson * We must be careful to not open a new scope, however, no matter 65953289f6aSNate Lawson * what type the external name refers to (e.g., a method) 66053289f6aSNate Lawson * 66153289f6aSNate Lawson * first child is name, next child is ObjectType 66253289f6aSNate Lawson */ 66353289f6aSNate Lawson ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; 66453289f6aSNate Lawson ObjectType = ACPI_TYPE_ANY; 66553289f6aSNate Lawson 6661a39cfb0SJung-uk Kim /* 6671a39cfb0SJung-uk Kim * We will mark every new node along the path as "External". This 6681a39cfb0SJung-uk Kim * allows some or all of the nodes to be created later in the ASL 6691a39cfb0SJung-uk Kim * code. Handles cases like this: 6701a39cfb0SJung-uk Kim * 6711a39cfb0SJung-uk Kim * External (\_SB_.PCI0.ABCD, IntObj) 6721a39cfb0SJung-uk Kim * Scope (_SB_) 6731a39cfb0SJung-uk Kim * { 6741a39cfb0SJung-uk Kim * Device (PCI0) 6751a39cfb0SJung-uk Kim * { 6761a39cfb0SJung-uk Kim * } 6771a39cfb0SJung-uk Kim * } 6781a39cfb0SJung-uk Kim * Method (X) 6791a39cfb0SJung-uk Kim * { 6801a39cfb0SJung-uk Kim * Store (\_SB_.PCI0.ABCD, Local0) 6811a39cfb0SJung-uk Kim * } 6821a39cfb0SJung-uk Kim */ 6831a39cfb0SJung-uk Kim Flags |= ACPI_NS_EXTERNAL; 6841a39cfb0SJung-uk Kim break; 68553289f6aSNate Lawson 68653289f6aSNate Lawson case PARSEOP_DEFAULT_ARG: 68753289f6aSNate Lawson 6885f9b24faSJung-uk Kim if (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC) 68953289f6aSNate Lawson { 69053289f6aSNate Lawson Status = LdLoadResourceElements (Op, WalkState); 6919a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 69253289f6aSNate Lawson } 69353289f6aSNate Lawson 69453289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 69553289f6aSNate Lawson break; 69653289f6aSNate Lawson 69753289f6aSNate Lawson case PARSEOP_SCOPE: 69853289f6aSNate Lawson /* 69953289f6aSNate Lawson * The name referenced by Scope(Name) must already exist at this point. 70053289f6aSNate Lawson * In other words, forward references for Scope() are not supported. 70153289f6aSNate Lawson * The only real reason for this is that the MS interpreter cannot 70253289f6aSNate Lawson * handle this case. Perhaps someday this case can go away. 70353289f6aSNate Lawson */ 70453289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 705fba7fc7eSJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 706fba7fc7eSJung-uk Kim WalkState, &(Node)); 70753289f6aSNate Lawson if (ACPI_FAILURE (Status)) 70853289f6aSNate Lawson { 70953289f6aSNate Lawson if (Status == AE_NOT_FOUND) 71053289f6aSNate Lawson { 71153289f6aSNate Lawson /* The name was not found, go ahead and create it */ 71253289f6aSNate Lawson 713fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 714fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_SCOPE, 715fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, 716fba7fc7eSJung-uk Kim WalkState, &(Node)); 71779c6d946SJung-uk Kim if (ACPI_FAILURE (Status)) 71879c6d946SJung-uk Kim { 71979c6d946SJung-uk Kim return_ACPI_STATUS (Status); 72079c6d946SJung-uk Kim } 72153289f6aSNate Lawson 72253289f6aSNate Lawson /* 72353289f6aSNate Lawson * However, this is an error -- primarily because the MS 72453289f6aSNate Lawson * interpreter can't handle a forward reference from the 72553289f6aSNate Lawson * Scope() operator. 72653289f6aSNate Lawson */ 727fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 728fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 729fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, 730fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 73153289f6aSNate Lawson goto FinishNode; 73253289f6aSNate Lawson } 73353289f6aSNate Lawson 734f556842eSJung-uk Kim AslCoreSubsystemError (Op, Status, 735f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 736f556842eSJung-uk Kim 7379a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 73853289f6aSNate Lawson } 739f8146b88SJung-uk Kim else /* Status AE_OK */ 740f8146b88SJung-uk Kim { 741f8146b88SJung-uk Kim /* 742f8146b88SJung-uk Kim * Do not allow references to external scopes from the DSDT. 743f8146b88SJung-uk Kim * This is because the DSDT is always loaded first, and the 744f8146b88SJung-uk Kim * external reference cannot be resolved -- causing a runtime 745f8146b88SJung-uk Kim * error because Scope() must be resolved immediately. 746f8146b88SJung-uk Kim * 10/2015. 747f8146b88SJung-uk Kim */ 748f8146b88SJung-uk Kim if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 749f8146b88SJung-uk Kim (ACPI_COMPARE_NAME (Gbl_TableSignature, "DSDT"))) 750f8146b88SJung-uk Kim { 751f8146b88SJung-uk Kim /* However, allowed if the reference is within a method */ 752f8146b88SJung-uk Kim 753f8146b88SJung-uk Kim MethodOp = Op->Asl.Parent; 754f8146b88SJung-uk Kim while (MethodOp && 755f8146b88SJung-uk Kim (MethodOp->Asl.ParseOpcode != PARSEOP_METHOD)) 756f8146b88SJung-uk Kim { 757f8146b88SJung-uk Kim MethodOp = MethodOp->Asl.Parent; 758f8146b88SJung-uk Kim } 759f8146b88SJung-uk Kim 760f8146b88SJung-uk Kim if (!MethodOp) 761f8146b88SJung-uk Kim { 762f8146b88SJung-uk Kim /* Not in a control method, error */ 763f8146b88SJung-uk Kim 764f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_CROSS_TABLE_SCOPE, Op, NULL); 765f8146b88SJung-uk Kim } 766f8146b88SJung-uk Kim } 767f8146b88SJung-uk Kim } 76853289f6aSNate Lawson 76953289f6aSNate Lawson /* We found a node with this name, now check the type */ 77053289f6aSNate Lawson 77153289f6aSNate Lawson switch (Node->Type) 77253289f6aSNate Lawson { 77353289f6aSNate Lawson case ACPI_TYPE_LOCAL_SCOPE: 77453289f6aSNate Lawson case ACPI_TYPE_DEVICE: 77553289f6aSNate Lawson case ACPI_TYPE_POWER: 77653289f6aSNate Lawson case ACPI_TYPE_PROCESSOR: 77753289f6aSNate Lawson case ACPI_TYPE_THERMAL: 77853289f6aSNate Lawson 77953289f6aSNate Lawson /* These are acceptable types - they all open a new scope */ 78053289f6aSNate Lawson break; 78153289f6aSNate Lawson 78253289f6aSNate Lawson case ACPI_TYPE_INTEGER: 78353289f6aSNate Lawson case ACPI_TYPE_STRING: 78453289f6aSNate Lawson case ACPI_TYPE_BUFFER: 78553289f6aSNate Lawson /* 786fba7fc7eSJung-uk Kim * These types we will allow, but we will change the type. 787fba7fc7eSJung-uk Kim * This enables some existing code of the form: 78853289f6aSNate Lawson * 78953289f6aSNate Lawson * Name (DEB, 0) 79053289f6aSNate Lawson * Scope (DEB) { ... } 79153289f6aSNate Lawson * 79253289f6aSNate Lawson * Which is used to workaround the fact that the MS interpreter 79353289f6aSNate Lawson * does not allow Scope() forward references. 79453289f6aSNate Lawson */ 795e0ef747bSNate Lawson sprintf (MsgBuffer, "%s [%s], changing type to [Scope]", 79653289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 79753289f6aSNate Lawson AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 79853289f6aSNate Lawson 799fba7fc7eSJung-uk Kim /* Switch the type to scope, open the new scope */ 800fba7fc7eSJung-uk Kim 801e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 802fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 803fba7fc7eSJung-uk Kim WalkState); 804e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 805e0ef747bSNate Lawson { 806e0ef747bSNate Lawson return_ACPI_STATUS (Status); 807e0ef747bSNate Lawson } 80853289f6aSNate Lawson break; 80953289f6aSNate Lawson 81053289f6aSNate Lawson default: 81153289f6aSNate Lawson 812fba7fc7eSJung-uk Kim /* All other types are an error */ 813fba7fc7eSJung-uk Kim 814fba7fc7eSJung-uk Kim sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 815fba7fc7eSJung-uk Kim AcpiUtGetTypeName (Node->Type)); 81653289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 81753289f6aSNate Lawson 81853289f6aSNate Lawson /* 81953289f6aSNate Lawson * However, switch the type to be an actual scope so 82053289f6aSNate Lawson * that compilation can continue without generating a whole 821e0ef747bSNate Lawson * cascade of additional errors. Open the new scope. 82253289f6aSNate Lawson */ 823e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 824fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 825fba7fc7eSJung-uk Kim WalkState); 826e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 827e0ef747bSNate Lawson { 828e0ef747bSNate Lawson return_ACPI_STATUS (Status); 829e0ef747bSNate Lawson } 83053289f6aSNate Lawson break; 83153289f6aSNate Lawson } 83253289f6aSNate Lawson 83353289f6aSNate Lawson Status = AE_OK; 83453289f6aSNate Lawson goto FinishNode; 83553289f6aSNate Lawson 83653289f6aSNate Lawson default: 83753289f6aSNate Lawson 83853289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 83953289f6aSNate Lawson break; 84053289f6aSNate Lawson } 84153289f6aSNate Lawson 84253289f6aSNate Lawson 84353289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", 84453289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); 84553289f6aSNate Lawson 84653289f6aSNate Lawson /* The name must not already exist */ 84753289f6aSNate Lawson 84853289f6aSNate Lawson Flags |= ACPI_NS_ERROR_IF_FOUND; 84953289f6aSNate Lawson 85053289f6aSNate Lawson /* 85153289f6aSNate Lawson * Enter the named type into the internal namespace. We enter the name 852fba7fc7eSJung-uk Kim * as we go downward in the parse tree. Any necessary subobjects that 853fba7fc7eSJung-uk Kim * involve arguments to the opcode must be created as we go back up the 854fba7fc7eSJung-uk Kim * parse tree later. 85553289f6aSNate Lawson */ 85653289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 8571a39cfb0SJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 85853289f6aSNate Lawson if (ACPI_FAILURE (Status)) 85953289f6aSNate Lawson { 86053289f6aSNate Lawson if (Status == AE_ALREADY_EXISTS) 86153289f6aSNate Lawson { 86253289f6aSNate Lawson /* The name already exists in this scope */ 86353289f6aSNate Lawson 86453289f6aSNate Lawson if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 86553289f6aSNate Lawson { 8661a39cfb0SJung-uk Kim /* Allow multiple references to the same scope */ 8671a39cfb0SJung-uk Kim 86853289f6aSNate Lawson Node->Type = (UINT8) ObjectType; 86953289f6aSNate Lawson Status = AE_OK; 87053289f6aSNate Lawson } 871a9f12690SJung-uk Kim else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 872a9f12690SJung-uk Kim (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) 8731a39cfb0SJung-uk Kim { 8741a39cfb0SJung-uk Kim /* 8751a39cfb0SJung-uk Kim * Allow one create on an object or segment that was 876af051161SJung-uk Kim * previously declared External only if WalkState->OwnerId and 87767d9aa44SJung-uk Kim * Node->OwnerId are different (meaning that the current WalkState 87867d9aa44SJung-uk Kim * and the Node are in different tables). 8791a39cfb0SJung-uk Kim */ 8801a39cfb0SJung-uk Kim Node->Flags &= ~ANOBJ_IS_EXTERNAL; 8811a39cfb0SJung-uk Kim Node->Type = (UINT8) ObjectType; 8821a39cfb0SJung-uk Kim 8831a39cfb0SJung-uk Kim /* Just retyped a node, probably will need to open a scope */ 8841a39cfb0SJung-uk Kim 8851a39cfb0SJung-uk Kim if (AcpiNsOpensScope (ObjectType)) 8861a39cfb0SJung-uk Kim { 8871a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 8881a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 8891a39cfb0SJung-uk Kim { 8901a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 8911a39cfb0SJung-uk Kim } 8921a39cfb0SJung-uk Kim } 893f8146b88SJung-uk Kim 8941a39cfb0SJung-uk Kim Status = AE_OK; 895af051161SJung-uk Kim 8965f9b24faSJung-uk Kim if (Node->OwnerId == WalkState->OwnerId && 8975f9b24faSJung-uk Kim !(Node->Flags & IMPLICIT_EXTERNAL)) 898af051161SJung-uk Kim { 899ff879b07SJung-uk Kim AslDualParseOpError (ASL_WARNING, ASL_MSG_EXTERN_COLLISION, Op, 900ff879b07SJung-uk Kim Op->Asl.ExternalName, ASL_MSG_EXTERN_FOUND_HERE, Node->Op, 90167d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 902af051161SJung-uk Kim } 9035f9b24faSJung-uk Kim if (Node->Flags & IMPLICIT_EXTERNAL) 9045f9b24faSJung-uk Kim { 9055f9b24faSJung-uk Kim Node->Flags &= ~IMPLICIT_EXTERNAL; 9065f9b24faSJung-uk Kim } 9071a39cfb0SJung-uk Kim } 908f8146b88SJung-uk Kim else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && 909f8146b88SJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) 910f8146b88SJung-uk Kim { 911f8146b88SJung-uk Kim /* 912f8146b88SJung-uk Kim * Allow externals in same scope as the definition of the 913f8146b88SJung-uk Kim * actual object. Similar to C. Allows multiple definition 914af051161SJung-uk Kim * blocks that refer to each other in the same file. However, 915af051161SJung-uk Kim * do not allow name declaration and an external declaration 916af051161SJung-uk Kim * within the same table. This is considered a re-declaration. 917f8146b88SJung-uk Kim */ 918f8146b88SJung-uk Kim Status = AE_OK; 919af051161SJung-uk Kim 920af051161SJung-uk Kim if (Node->OwnerId == WalkState->OwnerId) 921af051161SJung-uk Kim { 922ff879b07SJung-uk Kim AslDualParseOpError (ASL_WARNING, ASL_MSG_EXTERN_COLLISION, Op, 923ff879b07SJung-uk Kim Op->Asl.ExternalName, ASL_MSG_EXTERN_FOUND_HERE, Node->Op, 92467d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 925af051161SJung-uk Kim } 926f8146b88SJung-uk Kim } 927f8146b88SJung-uk Kim else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 928f8146b88SJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && 929f8146b88SJung-uk Kim (ObjectType == ACPI_TYPE_ANY)) 930f8146b88SJung-uk Kim { 931af051161SJung-uk Kim /* 932af051161SJung-uk Kim * Allow update of externals of unknown type. 933af051161SJung-uk Kim * In the case that multiple definition blocks are being 934af051161SJung-uk Kim * parsed, updating the OwnerId allows enables subsequent calls 935af051161SJung-uk Kim * of this method to understand which table the most recent 936af051161SJung-uk Kim * external declaration was seen. Without this OwnerId update, 937af051161SJung-uk Kim * code like the following is allowed to compile: 938af051161SJung-uk Kim * 939af051161SJung-uk Kim * DefinitionBlock("externtest.aml", "DSDT", 0x02, "Intel", "Many", 0x00000001) 940af051161SJung-uk Kim * { 941af051161SJung-uk Kim * External(ERRS,methodobj) 942af051161SJung-uk Kim * Method (MAIN) 943af051161SJung-uk Kim * { 944af051161SJung-uk Kim * Name(NUM2, 0) 945af051161SJung-uk Kim * ERRS(1,2,3) 946af051161SJung-uk Kim * } 947af051161SJung-uk Kim * } 948af051161SJung-uk Kim * 949af051161SJung-uk Kim * DefinitionBlock("externtest.aml", "SSDT", 0x02, "Intel", "Many", 0x00000001) 950af051161SJung-uk Kim * { 951af051161SJung-uk Kim * if (0) 952af051161SJung-uk Kim * { 953af051161SJung-uk Kim * External(ERRS,methodobj) 954af051161SJung-uk Kim * } 955af051161SJung-uk Kim * Method (ERRS,3) 956af051161SJung-uk Kim * {} 957af051161SJung-uk Kim * 958af051161SJung-uk Kim * } 959af051161SJung-uk Kim */ 960af051161SJung-uk Kim Node->OwnerId = WalkState->OwnerId; 961f8146b88SJung-uk Kim 962f8146b88SJung-uk Kim if (AcpiNsOpensScope (ActualObjectType)) 963f8146b88SJung-uk Kim { 964f8146b88SJung-uk Kim Node->Type = (UINT8) ActualObjectType; 965f8146b88SJung-uk Kim Status = AE_OK; 966f8146b88SJung-uk Kim } 967f8146b88SJung-uk Kim else 968f8146b88SJung-uk Kim { 969f8146b88SJung-uk Kim sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 970f8146b88SJung-uk Kim AcpiUtGetTypeName (Node->Type)); 971f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 972f8146b88SJung-uk Kim return_ACPI_STATUS (AE_OK); 973f8146b88SJung-uk Kim } 974f8146b88SJung-uk Kim } 97553289f6aSNate Lawson else 97653289f6aSNate Lawson { 9771a39cfb0SJung-uk Kim /* Valid error, object already exists */ 9781a39cfb0SJung-uk Kim 97967d9aa44SJung-uk Kim AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, 98067d9aa44SJung-uk Kim Op->Asl.ExternalName, ASL_MSG_FOUND_HERE, Node->Op, 98167d9aa44SJung-uk Kim Node->Op->Asl.ExternalName); 9829a179dd8SJung-uk Kim return_ACPI_STATUS (AE_OK); 98353289f6aSNate Lawson } 98453289f6aSNate Lawson } 98553289f6aSNate Lawson else 98653289f6aSNate Lawson { 987fba7fc7eSJung-uk Kim AslCoreSubsystemError (Op, Status, 988f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 9899a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 99053289f6aSNate Lawson } 99153289f6aSNate Lawson } 99253289f6aSNate Lawson 9931a39cfb0SJung-uk Kim if (ForceNewScope) 9941a39cfb0SJung-uk Kim { 9951a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 9961a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 9971a39cfb0SJung-uk Kim { 9981a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 9991a39cfb0SJung-uk Kim } 10001a39cfb0SJung-uk Kim } 100153289f6aSNate Lawson 100253289f6aSNate Lawson FinishNode: 100353289f6aSNate Lawson /* 100453289f6aSNate Lawson * Point the parse node to the new namespace node, and point 100553289f6aSNate Lawson * the Node back to the original Parse node 100653289f6aSNate Lawson */ 100753289f6aSNate Lawson Op->Asl.Node = Node; 1008fba7fc7eSJung-uk Kim Node->Op = Op; 100953289f6aSNate Lawson 101053289f6aSNate Lawson /* Set the actual data type if appropriate (EXTERNAL term only) */ 101153289f6aSNate Lawson 101253289f6aSNate Lawson if (ActualObjectType != ACPI_TYPE_ANY) 101353289f6aSNate Lawson { 101453289f6aSNate Lawson Node->Type = (UINT8) ActualObjectType; 1015fba7fc7eSJung-uk Kim Node->Value = ASL_EXTERNAL_METHOD; 101653289f6aSNate Lawson } 101753289f6aSNate Lawson 101853289f6aSNate Lawson if (Op->Asl.ParseOpcode == PARSEOP_METHOD) 101953289f6aSNate Lawson { 102053289f6aSNate Lawson /* 1021fba7fc7eSJung-uk Kim * Get the method argument count from "Extra" and save 1022fba7fc7eSJung-uk Kim * it in the namespace node 102353289f6aSNate Lawson */ 1024fba7fc7eSJung-uk Kim Node->Value = (UINT32) Op->Asl.Extra; 102553289f6aSNate Lawson } 102653289f6aSNate Lawson 10279a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 102853289f6aSNate Lawson } 102953289f6aSNate Lawson 103053289f6aSNate Lawson 103153289f6aSNate Lawson /******************************************************************************* 103253289f6aSNate Lawson * 1033a9f12690SJung-uk Kim * FUNCTION: LdNamespace2Begin 1034a9f12690SJung-uk Kim * 1035a9f12690SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 1036a9f12690SJung-uk Kim * 1037a9f12690SJung-uk Kim * RETURN: Status 1038a9f12690SJung-uk Kim * 1039a9f12690SJung-uk Kim * DESCRIPTION: Descending callback used during the pass 2 parse tree walk. 1040a9f12690SJung-uk Kim * Second pass resolves some forward references. 1041a9f12690SJung-uk Kim * 1042a9f12690SJung-uk Kim * Notes: 1043a9f12690SJung-uk Kim * Currently only needs to handle the Alias operator. 1044a9f12690SJung-uk Kim * Could be used to allow forward references from the Scope() operator, but 1045a9f12690SJung-uk Kim * the MS interpreter does not allow this, so this compiler does not either. 1046a9f12690SJung-uk Kim * 1047a9f12690SJung-uk Kim ******************************************************************************/ 1048a9f12690SJung-uk Kim 1049a9f12690SJung-uk Kim static ACPI_STATUS 1050a9f12690SJung-uk Kim LdNamespace2Begin ( 1051a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Op, 1052a9f12690SJung-uk Kim UINT32 Level, 1053a9f12690SJung-uk Kim void *Context) 1054a9f12690SJung-uk Kim { 1055a9f12690SJung-uk Kim ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 1056a9f12690SJung-uk Kim ACPI_STATUS Status; 1057a9f12690SJung-uk Kim ACPI_NAMESPACE_NODE *Node; 1058a9f12690SJung-uk Kim ACPI_OBJECT_TYPE ObjectType; 1059a9f12690SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 1060a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Arg; 1061a9f12690SJung-uk Kim char *Path; 1062a9f12690SJung-uk Kim ACPI_NAMESPACE_NODE *TargetNode; 1063a9f12690SJung-uk Kim 1064a9f12690SJung-uk Kim 1065a9f12690SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace2Begin); 1066a9f12690SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 1067a9f12690SJung-uk Kim Op, Op->Asl.ParseOpName)); 1068a9f12690SJung-uk Kim 1069a9f12690SJung-uk Kim 1070a9f12690SJung-uk Kim /* Ignore Ops with no namespace node */ 1071a9f12690SJung-uk Kim 1072a9f12690SJung-uk Kim Node = Op->Asl.Node; 1073a9f12690SJung-uk Kim if (!Node) 1074a9f12690SJung-uk Kim { 1075a9f12690SJung-uk Kim return (AE_OK); 1076a9f12690SJung-uk Kim } 1077a9f12690SJung-uk Kim 1078a9f12690SJung-uk Kim /* Get the type to determine if we should push the scope */ 1079a9f12690SJung-uk Kim 1080a9f12690SJung-uk Kim if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 10815f9b24faSJung-uk Kim (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC)) 1082a9f12690SJung-uk Kim { 1083a9f12690SJung-uk Kim ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 1084a9f12690SJung-uk Kim } 1085a9f12690SJung-uk Kim else 1086a9f12690SJung-uk Kim { 1087a9f12690SJung-uk Kim ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 1088a9f12690SJung-uk Kim } 1089a9f12690SJung-uk Kim 1090a9f12690SJung-uk Kim /* Push scope for Resource Templates */ 1091a9f12690SJung-uk Kim 1092a9f12690SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 1093a9f12690SJung-uk Kim { 10945f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 1095a9f12690SJung-uk Kim { 1096a9f12690SJung-uk Kim ForceNewScope = TRUE; 1097a9f12690SJung-uk Kim } 1098a9f12690SJung-uk Kim } 1099a9f12690SJung-uk Kim 1100a9f12690SJung-uk Kim /* Push the scope stack */ 1101a9f12690SJung-uk Kim 1102a9f12690SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 1103a9f12690SJung-uk Kim { 1104a9f12690SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 1105a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 1106a9f12690SJung-uk Kim { 1107a9f12690SJung-uk Kim return_ACPI_STATUS (Status); 1108a9f12690SJung-uk Kim } 1109a9f12690SJung-uk Kim } 1110a9f12690SJung-uk Kim 1111a9f12690SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_ALIAS) 1112a9f12690SJung-uk Kim { 1113a9f12690SJung-uk Kim /* Complete the alias node by getting and saving the target node */ 1114a9f12690SJung-uk Kim 1115a9f12690SJung-uk Kim /* First child is the alias target */ 1116a9f12690SJung-uk Kim 1117a9f12690SJung-uk Kim Arg = Op->Asl.Child; 1118a9f12690SJung-uk Kim 1119a9f12690SJung-uk Kim /* Get the target pathname */ 1120a9f12690SJung-uk Kim 1121a9f12690SJung-uk Kim Path = Arg->Asl.Namepath; 1122a9f12690SJung-uk Kim if (!Path) 1123a9f12690SJung-uk Kim { 1124a9f12690SJung-uk Kim Status = UtInternalizeName (Arg->Asl.ExternalName, &Path); 1125a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 1126a9f12690SJung-uk Kim { 1127a9f12690SJung-uk Kim return (Status); 1128a9f12690SJung-uk Kim } 1129a9f12690SJung-uk Kim } 1130a9f12690SJung-uk Kim 1131a9f12690SJung-uk Kim /* Get the NS node associated with the target. It must exist. */ 1132a9f12690SJung-uk Kim 1133a9f12690SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 1134a9f12690SJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 1135a9f12690SJung-uk Kim WalkState, &TargetNode); 1136a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 1137a9f12690SJung-uk Kim { 1138a9f12690SJung-uk Kim if (Status == AE_NOT_FOUND) 1139a9f12690SJung-uk Kim { 1140a9f12690SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 1141a9f12690SJung-uk Kim Op->Asl.ExternalName); 1142a9f12690SJung-uk Kim 1143a9f12690SJung-uk Kim /* 1144a9f12690SJung-uk Kim * The name was not found, go ahead and create it. 1145a9f12690SJung-uk Kim * This prevents more errors later. 1146a9f12690SJung-uk Kim */ 1147a9f12690SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 1148a9f12690SJung-uk Kim ACPI_TYPE_ANY, 1149a9f12690SJung-uk Kim ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, 1150a9f12690SJung-uk Kim WalkState, &(Node)); 1151a9f12690SJung-uk Kim return (AE_OK); 1152a9f12690SJung-uk Kim } 1153a9f12690SJung-uk Kim 1154f556842eSJung-uk Kim AslCoreSubsystemError (Op, Status, 1155f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 1156a9f12690SJung-uk Kim return (AE_OK); 1157a9f12690SJung-uk Kim } 1158a9f12690SJung-uk Kim 1159a9f12690SJung-uk Kim /* Save the target node within the alias node */ 1160a9f12690SJung-uk Kim 1161a9f12690SJung-uk Kim Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 1162a9f12690SJung-uk Kim } 1163a9f12690SJung-uk Kim 1164a9f12690SJung-uk Kim return (AE_OK); 1165a9f12690SJung-uk Kim } 1166a9f12690SJung-uk Kim 1167a9f12690SJung-uk Kim 1168a9f12690SJung-uk Kim /******************************************************************************* 1169a9f12690SJung-uk Kim * 1170a9f12690SJung-uk Kim * FUNCTION: LdCommonNamespaceEnd 117153289f6aSNate Lawson * 117253289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 117353289f6aSNate Lawson * 117453289f6aSNate Lawson * RETURN: Status 117553289f6aSNate Lawson * 117653289f6aSNate Lawson * DESCRIPTION: Ascending callback used during the loading of the namespace, 117753289f6aSNate Lawson * We only need to worry about managing the scope stack here. 117853289f6aSNate Lawson * 117953289f6aSNate Lawson ******************************************************************************/ 118053289f6aSNate Lawson 1181fba7fc7eSJung-uk Kim static ACPI_STATUS 1182a9f12690SJung-uk Kim LdCommonNamespaceEnd ( 118353289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 118453289f6aSNate Lawson UINT32 Level, 118553289f6aSNate Lawson void *Context) 118653289f6aSNate Lawson { 118753289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 118853289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 11891a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 119053289f6aSNate Lawson 119153289f6aSNate Lawson 1192a9f12690SJung-uk Kim ACPI_FUNCTION_NAME (LdCommonNamespaceEnd); 119353289f6aSNate Lawson 119453289f6aSNate Lawson 119553289f6aSNate Lawson /* We are only interested in opcodes that have an associated name */ 119653289f6aSNate Lawson 119753289f6aSNate Lawson if (!Op->Asl.Namepath) 119853289f6aSNate Lawson { 119953289f6aSNate Lawson return (AE_OK); 120053289f6aSNate Lawson } 120153289f6aSNate Lawson 120253289f6aSNate Lawson /* Get the type to determine if we should pop the scope */ 120353289f6aSNate Lawson 120453289f6aSNate Lawson if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 12055f9b24faSJung-uk Kim (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC)) 120653289f6aSNate Lawson { 120753289f6aSNate Lawson /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */ 120853289f6aSNate Lawson 120953289f6aSNate Lawson ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 121053289f6aSNate Lawson } 121153289f6aSNate Lawson else 121253289f6aSNate Lawson { 121353289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 121453289f6aSNate Lawson } 121553289f6aSNate Lawson 12161a39cfb0SJung-uk Kim /* Pop scope that was pushed for Resource Templates */ 12171a39cfb0SJung-uk Kim 12181a39cfb0SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 12191a39cfb0SJung-uk Kim { 12205f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 12211a39cfb0SJung-uk Kim { 12221a39cfb0SJung-uk Kim ForceNewScope = TRUE; 12231a39cfb0SJung-uk Kim } 12241a39cfb0SJung-uk Kim } 12251a39cfb0SJung-uk Kim 122653289f6aSNate Lawson /* Pop the scope stack */ 122753289f6aSNate Lawson 12281a39cfb0SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 122953289f6aSNate Lawson { 123053289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 123153289f6aSNate Lawson "(%s): Popping scope for Op [%s] %p\n", 123253289f6aSNate Lawson AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); 123353289f6aSNate Lawson 1234fba7fc7eSJung-uk Kim (void) AcpiDsScopeStackPop (WalkState); 123553289f6aSNate Lawson } 123653289f6aSNate Lawson 123753289f6aSNate Lawson return (AE_OK); 123853289f6aSNate Lawson } 1239