153289f6aSNate Lawson /****************************************************************************** 253289f6aSNate Lawson * 353289f6aSNate Lawson * Module Name: dswload - Dispatcher namespace load callbacks 4*e0ef747bSNate Lawson * $Revision: 62 $ 553289f6aSNate Lawson * 653289f6aSNate Lawson *****************************************************************************/ 753289f6aSNate Lawson 853289f6aSNate Lawson /****************************************************************************** 953289f6aSNate Lawson * 1053289f6aSNate Lawson * 1. Copyright Notice 1153289f6aSNate Lawson * 122a2a3f27SNate Lawson * Some or all of this work - Copyright (c) 1999 - 2004, 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 11953289f6aSNate Lawson #include "aslcompiler.h" 12053289f6aSNate Lawson #include "amlcode.h" 12153289f6aSNate Lawson #include "acdispat.h" 12253289f6aSNate Lawson #include "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 12953289f6aSNate Lawson 13053289f6aSNate Lawson /******************************************************************************* 13153289f6aSNate Lawson * 13253289f6aSNate Lawson * FUNCTION: LdLoadNamespace 13353289f6aSNate Lawson * 13453289f6aSNate Lawson * PARAMETERS: None 13553289f6aSNate Lawson * 13653289f6aSNate Lawson * RETURN: Status 13753289f6aSNate Lawson * 13853289f6aSNate Lawson * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the 13953289f6aSNate Lawson * named ASL/AML objects into the namespace. The namespace is 14053289f6aSNate Lawson * constructed in order to resolve named references and references 14153289f6aSNate Lawson * to named fields within resource templates/descriptors. 14253289f6aSNate Lawson * 14353289f6aSNate Lawson ******************************************************************************/ 14453289f6aSNate Lawson 14553289f6aSNate Lawson ACPI_STATUS 14653289f6aSNate Lawson LdLoadNamespace ( 14753289f6aSNate Lawson ACPI_PARSE_OBJECT *RootOp) 14853289f6aSNate Lawson { 14953289f6aSNate Lawson ACPI_WALK_STATE *WalkState; 15053289f6aSNate Lawson 15153289f6aSNate Lawson 15253289f6aSNate Lawson DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n"); 15353289f6aSNate Lawson 15453289f6aSNate Lawson /* Create a new walk state */ 15553289f6aSNate Lawson 15653289f6aSNate Lawson WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 15753289f6aSNate Lawson if (!WalkState) 15853289f6aSNate Lawson { 15953289f6aSNate Lawson return AE_NO_MEMORY; 16053289f6aSNate Lawson } 16153289f6aSNate Lawson 16253289f6aSNate Lawson /* Perform the walk of the parse tree */ 16353289f6aSNate Lawson 16453289f6aSNate Lawson TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, 16553289f6aSNate Lawson LdNamespace1End, WalkState); 16653289f6aSNate Lawson 16753289f6aSNate Lawson /* Dump the namespace if debug is enabled */ 16853289f6aSNate Lawson 16953289f6aSNate Lawson AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); 17053289f6aSNate Lawson return AE_OK; 17153289f6aSNate Lawson } 17253289f6aSNate Lawson 17353289f6aSNate Lawson 17453289f6aSNate Lawson /******************************************************************************* 17553289f6aSNate Lawson * 17653289f6aSNate Lawson * FUNCTION: LdLoadFieldElements 17753289f6aSNate Lawson * 17853289f6aSNate Lawson * PARAMETERS: Op - Parent node (Field) 17953289f6aSNate Lawson * WalkState - Current walk state 18053289f6aSNate Lawson * 18153289f6aSNate Lawson * RETURN: Status 18253289f6aSNate Lawson * 18353289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the field (children of the parent) 18453289f6aSNate Lawson * into the namespace. 18553289f6aSNate Lawson * 18653289f6aSNate Lawson ******************************************************************************/ 18753289f6aSNate Lawson 18853289f6aSNate Lawson ACPI_STATUS 18953289f6aSNate Lawson LdLoadFieldElements ( 19053289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 19153289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 19253289f6aSNate Lawson { 19353289f6aSNate Lawson ACPI_PARSE_OBJECT *Child = NULL; 19453289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 19553289f6aSNate Lawson ACPI_STATUS Status; 19653289f6aSNate Lawson 19753289f6aSNate Lawson 19853289f6aSNate Lawson /* Get the first named field element */ 19953289f6aSNate Lawson 20053289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 20153289f6aSNate Lawson { 20253289f6aSNate Lawson case AML_BANK_FIELD_OP: 20353289f6aSNate Lawson 20453289f6aSNate Lawson Child = UtGetArg (Op, 6); 20553289f6aSNate Lawson break; 20653289f6aSNate Lawson 20753289f6aSNate Lawson case AML_INDEX_FIELD_OP: 20853289f6aSNate Lawson 20953289f6aSNate Lawson Child = UtGetArg (Op, 5); 21053289f6aSNate Lawson break; 21153289f6aSNate Lawson 21253289f6aSNate Lawson case AML_FIELD_OP: 21353289f6aSNate Lawson 21453289f6aSNate Lawson Child = UtGetArg (Op, 4); 21553289f6aSNate Lawson break; 21653289f6aSNate Lawson 21753289f6aSNate Lawson default: 21853289f6aSNate Lawson /* No other opcodes should arrive here */ 21953289f6aSNate Lawson return (AE_BAD_PARAMETER); 22053289f6aSNate Lawson } 22153289f6aSNate Lawson 22253289f6aSNate Lawson /* Enter all elements into the namespace */ 22353289f6aSNate Lawson 22453289f6aSNate Lawson while (Child) 22553289f6aSNate Lawson { 22653289f6aSNate Lawson switch (Child->Asl.AmlOpcode) 22753289f6aSNate Lawson { 22853289f6aSNate Lawson case AML_INT_RESERVEDFIELD_OP: 22953289f6aSNate Lawson case AML_INT_ACCESSFIELD_OP: 23053289f6aSNate Lawson 23153289f6aSNate Lawson break; 23253289f6aSNate Lawson 23353289f6aSNate Lawson default: 23453289f6aSNate Lawson 23553289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Child->Asl.Value.String, 23653289f6aSNate Lawson ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_IMODE_LOAD_PASS1, 23753289f6aSNate Lawson ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, 23853289f6aSNate Lawson NULL, &Node); 23953289f6aSNate Lawson if (ACPI_FAILURE (Status)) 24053289f6aSNate Lawson { 24153289f6aSNate Lawson if (Status != AE_ALREADY_EXISTS) 24253289f6aSNate Lawson { 24353289f6aSNate Lawson return (Status); 24453289f6aSNate Lawson } 24553289f6aSNate Lawson 24653289f6aSNate Lawson /* 24753289f6aSNate Lawson * The name already exists in this scope 24853289f6aSNate Lawson * But continue processing the elements 24953289f6aSNate Lawson */ 25053289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, Child->Asl.Value.String); 25153289f6aSNate Lawson } 25253289f6aSNate Lawson else 25353289f6aSNate Lawson { 25453289f6aSNate Lawson Child->Asl.Node = Node; 25553289f6aSNate Lawson Node->Object = (ACPI_OPERAND_OBJECT *) Child; 25653289f6aSNate Lawson } 25753289f6aSNate Lawson break; 25853289f6aSNate Lawson } 25953289f6aSNate Lawson Child = Child->Asl.Next; 26053289f6aSNate Lawson } 26153289f6aSNate Lawson return (AE_OK); 26253289f6aSNate Lawson } 26353289f6aSNate Lawson 26453289f6aSNate Lawson 26553289f6aSNate Lawson /******************************************************************************* 26653289f6aSNate Lawson * 26753289f6aSNate Lawson * FUNCTION: LdLoadResourceElements 26853289f6aSNate Lawson * 26953289f6aSNate Lawson * PARAMETERS: Op - Parent node (Resource Descriptor) 27053289f6aSNate Lawson * WalkState - Current walk state 27153289f6aSNate Lawson * 27253289f6aSNate Lawson * RETURN: Status 27353289f6aSNate Lawson * 27453289f6aSNate Lawson * DESCRIPTION: Enter the named elements of the resource descriptor (children 27553289f6aSNate Lawson * of the parent) into the namespace. 27653289f6aSNate Lawson * 27753289f6aSNate Lawson * NOTE: In the real AML namespace, these named elements never exist. But 27853289f6aSNate Lawson * we simply use the namespace here as a symbol table so we can look 27953289f6aSNate Lawson * them up as they are referenced. 28053289f6aSNate Lawson * 28153289f6aSNate Lawson ******************************************************************************/ 28253289f6aSNate Lawson 28353289f6aSNate Lawson ACPI_STATUS 28453289f6aSNate Lawson LdLoadResourceElements ( 28553289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 28653289f6aSNate Lawson ACPI_WALK_STATE *WalkState) 28753289f6aSNate Lawson { 28853289f6aSNate Lawson ACPI_PARSE_OBJECT *InitializerOp = NULL; 28953289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 29053289f6aSNate Lawson ACPI_STATUS Status; 29153289f6aSNate Lawson 29253289f6aSNate Lawson 29353289f6aSNate Lawson /* 29453289f6aSNate Lawson * Enter the resouce name into the namespace 29553289f6aSNate Lawson * This opens a scope 29653289f6aSNate Lawson */ 29753289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, 29853289f6aSNate Lawson ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, 29953289f6aSNate Lawson WalkState, &Node); 30053289f6aSNate Lawson if (ACPI_FAILURE (Status)) 30153289f6aSNate Lawson { 30253289f6aSNate Lawson return (Status); 30353289f6aSNate Lawson } 30453289f6aSNate Lawson 30553289f6aSNate Lawson /* 30653289f6aSNate Lawson * Now enter the predefined fields, for easy lookup when referenced 30753289f6aSNate Lawson * by the source ASL 30853289f6aSNate Lawson */ 30953289f6aSNate Lawson InitializerOp = ASL_GET_CHILD_NODE (Op); 31053289f6aSNate Lawson while (InitializerOp) 31153289f6aSNate Lawson { 31253289f6aSNate Lawson 31353289f6aSNate Lawson if (InitializerOp->Asl.ExternalName) 31453289f6aSNate Lawson { 31553289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, 31653289f6aSNate Lawson InitializerOp->Asl.ExternalName, 31753289f6aSNate Lawson ACPI_TYPE_LOCAL_RESOURCE_FIELD, 31853289f6aSNate Lawson ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, 31953289f6aSNate Lawson NULL, &Node); 32053289f6aSNate Lawson if (ACPI_FAILURE (Status)) 32153289f6aSNate Lawson { 32253289f6aSNate Lawson return (Status); 32353289f6aSNate Lawson } 32453289f6aSNate Lawson 32553289f6aSNate Lawson /* 32653289f6aSNate Lawson * Store the field offset in the namespace node so it 32753289f6aSNate Lawson * can be used when the field is referenced 32853289f6aSNate Lawson */ 32953289f6aSNate Lawson Node->OwnerId = (UINT16) InitializerOp->Asl.Value.Integer; 33053289f6aSNate Lawson InitializerOp->Asl.Node = Node; 33153289f6aSNate Lawson Node->Object = (ACPI_OPERAND_OBJECT *) InitializerOp; 33253289f6aSNate Lawson 33353289f6aSNate Lawson /* Pass thru the field type (Bitfield or Bytefield) */ 33453289f6aSNate Lawson 33553289f6aSNate Lawson if (InitializerOp->Asl.CompileFlags & NODE_IS_BIT_OFFSET) 33653289f6aSNate Lawson { 33753289f6aSNate Lawson Node->Flags |= ANOBJ_IS_BIT_OFFSET; 33853289f6aSNate Lawson } 33953289f6aSNate Lawson } 34053289f6aSNate Lawson InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 34153289f6aSNate Lawson } 34253289f6aSNate Lawson 34353289f6aSNate Lawson return (AE_OK); 34453289f6aSNate Lawson } 34553289f6aSNate Lawson 34653289f6aSNate Lawson 34753289f6aSNate Lawson /******************************************************************************* 34853289f6aSNate Lawson * 34953289f6aSNate Lawson * FUNCTION: LdNamespace1Begin 35053289f6aSNate Lawson * 35153289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 35253289f6aSNate Lawson * 35353289f6aSNate Lawson * RETURN: Status 35453289f6aSNate Lawson * 35553289f6aSNate Lawson * DESCRIPTION: Descending callback used during the parse tree walk. If this 35653289f6aSNate Lawson * is a named AML opcode, enter into the namespace 35753289f6aSNate Lawson * 35853289f6aSNate Lawson ******************************************************************************/ 35953289f6aSNate Lawson 36053289f6aSNate Lawson ACPI_STATUS 36153289f6aSNate Lawson LdNamespace1Begin ( 36253289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 36353289f6aSNate Lawson UINT32 Level, 36453289f6aSNate Lawson void *Context) 36553289f6aSNate Lawson { 36653289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 36753289f6aSNate Lawson ACPI_NAMESPACE_NODE *Node; 36853289f6aSNate Lawson ACPI_STATUS Status; 36953289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 37053289f6aSNate Lawson ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; 37153289f6aSNate Lawson char *Path; 37253289f6aSNate Lawson UINT32 Flags = ACPI_NS_NO_UPSEARCH; 37353289f6aSNate Lawson ACPI_PARSE_OBJECT *Arg; 37453289f6aSNate Lawson UINT32 i; 37553289f6aSNate Lawson 37653289f6aSNate Lawson 37753289f6aSNate Lawson ACPI_FUNCTION_NAME ("LdNamespace1Begin"); 37853289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 37953289f6aSNate Lawson Op, Op->Asl.ParseOpName)); 38053289f6aSNate Lawson 38153289f6aSNate Lawson 38253289f6aSNate Lawson /* 38353289f6aSNate Lawson * We are only interested in opcodes that have an associated name 38453289f6aSNate Lawson * (or multiple names) 38553289f6aSNate Lawson */ 38653289f6aSNate Lawson switch (Op->Asl.AmlOpcode) 38753289f6aSNate Lawson { 38853289f6aSNate Lawson case AML_BANK_FIELD_OP: 38953289f6aSNate Lawson case AML_INDEX_FIELD_OP: 39053289f6aSNate Lawson case AML_FIELD_OP: 39153289f6aSNate Lawson 39253289f6aSNate Lawson Status = LdLoadFieldElements (Op, WalkState); 39353289f6aSNate Lawson return (Status); 39453289f6aSNate Lawson 39553289f6aSNate Lawson default: 39653289f6aSNate Lawson 39753289f6aSNate Lawson /* All other opcodes go below */ 39853289f6aSNate Lawson break; 39953289f6aSNate Lawson } 40053289f6aSNate Lawson 40153289f6aSNate Lawson /* Check if this object has already been installed in the namespace */ 40253289f6aSNate Lawson 40353289f6aSNate Lawson if (Op->Asl.Node) 40453289f6aSNate Lawson { 40553289f6aSNate Lawson return (AE_OK); 40653289f6aSNate Lawson } 40753289f6aSNate Lawson 40853289f6aSNate Lawson Path = Op->Asl.Namepath; 40953289f6aSNate Lawson if (!Path) 41053289f6aSNate Lawson { 41153289f6aSNate Lawson return (AE_OK); 41253289f6aSNate Lawson } 41353289f6aSNate Lawson 41453289f6aSNate Lawson /* Map the raw opcode into an internal object type */ 41553289f6aSNate Lawson 41653289f6aSNate Lawson switch (Op->Asl.ParseOpcode) 41753289f6aSNate Lawson { 41853289f6aSNate Lawson case PARSEOP_NAME: 41953289f6aSNate Lawson 42053289f6aSNate Lawson Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ 42153289f6aSNate Lawson Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ 42253289f6aSNate Lawson 42353289f6aSNate Lawson /* Get the data type associated with the named object, not the name itself */ 42453289f6aSNate Lawson 42553289f6aSNate Lawson /* Log2 loop to convert from Btype (binary) to Etype (encoded) */ 42653289f6aSNate Lawson 42753289f6aSNate Lawson ObjectType = 1; 42853289f6aSNate Lawson for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2) 42953289f6aSNate Lawson { 43053289f6aSNate Lawson ObjectType++; 43153289f6aSNate Lawson } 43253289f6aSNate Lawson break; 43353289f6aSNate Lawson 43453289f6aSNate Lawson 43553289f6aSNate Lawson case PARSEOP_EXTERNAL: 43653289f6aSNate Lawson 43753289f6aSNate Lawson /* 43853289f6aSNate Lawson * "External" simply enters a name and type into the namespace. 43953289f6aSNate Lawson * We must be careful to not open a new scope, however, no matter 44053289f6aSNate Lawson * what type the external name refers to (e.g., a method) 44153289f6aSNate Lawson * 44253289f6aSNate Lawson * first child is name, next child is ObjectType 44353289f6aSNate Lawson */ 44453289f6aSNate Lawson ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; 44553289f6aSNate Lawson ObjectType = ACPI_TYPE_ANY; 44653289f6aSNate Lawson break; 44753289f6aSNate Lawson 44853289f6aSNate Lawson 44953289f6aSNate Lawson case PARSEOP_DEFAULT_ARG: 45053289f6aSNate Lawson 45153289f6aSNate Lawson if(Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC) 45253289f6aSNate Lawson { 45353289f6aSNate Lawson Status = LdLoadResourceElements (Op, WalkState); 45453289f6aSNate Lawson goto Exit; 45553289f6aSNate Lawson } 45653289f6aSNate Lawson 45753289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 45853289f6aSNate Lawson break; 45953289f6aSNate Lawson 46053289f6aSNate Lawson 46153289f6aSNate Lawson case PARSEOP_SCOPE: 46253289f6aSNate Lawson 46353289f6aSNate Lawson /* 46453289f6aSNate Lawson * The name referenced by Scope(Name) must already exist at this point. 46553289f6aSNate Lawson * In other words, forward references for Scope() are not supported. 46653289f6aSNate Lawson * The only real reason for this is that the MS interpreter cannot 46753289f6aSNate Lawson * handle this case. Perhaps someday this case can go away. 46853289f6aSNate Lawson */ 46953289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 47053289f6aSNate Lawson ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); 47153289f6aSNate Lawson if (ACPI_FAILURE (Status)) 47253289f6aSNate Lawson { 47353289f6aSNate Lawson if (Status == AE_NOT_FOUND) 47453289f6aSNate Lawson { 47553289f6aSNate Lawson /* The name was not found, go ahead and create it */ 47653289f6aSNate Lawson 47753289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_LOCAL_SCOPE, 47853289f6aSNate Lawson ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); 47953289f6aSNate Lawson 48053289f6aSNate Lawson /* 48153289f6aSNate Lawson * However, this is an error -- primarily because the MS 48253289f6aSNate Lawson * interpreter can't handle a forward reference from the 48353289f6aSNate Lawson * Scope() operator. 48453289f6aSNate Lawson */ 48553289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName); 48653289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, Op->Asl.ExternalName); 48753289f6aSNate Lawson goto FinishNode; 48853289f6aSNate Lawson } 48953289f6aSNate Lawson 49053289f6aSNate Lawson AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE); 49153289f6aSNate Lawson goto Exit; 49253289f6aSNate Lawson } 49353289f6aSNate Lawson 49453289f6aSNate Lawson /* We found a node with this name, now check the type */ 49553289f6aSNate Lawson 49653289f6aSNate Lawson switch (Node->Type) 49753289f6aSNate Lawson { 49853289f6aSNate Lawson case ACPI_TYPE_LOCAL_SCOPE: 49953289f6aSNate Lawson case ACPI_TYPE_DEVICE: 50053289f6aSNate Lawson case ACPI_TYPE_POWER: 50153289f6aSNate Lawson case ACPI_TYPE_PROCESSOR: 50253289f6aSNate Lawson case ACPI_TYPE_THERMAL: 50353289f6aSNate Lawson 50453289f6aSNate Lawson /* These are acceptable types - they all open a new scope */ 50553289f6aSNate Lawson break; 50653289f6aSNate Lawson 50753289f6aSNate Lawson case ACPI_TYPE_INTEGER: 50853289f6aSNate Lawson case ACPI_TYPE_STRING: 50953289f6aSNate Lawson case ACPI_TYPE_BUFFER: 51053289f6aSNate Lawson 51153289f6aSNate Lawson /* 51253289f6aSNate Lawson * These types we will allow, but we will change the type. This 51353289f6aSNate Lawson * enables some existing code of the form: 51453289f6aSNate Lawson * 51553289f6aSNate Lawson * Name (DEB, 0) 51653289f6aSNate Lawson * Scope (DEB) { ... } 51753289f6aSNate Lawson * 51853289f6aSNate Lawson * Which is used to workaround the fact that the MS interpreter 51953289f6aSNate Lawson * does not allow Scope() forward references. 52053289f6aSNate Lawson */ 521*e0ef747bSNate Lawson sprintf (MsgBuffer, "%s [%s], changing type to [Scope]", 52253289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 52353289f6aSNate Lawson AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 52453289f6aSNate Lawson 52553289f6aSNate Lawson /* 526*e0ef747bSNate Lawson * Switch the type to scope, open the new scope 52753289f6aSNate Lawson */ 528*e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 529*e0ef747bSNate Lawson Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, WalkState); 530*e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 531*e0ef747bSNate Lawson { 532*e0ef747bSNate Lawson return_ACPI_STATUS (Status); 533*e0ef747bSNate Lawson } 53453289f6aSNate Lawson break; 53553289f6aSNate Lawson 53653289f6aSNate Lawson default: 53753289f6aSNate Lawson 53853289f6aSNate Lawson /* 53953289f6aSNate Lawson * All other types are an error 54053289f6aSNate Lawson */ 541*e0ef747bSNate Lawson sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 54253289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); 54353289f6aSNate Lawson 54453289f6aSNate Lawson /* 54553289f6aSNate Lawson * However, switch the type to be an actual scope so 54653289f6aSNate Lawson * that compilation can continue without generating a whole 547*e0ef747bSNate Lawson * cascade of additional errors. Open the new scope. 54853289f6aSNate Lawson */ 549*e0ef747bSNate Lawson Node->Type = ACPI_TYPE_LOCAL_SCOPE; 550*e0ef747bSNate Lawson Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, WalkState); 551*e0ef747bSNate Lawson if (ACPI_FAILURE (Status)) 552*e0ef747bSNate Lawson { 553*e0ef747bSNate Lawson return_ACPI_STATUS (Status); 554*e0ef747bSNate Lawson } 55553289f6aSNate Lawson break; 55653289f6aSNate Lawson } 55753289f6aSNate Lawson 55853289f6aSNate Lawson Status = AE_OK; 55953289f6aSNate Lawson goto FinishNode; 56053289f6aSNate Lawson 56153289f6aSNate Lawson 56253289f6aSNate Lawson default: 56353289f6aSNate Lawson 56453289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 56553289f6aSNate Lawson break; 56653289f6aSNate Lawson } 56753289f6aSNate Lawson 56853289f6aSNate Lawson 56953289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", 57053289f6aSNate Lawson Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); 57153289f6aSNate Lawson 57253289f6aSNate Lawson /* The name must not already exist */ 57353289f6aSNate Lawson 57453289f6aSNate Lawson Flags |= ACPI_NS_ERROR_IF_FOUND; 57553289f6aSNate Lawson 57653289f6aSNate Lawson /* 57753289f6aSNate Lawson * Enter the named type into the internal namespace. We enter the name 57853289f6aSNate Lawson * as we go downward in the parse tree. Any necessary subobjects that involve 57953289f6aSNate Lawson * arguments to the opcode must be created as we go back up the parse tree later. 58053289f6aSNate Lawson */ 58153289f6aSNate Lawson Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 58253289f6aSNate Lawson ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); 58353289f6aSNate Lawson if (ACPI_FAILURE (Status)) 58453289f6aSNate Lawson { 58553289f6aSNate Lawson if (Status == AE_ALREADY_EXISTS) 58653289f6aSNate Lawson { 58753289f6aSNate Lawson /* The name already exists in this scope */ 58853289f6aSNate Lawson 58953289f6aSNate Lawson if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 59053289f6aSNate Lawson { 59153289f6aSNate Lawson Node->Type = (UINT8) ObjectType; 59253289f6aSNate Lawson Status = AE_OK; 59353289f6aSNate Lawson } 59453289f6aSNate Lawson else 59553289f6aSNate Lawson { 59653289f6aSNate Lawson AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, Op->Asl.ExternalName); 59753289f6aSNate Lawson Status = AE_OK; 59853289f6aSNate Lawson goto Exit; 59953289f6aSNate Lawson } 60053289f6aSNate Lawson } 60153289f6aSNate Lawson else 60253289f6aSNate Lawson { 60353289f6aSNate Lawson AslCoreSubsystemError (Op, Status, "Failure from lookup %s\n", FALSE); 60453289f6aSNate Lawson goto Exit; 60553289f6aSNate Lawson } 60653289f6aSNate Lawson } 60753289f6aSNate Lawson 60853289f6aSNate Lawson 60953289f6aSNate Lawson FinishNode: 61053289f6aSNate Lawson /* 61153289f6aSNate Lawson * Point the parse node to the new namespace node, and point 61253289f6aSNate Lawson * the Node back to the original Parse node 61353289f6aSNate Lawson */ 61453289f6aSNate Lawson Op->Asl.Node = Node; 61553289f6aSNate Lawson Node->Object = (ACPI_OPERAND_OBJECT *) Op; 61653289f6aSNate Lawson 61753289f6aSNate Lawson /* Set the actual data type if appropriate (EXTERNAL term only) */ 61853289f6aSNate Lawson 61953289f6aSNate Lawson if (ActualObjectType != ACPI_TYPE_ANY) 62053289f6aSNate Lawson { 62153289f6aSNate Lawson Node->Type = (UINT8) ActualObjectType; 62253289f6aSNate Lawson Node->OwnerId = ASL_EXTERNAL_METHOD; 62353289f6aSNate Lawson } 62453289f6aSNate Lawson 62553289f6aSNate Lawson if (Op->Asl.ParseOpcode == PARSEOP_METHOD) 62653289f6aSNate Lawson { 62753289f6aSNate Lawson /* 62853289f6aSNate Lawson * Get the method argument count from "Extra" and store 62953289f6aSNate Lawson * it in the OwnerId field of the namespace node 63053289f6aSNate Lawson */ 63153289f6aSNate Lawson Node->OwnerId = (UINT16) Op->Asl.Extra; 63253289f6aSNate Lawson } 63353289f6aSNate Lawson 63453289f6aSNate Lawson Exit: 63553289f6aSNate Lawson return (Status); 63653289f6aSNate Lawson } 63753289f6aSNate Lawson 63853289f6aSNate Lawson 63953289f6aSNate Lawson /******************************************************************************* 64053289f6aSNate Lawson * 64153289f6aSNate Lawson * FUNCTION: LdNamespace1End 64253289f6aSNate Lawson * 64353289f6aSNate Lawson * PARAMETERS: ASL_WALK_CALLBACK 64453289f6aSNate Lawson * 64553289f6aSNate Lawson * RETURN: Status 64653289f6aSNate Lawson * 64753289f6aSNate Lawson * DESCRIPTION: Ascending callback used during the loading of the namespace, 64853289f6aSNate Lawson * We only need to worry about managing the scope stack here. 64953289f6aSNate Lawson * 65053289f6aSNate Lawson ******************************************************************************/ 65153289f6aSNate Lawson 65253289f6aSNate Lawson ACPI_STATUS 65353289f6aSNate Lawson LdNamespace1End ( 65453289f6aSNate Lawson ACPI_PARSE_OBJECT *Op, 65553289f6aSNate Lawson UINT32 Level, 65653289f6aSNate Lawson void *Context) 65753289f6aSNate Lawson { 65853289f6aSNate Lawson ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 65953289f6aSNate Lawson ACPI_OBJECT_TYPE ObjectType; 66053289f6aSNate Lawson 66153289f6aSNate Lawson 66253289f6aSNate Lawson ACPI_FUNCTION_NAME ("LdNamespace1End"); 66353289f6aSNate Lawson 66453289f6aSNate Lawson 66553289f6aSNate Lawson /* We are only interested in opcodes that have an associated name */ 66653289f6aSNate Lawson 66753289f6aSNate Lawson if (!Op->Asl.Namepath) 66853289f6aSNate Lawson { 66953289f6aSNate Lawson return (AE_OK); 67053289f6aSNate Lawson } 67153289f6aSNate Lawson 67253289f6aSNate Lawson /* Get the type to determine if we should pop the scope */ 67353289f6aSNate Lawson 67453289f6aSNate Lawson if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 67553289f6aSNate Lawson (Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)) 67653289f6aSNate Lawson { 67753289f6aSNate Lawson /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */ 67853289f6aSNate Lawson 67953289f6aSNate Lawson ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 68053289f6aSNate Lawson } 68153289f6aSNate Lawson else 68253289f6aSNate Lawson { 68353289f6aSNate Lawson ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 68453289f6aSNate Lawson } 68553289f6aSNate Lawson 68653289f6aSNate Lawson /* Pop the scope stack */ 68753289f6aSNate Lawson 68853289f6aSNate Lawson if (AcpiNsOpensScope (ObjectType)) 68953289f6aSNate Lawson { 69053289f6aSNate Lawson 69153289f6aSNate Lawson ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 69253289f6aSNate Lawson "(%s): Popping scope for Op [%s] %p\n", 69353289f6aSNate Lawson AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); 69453289f6aSNate Lawson 69553289f6aSNate Lawson AcpiDsScopeStackPop (WalkState); 69653289f6aSNate Lawson } 69753289f6aSNate Lawson 69853289f6aSNate Lawson return (AE_OK); 69953289f6aSNate Lawson } 70053289f6aSNate Lawson 70153289f6aSNate Lawson 702