1a159c266SJung-uk Kim /****************************************************************************** 2a159c266SJung-uk Kim * 3a159c266SJung-uk Kim * Module Name: dswload - Dispatcher first pass namespace load callbacks 4a159c266SJung-uk Kim * 5a159c266SJung-uk Kim *****************************************************************************/ 6a159c266SJung-uk Kim 7*0d84335fSJung-uk Kim /****************************************************************************** 8*0d84335fSJung-uk Kim * 9*0d84335fSJung-uk Kim * 1. Copyright Notice 10*0d84335fSJung-uk Kim * 11*0d84335fSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 12a159c266SJung-uk Kim * All rights reserved. 13a159c266SJung-uk Kim * 14*0d84335fSJung-uk Kim * 2. License 15*0d84335fSJung-uk Kim * 16*0d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 17*0d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 18*0d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 19*0d84335fSJung-uk Kim * property rights. 20*0d84335fSJung-uk Kim * 21*0d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22*0d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 23*0d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24*0d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 25*0d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 26*0d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 27*0d84335fSJung-uk Kim * 28*0d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29*0d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 30*0d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 31*0d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 32*0d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 33*0d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 34*0d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 35*0d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 36*0d84335fSJung-uk Kim * 37*0d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 38*0d84335fSJung-uk Kim * conditions are met: 39*0d84335fSJung-uk Kim * 40*0d84335fSJung-uk Kim * 3. Conditions 41*0d84335fSJung-uk Kim * 42*0d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 44*0d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 45*0d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 46*0d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 47*0d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 48*0d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 49*0d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 50*0d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 51*0d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 52*0d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 53*0d84335fSJung-uk Kim * 54*0d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 56*0d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 57*0d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 58*0d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 59*0d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 60*0d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 61*0d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 62*0d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 63*0d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 64*0d84335fSJung-uk Kim * make. 65*0d84335fSJung-uk Kim * 66*0d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67*0d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 68*0d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 69*0d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 70*0d84335fSJung-uk Kim * distribution. 71*0d84335fSJung-uk Kim * 72*0d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 73*0d84335fSJung-uk Kim * Intel Code. 74*0d84335fSJung-uk Kim * 75*0d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76*0d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 77*0d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 78*0d84335fSJung-uk Kim * without prior written authorization from Intel. 79*0d84335fSJung-uk Kim * 80*0d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 81*0d84335fSJung-uk Kim * 82*0d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83*0d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84*0d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85*0d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86*0d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87*0d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88*0d84335fSJung-uk Kim * PARTICULAR PURPOSE. 89*0d84335fSJung-uk Kim * 90*0d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91*0d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92*0d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93*0d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94*0d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95*0d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96*0d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97*0d84335fSJung-uk Kim * LIMITED REMEDY. 98*0d84335fSJung-uk Kim * 99*0d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100*0d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 101*0d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 102*0d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 103*0d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 104*0d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 105*0d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 106*0d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 107*0d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108*0d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 109*0d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 110*0d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 111*0d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 112*0d84335fSJung-uk Kim * such license, approval or letter. 113*0d84335fSJung-uk Kim * 114*0d84335fSJung-uk Kim ***************************************************************************** 115*0d84335fSJung-uk Kim * 116*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 117*0d84335fSJung-uk Kim * following license: 118*0d84335fSJung-uk Kim * 119a159c266SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120a159c266SJung-uk Kim * modification, are permitted provided that the following conditions 121a159c266SJung-uk Kim * are met: 122a159c266SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123a159c266SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124a159c266SJung-uk Kim * without modification. 125a159c266SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126a159c266SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127a159c266SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128a159c266SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129a159c266SJung-uk Kim * binary redistribution. 130a159c266SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131a159c266SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132a159c266SJung-uk Kim * from this software without specific prior written permission. 133a159c266SJung-uk Kim * 134*0d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135*0d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136*0d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137*0d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138*0d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139*0d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140*0d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141*0d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142*0d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143*0d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144*0d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145*0d84335fSJung-uk Kim * 146*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 147a159c266SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148a159c266SJung-uk Kim * Software Foundation. 149a159c266SJung-uk Kim * 150*0d84335fSJung-uk Kim *****************************************************************************/ 151a159c266SJung-uk Kim 152a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h> 153a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h> 154a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 155a159c266SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h> 156a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdispat.h> 157a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acinterp.h> 158a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 159a159c266SJung-uk Kim 160a159c266SJung-uk Kim #ifdef ACPI_ASL_COMPILER 161a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h> 162a159c266SJung-uk Kim #endif 163a159c266SJung-uk Kim 164a159c266SJung-uk Kim #define _COMPONENT ACPI_DISPATCHER 165a159c266SJung-uk Kim ACPI_MODULE_NAME ("dswload") 166a159c266SJung-uk Kim 167a159c266SJung-uk Kim 168a159c266SJung-uk Kim /******************************************************************************* 169a159c266SJung-uk Kim * 170a159c266SJung-uk Kim * FUNCTION: AcpiDsInitCallbacks 171a159c266SJung-uk Kim * 172a159c266SJung-uk Kim * PARAMETERS: WalkState - Current state of the parse tree walk 173a159c266SJung-uk Kim * PassNumber - 1, 2, or 3 174a159c266SJung-uk Kim * 175a159c266SJung-uk Kim * RETURN: Status 176a159c266SJung-uk Kim * 177a159c266SJung-uk Kim * DESCRIPTION: Init walk state callbacks 178a159c266SJung-uk Kim * 179a159c266SJung-uk Kim ******************************************************************************/ 180a159c266SJung-uk Kim 181a159c266SJung-uk Kim ACPI_STATUS 182a159c266SJung-uk Kim AcpiDsInitCallbacks ( 183a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState, 184a159c266SJung-uk Kim UINT32 PassNumber) 185a159c266SJung-uk Kim { 186a159c266SJung-uk Kim 187a159c266SJung-uk Kim switch (PassNumber) 188a159c266SJung-uk Kim { 189313a0c13SJung-uk Kim case 0: 190313a0c13SJung-uk Kim 191313a0c13SJung-uk Kim /* Parse only - caller will setup callbacks */ 192313a0c13SJung-uk Kim 193313a0c13SJung-uk Kim WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 194313a0c13SJung-uk Kim ACPI_PARSE_DELETE_TREE | 195313a0c13SJung-uk Kim ACPI_PARSE_DISASSEMBLE; 196313a0c13SJung-uk Kim WalkState->DescendingCallback = NULL; 197313a0c13SJung-uk Kim WalkState->AscendingCallback = NULL; 198313a0c13SJung-uk Kim break; 199313a0c13SJung-uk Kim 200a159c266SJung-uk Kim case 1: 201a9d8d09cSJung-uk Kim 202313a0c13SJung-uk Kim /* Load pass 1 */ 203313a0c13SJung-uk Kim 204a159c266SJung-uk Kim WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 205a159c266SJung-uk Kim ACPI_PARSE_DELETE_TREE; 206a159c266SJung-uk Kim WalkState->DescendingCallback = AcpiDsLoad1BeginOp; 207a159c266SJung-uk Kim WalkState->AscendingCallback = AcpiDsLoad1EndOp; 208a159c266SJung-uk Kim break; 209a159c266SJung-uk Kim 210a159c266SJung-uk Kim case 2: 211a9d8d09cSJung-uk Kim 212313a0c13SJung-uk Kim /* Load pass 2 */ 213313a0c13SJung-uk Kim 214a159c266SJung-uk Kim WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 215a159c266SJung-uk Kim ACPI_PARSE_DELETE_TREE; 216a159c266SJung-uk Kim WalkState->DescendingCallback = AcpiDsLoad2BeginOp; 217a159c266SJung-uk Kim WalkState->AscendingCallback = AcpiDsLoad2EndOp; 218a159c266SJung-uk Kim break; 219a159c266SJung-uk Kim 220a159c266SJung-uk Kim case 3: 221a9d8d09cSJung-uk Kim 222313a0c13SJung-uk Kim /* Execution pass */ 223313a0c13SJung-uk Kim 224a159c266SJung-uk Kim #ifndef ACPI_NO_METHOD_EXECUTION 225a159c266SJung-uk Kim WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | 226a159c266SJung-uk Kim ACPI_PARSE_DELETE_TREE; 227a159c266SJung-uk Kim WalkState->DescendingCallback = AcpiDsExecBeginOp; 228a159c266SJung-uk Kim WalkState->AscendingCallback = AcpiDsExecEndOp; 229a159c266SJung-uk Kim #endif 230a159c266SJung-uk Kim break; 231a159c266SJung-uk Kim 232a159c266SJung-uk Kim default: 233a9d8d09cSJung-uk Kim 234a159c266SJung-uk Kim return (AE_BAD_PARAMETER); 235a159c266SJung-uk Kim } 236a159c266SJung-uk Kim 237a159c266SJung-uk Kim return (AE_OK); 238a159c266SJung-uk Kim } 239a159c266SJung-uk Kim 240a159c266SJung-uk Kim 241a159c266SJung-uk Kim /******************************************************************************* 242a159c266SJung-uk Kim * 243a159c266SJung-uk Kim * FUNCTION: AcpiDsLoad1BeginOp 244a159c266SJung-uk Kim * 245a159c266SJung-uk Kim * PARAMETERS: WalkState - Current state of the parse tree walk 246a159c266SJung-uk Kim * OutOp - Where to return op if a new one is created 247a159c266SJung-uk Kim * 248a159c266SJung-uk Kim * RETURN: Status 249a159c266SJung-uk Kim * 250a159c266SJung-uk Kim * DESCRIPTION: Descending callback used during the loading of ACPI tables. 251a159c266SJung-uk Kim * 252a159c266SJung-uk Kim ******************************************************************************/ 253a159c266SJung-uk Kim 254a159c266SJung-uk Kim ACPI_STATUS 255a159c266SJung-uk Kim AcpiDsLoad1BeginOp ( 256a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState, 257a159c266SJung-uk Kim ACPI_PARSE_OBJECT **OutOp) 258a159c266SJung-uk Kim { 259a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op; 260a159c266SJung-uk Kim ACPI_NAMESPACE_NODE *Node; 261a159c266SJung-uk Kim ACPI_STATUS Status; 262a159c266SJung-uk Kim ACPI_OBJECT_TYPE ObjectType; 263a159c266SJung-uk Kim char *Path; 264a159c266SJung-uk Kim UINT32 Flags; 265a159c266SJung-uk Kim 266a159c266SJung-uk Kim 267a159c266SJung-uk Kim ACPI_FUNCTION_TRACE (DsLoad1BeginOp); 268a159c266SJung-uk Kim 269a159c266SJung-uk Kim 270a159c266SJung-uk Kim Op = WalkState->Op; 271a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 272a159c266SJung-uk Kim 273a159c266SJung-uk Kim /* We are only interested in opcodes that have an associated name */ 274a159c266SJung-uk Kim 275a159c266SJung-uk Kim if (Op) 276a159c266SJung-uk Kim { 277a159c266SJung-uk Kim if (!(WalkState->OpInfo->Flags & AML_NAMED)) 278a159c266SJung-uk Kim { 279a159c266SJung-uk Kim *OutOp = Op; 280a159c266SJung-uk Kim return_ACPI_STATUS (AE_OK); 281a159c266SJung-uk Kim } 282a159c266SJung-uk Kim 283a159c266SJung-uk Kim /* Check if this object has already been installed in the namespace */ 284a159c266SJung-uk Kim 285a159c266SJung-uk Kim if (Op->Common.Node) 286a159c266SJung-uk Kim { 287a159c266SJung-uk Kim *OutOp = Op; 288a159c266SJung-uk Kim return_ACPI_STATUS (AE_OK); 289a159c266SJung-uk Kim } 290a159c266SJung-uk Kim } 291a159c266SJung-uk Kim 292a159c266SJung-uk Kim Path = AcpiPsGetNextNamestring (&WalkState->ParserState); 293a159c266SJung-uk Kim 294a159c266SJung-uk Kim /* Map the raw opcode into an internal object type */ 295a159c266SJung-uk Kim 296a159c266SJung-uk Kim ObjectType = WalkState->OpInfo->ObjectType; 297a159c266SJung-uk Kim 298a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 299f8146b88SJung-uk Kim "State=%p Op=%p [%s]\n", WalkState, Op, 300f8146b88SJung-uk Kim AcpiUtGetTypeName (ObjectType))); 301a159c266SJung-uk Kim 302a159c266SJung-uk Kim switch (WalkState->Opcode) 303a159c266SJung-uk Kim { 304a159c266SJung-uk Kim case AML_SCOPE_OP: 305a159c266SJung-uk Kim /* 306a159c266SJung-uk Kim * The target name of the Scope() operator must exist at this point so 307a159c266SJung-uk Kim * that we can actually open the scope to enter new names underneath it. 308a159c266SJung-uk Kim * Allow search-to-root for single namesegs. 309a159c266SJung-uk Kim */ 310a159c266SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 311a159c266SJung-uk Kim ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); 312a159c266SJung-uk Kim #ifdef ACPI_ASL_COMPILER 313a159c266SJung-uk Kim if (Status == AE_NOT_FOUND) 314a159c266SJung-uk Kim { 315a159c266SJung-uk Kim /* 316a159c266SJung-uk Kim * Table disassembly: 317a159c266SJung-uk Kim * Target of Scope() not found. Generate an External for it, and 318a159c266SJung-uk Kim * insert the name into the namespace. 319a159c266SJung-uk Kim */ 320313a0c13SJung-uk Kim AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0); 321a159c266SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 322a159c266SJung-uk Kim ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 323a159c266SJung-uk Kim WalkState, &Node); 324a159c266SJung-uk Kim } 325a159c266SJung-uk Kim #endif 326a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 327a159c266SJung-uk Kim { 328a159c266SJung-uk Kim ACPI_ERROR_NAMESPACE (Path, Status); 329a159c266SJung-uk Kim return_ACPI_STATUS (Status); 330a159c266SJung-uk Kim } 331a159c266SJung-uk Kim 332a159c266SJung-uk Kim /* 333a159c266SJung-uk Kim * Check to make sure that the target is 334a159c266SJung-uk Kim * one of the opcodes that actually opens a scope 335a159c266SJung-uk Kim */ 336a159c266SJung-uk Kim switch (Node->Type) 337a159c266SJung-uk Kim { 338a159c266SJung-uk Kim case ACPI_TYPE_ANY: 339a159c266SJung-uk Kim case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 340a159c266SJung-uk Kim case ACPI_TYPE_DEVICE: 341a159c266SJung-uk Kim case ACPI_TYPE_POWER: 342a159c266SJung-uk Kim case ACPI_TYPE_PROCESSOR: 343a159c266SJung-uk Kim case ACPI_TYPE_THERMAL: 344a159c266SJung-uk Kim 345a159c266SJung-uk Kim /* These are acceptable types */ 346a159c266SJung-uk Kim break; 347a159c266SJung-uk Kim 348a159c266SJung-uk Kim case ACPI_TYPE_INTEGER: 349a159c266SJung-uk Kim case ACPI_TYPE_STRING: 350a159c266SJung-uk Kim case ACPI_TYPE_BUFFER: 351a159c266SJung-uk Kim /* 352a159c266SJung-uk Kim * These types we will allow, but we will change the type. 353a159c266SJung-uk Kim * This enables some existing code of the form: 354a159c266SJung-uk Kim * 355a159c266SJung-uk Kim * Name (DEB, 0) 356a159c266SJung-uk Kim * Scope (DEB) { ... } 357a159c266SJung-uk Kim * 358a159c266SJung-uk Kim * Note: silently change the type here. On the second pass, 359a159c266SJung-uk Kim * we will report a warning 360a159c266SJung-uk Kim */ 361a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 362a159c266SJung-uk Kim "Type override - [%4.4s] had invalid type (%s) " 363a159c266SJung-uk Kim "for Scope operator, changed to type ANY\n", 364a159c266SJung-uk Kim AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); 365a159c266SJung-uk Kim 366a159c266SJung-uk Kim Node->Type = ACPI_TYPE_ANY; 367a159c266SJung-uk Kim WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; 368a159c266SJung-uk Kim break; 369a159c266SJung-uk Kim 3701df130f1SJung-uk Kim case ACPI_TYPE_METHOD: 3711df130f1SJung-uk Kim /* 3721df130f1SJung-uk Kim * Allow scope change to root during execution of module-level 3731df130f1SJung-uk Kim * code. Root is typed METHOD during this time. 3741df130f1SJung-uk Kim */ 3751df130f1SJung-uk Kim if ((Node == AcpiGbl_RootNode) && 3761df130f1SJung-uk Kim (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) 3771df130f1SJung-uk Kim { 3781df130f1SJung-uk Kim break; 3791df130f1SJung-uk Kim } 3801df130f1SJung-uk Kim 3811df130f1SJung-uk Kim /*lint -fallthrough */ 3821df130f1SJung-uk Kim 383a159c266SJung-uk Kim default: 384a159c266SJung-uk Kim 385a159c266SJung-uk Kim /* All other types are an error */ 386a159c266SJung-uk Kim 387a159c266SJung-uk Kim ACPI_ERROR ((AE_INFO, 388a159c266SJung-uk Kim "Invalid type (%s) for target of " 389a159c266SJung-uk Kim "Scope operator [%4.4s] (Cannot override)", 390a159c266SJung-uk Kim AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); 391a159c266SJung-uk Kim 392a159c266SJung-uk Kim return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 393a159c266SJung-uk Kim } 394a159c266SJung-uk Kim break; 395a159c266SJung-uk Kim 396a159c266SJung-uk Kim default: 397a159c266SJung-uk Kim /* 398a159c266SJung-uk Kim * For all other named opcodes, we will enter the name into 399a159c266SJung-uk Kim * the namespace. 400a159c266SJung-uk Kim * 401a159c266SJung-uk Kim * Setup the search flags. 402a159c266SJung-uk Kim * Since we are entering a name into the namespace, we do not want to 403a159c266SJung-uk Kim * enable the search-to-root upsearch. 404a159c266SJung-uk Kim * 405a159c266SJung-uk Kim * There are only two conditions where it is acceptable that the name 406a159c266SJung-uk Kim * already exists: 407a159c266SJung-uk Kim * 1) the Scope() operator can reopen a scoping object that was 408a159c266SJung-uk Kim * previously defined (Scope, Method, Device, etc.) 409a159c266SJung-uk Kim * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, 410a159c266SJung-uk Kim * BufferField, or Package), the name of the object is already 411a159c266SJung-uk Kim * in the namespace. 412a159c266SJung-uk Kim */ 413a159c266SJung-uk Kim if (WalkState->DeferredNode) 414a159c266SJung-uk Kim { 415a159c266SJung-uk Kim /* This name is already in the namespace, get the node */ 416a159c266SJung-uk Kim 417a159c266SJung-uk Kim Node = WalkState->DeferredNode; 418a159c266SJung-uk Kim Status = AE_OK; 419a159c266SJung-uk Kim break; 420a159c266SJung-uk Kim } 421a159c266SJung-uk Kim 422a159c266SJung-uk Kim /* 423a159c266SJung-uk Kim * If we are executing a method, do not create any namespace objects 424a159c266SJung-uk Kim * during the load phase, only during execution. 425a159c266SJung-uk Kim */ 426a159c266SJung-uk Kim if (WalkState->MethodNode) 427a159c266SJung-uk Kim { 428a159c266SJung-uk Kim Node = NULL; 429a159c266SJung-uk Kim Status = AE_OK; 430a159c266SJung-uk Kim break; 431a159c266SJung-uk Kim } 432a159c266SJung-uk Kim 433a159c266SJung-uk Kim Flags = ACPI_NS_NO_UPSEARCH; 434a159c266SJung-uk Kim if ((WalkState->Opcode != AML_SCOPE_OP) && 435a159c266SJung-uk Kim (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) 436a159c266SJung-uk Kim { 4375ef50723SJung-uk Kim if (WalkState->NamespaceOverride) 4385ef50723SJung-uk Kim { 4395ef50723SJung-uk Kim Flags |= ACPI_NS_OVERRIDE_IF_FOUND; 4405ef50723SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n", 4415ef50723SJung-uk Kim AcpiUtGetTypeName (ObjectType))); 4425ef50723SJung-uk Kim } 4435ef50723SJung-uk Kim else 4445ef50723SJung-uk Kim { 445a159c266SJung-uk Kim Flags |= ACPI_NS_ERROR_IF_FOUND; 446a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", 447a159c266SJung-uk Kim AcpiUtGetTypeName (ObjectType))); 448a159c266SJung-uk Kim } 4495ef50723SJung-uk Kim } 450a159c266SJung-uk Kim else 451a159c266SJung-uk Kim { 452a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 453a159c266SJung-uk Kim "[%s] Both Find or Create allowed\n", 454a159c266SJung-uk Kim AcpiUtGetTypeName (ObjectType))); 455a159c266SJung-uk Kim } 456a159c266SJung-uk Kim 457a159c266SJung-uk Kim /* 458a159c266SJung-uk Kim * Enter the named type into the internal namespace. We enter the name 459a159c266SJung-uk Kim * as we go downward in the parse tree. Any necessary subobjects that 460a159c266SJung-uk Kim * involve arguments to the opcode must be created as we go back up the 461a159c266SJung-uk Kim * parse tree later. 462a159c266SJung-uk Kim */ 463a159c266SJung-uk Kim Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 464a159c266SJung-uk Kim ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 465a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 466a159c266SJung-uk Kim { 467a159c266SJung-uk Kim if (Status == AE_ALREADY_EXISTS) 468a159c266SJung-uk Kim { 469a159c266SJung-uk Kim /* The name already exists in this scope */ 470a159c266SJung-uk Kim 471a159c266SJung-uk Kim if (Node->Flags & ANOBJ_IS_EXTERNAL) 472a159c266SJung-uk Kim { 473a159c266SJung-uk Kim /* 474a159c266SJung-uk Kim * Allow one create on an object or segment that was 475a159c266SJung-uk Kim * previously declared External 476a159c266SJung-uk Kim */ 477a159c266SJung-uk Kim Node->Flags &= ~ANOBJ_IS_EXTERNAL; 478a159c266SJung-uk Kim Node->Type = (UINT8) ObjectType; 479a159c266SJung-uk Kim 480a159c266SJung-uk Kim /* Just retyped a node, probably will need to open a scope */ 481a159c266SJung-uk Kim 482a159c266SJung-uk Kim if (AcpiNsOpensScope (ObjectType)) 483a159c266SJung-uk Kim { 484f8146b88SJung-uk Kim Status = AcpiDsScopeStackPush ( 485f8146b88SJung-uk Kim Node, ObjectType, WalkState); 486a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 487a159c266SJung-uk Kim { 488a159c266SJung-uk Kim return_ACPI_STATUS (Status); 489a159c266SJung-uk Kim } 490a159c266SJung-uk Kim } 491a159c266SJung-uk Kim 492a159c266SJung-uk Kim Status = AE_OK; 493a159c266SJung-uk Kim } 494a159c266SJung-uk Kim } 495a159c266SJung-uk Kim 496a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 497a159c266SJung-uk Kim { 498a159c266SJung-uk Kim ACPI_ERROR_NAMESPACE (Path, Status); 499a159c266SJung-uk Kim return_ACPI_STATUS (Status); 500a159c266SJung-uk Kim } 501a159c266SJung-uk Kim } 502a159c266SJung-uk Kim break; 503a159c266SJung-uk Kim } 504a159c266SJung-uk Kim 505a159c266SJung-uk Kim /* Common exit */ 506a159c266SJung-uk Kim 507a159c266SJung-uk Kim if (!Op) 508a159c266SJung-uk Kim { 509a159c266SJung-uk Kim /* Create a new op */ 510a159c266SJung-uk Kim 511fe0f0bbbSJung-uk Kim Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml); 512a159c266SJung-uk Kim if (!Op) 513a159c266SJung-uk Kim { 514a159c266SJung-uk Kim return_ACPI_STATUS (AE_NO_MEMORY); 515a159c266SJung-uk Kim } 516a159c266SJung-uk Kim } 517a159c266SJung-uk Kim 518a159c266SJung-uk Kim /* Initialize the op */ 519a159c266SJung-uk Kim 520a159c266SJung-uk Kim #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) 521a159c266SJung-uk Kim Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); 522a159c266SJung-uk Kim #endif 523a159c266SJung-uk Kim 524a159c266SJung-uk Kim if (Node) 525a159c266SJung-uk Kim { 526a159c266SJung-uk Kim /* 527a159c266SJung-uk Kim * Put the Node in the "op" object that the parser uses, so we 528a159c266SJung-uk Kim * can get it again quickly when this scope is closed 529a159c266SJung-uk Kim */ 530a159c266SJung-uk Kim Op->Common.Node = Node; 531a159c266SJung-uk Kim Op->Named.Name = Node->Name.Integer; 532a159c266SJung-uk Kim } 533a159c266SJung-uk Kim 534a159c266SJung-uk Kim AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); 535a159c266SJung-uk Kim *OutOp = Op; 536a159c266SJung-uk Kim return_ACPI_STATUS (Status); 537a159c266SJung-uk Kim } 538a159c266SJung-uk Kim 539a159c266SJung-uk Kim 540a159c266SJung-uk Kim /******************************************************************************* 541a159c266SJung-uk Kim * 542a159c266SJung-uk Kim * FUNCTION: AcpiDsLoad1EndOp 543a159c266SJung-uk Kim * 544a159c266SJung-uk Kim * PARAMETERS: WalkState - Current state of the parse tree walk 545a159c266SJung-uk Kim * 546a159c266SJung-uk Kim * RETURN: Status 547a159c266SJung-uk Kim * 548a159c266SJung-uk Kim * DESCRIPTION: Ascending callback used during the loading of the namespace, 549a159c266SJung-uk Kim * both control methods and everything else. 550a159c266SJung-uk Kim * 551a159c266SJung-uk Kim ******************************************************************************/ 552a159c266SJung-uk Kim 553a159c266SJung-uk Kim ACPI_STATUS 554a159c266SJung-uk Kim AcpiDsLoad1EndOp ( 555a159c266SJung-uk Kim ACPI_WALK_STATE *WalkState) 556a159c266SJung-uk Kim { 557a159c266SJung-uk Kim ACPI_PARSE_OBJECT *Op; 558a159c266SJung-uk Kim ACPI_OBJECT_TYPE ObjectType; 559a159c266SJung-uk Kim ACPI_STATUS Status = AE_OK; 560a159c266SJung-uk Kim 561a159c266SJung-uk Kim 562a159c266SJung-uk Kim ACPI_FUNCTION_TRACE (DsLoad1EndOp); 563a159c266SJung-uk Kim 564a159c266SJung-uk Kim 565a159c266SJung-uk Kim Op = WalkState->Op; 566a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 567a159c266SJung-uk Kim 568a159c266SJung-uk Kim /* We are only interested in opcodes that have an associated name */ 569a159c266SJung-uk Kim 570a159c266SJung-uk Kim if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) 571a159c266SJung-uk Kim { 572a159c266SJung-uk Kim return_ACPI_STATUS (AE_OK); 573a159c266SJung-uk Kim } 574a159c266SJung-uk Kim 575a159c266SJung-uk Kim /* Get the object type to determine if we should pop the scope */ 576a159c266SJung-uk Kim 577a159c266SJung-uk Kim ObjectType = WalkState->OpInfo->ObjectType; 578a159c266SJung-uk Kim 579a159c266SJung-uk Kim #ifndef ACPI_NO_METHOD_EXECUTION 580a159c266SJung-uk Kim if (WalkState->OpInfo->Flags & AML_FIELD) 581a159c266SJung-uk Kim { 582a159c266SJung-uk Kim /* 583a159c266SJung-uk Kim * If we are executing a method, do not create any namespace objects 584a159c266SJung-uk Kim * during the load phase, only during execution. 585a159c266SJung-uk Kim */ 586a159c266SJung-uk Kim if (!WalkState->MethodNode) 587a159c266SJung-uk Kim { 588a159c266SJung-uk Kim if (WalkState->Opcode == AML_FIELD_OP || 589a159c266SJung-uk Kim WalkState->Opcode == AML_BANK_FIELD_OP || 590a159c266SJung-uk Kim WalkState->Opcode == AML_INDEX_FIELD_OP) 591a159c266SJung-uk Kim { 592a159c266SJung-uk Kim Status = AcpiDsInitFieldObjects (Op, WalkState); 593a159c266SJung-uk Kim } 594a159c266SJung-uk Kim } 595a159c266SJung-uk Kim return_ACPI_STATUS (Status); 596a159c266SJung-uk Kim } 597a159c266SJung-uk Kim 598a159c266SJung-uk Kim /* 599a159c266SJung-uk Kim * If we are executing a method, do not create any namespace objects 600a159c266SJung-uk Kim * during the load phase, only during execution. 601a159c266SJung-uk Kim */ 602a159c266SJung-uk Kim if (!WalkState->MethodNode) 603a159c266SJung-uk Kim { 604a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_REGION_OP) 605a159c266SJung-uk Kim { 606a159c266SJung-uk Kim Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 607f8146b88SJung-uk Kim (ACPI_ADR_SPACE_TYPE) 608f8146b88SJung-uk Kim ((Op->Common.Value.Arg)->Common.Value.Integer), 609a159c266SJung-uk Kim WalkState); 610a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 611a159c266SJung-uk Kim { 612a159c266SJung-uk Kim return_ACPI_STATUS (Status); 613a159c266SJung-uk Kim } 614a159c266SJung-uk Kim } 615a159c266SJung-uk Kim else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) 616a159c266SJung-uk Kim { 617a159c266SJung-uk Kim Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 618a159c266SJung-uk Kim ACPI_ADR_SPACE_DATA_TABLE, WalkState); 619a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 620a159c266SJung-uk Kim { 621a159c266SJung-uk Kim return_ACPI_STATUS (Status); 622a159c266SJung-uk Kim } 623a159c266SJung-uk Kim } 624a159c266SJung-uk Kim } 625a159c266SJung-uk Kim #endif 626a159c266SJung-uk Kim 627a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_NAME_OP) 628a159c266SJung-uk Kim { 629a159c266SJung-uk Kim /* For Name opcode, get the object type from the argument */ 630a159c266SJung-uk Kim 631a159c266SJung-uk Kim if (Op->Common.Value.Arg) 632a159c266SJung-uk Kim { 633a159c266SJung-uk Kim ObjectType = (AcpiPsGetOpcodeInfo ( 634a159c266SJung-uk Kim (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; 635a159c266SJung-uk Kim 636a159c266SJung-uk Kim /* Set node type if we have a namespace node */ 637a159c266SJung-uk Kim 638a159c266SJung-uk Kim if (Op->Common.Node) 639a159c266SJung-uk Kim { 640a159c266SJung-uk Kim Op->Common.Node->Type = (UINT8) ObjectType; 641a159c266SJung-uk Kim } 642a159c266SJung-uk Kim } 643a159c266SJung-uk Kim } 644a159c266SJung-uk Kim 645a159c266SJung-uk Kim /* 646a159c266SJung-uk Kim * If we are executing a method, do not create any namespace objects 647a159c266SJung-uk Kim * during the load phase, only during execution. 648a159c266SJung-uk Kim */ 649a159c266SJung-uk Kim if (!WalkState->MethodNode) 650a159c266SJung-uk Kim { 651a159c266SJung-uk Kim if (Op->Common.AmlOpcode == AML_METHOD_OP) 652a159c266SJung-uk Kim { 653a159c266SJung-uk Kim /* 654a159c266SJung-uk Kim * MethodOp PkgLength NameString MethodFlags TermList 655a159c266SJung-uk Kim * 656a159c266SJung-uk Kim * Note: We must create the method node/object pair as soon as we 657a159c266SJung-uk Kim * see the method declaration. This allows later pass1 parsing 658a159c266SJung-uk Kim * of invocations of the method (need to know the number of 659a159c266SJung-uk Kim * arguments.) 660a159c266SJung-uk Kim */ 661a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 662a159c266SJung-uk Kim "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 663a159c266SJung-uk Kim WalkState, Op, Op->Named.Node)); 664a159c266SJung-uk Kim 665a159c266SJung-uk Kim if (!AcpiNsGetAttachedObject (Op->Named.Node)) 666a159c266SJung-uk Kim { 667a159c266SJung-uk Kim WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); 668a159c266SJung-uk Kim WalkState->NumOperands = 1; 669a159c266SJung-uk Kim 670f8146b88SJung-uk Kim Status = AcpiDsCreateOperands ( 671f8146b88SJung-uk Kim WalkState, Op->Common.Value.Arg); 672a159c266SJung-uk Kim if (ACPI_SUCCESS (Status)) 673a159c266SJung-uk Kim { 674a159c266SJung-uk Kim Status = AcpiExCreateMethod (Op->Named.Data, 675a159c266SJung-uk Kim Op->Named.Length, WalkState); 676a159c266SJung-uk Kim } 677a159c266SJung-uk Kim 678a159c266SJung-uk Kim WalkState->Operands[0] = NULL; 679a159c266SJung-uk Kim WalkState->NumOperands = 0; 680a159c266SJung-uk Kim 681a159c266SJung-uk Kim if (ACPI_FAILURE (Status)) 682a159c266SJung-uk Kim { 683a159c266SJung-uk Kim return_ACPI_STATUS (Status); 684a159c266SJung-uk Kim } 685a159c266SJung-uk Kim } 686a159c266SJung-uk Kim } 687a159c266SJung-uk Kim } 688a159c266SJung-uk Kim 689a159c266SJung-uk Kim /* Pop the scope stack (only if loading a table) */ 690a159c266SJung-uk Kim 691a159c266SJung-uk Kim if (!WalkState->MethodNode && 692a159c266SJung-uk Kim AcpiNsOpensScope (ObjectType)) 693a159c266SJung-uk Kim { 694a159c266SJung-uk Kim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 695a159c266SJung-uk Kim AcpiUtGetTypeName (ObjectType), Op)); 696a159c266SJung-uk Kim 697a159c266SJung-uk Kim Status = AcpiDsScopeStackPop (WalkState); 698a159c266SJung-uk Kim } 699a159c266SJung-uk Kim 700a159c266SJung-uk Kim return_ACPI_STATUS (Status); 701a159c266SJung-uk Kim } 702