153289f6aSNate Lawson /****************************************************************************** 253289f6aSNate Lawson * 353289f6aSNate Lawson * Module Name: dswload - Dispatcher namespace load callbacks 453289f6aSNate Lawson * 553289f6aSNate Lawson *****************************************************************************/ 653289f6aSNate Lawson 753289f6aSNate Lawson /****************************************************************************** 853289f6aSNate Lawson * 953289f6aSNate Lawson * 1. Copyright Notice 1053289f6aSNate Lawson * 11*9a179dd8SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 1253289f6aSNate Lawson * All rights reserved. 1353289f6aSNate Lawson * 1453289f6aSNate Lawson * 2. License 1553289f6aSNate Lawson * 1653289f6aSNate Lawson * 2.1. This is your license from Intel Corp. under its intellectual property 1753289f6aSNate Lawson * rights. You may have additional license terms from the party that provided 1853289f6aSNate Lawson * you this software, covering your right to use that party's intellectual 1953289f6aSNate Lawson * property rights. 2053289f6aSNate Lawson * 2153289f6aSNate Lawson * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2253289f6aSNate Lawson * copy of the source code appearing in this file ("Covered Code") an 2353289f6aSNate Lawson * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2453289f6aSNate Lawson * base code distributed originally by Intel ("Original Intel Code") to copy, 2553289f6aSNate Lawson * make derivatives, distribute, use and display any portion of the Covered 2653289f6aSNate Lawson * Code in any form, with the right to sublicense such rights; and 2753289f6aSNate Lawson * 2853289f6aSNate Lawson * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 2953289f6aSNate Lawson * license (with the right to sublicense), under only those claims of Intel 3053289f6aSNate Lawson * patents that are infringed by the Original Intel Code, to make, use, sell, 3153289f6aSNate Lawson * offer to sell, and import the Covered Code and derivative works thereof 3253289f6aSNate Lawson * solely to the minimum extent necessary to exercise the above copyright 3353289f6aSNate Lawson * license, and in no event shall the patent license extend to any additions 3453289f6aSNate Lawson * to or modifications of the Original Intel Code. No other license or right 3553289f6aSNate Lawson * is granted directly or by implication, estoppel or otherwise; 3653289f6aSNate Lawson * 3753289f6aSNate Lawson * The above copyright and patent license is granted only if the following 3853289f6aSNate Lawson * conditions are met: 3953289f6aSNate Lawson * 4053289f6aSNate Lawson * 3. Conditions 4153289f6aSNate Lawson * 4253289f6aSNate Lawson * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4353289f6aSNate Lawson * Redistribution of source code of any substantial portion of the Covered 4453289f6aSNate Lawson * Code or modification with rights to further distribute source must include 4553289f6aSNate Lawson * the above Copyright Notice, the above License, this list of Conditions, 4653289f6aSNate Lawson * and the following Disclaimer and Export Compliance provision. In addition, 4753289f6aSNate Lawson * Licensee must cause all Covered Code to which Licensee contributes to 4853289f6aSNate Lawson * contain a file documenting the changes Licensee made to create that Covered 4953289f6aSNate Lawson * Code and the date of any change. Licensee must include in that file the 5053289f6aSNate Lawson * documentation of any changes made by any predecessor Licensee. Licensee 5153289f6aSNate Lawson * must include a prominent statement that the modification is derived, 5253289f6aSNate Lawson * directly or indirectly, from Original Intel Code. 5353289f6aSNate Lawson * 5453289f6aSNate Lawson * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5553289f6aSNate Lawson * Redistribution of source code of any substantial portion of the Covered 5653289f6aSNate Lawson * Code or modification without rights to further distribute source must 5753289f6aSNate Lawson * include the following Disclaimer and Export Compliance provision in the 5853289f6aSNate Lawson * documentation and/or other materials provided with distribution. In 5953289f6aSNate Lawson * addition, Licensee may not authorize further sublicense of source of any 6053289f6aSNate Lawson * portion of the Covered Code, and must include terms to the effect that the 6153289f6aSNate Lawson * license from Licensee to its licensee is limited to the intellectual 6253289f6aSNate Lawson * property embodied in the software Licensee provides to its licensee, and 6353289f6aSNate Lawson * not to intellectual property embodied in modifications its licensee may 6453289f6aSNate Lawson * make. 6553289f6aSNate Lawson * 6653289f6aSNate Lawson * 3.3. Redistribution of Executable. Redistribution in executable form of any 6753289f6aSNate Lawson * substantial portion of the Covered Code or modification must reproduce the 6853289f6aSNate Lawson * above Copyright Notice, and the following Disclaimer and Export Compliance 6953289f6aSNate Lawson * provision in the documentation and/or other materials provided with the 7053289f6aSNate Lawson * distribution. 7153289f6aSNate Lawson * 7253289f6aSNate Lawson * 3.4. Intel retains all right, title, and interest in and to the Original 7353289f6aSNate Lawson * Intel Code. 7453289f6aSNate Lawson * 7553289f6aSNate Lawson * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7653289f6aSNate Lawson * Intel shall be used in advertising or otherwise to promote the sale, use or 7753289f6aSNate Lawson * other dealings in products derived from or relating to the Covered Code 7853289f6aSNate Lawson * without prior written authorization from Intel. 7953289f6aSNate Lawson * 8053289f6aSNate Lawson * 4. Disclaimer and Export Compliance 8153289f6aSNate Lawson * 8253289f6aSNate Lawson * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8353289f6aSNate Lawson * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8453289f6aSNate Lawson * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8553289f6aSNate Lawson * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8653289f6aSNate Lawson * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8753289f6aSNate Lawson * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8853289f6aSNate Lawson * PARTICULAR PURPOSE. 8953289f6aSNate Lawson * 9053289f6aSNate Lawson * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9153289f6aSNate Lawson * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9253289f6aSNate Lawson * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9353289f6aSNate Lawson * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9453289f6aSNate Lawson * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9553289f6aSNate Lawson * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9653289f6aSNate Lawson * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9753289f6aSNate Lawson * LIMITED REMEDY. 9853289f6aSNate Lawson * 9953289f6aSNate Lawson * 4.3. Licensee shall not export, either directly or indirectly, any of this 10053289f6aSNate Lawson * software or system incorporating such software without first obtaining any 10153289f6aSNate Lawson * required license or other approval from the U. S. Department of Commerce or 10253289f6aSNate Lawson * any other agency or department of the United States Government. In the 10353289f6aSNate Lawson * event Licensee exports any such software from the United States or 10453289f6aSNate Lawson * re-exports any such software from a foreign destination, Licensee shall 10553289f6aSNate Lawson * ensure that the distribution and export/re-export of the software is in 10653289f6aSNate Lawson * compliance with all laws, regulations, orders, or other restrictions of the 10753289f6aSNate Lawson * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10853289f6aSNate Lawson * any of its subsidiaries will export/re-export any technical data, process, 10953289f6aSNate Lawson * software, or service, directly or indirectly, to any country for which the 11053289f6aSNate Lawson * United States government or any agency thereof requires an export license, 11153289f6aSNate Lawson * other governmental approval, or letter of assurance, without first obtaining 11253289f6aSNate Lawson * such license, approval or letter. 11353289f6aSNate Lawson * 11453289f6aSNate Lawson *****************************************************************************/ 11553289f6aSNate Lawson 11653289f6aSNate Lawson #define __ASLLOAD_C__ 11753289f6aSNate Lawson 118ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 119ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h> 120ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h> 121ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 12253289f6aSNate Lawson 12353289f6aSNate Lawson #include "aslcompiler.y.h" 12453289f6aSNate Lawson 12553289f6aSNate Lawson #define _COMPONENT ACPI_COMPILER 12653289f6aSNate Lawson ACPI_MODULE_NAME ("aslload") 12753289f6aSNate Lawson 128fba7fc7eSJung-uk Kim /* Local prototypes */ 129fba7fc7eSJung-uk Kim 130fba7fc7eSJung-uk Kim static ACPI_STATUS 131fba7fc7eSJung-uk Kim LdLoadFieldElements ( 132fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 133fba7fc7eSJung-uk Kim ACPI_WALK_STATE *WalkState); 134fba7fc7eSJung-uk Kim 135fba7fc7eSJung-uk Kim static ACPI_STATUS 136fba7fc7eSJung-uk Kim LdLoadResourceElements ( 137fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 138fba7fc7eSJung-uk Kim ACPI_WALK_STATE *WalkState); 139fba7fc7eSJung-uk Kim 140fba7fc7eSJung-uk Kim static ACPI_STATUS 141fba7fc7eSJung-uk Kim LdNamespace1Begin ( 142fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 143fba7fc7eSJung-uk Kim UINT32 Level, 144fba7fc7eSJung-uk Kim void *Context); 145fba7fc7eSJung-uk Kim 146fba7fc7eSJung-uk Kim static ACPI_STATUS 147a9f12690SJung-uk Kim LdNamespace2Begin ( 148a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Op, 149a9f12690SJung-uk Kim UINT32 Level, 150a9f12690SJung-uk Kim void *Context); 151a9f12690SJung-uk Kim 152a9f12690SJung-uk Kim static ACPI_STATUS 153a9f12690SJung-uk Kim LdCommonNamespaceEnd ( 154fba7fc7eSJung-uk Kim ACPI_PARSE_OBJECT *Op, 155fba7fc7eSJung-uk Kim UINT32 Level, 156fba7fc7eSJung-uk Kim void *Context); 157fba7fc7eSJung-uk Kim 15853289f6aSNate Lawson 15953289f6aSNate Lawson /******************************************************************************* 16053289f6aSNate Lawson * 16153289f6aSNate Lawson * FUNCTION: LdLoadNamespace 16253289f6aSNate Lawson * 163fba7fc7eSJung-uk Kim * PARAMETERS: RootOp - Root of the parse tree 16453289f6aSNate Lawson * 16553289f6aSNate Lawson * RETURN: Status 16653289f6aSNate Lawson * 16753289f6aSNate Lawson * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the 16853289f6aSNate Lawson * named ASL/AML objects into the namespace. The namespace is 16953289f6aSNate Lawson * constructed in order to resolve named references and references 17053289f6aSNate Lawson * to named fields within resource templates/descriptors. 17153289f6aSNate Lawson * 17253289f6aSNate Lawson ******************************************************************************/ 17353289f6aSNate Lawson 17453289f6aSNate Lawson ACPI_STATUS 17553289f6aSNate Lawson LdLoadNamespace ( 17653289f6aSNate Lawson ACPI_PARSE_OBJECT *RootOp) 17753289f6aSNate Lawson { 17853289f6aSNate Lawson ACPI_WALK_STATE *WalkState; 17953289f6aSNate Lawson 18053289f6aSNate Lawson 18153289f6aSNate Lawson DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n"); 18253289f6aSNate Lawson 18353289f6aSNate Lawson /* Create a new walk state */ 18453289f6aSNate Lawson 18553289f6aSNate Lawson WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 18653289f6aSNate Lawson if (!WalkState) 18753289f6aSNate Lawson { 18853289f6aSNate Lawson return AE_NO_MEMORY; 18953289f6aSNate Lawson } 19053289f6aSNate Lawson 191a9f12690SJung-uk Kim /* Walk the entire parse tree, first pass */ 19253289f6aSNate Lawson 19353289f6aSNate Lawson TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, 194a9f12690SJung-uk Kim LdCommonNamespaceEnd, WalkState); 195a9f12690SJung-uk Kim 196a9f12690SJung-uk Kim /* Second pass to handle forward references */ 197a9f12690SJung-uk Kim 198a9f12690SJung-uk Kim TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace2Begin, 199a9f12690SJung-uk Kim LdCommonNamespaceEnd, WalkState); 20053289f6aSNate Lawson 20153289f6aSNate Lawson /* Dump the namespace if debug is enabled */ 20253289f6aSNate Lawson 20353289f6aSNate Lawson AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); 20453289f6aSNate Lawson return AE_OK; 20553289f6aSNate Lawson } 20653289f6aSNate Lawson 20753289f6aSNate Lawson 20853289f6aSNate Lawson /******************************************************************************* 20953289f6aSNate Lawson * 21053289f6aSNate Lawson * FUNCTION: LdLoadFieldElements 21153289f6aSNate Lawson * 21253289f6aSNate Lawson * PARAMETERS: Op - Parent node (Field) 21353289f6aSNate Lawson * WalkState - Current walk state 21453289f6aSNate Lawson * 21553289f6aSNate Lawson * RETURN: Status 21653289f6aSNate Lawson * 21753289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the field (children of the parent) 21853289f6aSNate Lawson * into the namespace. 21953289f6aSNate Lawson * 22053289f6aSNate Lawson ******************************************************************************/ 22153289f6aSNate Lawson 222fba7fc7eSJung-uk Kim static ACPI_STATUS 22353289f6aSNate Lawson LdLoadFieldElements ( 22453289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 22553289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 22653289f6aSNate Lawson { 22753289f6aSNate Lawson ACPI_PARSE_OBJECT *Child = NULL; 22853289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 22953289f6aSNate Lawson ACPI_STATUS Status; 23053289f6aSNate Lawson 23153289f6aSNate Lawson 23253289f6aSNate Lawson /* Get the first named field element */ 23353289f6aSNate Lawson 23453289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 23553289f6aSNate Lawson { 23653289f6aSNate Lawson case AML_BANK_FIELD_OP: 23753289f6aSNate Lawson 23853289f6aSNate Lawson Child = UtGetArg (Op, 6); 23953289f6aSNate Lawson break; 24053289f6aSNate Lawson 24153289f6aSNate Lawson case AML_INDEX_FIELD_OP: 24253289f6aSNate Lawson 24353289f6aSNate Lawson Child = UtGetArg (Op, 5); 24453289f6aSNate Lawson break; 24553289f6aSNate Lawson 24653289f6aSNate Lawson case AML_FIELD_OP: 24753289f6aSNate Lawson 24853289f6aSNate Lawson Child = UtGetArg (Op, 4); 24953289f6aSNate Lawson break; 25053289f6aSNate Lawson 25153289f6aSNate Lawson default: 25253289f6aSNate Lawson /* No other opcodes should arrive here */ 25353289f6aSNate Lawson return (AE_BAD_PARAMETER); 25453289f6aSNate Lawson } 25553289f6aSNate Lawson 25653289f6aSNate Lawson /* Enter all elements into the namespace */ 25753289f6aSNate Lawson 25853289f6aSNate Lawson while (Child) 25953289f6aSNate Lawson { 26053289f6aSNate Lawson switch (Child->Asl.AmlOpcode) 26153289f6aSNate Lawson { 26253289f6aSNate Lawson case AML_INT_RESERVEDFIELD_OP: 26353289f6aSNate Lawson case AML_INT_ACCESSFIELD_OP: 26453289f6aSNate Lawson 26553289f6aSNate Lawson break; 26653289f6aSNate Lawson 26753289f6aSNate Lawson default: 26853289f6aSNate Lawson 269fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, 270fba7fc7eSJung-uk Kim Child->Asl.Value.String, 271fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_REGION_FIELD, 272fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 273fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 274fba7fc7eSJung-uk Kim ACPI_NS_ERROR_IF_FOUND, 27553289f6aSNate Lawson NULL, &Node); 27653289f6aSNate Lawson if (ACPI_FAILURE (Status)) 27753289f6aSNate Lawson { 27853289f6aSNate Lawson if (Status != AE_ALREADY_EXISTS) 27953289f6aSNate Lawson { 280fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child, 281fba7fc7eSJung-uk Kim Child->Asl.Value.String); 28253289f6aSNate Lawson return (Status); 28353289f6aSNate Lawson } 28453289f6aSNate Lawson 28553289f6aSNate Lawson /* 28653289f6aSNate Lawson * The name already exists in this scope 28753289f6aSNate Lawson * But continue processing the elements 28853289f6aSNate Lawson */ 289fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, 290fba7fc7eSJung-uk Kim Child->Asl.Value.String); 29153289f6aSNate Lawson } 29253289f6aSNate Lawson else 29353289f6aSNate Lawson { 29453289f6aSNate Lawson Child->Asl.Node = Node; 295fba7fc7eSJung-uk Kim Node->Op = Child; 29653289f6aSNate Lawson } 29753289f6aSNate Lawson break; 29853289f6aSNate Lawson } 29953289f6aSNate Lawson Child = Child->Asl.Next; 30053289f6aSNate Lawson } 30153289f6aSNate Lawson return (AE_OK); 30253289f6aSNate Lawson } 30353289f6aSNate Lawson 30453289f6aSNate Lawson 30553289f6aSNate Lawson /******************************************************************************* 30653289f6aSNate Lawson * 30753289f6aSNate Lawson * FUNCTION: LdLoadResourceElements 30853289f6aSNate Lawson * 30953289f6aSNate Lawson * PARAMETERS: Op - Parent node (Resource Descriptor) 31053289f6aSNate Lawson * WalkState - Current walk state 31153289f6aSNate Lawson * 31253289f6aSNate Lawson * RETURN: Status 31353289f6aSNate Lawson * 31453289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the resource descriptor (children 31553289f6aSNate Lawson * of the parent) into the namespace. 31653289f6aSNate Lawson * 31753289f6aSNate Lawson * NOTE: In the real AML namespace, these named elements never exist. But 31853289f6aSNate Lawson * we simply use the namespace here as a symbol table so we can look 31953289f6aSNate Lawson * them up as they are referenced. 32053289f6aSNate Lawson * 32153289f6aSNate Lawson ******************************************************************************/ 32253289f6aSNate Lawson 323fba7fc7eSJung-uk Kim static ACPI_STATUS 32453289f6aSNate Lawson LdLoadResourceElements ( 32553289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 32653289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 32753289f6aSNate Lawson { 32853289f6aSNate Lawson ACPI_PARSE_OBJECT *InitializerOp = NULL; 32953289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 33053289f6aSNate Lawson ACPI_STATUS Status; 33153289f6aSNate Lawson 33253289f6aSNate Lawson 33353289f6aSNate Lawson /* 334fba7fc7eSJung-uk Kim * Enter the resource name into the namespace. Name must not already exist. 335fba7fc7eSJung-uk Kim * This opens a scope, so later field names are guaranteed to be new/unique. 33653289f6aSNate Lawson */ 33753289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, 338fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, 339fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, 34053289f6aSNate Lawson WalkState, &Node); 34153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 34253289f6aSNate Lawson { 343fba7fc7eSJung-uk Kim if (Status == AE_ALREADY_EXISTS) 344fba7fc7eSJung-uk Kim { 345fba7fc7eSJung-uk Kim /* Actual node causing the error was saved in ParentMethod */ 346fba7fc7eSJung-uk Kim 347fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, 348fba7fc7eSJung-uk Kim (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, Op->Asl.Namepath); 349fba7fc7eSJung-uk Kim return (AE_OK); 350fba7fc7eSJung-uk Kim } 35153289f6aSNate Lawson return (Status); 35253289f6aSNate Lawson } 35353289f6aSNate Lawson 3541a39cfb0SJung-uk Kim Node->Value = (UINT32) Op->Asl.Value.Integer; 3551a39cfb0SJung-uk Kim Node->Op = Op; 356d6dd1baeSJung-uk Kim Op->Asl.Node = Node; 3571a39cfb0SJung-uk Kim 35853289f6aSNate Lawson /* 35953289f6aSNate Lawson * Now enter the predefined fields, for easy lookup when referenced 36053289f6aSNate Lawson * by the source ASL 36153289f6aSNate Lawson */ 36253289f6aSNate Lawson InitializerOp = ASL_GET_CHILD_NODE (Op); 36353289f6aSNate Lawson while (InitializerOp) 36453289f6aSNate Lawson { 36553289f6aSNate Lawson 36653289f6aSNate Lawson if (InitializerOp->Asl.ExternalName) 36753289f6aSNate Lawson { 36853289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, 36953289f6aSNate Lawson InitializerOp->Asl.ExternalName, 37053289f6aSNate Lawson ACPI_TYPE_LOCAL_RESOURCE_FIELD, 371fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, 372fba7fc7eSJung-uk Kim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, 37353289f6aSNate Lawson NULL, &Node); 37453289f6aSNate Lawson if (ACPI_FAILURE (Status)) 37553289f6aSNate Lawson { 37653289f6aSNate Lawson return (Status); 37753289f6aSNate Lawson } 37853289f6aSNate Lawson 37953289f6aSNate Lawson /* 38053289f6aSNate Lawson * Store the field offset in the namespace node so it 38153289f6aSNate Lawson * can be used when the field is referenced 38253289f6aSNate Lawson */ 383fba7fc7eSJung-uk Kim Node->Value = (UINT32) InitializerOp->Asl.Value.Integer; 38453289f6aSNate Lawson InitializerOp->Asl.Node = Node; 385fba7fc7eSJung-uk Kim Node->Op = InitializerOp; 38653289f6aSNate Lawson 38753289f6aSNate Lawson /* Pass thru the field type (Bitfield or Bytefield) */ 38853289f6aSNate Lawson 38953289f6aSNate Lawson if (InitializerOp->Asl.CompileFlags & NODE_IS_BIT_OFFSET) 39053289f6aSNate Lawson { 39153289f6aSNate Lawson Node->Flags |= ANOBJ_IS_BIT_OFFSET; 39253289f6aSNate Lawson } 39353289f6aSNate Lawson } 39453289f6aSNate Lawson InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 39553289f6aSNate Lawson } 39653289f6aSNate Lawson 39753289f6aSNate Lawson return (AE_OK); 39853289f6aSNate Lawson } 39953289f6aSNate Lawson 40053289f6aSNate Lawson 40153289f6aSNate Lawson /******************************************************************************* 40253289f6aSNate Lawson * 40353289f6aSNate Lawson * FUNCTION: LdNamespace1Begin 40453289f6aSNate Lawson * 40553289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 40653289f6aSNate Lawson * 40753289f6aSNate Lawson * RETURN: Status 40853289f6aSNate Lawson * 40953289f6aSNate Lawson * DESCRIPTION: Descending callback used during the parse tree walk. If this 41053289f6aSNate Lawson * is a named AML opcode, enter into the namespace 41153289f6aSNate Lawson * 41253289f6aSNate Lawson ******************************************************************************/ 41353289f6aSNate Lawson 414fba7fc7eSJung-uk Kim static ACPI_STATUS 41553289f6aSNate Lawson LdNamespace1Begin ( 41653289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 41753289f6aSNate Lawson UINT32 Level, 41853289f6aSNate Lawson void *Context) 41953289f6aSNate Lawson { 42053289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 42153289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 42253289f6aSNate Lawson ACPI_STATUS Status; 42353289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 42453289f6aSNate Lawson ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; 42553289f6aSNate Lawson char *Path; 42653289f6aSNate Lawson UINT32 Flags = ACPI_NS_NO_UPSEARCH; 42753289f6aSNate Lawson ACPI_PARSE_OBJECT *Arg; 42853289f6aSNate Lawson UINT32 i; 4291a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 43053289f6aSNate Lawson 43153289f6aSNate Lawson 4321a39cfb0SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace1Begin); 43353289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 43453289f6aSNate Lawson Op, Op->Asl.ParseOpName)); 43553289f6aSNate Lawson 43653289f6aSNate Lawson 43753289f6aSNate Lawson /* 43853289f6aSNate Lawson * We are only interested in opcodes that have an associated name 43953289f6aSNate Lawson * (or multiple names) 44053289f6aSNate Lawson */ 44153289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 44253289f6aSNate Lawson { 44353289f6aSNate Lawson case AML_BANK_FIELD_OP: 44453289f6aSNate Lawson case AML_INDEX_FIELD_OP: 44553289f6aSNate Lawson case AML_FIELD_OP: 44653289f6aSNate Lawson 44753289f6aSNate Lawson Status = LdLoadFieldElements (Op, WalkState); 44853289f6aSNate Lawson return (Status); 44953289f6aSNate Lawson 45053289f6aSNate Lawson default: 45153289f6aSNate Lawson 45253289f6aSNate Lawson /* All other opcodes go below */ 45353289f6aSNate Lawson break; 45453289f6aSNate Lawson } 45553289f6aSNate Lawson 45653289f6aSNate Lawson /* Check if this object has already been installed in the namespace */ 45753289f6aSNate Lawson 45853289f6aSNate Lawson if (Op->Asl.Node) 45953289f6aSNate Lawson { 46053289f6aSNate Lawson return (AE_OK); 46153289f6aSNate Lawson } 46253289f6aSNate Lawson 46353289f6aSNate Lawson Path = Op->Asl.Namepath; 46453289f6aSNate Lawson if (!Path) 46553289f6aSNate Lawson { 46653289f6aSNate Lawson return (AE_OK); 46753289f6aSNate Lawson } 46853289f6aSNate Lawson 46953289f6aSNate Lawson /* Map the raw opcode into an internal object type */ 47053289f6aSNate Lawson 47153289f6aSNate Lawson switch (Op->Asl.ParseOpcode) 47253289f6aSNate Lawson { 47353289f6aSNate Lawson case PARSEOP_NAME: 47453289f6aSNate Lawson 47553289f6aSNate Lawson Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ 47653289f6aSNate Lawson Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ 47753289f6aSNate Lawson 4781a39cfb0SJung-uk Kim /* 4791a39cfb0SJung-uk Kim * If this name refers to a ResourceTemplate, we will need to open 4801a39cfb0SJung-uk Kim * a new scope so that the resource subfield names can be entered into 4811a39cfb0SJung-uk Kim * the namespace underneath this name 4821a39cfb0SJung-uk Kim */ 4831a39cfb0SJung-uk Kim if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) 4841a39cfb0SJung-uk Kim { 4851a39cfb0SJung-uk Kim ForceNewScope = TRUE; 4861a39cfb0SJung-uk Kim } 4871a39cfb0SJung-uk Kim 48853289f6aSNate Lawson /* Get the data type associated with the named object, not the name itself */ 48953289f6aSNate Lawson 49053289f6aSNate Lawson /* Log2 loop to convert from Btype (binary) to Etype (encoded) */ 49153289f6aSNate Lawson 49253289f6aSNate Lawson ObjectType = 1; 49353289f6aSNate Lawson for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2) 49453289f6aSNate Lawson { 49553289f6aSNate Lawson ObjectType++; 49653289f6aSNate Lawson } 49753289f6aSNate Lawson break; 49853289f6aSNate Lawson 49953289f6aSNate Lawson 50053289f6aSNate Lawson case PARSEOP_EXTERNAL: 50153289f6aSNate Lawson 50253289f6aSNate Lawson /* 50353289f6aSNate Lawson * "External" simply enters a name and type into the namespace. 50453289f6aSNate Lawson * We must be careful to not open a new scope, however, no matter 50553289f6aSNate Lawson * what type the external name refers to (e.g., a method) 50653289f6aSNate Lawson * 50753289f6aSNate Lawson * first child is name, next child is ObjectType 50853289f6aSNate Lawson */ 50953289f6aSNate Lawson ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; 51053289f6aSNate Lawson ObjectType = ACPI_TYPE_ANY; 51153289f6aSNate Lawson 5121a39cfb0SJung-uk Kim /* 5131a39cfb0SJung-uk Kim * We will mark every new node along the path as "External". This 5141a39cfb0SJung-uk Kim * allows some or all of the nodes to be created later in the ASL 5151a39cfb0SJung-uk Kim * code. Handles cases like this: 5161a39cfb0SJung-uk Kim * 5171a39cfb0SJung-uk Kim * External (\_SB_.PCI0.ABCD, IntObj) 5181a39cfb0SJung-uk Kim * Scope (_SB_) 5191a39cfb0SJung-uk Kim * { 5201a39cfb0SJung-uk Kim * Device (PCI0) 5211a39cfb0SJung-uk Kim * { 5221a39cfb0SJung-uk Kim * } 5231a39cfb0SJung-uk Kim * } 5241a39cfb0SJung-uk Kim * Method (X) 5251a39cfb0SJung-uk Kim * { 5261a39cfb0SJung-uk Kim * Store (\_SB_.PCI0.ABCD, Local0) 5271a39cfb0SJung-uk Kim * } 5281a39cfb0SJung-uk Kim */ 5291a39cfb0SJung-uk Kim Flags |= ACPI_NS_EXTERNAL; 5301a39cfb0SJung-uk Kim break; 53153289f6aSNate Lawson 53253289f6aSNate Lawson case PARSEOP_DEFAULT_ARG: 53353289f6aSNate Lawson 53453289f6aSNate Lawson if (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC) 53553289f6aSNate Lawson { 53653289f6aSNate Lawson Status = LdLoadResourceElements (Op, WalkState); 537*9a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 53853289f6aSNate Lawson } 53953289f6aSNate Lawson 54053289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 54153289f6aSNate Lawson break; 54253289f6aSNate Lawson 54353289f6aSNate Lawson 54453289f6aSNate Lawson case PARSEOP_SCOPE: 54553289f6aSNate Lawson 54653289f6aSNate Lawson /* 54753289f6aSNate Lawson * The name referenced by Scope(Name) must already exist at this point. 54853289f6aSNate Lawson * In other words, forward references for Scope() are not supported. 54953289f6aSNate Lawson * The only real reason for this is that the MS interpreter cannot 55053289f6aSNate Lawson * handle this case. Perhaps someday this case can go away. 55153289f6aSNate Lawson */ 55253289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 553fba7fc7eSJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 554fba7fc7eSJung-uk Kim WalkState, &(Node)); 55553289f6aSNate Lawson if (ACPI_FAILURE (Status)) 55653289f6aSNate Lawson { 55753289f6aSNate Lawson if (Status == AE_NOT_FOUND) 55853289f6aSNate Lawson { 55953289f6aSNate Lawson /* The name was not found, go ahead and create it */ 56053289f6aSNate Lawson 561fba7fc7eSJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 562fba7fc7eSJung-uk Kim ACPI_TYPE_LOCAL_SCOPE, 563fba7fc7eSJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, 564fba7fc7eSJung-uk Kim WalkState, &(Node)); 56553289f6aSNate Lawson 56653289f6aSNate Lawson /* 56753289f6aSNate Lawson * However, this is an error -- primarily because the MS 56853289f6aSNate Lawson * interpreter can't handle a forward reference from the 56953289f6aSNate Lawson * Scope() operator. 57053289f6aSNate Lawson */ 571fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 572fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 573fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, 574fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 57553289f6aSNate Lawson goto FinishNode; 57653289f6aSNate Lawson } 57753289f6aSNate Lawson 578f556842eSJung-uk Kim AslCoreSubsystemError (Op, Status, 579f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 580f556842eSJung-uk Kim 581*9a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 58253289f6aSNate Lawson } 58353289f6aSNate Lawson 58453289f6aSNate Lawson /* We found a node with this name, now check the type */ 58553289f6aSNate Lawson 58653289f6aSNate Lawson switch (Node->Type) 58753289f6aSNate Lawson { 58853289f6aSNate Lawson case ACPI_TYPE_LOCAL_SCOPE: 58953289f6aSNate Lawson case ACPI_TYPE_DEVICE: 59053289f6aSNate Lawson case ACPI_TYPE_POWER: 59153289f6aSNate Lawson case ACPI_TYPE_PROCESSOR: 59253289f6aSNate Lawson case ACPI_TYPE_THERMAL: 59353289f6aSNate Lawson 59453289f6aSNate Lawson /* These are acceptable types - they all open a new scope */ 59553289f6aSNate Lawson break; 59653289f6aSNate Lawson 59753289f6aSNate Lawson case ACPI_TYPE_INTEGER: 59853289f6aSNate Lawson case ACPI_TYPE_STRING: 59953289f6aSNate Lawson case ACPI_TYPE_BUFFER: 60053289f6aSNate Lawson 60153289f6aSNate Lawson /* 602fba7fc7eSJung-uk Kim * These types we will allow, but we will change the type. 603fba7fc7eSJung-uk Kim * This enables some existing code of the form: 60453289f6aSNate Lawson * 60553289f6aSNate Lawson * Name (DEB, 0) 60653289f6aSNate Lawson * Scope (DEB) { ... } 60753289f6aSNate Lawson * 60853289f6aSNate Lawson * Which is used to workaround the fact that the MS interpreter 60953289f6aSNate Lawson * does not allow Scope() forward references. 61053289f6aSNate Lawson */ 611e0ef747bSNate Lawson sprintf (MsgBuffer, "%s [%s], changing type to [Scope]", 61253289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 61353289f6aSNate Lawson AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 61453289f6aSNate Lawson 615fba7fc7eSJung-uk Kim /* Switch the type to scope, open the new scope */ 616fba7fc7eSJung-uk Kim 617e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 618fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 619fba7fc7eSJung-uk Kim WalkState); 620e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 621e0ef747bSNate Lawson { 622e0ef747bSNate Lawson return_ACPI_STATUS (Status); 623e0ef747bSNate Lawson } 62453289f6aSNate Lawson break; 62553289f6aSNate Lawson 62653289f6aSNate Lawson default: 62753289f6aSNate Lawson 628fba7fc7eSJung-uk Kim /* All other types are an error */ 629fba7fc7eSJung-uk Kim 630fba7fc7eSJung-uk Kim sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 631fba7fc7eSJung-uk Kim AcpiUtGetTypeName (Node->Type)); 63253289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 63353289f6aSNate Lawson 63453289f6aSNate Lawson /* 63553289f6aSNate Lawson * However, switch the type to be an actual scope so 63653289f6aSNate Lawson * that compilation can continue without generating a whole 637e0ef747bSNate Lawson * cascade of additional errors. Open the new scope. 63853289f6aSNate Lawson */ 639e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 640fba7fc7eSJung-uk Kim Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 641fba7fc7eSJung-uk Kim WalkState); 642e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 643e0ef747bSNate Lawson { 644e0ef747bSNate Lawson return_ACPI_STATUS (Status); 645e0ef747bSNate Lawson } 64653289f6aSNate Lawson break; 64753289f6aSNate Lawson } 64853289f6aSNate Lawson 64953289f6aSNate Lawson Status = AE_OK; 65053289f6aSNate Lawson goto FinishNode; 65153289f6aSNate Lawson 65253289f6aSNate Lawson 65353289f6aSNate Lawson default: 65453289f6aSNate Lawson 65553289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 65653289f6aSNate Lawson break; 65753289f6aSNate Lawson } 65853289f6aSNate Lawson 65953289f6aSNate Lawson 66053289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", 66153289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); 66253289f6aSNate Lawson 66353289f6aSNate Lawson /* The name must not already exist */ 66453289f6aSNate Lawson 66553289f6aSNate Lawson Flags |= ACPI_NS_ERROR_IF_FOUND; 66653289f6aSNate Lawson 66753289f6aSNate Lawson /* 66853289f6aSNate Lawson * Enter the named type into the internal namespace. We enter the name 669fba7fc7eSJung-uk Kim * as we go downward in the parse tree. Any necessary subobjects that 670fba7fc7eSJung-uk Kim * involve arguments to the opcode must be created as we go back up the 671fba7fc7eSJung-uk Kim * parse tree later. 67253289f6aSNate Lawson */ 67353289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 6741a39cfb0SJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 67553289f6aSNate Lawson if (ACPI_FAILURE (Status)) 67653289f6aSNate Lawson { 67753289f6aSNate Lawson if (Status == AE_ALREADY_EXISTS) 67853289f6aSNate Lawson { 67953289f6aSNate Lawson /* The name already exists in this scope */ 68053289f6aSNate Lawson 68153289f6aSNate Lawson if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 68253289f6aSNate Lawson { 6831a39cfb0SJung-uk Kim /* Allow multiple references to the same scope */ 6841a39cfb0SJung-uk Kim 68553289f6aSNate Lawson Node->Type = (UINT8) ObjectType; 68653289f6aSNate Lawson Status = AE_OK; 68753289f6aSNate Lawson } 688a9f12690SJung-uk Kim else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 689a9f12690SJung-uk Kim (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) 6901a39cfb0SJung-uk Kim { 6911a39cfb0SJung-uk Kim /* 6921a39cfb0SJung-uk Kim * Allow one create on an object or segment that was 6931a39cfb0SJung-uk Kim * previously declared External 6941a39cfb0SJung-uk Kim */ 6951a39cfb0SJung-uk Kim Node->Flags &= ~ANOBJ_IS_EXTERNAL; 6961a39cfb0SJung-uk Kim Node->Type = (UINT8) ObjectType; 6971a39cfb0SJung-uk Kim 6981a39cfb0SJung-uk Kim /* Just retyped a node, probably will need to open a scope */ 6991a39cfb0SJung-uk Kim 7001a39cfb0SJung-uk Kim if (AcpiNsOpensScope (ObjectType)) 7011a39cfb0SJung-uk Kim { 7021a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 7031a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 7041a39cfb0SJung-uk Kim { 7051a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 7061a39cfb0SJung-uk Kim } 7071a39cfb0SJung-uk Kim } 7081a39cfb0SJung-uk Kim Status = AE_OK; 7091a39cfb0SJung-uk Kim } 71053289f6aSNate Lawson else 71153289f6aSNate Lawson { 7121a39cfb0SJung-uk Kim /* Valid error, object already exists */ 7131a39cfb0SJung-uk Kim 714fba7fc7eSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, 715fba7fc7eSJung-uk Kim Op->Asl.ExternalName); 716*9a179dd8SJung-uk Kim return_ACPI_STATUS (AE_OK); 71753289f6aSNate Lawson } 71853289f6aSNate Lawson } 71953289f6aSNate Lawson else 72053289f6aSNate Lawson { 721fba7fc7eSJung-uk Kim AslCoreSubsystemError (Op, Status, 722f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 723*9a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 72453289f6aSNate Lawson } 72553289f6aSNate Lawson } 72653289f6aSNate Lawson 7271a39cfb0SJung-uk Kim if (ForceNewScope) 7281a39cfb0SJung-uk Kim { 7291a39cfb0SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 7301a39cfb0SJung-uk Kim if (ACPI_FAILURE (Status)) 7311a39cfb0SJung-uk Kim { 7321a39cfb0SJung-uk Kim return_ACPI_STATUS (Status); 7331a39cfb0SJung-uk Kim } 7341a39cfb0SJung-uk Kim } 73553289f6aSNate Lawson 73653289f6aSNate Lawson FinishNode: 73753289f6aSNate Lawson /* 73853289f6aSNate Lawson * Point the parse node to the new namespace node, and point 73953289f6aSNate Lawson * the Node back to the original Parse node 74053289f6aSNate Lawson */ 74153289f6aSNate Lawson Op->Asl.Node = Node; 742fba7fc7eSJung-uk Kim Node->Op = Op; 74353289f6aSNate Lawson 74453289f6aSNate Lawson /* Set the actual data type if appropriate (EXTERNAL term only) */ 74553289f6aSNate Lawson 74653289f6aSNate Lawson if (ActualObjectType != ACPI_TYPE_ANY) 74753289f6aSNate Lawson { 74853289f6aSNate Lawson Node->Type = (UINT8) ActualObjectType; 749fba7fc7eSJung-uk Kim Node->Value = ASL_EXTERNAL_METHOD; 75053289f6aSNate Lawson } 75153289f6aSNate Lawson 75253289f6aSNate Lawson if (Op->Asl.ParseOpcode == PARSEOP_METHOD) 75353289f6aSNate Lawson { 75453289f6aSNate Lawson /* 755fba7fc7eSJung-uk Kim * Get the method argument count from "Extra" and save 756fba7fc7eSJung-uk Kim * it in the namespace node 75753289f6aSNate Lawson */ 758fba7fc7eSJung-uk Kim Node->Value = (UINT32) Op->Asl.Extra; 75953289f6aSNate Lawson } 76053289f6aSNate Lawson 761*9a179dd8SJung-uk Kim return_ACPI_STATUS (Status); 76253289f6aSNate Lawson } 76353289f6aSNate Lawson 76453289f6aSNate Lawson 76553289f6aSNate Lawson /******************************************************************************* 76653289f6aSNate Lawson * 767a9f12690SJung-uk Kim * FUNCTION: LdNamespace2Begin 768a9f12690SJung-uk Kim * 769a9f12690SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 770a9f12690SJung-uk Kim * 771a9f12690SJung-uk Kim * RETURN: Status 772a9f12690SJung-uk Kim * 773a9f12690SJung-uk Kim * DESCRIPTION: Descending callback used during the pass 2 parse tree walk. 774a9f12690SJung-uk Kim * Second pass resolves some forward references. 775a9f12690SJung-uk Kim * 776a9f12690SJung-uk Kim * Notes: 777a9f12690SJung-uk Kim * Currently only needs to handle the Alias operator. 778a9f12690SJung-uk Kim * Could be used to allow forward references from the Scope() operator, but 779a9f12690SJung-uk Kim * the MS interpreter does not allow this, so this compiler does not either. 780a9f12690SJung-uk Kim * 781a9f12690SJung-uk Kim ******************************************************************************/ 782a9f12690SJung-uk Kim 783a9f12690SJung-uk Kim static ACPI_STATUS 784a9f12690SJung-uk Kim LdNamespace2Begin ( 785a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Op, 786a9f12690SJung-uk Kim UINT32 Level, 787a9f12690SJung-uk Kim void *Context) 788a9f12690SJung-uk Kim { 789a9f12690SJung-uk Kim ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 790a9f12690SJung-uk Kim ACPI_STATUS Status; 791a9f12690SJung-uk Kim ACPI_NAMESPACE_NODE *Node; 792a9f12690SJung-uk Kim ACPI_OBJECT_TYPE ObjectType; 793a9f12690SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 794a9f12690SJung-uk Kim ACPI_PARSE_OBJECT *Arg; 795a9f12690SJung-uk Kim char *Path; 796a9f12690SJung-uk Kim ACPI_NAMESPACE_NODE *TargetNode; 797a9f12690SJung-uk Kim 798a9f12690SJung-uk Kim 799a9f12690SJung-uk Kim ACPI_FUNCTION_NAME (LdNamespace2Begin); 800a9f12690SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 801a9f12690SJung-uk Kim Op, Op->Asl.ParseOpName)); 802a9f12690SJung-uk Kim 803a9f12690SJung-uk Kim 804a9f12690SJung-uk Kim /* Ignore Ops with no namespace node */ 805a9f12690SJung-uk Kim 806a9f12690SJung-uk Kim Node = Op->Asl.Node; 807a9f12690SJung-uk Kim if (!Node) 808a9f12690SJung-uk Kim { 809a9f12690SJung-uk Kim return (AE_OK); 810a9f12690SJung-uk Kim } 811a9f12690SJung-uk Kim 812a9f12690SJung-uk Kim /* Get the type to determine if we should push the scope */ 813a9f12690SJung-uk Kim 814a9f12690SJung-uk Kim if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 815a9f12690SJung-uk Kim (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)) 816a9f12690SJung-uk Kim { 817a9f12690SJung-uk Kim ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 818a9f12690SJung-uk Kim } 819a9f12690SJung-uk Kim else 820a9f12690SJung-uk Kim { 821a9f12690SJung-uk Kim ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 822a9f12690SJung-uk Kim } 823a9f12690SJung-uk Kim 824a9f12690SJung-uk Kim /* Push scope for Resource Templates */ 825a9f12690SJung-uk Kim 826a9f12690SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 827a9f12690SJung-uk Kim { 828a9f12690SJung-uk Kim if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) 829a9f12690SJung-uk Kim { 830a9f12690SJung-uk Kim ForceNewScope = TRUE; 831a9f12690SJung-uk Kim } 832a9f12690SJung-uk Kim } 833a9f12690SJung-uk Kim 834a9f12690SJung-uk Kim /* Push the scope stack */ 835a9f12690SJung-uk Kim 836a9f12690SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 837a9f12690SJung-uk Kim { 838a9f12690SJung-uk Kim Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 839a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 840a9f12690SJung-uk Kim { 841a9f12690SJung-uk Kim return_ACPI_STATUS (Status); 842a9f12690SJung-uk Kim } 843a9f12690SJung-uk Kim } 844a9f12690SJung-uk Kim 845a9f12690SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_ALIAS) 846a9f12690SJung-uk Kim { 847a9f12690SJung-uk Kim /* Complete the alias node by getting and saving the target node */ 848a9f12690SJung-uk Kim 849a9f12690SJung-uk Kim /* First child is the alias target */ 850a9f12690SJung-uk Kim 851a9f12690SJung-uk Kim Arg = Op->Asl.Child; 852a9f12690SJung-uk Kim 853a9f12690SJung-uk Kim /* Get the target pathname */ 854a9f12690SJung-uk Kim 855a9f12690SJung-uk Kim Path = Arg->Asl.Namepath; 856a9f12690SJung-uk Kim if (!Path) 857a9f12690SJung-uk Kim { 858a9f12690SJung-uk Kim Status = UtInternalizeName (Arg->Asl.ExternalName, &Path); 859a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 860a9f12690SJung-uk Kim { 861a9f12690SJung-uk Kim return (Status); 862a9f12690SJung-uk Kim } 863a9f12690SJung-uk Kim } 864a9f12690SJung-uk Kim 865a9f12690SJung-uk Kim /* Get the NS node associated with the target. It must exist. */ 866a9f12690SJung-uk Kim 867a9f12690SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 868a9f12690SJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 869a9f12690SJung-uk Kim WalkState, &TargetNode); 870a9f12690SJung-uk Kim if (ACPI_FAILURE (Status)) 871a9f12690SJung-uk Kim { 872a9f12690SJung-uk Kim if (Status == AE_NOT_FOUND) 873a9f12690SJung-uk Kim { 874a9f12690SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 875a9f12690SJung-uk Kim Op->Asl.ExternalName); 876a9f12690SJung-uk Kim 877a9f12690SJung-uk Kim /* 878a9f12690SJung-uk Kim * The name was not found, go ahead and create it. 879a9f12690SJung-uk Kim * This prevents more errors later. 880a9f12690SJung-uk Kim */ 881a9f12690SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 882a9f12690SJung-uk Kim ACPI_TYPE_ANY, 883a9f12690SJung-uk Kim ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, 884a9f12690SJung-uk Kim WalkState, &(Node)); 885a9f12690SJung-uk Kim return (AE_OK); 886a9f12690SJung-uk Kim } 887a9f12690SJung-uk Kim 888f556842eSJung-uk Kim AslCoreSubsystemError (Op, Status, 889f556842eSJung-uk Kim "Failure from namespace lookup", FALSE); 890a9f12690SJung-uk Kim return (AE_OK); 891a9f12690SJung-uk Kim } 892a9f12690SJung-uk Kim 893a9f12690SJung-uk Kim /* Save the target node within the alias node */ 894a9f12690SJung-uk Kim 895a9f12690SJung-uk Kim Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 896a9f12690SJung-uk Kim } 897a9f12690SJung-uk Kim 898a9f12690SJung-uk Kim return (AE_OK); 899a9f12690SJung-uk Kim } 900a9f12690SJung-uk Kim 901a9f12690SJung-uk Kim 902a9f12690SJung-uk Kim /******************************************************************************* 903a9f12690SJung-uk Kim * 904a9f12690SJung-uk Kim * FUNCTION: LdCommonNamespaceEnd 90553289f6aSNate Lawson * 90653289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 90753289f6aSNate Lawson * 90853289f6aSNate Lawson * RETURN: Status 90953289f6aSNate Lawson * 91053289f6aSNate Lawson * DESCRIPTION: Ascending callback used during the loading of the namespace, 91153289f6aSNate Lawson * We only need to worry about managing the scope stack here. 91253289f6aSNate Lawson * 91353289f6aSNate Lawson ******************************************************************************/ 91453289f6aSNate Lawson 915fba7fc7eSJung-uk Kim static ACPI_STATUS 916a9f12690SJung-uk Kim LdCommonNamespaceEnd ( 91753289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 91853289f6aSNate Lawson UINT32 Level, 91953289f6aSNate Lawson void *Context) 92053289f6aSNate Lawson { 92153289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 92253289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 9231a39cfb0SJung-uk Kim BOOLEAN ForceNewScope = FALSE; 92453289f6aSNate Lawson 92553289f6aSNate Lawson 926a9f12690SJung-uk Kim ACPI_FUNCTION_NAME (LdCommonNamespaceEnd); 92753289f6aSNate Lawson 92853289f6aSNate Lawson 92953289f6aSNate Lawson /* We are only interested in opcodes that have an associated name */ 93053289f6aSNate Lawson 93153289f6aSNate Lawson if (!Op->Asl.Namepath) 93253289f6aSNate Lawson { 93353289f6aSNate Lawson return (AE_OK); 93453289f6aSNate Lawson } 93553289f6aSNate Lawson 93653289f6aSNate Lawson /* Get the type to determine if we should pop the scope */ 93753289f6aSNate Lawson 93853289f6aSNate Lawson if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 93953289f6aSNate Lawson (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)) 94053289f6aSNate Lawson { 94153289f6aSNate Lawson /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */ 94253289f6aSNate Lawson 94353289f6aSNate Lawson ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 94453289f6aSNate Lawson } 94553289f6aSNate Lawson else 94653289f6aSNate Lawson { 94753289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 94853289f6aSNate Lawson } 94953289f6aSNate Lawson 9501a39cfb0SJung-uk Kim /* Pop scope that was pushed for Resource Templates */ 9511a39cfb0SJung-uk Kim 9521a39cfb0SJung-uk Kim if (Op->Asl.ParseOpcode == PARSEOP_NAME) 9531a39cfb0SJung-uk Kim { 9541a39cfb0SJung-uk Kim if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC) 9551a39cfb0SJung-uk Kim { 9561a39cfb0SJung-uk Kim ForceNewScope = TRUE; 9571a39cfb0SJung-uk Kim } 9581a39cfb0SJung-uk Kim } 9591a39cfb0SJung-uk Kim 96053289f6aSNate Lawson /* Pop the scope stack */ 96153289f6aSNate Lawson 9621a39cfb0SJung-uk Kim if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 96353289f6aSNate Lawson { 96453289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 96553289f6aSNate Lawson "(%s): Popping scope for Op [%s] %p\n", 96653289f6aSNate Lawson AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); 96753289f6aSNate Lawson 968fba7fc7eSJung-uk Kim (void) AcpiDsScopeStackPop (WalkState); 96953289f6aSNate Lawson } 97053289f6aSNate Lawson 97153289f6aSNate Lawson return (AE_OK); 97253289f6aSNate Lawson } 97353289f6aSNate Lawson 97453289f6aSNate Lawson 975