153289f6aSNate Lawson /****************************************************************************** 253289f6aSNate Lawson * 353289f6aSNate Lawson * Module Name: dswload - Dispatcher namespace load callbacks 4*1a39cfb0SJung-uk Kim * $Revision: 1.77 $ 553289f6aSNate Lawson * 653289f6aSNate Lawson *****************************************************************************/ 753289f6aSNate Lawson 853289f6aSNate Lawson /****************************************************************************** 953289f6aSNate Lawson * 1053289f6aSNate Lawson * 1. Copyright Notice 1153289f6aSNate Lawson * 12*1a39cfb0SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. 1353289f6aSNate Lawson * All rights reserved. 1453289f6aSNate Lawson * 1553289f6aSNate Lawson * 2. License 1653289f6aSNate Lawson * 1753289f6aSNate Lawson * 2.1. This is your license from Intel Corp. under its intellectual property 1853289f6aSNate Lawson * rights. You may have additional license terms from the party that provided 1953289f6aSNate Lawson * you this software, covering your right to use that party's intellectual 2053289f6aSNate Lawson * property rights. 2153289f6aSNate Lawson * 2253289f6aSNate Lawson * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2353289f6aSNate Lawson * copy of the source code appearing in this file ("Covered Code") an 2453289f6aSNate Lawson * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2553289f6aSNate Lawson * base code distributed originally by Intel ("Original Intel Code") to copy, 2653289f6aSNate Lawson * make derivatives, distribute, use and display any portion of the Covered 2753289f6aSNate Lawson * Code in any form, with the right to sublicense such rights; and 2853289f6aSNate Lawson * 2953289f6aSNate Lawson * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3053289f6aSNate Lawson * license (with the right to sublicense), under only those claims of Intel 3153289f6aSNate Lawson * patents that are infringed by the Original Intel Code, to make, use, sell, 3253289f6aSNate Lawson * offer to sell, and import the Covered Code and derivative works thereof 3353289f6aSNate Lawson * solely to the minimum extent necessary to exercise the above copyright 3453289f6aSNate Lawson * license, and in no event shall the patent license extend to any additions 3553289f6aSNate Lawson * to or modifications of the Original Intel Code. No other license or right 3653289f6aSNate Lawson * is granted directly or by implication, estoppel or otherwise; 3753289f6aSNate Lawson * 3853289f6aSNate Lawson * The above copyright and patent license is granted only if the following 3953289f6aSNate Lawson * conditions are met: 4053289f6aSNate Lawson * 4153289f6aSNate Lawson * 3. Conditions 4253289f6aSNate Lawson * 4353289f6aSNate Lawson * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4453289f6aSNate Lawson * Redistribution of source code of any substantial portion of the Covered 4553289f6aSNate Lawson * Code or modification with rights to further distribute source must include 4653289f6aSNate Lawson * the above Copyright Notice, the above License, this list of Conditions, 4753289f6aSNate Lawson * and the following Disclaimer and Export Compliance provision. In addition, 4853289f6aSNate Lawson * Licensee must cause all Covered Code to which Licensee contributes to 4953289f6aSNate Lawson * contain a file documenting the changes Licensee made to create that Covered 5053289f6aSNate Lawson * Code and the date of any change. Licensee must include in that file the 5153289f6aSNate Lawson * documentation of any changes made by any predecessor Licensee. Licensee 5253289f6aSNate Lawson * must include a prominent statement that the modification is derived, 5353289f6aSNate Lawson * directly or indirectly, from Original Intel Code. 5453289f6aSNate Lawson * 5553289f6aSNate Lawson * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5653289f6aSNate Lawson * Redistribution of source code of any substantial portion of the Covered 5753289f6aSNate Lawson * Code or modification without rights to further distribute source must 5853289f6aSNate Lawson * include the following Disclaimer and Export Compliance provision in the 5953289f6aSNate Lawson * documentation and/or other materials provided with distribution. In 6053289f6aSNate Lawson * addition, Licensee may not authorize further sublicense of source of any 6153289f6aSNate Lawson * portion of the Covered Code, and must include terms to the effect that the 6253289f6aSNate Lawson * license from Licensee to its licensee is limited to the intellectual 6353289f6aSNate Lawson * property embodied in the software Licensee provides to its licensee, and 6453289f6aSNate Lawson * not to intellectual property embodied in modifications its licensee may 6553289f6aSNate Lawson * make. 6653289f6aSNate Lawson * 6753289f6aSNate Lawson * 3.3. Redistribution of Executable. Redistribution in executable form of any 6853289f6aSNate Lawson * substantial portion of the Covered Code or modification must reproduce the 6953289f6aSNate Lawson * above Copyright Notice, and the following Disclaimer and Export Compliance 7053289f6aSNate Lawson * provision in the documentation and/or other materials provided with the 7153289f6aSNate Lawson * distribution. 7253289f6aSNate Lawson * 7353289f6aSNate Lawson * 3.4. Intel retains all right, title, and interest in and to the Original 7453289f6aSNate Lawson * Intel Code. 7553289f6aSNate Lawson * 7653289f6aSNate Lawson * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7753289f6aSNate Lawson * Intel shall be used in advertising or otherwise to promote the sale, use or 7853289f6aSNate Lawson * other dealings in products derived from or relating to the Covered Code 7953289f6aSNate Lawson * without prior written authorization from Intel. 8053289f6aSNate Lawson * 8153289f6aSNate Lawson * 4. Disclaimer and Export Compliance 8253289f6aSNate Lawson * 8353289f6aSNate Lawson * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8453289f6aSNate Lawson * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8553289f6aSNate Lawson * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8653289f6aSNate Lawson * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8753289f6aSNate Lawson * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8853289f6aSNate Lawson * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8953289f6aSNate Lawson * PARTICULAR PURPOSE. 9053289f6aSNate Lawson * 9153289f6aSNate Lawson * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9253289f6aSNate Lawson * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9353289f6aSNate Lawson * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9453289f6aSNate Lawson * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9553289f6aSNate Lawson * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9653289f6aSNate Lawson * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9753289f6aSNate Lawson * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9853289f6aSNate Lawson * LIMITED REMEDY. 9953289f6aSNate Lawson * 10053289f6aSNate Lawson * 4.3. Licensee shall not export, either directly or indirectly, any of this 10153289f6aSNate Lawson * software or system incorporating such software without first obtaining any 10253289f6aSNate Lawson * required license or other approval from the U. S. Department of Commerce or 10353289f6aSNate Lawson * any other agency or department of the United States Government. In the 10453289f6aSNate Lawson * event Licensee exports any such software from the United States or 10553289f6aSNate Lawson * re-exports any such software from a foreign destination, Licensee shall 10653289f6aSNate Lawson * ensure that the distribution and export/re-export of the software is in 10753289f6aSNate Lawson * compliance with all laws, regulations, orders, or other restrictions of the 10853289f6aSNate Lawson * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10953289f6aSNate Lawson * any of its subsidiaries will export/re-export any technical data, process, 11053289f6aSNate Lawson * software, or service, directly or indirectly, to any country for which the 11153289f6aSNate Lawson * United States government or any agency thereof requires an export license, 11253289f6aSNate Lawson * other governmental approval, or letter of assurance, without first obtaining 11353289f6aSNate Lawson * such license, approval or letter. 11453289f6aSNate Lawson * 11553289f6aSNate Lawson *****************************************************************************/ 11653289f6aSNate Lawson 11753289f6aSNate Lawson #define __ASLLOAD_C__ 11853289f6aSNate Lawson 119fba7fc7eSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 120fba7fc7eSJung-uk Kim #include <contrib/dev/acpica/amlcode.h> 121fba7fc7eSJung-uk Kim #include <contrib/dev/acpica/acdispat.h> 122fba7fc7eSJung-uk Kim #include <contrib/dev/acpica/acnamesp.h> 12353289f6aSNate Lawson 12453289f6aSNate Lawson #include "aslcompiler.y.h" 12553289f6aSNate Lawson 12653289f6aSNate Lawson #define _COMPONENT ACPI_COMPILER 12753289f6aSNate Lawson ACPI_MODULE_NAME ("aslload") 12853289f6aSNate Lawson 129fba7fc7eSJung-uk Kim /* Local prototypes */ 130fba7fc7eSJung-uk Kim 131fba7fc7eSJung-uk Kim static ACPI_STATUS 132fba7fc7eSJung-uk Kim LdLoadFieldElements ( 133fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 134fba7fc7eSJung-uk Kim ACPI_WALK_STATE *WalkState); 135fba7fc7eSJung-uk Kim 136fba7fc7eSJung-uk Kim static ACPI_STATUS 137fba7fc7eSJung-uk Kim LdLoadResourceElements ( 138fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 139fba7fc7eSJung-uk Kim ACPI_WALK_STATE *WalkState); 140fba7fc7eSJung-uk Kim 141fba7fc7eSJung-uk Kim static ACPI_STATUS 142fba7fc7eSJung-uk Kim LdNamespace1Begin ( 143fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 144fba7fc7eSJung-uk Kim UINT32 Level, 145fba7fc7eSJung-uk Kim void *Context); 146fba7fc7eSJung-uk Kim 147fba7fc7eSJung-uk Kim static ACPI_STATUS 148fba7fc7eSJung-uk Kim LdNamespace1End ( 149fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 150fba7fc7eSJung-uk Kim UINT32 Level, 151fba7fc7eSJung-uk Kim void *Context); 152fba7fc7eSJung-uk Kim 15353289f6aSNate Lawson 15453289f6aSNate Lawson /******************************************************************************* 15553289f6aSNate Lawson * 15653289f6aSNate Lawson * FUNCTION: LdLoadNamespace 15753289f6aSNate Lawson * 158fba7fc7eSJung-uk Kim * PARAMETERS: RootOp - Root of the parse tree 15953289f6aSNate Lawson * 16053289f6aSNate Lawson * RETURN: Status 16153289f6aSNate Lawson * 16253289f6aSNate Lawson * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the 16353289f6aSNate Lawson * named ASL/AML objects into the namespace. The namespace is 16453289f6aSNate Lawson * constructed in order to resolve named references and references 16553289f6aSNate Lawson * to named fields within resource templates/descriptors. 16653289f6aSNate Lawson * 16753289f6aSNate Lawson ******************************************************************************/ 16853289f6aSNate Lawson 16953289f6aSNate Lawson ACPI_STATUS 17053289f6aSNate Lawson LdLoadNamespace ( 17153289f6aSNate Lawson ACPI_PARSE_OBJECT *RootOp) 17253289f6aSNate Lawson { 17353289f6aSNate Lawson ACPI_WALK_STATE *WalkState; 17453289f6aSNate Lawson 17553289f6aSNate Lawson 17653289f6aSNate Lawson DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n"); 17753289f6aSNate Lawson 17853289f6aSNate Lawson /* Create a new walk state */ 17953289f6aSNate Lawson 18053289f6aSNate Lawson WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 18153289f6aSNate Lawson if (!WalkState) 18253289f6aSNate Lawson { 18353289f6aSNate Lawson return AE_NO_MEMORY; 18453289f6aSNate Lawson } 18553289f6aSNate Lawson 18653289f6aSNate Lawson /* Perform the walk of the parse tree */ 18753289f6aSNate Lawson 18853289f6aSNate Lawson TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, 18953289f6aSNate Lawson LdNamespace1End, WalkState); 19053289f6aSNate Lawson 19153289f6aSNate Lawson /* Dump the namespace if debug is enabled */ 19253289f6aSNate Lawson 19353289f6aSNate Lawson AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); 19453289f6aSNate Lawson return AE_OK; 19553289f6aSNate Lawson } 19653289f6aSNate Lawson 19753289f6aSNate Lawson 19853289f6aSNate Lawson /******************************************************************************* 19953289f6aSNate Lawson * 20053289f6aSNate Lawson * FUNCTION: LdLoadFieldElements 20153289f6aSNate Lawson * 20253289f6aSNate Lawson * PARAMETERS: Op - Parent node (Field) 20353289f6aSNate Lawson * WalkState - Current walk state 20453289f6aSNate Lawson * 20553289f6aSNate Lawson * RETURN: Status 20653289f6aSNate Lawson * 20753289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the field (children of the parent) 20853289f6aSNate Lawson * into the namespace. 20953289f6aSNate Lawson * 21053289f6aSNate Lawson ******************************************************************************/ 21153289f6aSNate Lawson 212fba7fc7eSJung-uk Kim static ACPI_STATUS 21353289f6aSNate Lawson LdLoadFieldElements ( 21453289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 21553289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 21653289f6aSNate Lawson { 21753289f6aSNate Lawson ACPI_PARSE_OBJECT *Child = NULL; 21853289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 21953289f6aSNate Lawson ACPI_STATUS Status; 22053289f6aSNate Lawson 22153289f6aSNate Lawson 22253289f6aSNate Lawson /* Get the first named field element */ 22353289f6aSNate Lawson 22453289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 22553289f6aSNate Lawson { 22653289f6aSNate Lawson case AML_BANK_FIELD_OP: 22753289f6aSNate Lawson 22853289f6aSNate Lawson Child = UtGetArg (Op, 6); 22953289f6aSNate Lawson break; 23053289f6aSNate Lawson 23153289f6aSNate Lawson case AML_INDEX_FIELD_OP: 23253289f6aSNate Lawson 23353289f6aSNate Lawson Child = UtGetArg (Op, 5); 23453289f6aSNate Lawson break; 23553289f6aSNate Lawson 23653289f6aSNate Lawson case AML_FIELD_OP: 23753289f6aSNate Lawson 23853289f6aSNate Lawson Child = UtGetArg (Op, 4); 23953289f6aSNate Lawson break; 24053289f6aSNate Lawson 24153289f6aSNate Lawson default: 24253289f6aSNate Lawson /* No other opcodes should arrive here */ 24353289f6aSNate Lawson return (AE_BAD_PARAMETER); 24453289f6aSNate Lawson } 24553289f6aSNate Lawson 24653289f6aSNate Lawson /* Enter all elements into the namespace */ 24753289f6aSNate Lawson 24853289f6aSNate Lawson while (Child) 24953289f6aSNate Lawson { 25053289f6aSNate Lawson switch (Child->Asl.AmlOpcode) 25153289f6aSNate Lawson { 25253289f6aSNate Lawson case AML_INT_RESERVEDFIELD_OP: 25353289f6aSNate Lawson case AML_INT_ACCESSFIELD_OP: 25453289f6aSNate Lawson 25553289f6aSNate Lawson break; 25653289f6aSNate Lawson 25753289f6aSNate Lawson default: 25853289f6aSNate Lawson 259fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, 260fba7fc7eSJung-uk Kim Child->Asl.Value.String, 261fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_REGION_FIELD, 262fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 263fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 264fba7fc7eSJung-uk Kim ACPI_NS_ERROR_IF_FOUND, 26553289f6aSNate Lawson NULL, &Node); 26653289f6aSNate Lawson if (ACPI_FAILURE (Status)) 26753289f6aSNate Lawson { 26853289f6aSNate Lawson if (Status != AE_ALREADY_EXISTS) 26953289f6aSNate Lawson { 270fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child, 271fba7fc7eSJung-uk Kim Child->Asl.Value.String); 27253289f6aSNate Lawson return (Status); 27353289f6aSNate Lawson } 27453289f6aSNate Lawson 27553289f6aSNate Lawson /* 27653289f6aSNate Lawson * The name already exists in this scope 27753289f6aSNate Lawson * But continue processing the elements 27853289f6aSNate Lawson */ 279fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, 280fba7fc7eSJung-uk Kim Child->Asl.Value.String); 28153289f6aSNate Lawson } 28253289f6aSNate Lawson else 28353289f6aSNate Lawson { 28453289f6aSNate Lawson Child->Asl.Node = Node; 285fba7fc7eSJung-uk Kim Node->Op = Child; 28653289f6aSNate Lawson } 28753289f6aSNate Lawson break; 28853289f6aSNate Lawson } 28953289f6aSNate Lawson Child = Child->Asl.Next; 29053289f6aSNate Lawson } 29153289f6aSNate Lawson return (AE_OK); 29253289f6aSNate Lawson } 29353289f6aSNate Lawson 29453289f6aSNate Lawson 29553289f6aSNate Lawson /******************************************************************************* 29653289f6aSNate Lawson * 29753289f6aSNate Lawson * FUNCTION: LdLoadResourceElements 29853289f6aSNate Lawson * 29953289f6aSNate Lawson * PARAMETERS: Op - Parent node (Resource Descriptor) 30053289f6aSNate Lawson * WalkState - Current walk state 30153289f6aSNate Lawson * 30253289f6aSNate Lawson * RETURN: Status 30353289f6aSNate Lawson * 30453289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the resource descriptor (children 30553289f6aSNate Lawson * of the parent) into the namespace. 30653289f6aSNate Lawson * 30753289f6aSNate Lawson * NOTE: In the real AML namespace, these named elements never exist. But 30853289f6aSNate Lawson * we simply use the namespace here as a symbol table so we can look 30953289f6aSNate Lawson * them up as they are referenced. 31053289f6aSNate Lawson * 31153289f6aSNate Lawson ******************************************************************************/ 31253289f6aSNate Lawson 313fba7fc7eSJung-uk Kim static ACPI_STATUS 31453289f6aSNate Lawson LdLoadResourceElements ( 31553289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 31653289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 31753289f6aSNate Lawson { 31853289f6aSNate Lawson ACPI_PARSE_OBJECT *InitializerOp = NULL; 31953289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 32053289f6aSNate Lawson ACPI_STATUS Status; 32153289f6aSNate Lawson 32253289f6aSNate Lawson 32353289f6aSNate Lawson /* 324fba7fc7eSJung-uk Kim * Enter the resource name into the namespace. Name must not already exist. 325fba7fc7eSJung-uk Kim * This opens a scope, so later field names are guaranteed to be new/unique. 32653289f6aSNate Lawson */ 32753289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, 328fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, 329fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, 33053289f6aSNate Lawson WalkState, &Node); 33153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 33253289f6aSNate Lawson { 333fba7fc7eSJung-uk Kim if (Status == AE_ALREADY_EXISTS) 334fba7fc7eSJung-uk Kim { 335fba7fc7eSJung-uk Kim /* Actual node causing the error was saved in ParentMethod */ 336fba7fc7eSJung-uk Kim 337fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, 338fba7fc7eSJung-uk Kim (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, Op->Asl.Namepath); 339fba7fc7eSJung-uk Kim return (AE_OK); 340fba7fc7eSJung-uk Kim } 34153289f6aSNate Lawson return (Status); 34253289f6aSNate Lawson } 34353289f6aSNate Lawson 344*1a39cfb0SJung-uk Kim Node->Value = (UINT32) Op->Asl.Value.Integer; 345*1a39cfb0SJung-uk Kim Node->Op = Op; 346*1a39cfb0SJung-uk Kim 34753289f6aSNate Lawson /* 34853289f6aSNate Lawson * Now enter the predefined fields, for easy lookup when referenced 34953289f6aSNate Lawson * by the source ASL 35053289f6aSNate Lawson */ 35153289f6aSNate Lawson InitializerOp = ASL_GET_CHILD_NODE (Op); 35253289f6aSNate Lawson while (InitializerOp) 35353289f6aSNate Lawson { 35453289f6aSNate Lawson 35553289f6aSNate Lawson if (InitializerOp->Asl.ExternalName) 35653289f6aSNate Lawson { 35753289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, 35853289f6aSNate Lawson InitializerOp->Asl.ExternalName, 35953289f6aSNate Lawson ACPI_TYPE_LOCAL_RESOURCE_FIELD, 360fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 361fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, 36253289f6aSNate Lawson NULL, &Node); 36353289f6aSNate Lawson if (ACPI_FAILURE (Status)) 36453289f6aSNate Lawson { 36553289f6aSNate Lawson return (Status); 36653289f6aSNate Lawson } 36753289f6aSNate Lawson 36853289f6aSNate Lawson /* 36953289f6aSNate Lawson * Store the field offset in the namespace node so it 37053289f6aSNate Lawson * can be used when the field is referenced 37153289f6aSNate Lawson */ 372fba7fc7eSJung-uk Kim Node->Value = (UINT32) InitializerOp->Asl.Value.Integer; 37353289f6aSNate Lawson InitializerOp->Asl.Node = Node; 374fba7fc7eSJung-uk Kim Node->Op = InitializerOp; 37553289f6aSNate Lawson 37653289f6aSNate Lawson /* Pass thru the field type (Bitfield or Bytefield) */ 37753289f6aSNate Lawson 37853289f6aSNate Lawson if (InitializerOp->Asl.CompileFlags & NODE_IS_BIT_OFFSET) 37953289f6aSNate Lawson { 38053289f6aSNate Lawson Node->Flags |= ANOBJ_IS_BIT_OFFSET; 38153289f6aSNate Lawson } 38253289f6aSNate Lawson } 38353289f6aSNate Lawson InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 38453289f6aSNate Lawson } 38553289f6aSNate Lawson 38653289f6aSNate Lawson return (AE_OK); 38753289f6aSNate Lawson } 38853289f6aSNate Lawson 38953289f6aSNate Lawson 39053289f6aSNate Lawson /******************************************************************************* 39153289f6aSNate Lawson * 39253289f6aSNate Lawson * FUNCTION: LdNamespace1Begin 39353289f6aSNate Lawson * 39453289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 39553289f6aSNate Lawson * 39653289f6aSNate Lawson * RETURN: Status 39753289f6aSNate Lawson * 39853289f6aSNate Lawson * DESCRIPTION: Descending callback used during the parse tree walk. If this 39953289f6aSNate Lawson * is a named AML opcode, enter into the namespace 40053289f6aSNate Lawson * 40153289f6aSNate Lawson ******************************************************************************/ 40253289f6aSNate Lawson 403fba7fc7eSJung-uk Kim static ACPI_STATUS 40453289f6aSNate Lawson LdNamespace1Begin ( 40553289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 40653289f6aSNate Lawson UINT32 Level, 40753289f6aSNate Lawson void *Context) 40853289f6aSNate Lawson { 40953289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 41053289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 41153289f6aSNate Lawson ACPI_STATUS Status; 41253289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 41353289f6aSNate Lawson ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; 41453289f6aSNate Lawson char *Path; 41553289f6aSNate Lawson UINT32 Flags = ACPI_NS_NO_UPSEARCH; 41653289f6aSNate Lawson ACPI_PARSE_OBJECT *Arg; 41753289f6aSNate Lawson UINT32 i; 418*1a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 41953289f6aSNate Lawson 42053289f6aSNate Lawson 421*1a39cfb0SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace1Begin); 42253289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 42353289f6aSNate Lawson Op, Op->Asl.ParseOpName)); 42453289f6aSNate Lawson 42553289f6aSNate Lawson 42653289f6aSNate Lawson /* 42753289f6aSNate Lawson * We are only interested in opcodes that have an associated name 42853289f6aSNate Lawson * (or multiple names) 42953289f6aSNate Lawson */ 43053289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 43153289f6aSNate Lawson { 43253289f6aSNate Lawson case AML_BANK_FIELD_OP: 43353289f6aSNate Lawson case AML_INDEX_FIELD_OP: 43453289f6aSNate Lawson case AML_FIELD_OP: 43553289f6aSNate Lawson 43653289f6aSNate Lawson Status = LdLoadFieldElements (Op, WalkState); 43753289f6aSNate Lawson return (Status); 43853289f6aSNate Lawson 43953289f6aSNate Lawson default: 44053289f6aSNate Lawson 44153289f6aSNate Lawson /* All other opcodes go below */ 44253289f6aSNate Lawson break; 44353289f6aSNate Lawson } 44453289f6aSNate Lawson 44553289f6aSNate Lawson /* Check if this object has already been installed in the namespace */ 44653289f6aSNate Lawson 44753289f6aSNate Lawson if (Op->Asl.Node) 44853289f6aSNate Lawson { 44953289f6aSNate Lawson return (AE_OK); 45053289f6aSNate Lawson } 45153289f6aSNate Lawson 45253289f6aSNate Lawson Path = Op->Asl.Namepath; 45353289f6aSNate Lawson if (!Path) 45453289f6aSNate Lawson { 45553289f6aSNate Lawson return (AE_OK); 45653289f6aSNate Lawson } 45753289f6aSNate Lawson 45853289f6aSNate Lawson /* Map the raw opcode into an internal object type */ 45953289f6aSNate Lawson 46053289f6aSNate Lawson switch (Op->Asl.ParseOpcode) 46153289f6aSNate Lawson { 46253289f6aSNate Lawson case PARSEOP_NAME: 46353289f6aSNate Lawson 46453289f6aSNate Lawson Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ 46553289f6aSNate Lawson Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ 46653289f6aSNate Lawson 467*1a39cfb0SJung-uk Kim /* 468*1a39cfb0SJung-uk Kim * If this name refers to a ResourceTemplate, we will need to open 469*1a39cfb0SJung-uk Kim * a new scope so that the resource subfield names can be entered into 470*1a39cfb0SJung-uk Kim * the namespace underneath this name 471*1a39cfb0SJung-uk Kim */ 472*1a39cfb0SJung-uk Kim if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) 473*1a39cfb0SJung-uk Kim { 474*1a39cfb0SJung-uk Kim ForceNewScope = TRUE; 475*1a39cfb0SJung-uk Kim } 476*1a39cfb0SJung-uk Kim 47753289f6aSNate Lawson /* Get the data type associated with the named object, not the name itself */ 47853289f6aSNate Lawson 47953289f6aSNate Lawson /* Log2 loop to convert from Btype (binary) to Etype (encoded) */ 48053289f6aSNate Lawson 48153289f6aSNate Lawson ObjectType = 1; 48253289f6aSNate Lawson for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2) 48353289f6aSNate Lawson { 48453289f6aSNate Lawson ObjectType++; 48553289f6aSNate Lawson } 48653289f6aSNate Lawson break; 48753289f6aSNate Lawson 48853289f6aSNate Lawson 48953289f6aSNate Lawson case PARSEOP_EXTERNAL: 49053289f6aSNate Lawson 49153289f6aSNate Lawson /* 49253289f6aSNate Lawson * "External" simply enters a name and type into the namespace. 49353289f6aSNate Lawson * We must be careful to not open a new scope, however, no matter 49453289f6aSNate Lawson * what type the external name refers to (e.g., a method) 49553289f6aSNate Lawson * 49653289f6aSNate Lawson * first child is name, next child is ObjectType 49753289f6aSNate Lawson */ 49853289f6aSNate Lawson ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; 49953289f6aSNate Lawson ObjectType = ACPI_TYPE_ANY; 50053289f6aSNate Lawson 501*1a39cfb0SJung-uk Kim /* 502*1a39cfb0SJung-uk Kim * We will mark every new node along the path as "External". This 503*1a39cfb0SJung-uk Kim * allows some or all of the nodes to be created later in the ASL 504*1a39cfb0SJung-uk Kim * code. Handles cases like this: 505*1a39cfb0SJung-uk Kim * 506*1a39cfb0SJung-uk Kim * External (\_SB_.PCI0.ABCD, IntObj) 507*1a39cfb0SJung-uk Kim * Scope (_SB_) 508*1a39cfb0SJung-uk Kim * { 509*1a39cfb0SJung-uk Kim * Device (PCI0) 510*1a39cfb0SJung-uk Kim * { 511*1a39cfb0SJung-uk Kim * } 512*1a39cfb0SJung-uk Kim * } 513*1a39cfb0SJung-uk Kim * Method (X) 514*1a39cfb0SJung-uk Kim * { 515*1a39cfb0SJung-uk Kim * Store (\_SB_.PCI0.ABCD, Local0) 516*1a39cfb0SJung-uk Kim * } 517*1a39cfb0SJung-uk Kim */ 518*1a39cfb0SJung-uk Kim Flags |= ACPI_NS_EXTERNAL; 519*1a39cfb0SJung-uk Kim break; 52053289f6aSNate Lawson 52153289f6aSNate Lawson case PARSEOP_DEFAULT_ARG: 52253289f6aSNate Lawson 52353289f6aSNate Lawson if (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC) 52453289f6aSNate Lawson { 52553289f6aSNate Lawson Status = LdLoadResourceElements (Op, WalkState); 52653289f6aSNate Lawson goto Exit; 52753289f6aSNate Lawson } 52853289f6aSNate Lawson 52953289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 53053289f6aSNate Lawson break; 53153289f6aSNate Lawson 53253289f6aSNate Lawson 53353289f6aSNate Lawson case PARSEOP_SCOPE: 53453289f6aSNate Lawson 53553289f6aSNate Lawson /* 53653289f6aSNate Lawson * The name referenced by Scope(Name) must already exist at this point. 53753289f6aSNate Lawson * In other words, forward references for Scope() are not supported. 53853289f6aSNate Lawson * The only real reason for this is that the MS interpreter cannot 53953289f6aSNate Lawson * handle this case. Perhaps someday this case can go away. 54053289f6aSNate Lawson */ 54153289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 542fba7fc7eSJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 543fba7fc7eSJung-uk Kim WalkState, &(Node)); 54453289f6aSNate Lawson if (ACPI_FAILURE (Status)) 54553289f6aSNate Lawson { 54653289f6aSNate Lawson if (Status == AE_NOT_FOUND) 54753289f6aSNate Lawson { 54853289f6aSNate Lawson /* The name was not found, go ahead and create it */ 54953289f6aSNate Lawson 550fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 551fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_SCOPE, 552fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, 553fba7fc7eSJung-uk Kim WalkState, &(Node)); 55453289f6aSNate Lawson 55553289f6aSNate Lawson /* 55653289f6aSNate Lawson * However, this is an error -- primarily because the MS 55753289f6aSNate Lawson * interpreter can't handle a forward reference from the 55853289f6aSNate Lawson * Scope() operator. 55953289f6aSNate Lawson */ 560fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 561fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 562fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, 563fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 56453289f6aSNate Lawson goto FinishNode; 56553289f6aSNate Lawson } 56653289f6aSNate Lawson 56753289f6aSNate Lawson AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE); 56853289f6aSNate Lawson goto Exit; 56953289f6aSNate Lawson } 57053289f6aSNate Lawson 57153289f6aSNate Lawson /* We found a node with this name, now check the type */ 57253289f6aSNate Lawson 57353289f6aSNate Lawson switch (Node->Type) 57453289f6aSNate Lawson { 57553289f6aSNate Lawson case ACPI_TYPE_LOCAL_SCOPE: 57653289f6aSNate Lawson case ACPI_TYPE_DEVICE: 57753289f6aSNate Lawson case ACPI_TYPE_POWER: 57853289f6aSNate Lawson case ACPI_TYPE_PROCESSOR: 57953289f6aSNate Lawson case ACPI_TYPE_THERMAL: 58053289f6aSNate Lawson 58153289f6aSNate Lawson /* These are acceptable types - they all open a new scope */ 58253289f6aSNate Lawson break; 58353289f6aSNate Lawson 58453289f6aSNate Lawson case ACPI_TYPE_INTEGER: 58553289f6aSNate Lawson case ACPI_TYPE_STRING: 58653289f6aSNate Lawson case ACPI_TYPE_BUFFER: 58753289f6aSNate Lawson 58853289f6aSNate Lawson /* 589fba7fc7eSJung-uk Kim * These types we will allow, but we will change the type. 590fba7fc7eSJung-uk Kim * This enables some existing code of the form: 59153289f6aSNate Lawson * 59253289f6aSNate Lawson * Name (DEB, 0) 59353289f6aSNate Lawson * Scope (DEB) { ... } 59453289f6aSNate Lawson * 59553289f6aSNate Lawson * Which is used to workaround the fact that the MS interpreter 59653289f6aSNate Lawson * does not allow Scope() forward references. 59753289f6aSNate Lawson */ 598e0ef747bSNate Lawson sprintf (MsgBuffer, "%s [%s], changing type to [Scope]", 59953289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 60053289f6aSNate Lawson AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 60153289f6aSNate Lawson 602fba7fc7eSJung-uk Kim /* Switch the type to scope, open the new scope */ 603fba7fc7eSJung-uk Kim 604e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 605fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 606fba7fc7eSJung-uk Kim WalkState); 607e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 608e0ef747bSNate Lawson { 609e0ef747bSNate Lawson return_ACPI_STATUS (Status); 610e0ef747bSNate Lawson } 61153289f6aSNate Lawson break; 61253289f6aSNate Lawson 61353289f6aSNate Lawson default: 61453289f6aSNate Lawson 615fba7fc7eSJung-uk Kim /* All other types are an error */ 616fba7fc7eSJung-uk Kim 617fba7fc7eSJung-uk Kim sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 618fba7fc7eSJung-uk Kim AcpiUtGetTypeName (Node->Type)); 61953289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 62053289f6aSNate Lawson 62153289f6aSNate Lawson /* 62253289f6aSNate Lawson * However, switch the type to be an actual scope so 62353289f6aSNate Lawson * that compilation can continue without generating a whole 624e0ef747bSNate Lawson * cascade of additional errors. Open the new scope. 62553289f6aSNate Lawson */ 626e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 627fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 628fba7fc7eSJung-uk Kim WalkState); 629e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 630e0ef747bSNate Lawson { 631e0ef747bSNate Lawson return_ACPI_STATUS (Status); 632e0ef747bSNate Lawson } 63353289f6aSNate Lawson break; 63453289f6aSNate Lawson } 63553289f6aSNate Lawson 63653289f6aSNate Lawson Status = AE_OK; 63753289f6aSNate Lawson goto FinishNode; 63853289f6aSNate Lawson 63953289f6aSNate Lawson 64053289f6aSNate Lawson default: 64153289f6aSNate Lawson 64253289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 64353289f6aSNate Lawson break; 64453289f6aSNate Lawson } 64553289f6aSNate Lawson 64653289f6aSNate Lawson 64753289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", 64853289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); 64953289f6aSNate Lawson 65053289f6aSNate Lawson /* The name must not already exist */ 65153289f6aSNate Lawson 65253289f6aSNate Lawson Flags |= ACPI_NS_ERROR_IF_FOUND; 65353289f6aSNate Lawson 65453289f6aSNate Lawson /* 65553289f6aSNate Lawson * Enter the named type into the internal namespace. We enter the name 656fba7fc7eSJung-uk Kim * as we go downward in the parse tree. Any necessary subobjects that 657fba7fc7eSJung-uk Kim * involve arguments to the opcode must be created as we go back up the 658fba7fc7eSJung-uk Kim * parse tree later. 65953289f6aSNate Lawson */ 66053289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 661*1a39cfb0SJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 66253289f6aSNate Lawson if (ACPI_FAILURE (Status)) 66353289f6aSNate Lawson { 66453289f6aSNate Lawson if (Status == AE_ALREADY_EXISTS) 66553289f6aSNate Lawson { 66653289f6aSNate Lawson /* The name already exists in this scope */ 66753289f6aSNate Lawson 66853289f6aSNate Lawson if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 66953289f6aSNate Lawson { 670*1a39cfb0SJung-uk Kim /* Allow multiple references to the same scope */ 671*1a39cfb0SJung-uk Kim 67253289f6aSNate Lawson Node->Type = (UINT8) ObjectType; 67353289f6aSNate Lawson Status = AE_OK; 67453289f6aSNate Lawson } 675*1a39cfb0SJung-uk Kim else if (Node->Flags & ANOBJ_IS_EXTERNAL) 676*1a39cfb0SJung-uk Kim { 677*1a39cfb0SJung-uk Kim /* 678*1a39cfb0SJung-uk Kim * Allow one create on an object or segment that was 679*1a39cfb0SJung-uk Kim * previously declared External 680*1a39cfb0SJung-uk Kim */ 681*1a39cfb0SJung-uk Kim Node->Flags &= ~ANOBJ_IS_EXTERNAL; 682*1a39cfb0SJung-uk Kim Node->Type = (UINT8) ObjectType; 683*1a39cfb0SJung-uk Kim 684*1a39cfb0SJung-uk Kim /* Just retyped a node, probably will need to open a scope */ 685*1a39cfb0SJung-uk Kim 686*1a39cfb0SJung-uk Kim if (AcpiNsOpensScope (ObjectType)) 687*1a39cfb0SJung-uk Kim { 688*1a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 689*1a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 690*1a39cfb0SJung-uk Kim { 691*1a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 692*1a39cfb0SJung-uk Kim } 693*1a39cfb0SJung-uk Kim } 694*1a39cfb0SJung-uk Kim Status = AE_OK; 695*1a39cfb0SJung-uk Kim } 69653289f6aSNate Lawson else 69753289f6aSNate Lawson { 698*1a39cfb0SJung-uk Kim /* Valid error, object already exists */ 699*1a39cfb0SJung-uk Kim 700fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, 701fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 70253289f6aSNate Lawson Status = AE_OK; 70353289f6aSNate Lawson goto Exit; 70453289f6aSNate Lawson } 70553289f6aSNate Lawson } 70653289f6aSNate Lawson else 70753289f6aSNate Lawson { 708fba7fc7eSJung-uk Kim AslCoreSubsystemError (Op, Status, 709fba7fc7eSJung-uk Kim "Failure from lookup %s\n", FALSE); 71053289f6aSNate Lawson goto Exit; 71153289f6aSNate Lawson } 71253289f6aSNate Lawson } 71353289f6aSNate Lawson 714*1a39cfb0SJung-uk Kim if (ForceNewScope) 715*1a39cfb0SJung-uk Kim { 716*1a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 717*1a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 718*1a39cfb0SJung-uk Kim { 719*1a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 720*1a39cfb0SJung-uk Kim } 721*1a39cfb0SJung-uk Kim } 72253289f6aSNate Lawson 72353289f6aSNate Lawson FinishNode: 72453289f6aSNate Lawson /* 72553289f6aSNate Lawson * Point the parse node to the new namespace node, and point 72653289f6aSNate Lawson * the Node back to the original Parse node 72753289f6aSNate Lawson */ 72853289f6aSNate Lawson Op->Asl.Node = Node; 729fba7fc7eSJung-uk Kim Node->Op = Op; 73053289f6aSNate Lawson 73153289f6aSNate Lawson /* Set the actual data type if appropriate (EXTERNAL term only) */ 73253289f6aSNate Lawson 73353289f6aSNate Lawson if (ActualObjectType != ACPI_TYPE_ANY) 73453289f6aSNate Lawson { 73553289f6aSNate Lawson Node->Type = (UINT8) ActualObjectType; 736fba7fc7eSJung-uk Kim Node->Value = ASL_EXTERNAL_METHOD; 73753289f6aSNate Lawson } 73853289f6aSNate Lawson 73953289f6aSNate Lawson if (Op->Asl.ParseOpcode == PARSEOP_METHOD) 74053289f6aSNate Lawson { 74153289f6aSNate Lawson /* 742fba7fc7eSJung-uk Kim * Get the method argument count from "Extra" and save 743fba7fc7eSJung-uk Kim * it in the namespace node 74453289f6aSNate Lawson */ 745fba7fc7eSJung-uk Kim Node->Value = (UINT32) Op->Asl.Extra; 74653289f6aSNate Lawson } 74753289f6aSNate Lawson 74853289f6aSNate Lawson Exit: 74953289f6aSNate Lawson return (Status); 75053289f6aSNate Lawson } 75153289f6aSNate Lawson 75253289f6aSNate Lawson 75353289f6aSNate Lawson /******************************************************************************* 75453289f6aSNate Lawson * 75553289f6aSNate Lawson * FUNCTION: LdNamespace1End 75653289f6aSNate Lawson * 75753289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 75853289f6aSNate Lawson * 75953289f6aSNate Lawson * RETURN: Status 76053289f6aSNate Lawson * 76153289f6aSNate Lawson * DESCRIPTION: Ascending callback used during the loading of the namespace, 76253289f6aSNate Lawson * We only need to worry about managing the scope stack here. 76353289f6aSNate Lawson * 76453289f6aSNate Lawson ******************************************************************************/ 76553289f6aSNate Lawson 766fba7fc7eSJung-uk Kim static ACPI_STATUS 76753289f6aSNate Lawson LdNamespace1End ( 76853289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 76953289f6aSNate Lawson UINT32 Level, 77053289f6aSNate Lawson void *Context) 77153289f6aSNate Lawson { 77253289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 77353289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 774*1a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 77553289f6aSNate Lawson 77653289f6aSNate Lawson 777*1a39cfb0SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace1End); 77853289f6aSNate Lawson 77953289f6aSNate Lawson 78053289f6aSNate Lawson /* We are only interested in opcodes that have an associated name */ 78153289f6aSNate Lawson 78253289f6aSNate Lawson if (!Op->Asl.Namepath) 78353289f6aSNate Lawson { 78453289f6aSNate Lawson return (AE_OK); 78553289f6aSNate Lawson } 78653289f6aSNate Lawson 78753289f6aSNate Lawson /* Get the type to determine if we should pop the scope */ 78853289f6aSNate Lawson 78953289f6aSNate Lawson if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 79053289f6aSNate Lawson (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)) 79153289f6aSNate Lawson { 79253289f6aSNate Lawson /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */ 79353289f6aSNate Lawson 79453289f6aSNate Lawson ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 79553289f6aSNate Lawson } 79653289f6aSNate Lawson else 79753289f6aSNate Lawson { 79853289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 79953289f6aSNate Lawson } 80053289f6aSNate Lawson 801*1a39cfb0SJung-uk Kim /* Pop scope that was pushed for Resource Templates */ 802*1a39cfb0SJung-uk Kim 803*1a39cfb0SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 804*1a39cfb0SJung-uk Kim { 805*1a39cfb0SJung-uk Kim if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) 806*1a39cfb0SJung-uk Kim { 807*1a39cfb0SJung-uk Kim ForceNewScope = TRUE; 808*1a39cfb0SJung-uk Kim } 809*1a39cfb0SJung-uk Kim } 810*1a39cfb0SJung-uk Kim 81153289f6aSNate Lawson /* Pop the scope stack */ 81253289f6aSNate Lawson 813*1a39cfb0SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 81453289f6aSNate Lawson { 81553289f6aSNate Lawson 81653289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 81753289f6aSNate Lawson "(%s): Popping scope for Op [%s] %p\n", 81853289f6aSNate Lawson AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); 81953289f6aSNate Lawson 820fba7fc7eSJung-uk Kim (void) AcpiDsScopeStackPop (WalkState); 82153289f6aSNate Lawson } 82253289f6aSNate Lawson 82353289f6aSNate Lawson return (AE_OK); 82453289f6aSNate Lawson } 82553289f6aSNate Lawson 82653289f6aSNate Lawson 827