1 1.1 jruoho /****************************************************************************** 2 1.1 jruoho * 3 1.1 jruoho * Module Name: dsobject - Dispatcher object management routines 4 1.1 jruoho * 5 1.1 jruoho *****************************************************************************/ 6 1.1 jruoho 7 1.1.1.20 christos /****************************************************************************** 8 1.1.1.20 christos * 9 1.1.1.20 christos * 1. Copyright Notice 10 1.1.1.20 christos * 11 1.1.1.21 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 12 1.1 jruoho * All rights reserved. 13 1.1 jruoho * 14 1.1.1.20 christos * 2. License 15 1.1.1.20 christos * 16 1.1.1.20 christos * 2.1. This is your license from Intel Corp. under its intellectual property 17 1.1.1.20 christos * rights. You may have additional license terms from the party that provided 18 1.1.1.20 christos * you this software, covering your right to use that party's intellectual 19 1.1.1.20 christos * property rights. 20 1.1.1.20 christos * 21 1.1.1.20 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 1.1.1.20 christos * copy of the source code appearing in this file ("Covered Code") an 23 1.1.1.20 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 1.1.1.20 christos * base code distributed originally by Intel ("Original Intel Code") to copy, 25 1.1.1.20 christos * make derivatives, distribute, use and display any portion of the Covered 26 1.1.1.20 christos * Code in any form, with the right to sublicense such rights; and 27 1.1.1.20 christos * 28 1.1.1.20 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 1.1.1.20 christos * license (with the right to sublicense), under only those claims of Intel 30 1.1.1.20 christos * patents that are infringed by the Original Intel Code, to make, use, sell, 31 1.1.1.20 christos * offer to sell, and import the Covered Code and derivative works thereof 32 1.1.1.20 christos * solely to the minimum extent necessary to exercise the above copyright 33 1.1.1.20 christos * license, and in no event shall the patent license extend to any additions 34 1.1.1.20 christos * to or modifications of the Original Intel Code. No other license or right 35 1.1.1.20 christos * is granted directly or by implication, estoppel or otherwise; 36 1.1.1.20 christos * 37 1.1.1.20 christos * The above copyright and patent license is granted only if the following 38 1.1.1.20 christos * conditions are met: 39 1.1.1.20 christos * 40 1.1.1.20 christos * 3. Conditions 41 1.1.1.20 christos * 42 1.1.1.20 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 1.1.1.20 christos * Redistribution of source code of any substantial portion of the Covered 44 1.1.1.20 christos * Code or modification with rights to further distribute source must include 45 1.1.1.20 christos * the above Copyright Notice, the above License, this list of Conditions, 46 1.1.1.20 christos * and the following Disclaimer and Export Compliance provision. In addition, 47 1.1.1.20 christos * Licensee must cause all Covered Code to which Licensee contributes to 48 1.1.1.20 christos * contain a file documenting the changes Licensee made to create that Covered 49 1.1.1.20 christos * Code and the date of any change. Licensee must include in that file the 50 1.1.1.20 christos * documentation of any changes made by any predecessor Licensee. Licensee 51 1.1.1.20 christos * must include a prominent statement that the modification is derived, 52 1.1.1.20 christos * directly or indirectly, from Original Intel Code. 53 1.1.1.20 christos * 54 1.1.1.20 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 1.1.1.20 christos * Redistribution of source code of any substantial portion of the Covered 56 1.1.1.20 christos * Code or modification without rights to further distribute source must 57 1.1.1.20 christos * include the following Disclaimer and Export Compliance provision in the 58 1.1.1.20 christos * documentation and/or other materials provided with distribution. In 59 1.1.1.20 christos * addition, Licensee may not authorize further sublicense of source of any 60 1.1.1.20 christos * portion of the Covered Code, and must include terms to the effect that the 61 1.1.1.20 christos * license from Licensee to its licensee is limited to the intellectual 62 1.1.1.20 christos * property embodied in the software Licensee provides to its licensee, and 63 1.1.1.20 christos * not to intellectual property embodied in modifications its licensee may 64 1.1.1.20 christos * make. 65 1.1.1.20 christos * 66 1.1.1.20 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 1.1.1.20 christos * substantial portion of the Covered Code or modification must reproduce the 68 1.1.1.20 christos * above Copyright Notice, and the following Disclaimer and Export Compliance 69 1.1.1.20 christos * provision in the documentation and/or other materials provided with the 70 1.1.1.20 christos * distribution. 71 1.1.1.20 christos * 72 1.1.1.20 christos * 3.4. Intel retains all right, title, and interest in and to the Original 73 1.1.1.20 christos * Intel Code. 74 1.1.1.20 christos * 75 1.1.1.20 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 1.1.1.20 christos * Intel shall be used in advertising or otherwise to promote the sale, use or 77 1.1.1.20 christos * other dealings in products derived from or relating to the Covered Code 78 1.1.1.20 christos * without prior written authorization from Intel. 79 1.1.1.20 christos * 80 1.1.1.20 christos * 4. Disclaimer and Export Compliance 81 1.1.1.20 christos * 82 1.1.1.20 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 1.1.1.20 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 1.1.1.20 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 1.1.1.20 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 1.1.1.20 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 1.1.1.20 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 1.1.1.20 christos * PARTICULAR PURPOSE. 89 1.1.1.20 christos * 90 1.1.1.20 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 1.1.1.20 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 1.1.1.20 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 1.1.1.20 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 1.1.1.20 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 1.1.1.20 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 1.1.1.20 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 1.1.1.20 christos * LIMITED REMEDY. 98 1.1.1.20 christos * 99 1.1.1.20 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 1.1.1.20 christos * software or system incorporating such software without first obtaining any 101 1.1.1.20 christos * required license or other approval from the U. S. Department of Commerce or 102 1.1.1.20 christos * any other agency or department of the United States Government. In the 103 1.1.1.20 christos * event Licensee exports any such software from the United States or 104 1.1.1.20 christos * re-exports any such software from a foreign destination, Licensee shall 105 1.1.1.20 christos * ensure that the distribution and export/re-export of the software is in 106 1.1.1.20 christos * compliance with all laws, regulations, orders, or other restrictions of the 107 1.1.1.20 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 1.1.1.20 christos * any of its subsidiaries will export/re-export any technical data, process, 109 1.1.1.20 christos * software, or service, directly or indirectly, to any country for which the 110 1.1.1.20 christos * United States government or any agency thereof requires an export license, 111 1.1.1.20 christos * other governmental approval, or letter of assurance, without first obtaining 112 1.1.1.20 christos * such license, approval or letter. 113 1.1.1.20 christos * 114 1.1.1.20 christos ***************************************************************************** 115 1.1.1.20 christos * 116 1.1.1.20 christos * Alternatively, you may choose to be licensed under the terms of the 117 1.1.1.20 christos * following license: 118 1.1.1.20 christos * 119 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without 120 1.1.1.2 jruoho * modification, are permitted provided that the following conditions 121 1.1.1.2 jruoho * are met: 122 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright 123 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer, 124 1.1.1.2 jruoho * without modification. 125 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below 127 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon 128 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further 129 1.1.1.2 jruoho * binary redistribution. 130 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names 131 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived 132 1.1.1.2 jruoho * from this software without specific prior written permission. 133 1.1.1.2 jruoho * 134 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 1.1.1.17 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 1.1.1.20 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 1.1.1.20 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 1.1.1.20 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 1.1.1.20 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 1.1.1.20 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 1.1.1.20 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 1.1.1.20 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 1.1.1.20 christos * 146 1.1.1.20 christos * Alternatively, you may choose to be licensed under the terms of the 147 1.1.1.20 christos * GNU General Public License ("GPL") version 2 as published by the Free 148 1.1.1.20 christos * Software Foundation. 149 1.1.1.20 christos * 150 1.1.1.20 christos *****************************************************************************/ 151 1.1 jruoho 152 1.1 jruoho #include "acpi.h" 153 1.1 jruoho #include "accommon.h" 154 1.1 jruoho #include "acparser.h" 155 1.1 jruoho #include "amlcode.h" 156 1.1 jruoho #include "acdispat.h" 157 1.1 jruoho #include "acnamesp.h" 158 1.1 jruoho #include "acinterp.h" 159 1.1 jruoho 160 1.1 jruoho #define _COMPONENT ACPI_DISPATCHER 161 1.1 jruoho ACPI_MODULE_NAME ("dsobject") 162 1.1 jruoho 163 1.1 jruoho 164 1.1 jruoho /******************************************************************************* 165 1.1 jruoho * 166 1.1 jruoho * FUNCTION: AcpiDsBuildInternalObject 167 1.1 jruoho * 168 1.1 jruoho * PARAMETERS: WalkState - Current walk state 169 1.1 jruoho * Op - Parser object to be translated 170 1.1 jruoho * ObjDescPtr - Where the ACPI internal object is returned 171 1.1 jruoho * 172 1.1 jruoho * RETURN: Status 173 1.1 jruoho * 174 1.1 jruoho * DESCRIPTION: Translate a parser Op object to the equivalent namespace object 175 1.1 jruoho * Simple objects are any objects other than a package object! 176 1.1 jruoho * 177 1.1 jruoho ******************************************************************************/ 178 1.1 jruoho 179 1.1.1.11 christos ACPI_STATUS 180 1.1 jruoho AcpiDsBuildInternalObject ( 181 1.1 jruoho ACPI_WALK_STATE *WalkState, 182 1.1 jruoho ACPI_PARSE_OBJECT *Op, 183 1.1 jruoho ACPI_OPERAND_OBJECT **ObjDescPtr) 184 1.1 jruoho { 185 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc; 186 1.1 jruoho ACPI_STATUS Status; 187 1.1 jruoho 188 1.1 jruoho 189 1.1 jruoho ACPI_FUNCTION_TRACE (DsBuildInternalObject); 190 1.1 jruoho 191 1.1 jruoho 192 1.1 jruoho *ObjDescPtr = NULL; 193 1.1 jruoho if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) 194 1.1 jruoho { 195 1.1 jruoho /* 196 1.1 jruoho * This is a named object reference. If this name was 197 1.1.1.11 christos * previously looked up in the namespace, it was stored in 198 1.1.1.11 christos * this op. Otherwise, go ahead and look it up now 199 1.1 jruoho */ 200 1.1 jruoho if (!Op->Common.Node) 201 1.1 jruoho { 202 1.1.1.11 christos /* Check if we are resolving a named reference within a package */ 203 1.1 jruoho 204 1.1.1.11 christos if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || 205 1.1.1.11 christos (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)) 206 1.1 jruoho { 207 1.1 jruoho /* 208 1.1.1.11 christos * We won't resolve package elements here, we will do this 209 1.1.1.11 christos * after all ACPI tables are loaded into the namespace. This 210 1.1.1.11 christos * behavior supports both forward references to named objects 211 1.1.1.11 christos * and external references to objects in other tables. 212 1.1 jruoho */ 213 1.1.1.11 christos goto CreateNewObject; 214 1.1.1.11 christos } 215 1.1.1.11 christos else 216 1.1.1.11 christos { 217 1.1.1.11 christos Status = AcpiNsLookup (WalkState->ScopeInfo, 218 1.1.1.11 christos Op->Common.Value.String, 219 1.1.1.11 christos ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 220 1.1.1.11 christos ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, 221 1.1.1.11 christos ACPI_CAST_INDIRECT_PTR ( 222 1.1.1.11 christos ACPI_NAMESPACE_NODE, &(Op->Common.Node))); 223 1.1.1.11 christos if (ACPI_FAILURE (Status)) 224 1.1.1.11 christos { 225 1.1.1.12 christos ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, 226 1.1.1.12 christos Op->Common.Value.String, Status); 227 1.1.1.11 christos return_ACPI_STATUS (Status); 228 1.1.1.11 christos } 229 1.1 jruoho } 230 1.1 jruoho } 231 1.1 jruoho } 232 1.1 jruoho 233 1.1.1.11 christos CreateNewObject: 234 1.1.1.11 christos 235 1.1 jruoho /* Create and init a new internal ACPI object */ 236 1.1 jruoho 237 1.1 jruoho ObjDesc = AcpiUtCreateInternalObject ( 238 1.1.1.7 christos (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); 239 1.1 jruoho if (!ObjDesc) 240 1.1 jruoho { 241 1.1 jruoho return_ACPI_STATUS (AE_NO_MEMORY); 242 1.1 jruoho } 243 1.1 jruoho 244 1.1.1.7 christos Status = AcpiDsInitObjectFromOp ( 245 1.1.1.7 christos WalkState, Op, Op->Common.AmlOpcode, &ObjDesc); 246 1.1 jruoho if (ACPI_FAILURE (Status)) 247 1.1 jruoho { 248 1.1 jruoho AcpiUtRemoveReference (ObjDesc); 249 1.1 jruoho return_ACPI_STATUS (Status); 250 1.1 jruoho } 251 1.1 jruoho 252 1.1.1.11 christos /* 253 1.1.1.11 christos * Handling for unresolved package reference elements. 254 1.1.1.11 christos * These are elements that are namepaths. 255 1.1.1.11 christos */ 256 1.1.1.11 christos if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || 257 1.1.1.11 christos (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)) 258 1.1.1.11 christos { 259 1.1.1.11 christos ObjDesc->Reference.Resolved = TRUE; 260 1.1.1.11 christos 261 1.1.1.11 christos if ((Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && 262 1.1.1.11 christos !ObjDesc->Reference.Node) 263 1.1.1.11 christos { 264 1.1.1.11 christos /* 265 1.1.1.11 christos * Name was unresolved above. 266 1.1.1.11 christos * Get the prefix node for later lookup 267 1.1.1.11 christos */ 268 1.1.1.11 christos ObjDesc->Reference.Node = WalkState->ScopeInfo->Scope.Node; 269 1.1.1.11 christos ObjDesc->Reference.Aml = Op->Common.Aml; 270 1.1.1.11 christos ObjDesc->Reference.Resolved = FALSE; 271 1.1.1.11 christos } 272 1.1.1.11 christos } 273 1.1.1.11 christos 274 1.1 jruoho *ObjDescPtr = ObjDesc; 275 1.1 jruoho return_ACPI_STATUS (Status); 276 1.1 jruoho } 277 1.1 jruoho 278 1.1 jruoho 279 1.1 jruoho /******************************************************************************* 280 1.1 jruoho * 281 1.1 jruoho * FUNCTION: AcpiDsBuildInternalBufferObj 282 1.1 jruoho * 283 1.1 jruoho * PARAMETERS: WalkState - Current walk state 284 1.1 jruoho * Op - Parser object to be translated 285 1.1 jruoho * BufferLength - Length of the buffer 286 1.1 jruoho * ObjDescPtr - Where the ACPI internal object is returned 287 1.1 jruoho * 288 1.1 jruoho * RETURN: Status 289 1.1 jruoho * 290 1.1 jruoho * DESCRIPTION: Translate a parser Op package object to the equivalent 291 1.1 jruoho * namespace object 292 1.1 jruoho * 293 1.1 jruoho ******************************************************************************/ 294 1.1 jruoho 295 1.1 jruoho ACPI_STATUS 296 1.1 jruoho AcpiDsBuildInternalBufferObj ( 297 1.1 jruoho ACPI_WALK_STATE *WalkState, 298 1.1 jruoho ACPI_PARSE_OBJECT *Op, 299 1.1 jruoho UINT32 BufferLength, 300 1.1 jruoho ACPI_OPERAND_OBJECT **ObjDescPtr) 301 1.1 jruoho { 302 1.1 jruoho ACPI_PARSE_OBJECT *Arg; 303 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc; 304 1.1 jruoho ACPI_PARSE_OBJECT *ByteList; 305 1.1 jruoho UINT32 ByteListLength = 0; 306 1.1 jruoho 307 1.1 jruoho 308 1.1 jruoho ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); 309 1.1 jruoho 310 1.1 jruoho 311 1.1 jruoho /* 312 1.1 jruoho * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". 313 1.1 jruoho * The buffer object already exists (from the NS node), otherwise it must 314 1.1 jruoho * be created. 315 1.1 jruoho */ 316 1.1 jruoho ObjDesc = *ObjDescPtr; 317 1.1 jruoho if (!ObjDesc) 318 1.1 jruoho { 319 1.1 jruoho /* Create a new buffer object */ 320 1.1 jruoho 321 1.1 jruoho ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 322 1.1 jruoho *ObjDescPtr = ObjDesc; 323 1.1 jruoho if (!ObjDesc) 324 1.1 jruoho { 325 1.1 jruoho return_ACPI_STATUS (AE_NO_MEMORY); 326 1.1 jruoho } 327 1.1 jruoho } 328 1.1 jruoho 329 1.1 jruoho /* 330 1.1 jruoho * Second arg is the buffer data (optional) ByteList can be either 331 1.1.1.3 christos * individual bytes or a string initializer. In either case, a 332 1.1 jruoho * ByteList appears in the AML. 333 1.1 jruoho */ 334 1.1 jruoho Arg = Op->Common.Value.Arg; /* skip first arg */ 335 1.1 jruoho 336 1.1 jruoho ByteList = Arg->Named.Next; 337 1.1 jruoho if (ByteList) 338 1.1 jruoho { 339 1.1 jruoho if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) 340 1.1 jruoho { 341 1.1 jruoho ACPI_ERROR ((AE_INFO, 342 1.1 jruoho "Expecting bytelist, found AML opcode 0x%X in op %p", 343 1.1 jruoho ByteList->Common.AmlOpcode, ByteList)); 344 1.1 jruoho 345 1.1 jruoho AcpiUtRemoveReference (ObjDesc); 346 1.1 jruoho return (AE_TYPE); 347 1.1 jruoho } 348 1.1 jruoho 349 1.1 jruoho ByteListLength = (UINT32) ByteList->Common.Value.Integer; 350 1.1 jruoho } 351 1.1 jruoho 352 1.1 jruoho /* 353 1.1 jruoho * The buffer length (number of bytes) will be the larger of: 354 1.1 jruoho * 1) The specified buffer length and 355 1.1 jruoho * 2) The length of the initializer byte list 356 1.1 jruoho */ 357 1.1 jruoho ObjDesc->Buffer.Length = BufferLength; 358 1.1 jruoho if (ByteListLength > BufferLength) 359 1.1 jruoho { 360 1.1 jruoho ObjDesc->Buffer.Length = ByteListLength; 361 1.1 jruoho } 362 1.1 jruoho 363 1.1 jruoho /* Allocate the buffer */ 364 1.1 jruoho 365 1.1 jruoho if (ObjDesc->Buffer.Length == 0) 366 1.1 jruoho { 367 1.1 jruoho ObjDesc->Buffer.Pointer = NULL; 368 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 369 1.1 jruoho "Buffer defined with zero length in AML, creating\n")); 370 1.1 jruoho } 371 1.1 jruoho else 372 1.1 jruoho { 373 1.1.1.7 christos ObjDesc->Buffer.Pointer = 374 1.1.1.7 christos ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length); 375 1.1 jruoho if (!ObjDesc->Buffer.Pointer) 376 1.1 jruoho { 377 1.1 jruoho AcpiUtDeleteObjectDesc (ObjDesc); 378 1.1 jruoho return_ACPI_STATUS (AE_NO_MEMORY); 379 1.1 jruoho } 380 1.1 jruoho 381 1.1 jruoho /* Initialize buffer from the ByteList (if present) */ 382 1.1 jruoho 383 1.1 jruoho if (ByteList) 384 1.1 jruoho { 385 1.1.1.6 christos memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data, 386 1.1.1.7 christos ByteListLength); 387 1.1 jruoho } 388 1.1 jruoho } 389 1.1 jruoho 390 1.1 jruoho ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; 391 1.1 jruoho Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); 392 1.1 jruoho return_ACPI_STATUS (AE_OK); 393 1.1 jruoho } 394 1.1 jruoho 395 1.1 jruoho /******************************************************************************* 396 1.1 jruoho * 397 1.1 jruoho * FUNCTION: AcpiDsCreateNode 398 1.1 jruoho * 399 1.1 jruoho * PARAMETERS: WalkState - Current walk state 400 1.1 jruoho * Node - NS Node to be initialized 401 1.1 jruoho * Op - Parser object to be translated 402 1.1 jruoho * 403 1.1 jruoho * RETURN: Status 404 1.1 jruoho * 405 1.1 jruoho * DESCRIPTION: Create the object to be associated with a namespace node 406 1.1 jruoho * 407 1.1 jruoho ******************************************************************************/ 408 1.1 jruoho 409 1.1 jruoho ACPI_STATUS 410 1.1 jruoho AcpiDsCreateNode ( 411 1.1 jruoho ACPI_WALK_STATE *WalkState, 412 1.1 jruoho ACPI_NAMESPACE_NODE *Node, 413 1.1 jruoho ACPI_PARSE_OBJECT *Op) 414 1.1 jruoho { 415 1.1 jruoho ACPI_STATUS Status; 416 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc; 417 1.1 jruoho 418 1.1 jruoho 419 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op); 420 1.1 jruoho 421 1.1 jruoho 422 1.1 jruoho /* 423 1.1 jruoho * Because of the execution pass through the non-control-method 424 1.1.1.3 christos * parts of the table, we can arrive here twice. Only init 425 1.1 jruoho * the named object node the first time through 426 1.1 jruoho */ 427 1.1 jruoho if (AcpiNsGetAttachedObject (Node)) 428 1.1 jruoho { 429 1.1 jruoho return_ACPI_STATUS (AE_OK); 430 1.1 jruoho } 431 1.1 jruoho 432 1.1 jruoho if (!Op->Common.Value.Arg) 433 1.1 jruoho { 434 1.1 jruoho /* No arguments, there is nothing to do */ 435 1.1 jruoho 436 1.1 jruoho return_ACPI_STATUS (AE_OK); 437 1.1 jruoho } 438 1.1 jruoho 439 1.1 jruoho /* Build an internal object for the argument(s) */ 440 1.1 jruoho 441 1.1.1.7 christos Status = AcpiDsBuildInternalObject ( 442 1.1.1.7 christos WalkState, Op->Common.Value.Arg, &ObjDesc); 443 1.1 jruoho if (ACPI_FAILURE (Status)) 444 1.1 jruoho { 445 1.1 jruoho return_ACPI_STATUS (Status); 446 1.1 jruoho } 447 1.1 jruoho 448 1.1 jruoho /* Re-type the object according to its argument */ 449 1.1 jruoho 450 1.1 jruoho Node->Type = ObjDesc->Common.Type; 451 1.1 jruoho 452 1.1 jruoho /* Attach obj to node */ 453 1.1 jruoho 454 1.1 jruoho Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); 455 1.1 jruoho 456 1.1 jruoho /* Remove local reference to the object */ 457 1.1 jruoho 458 1.1 jruoho AcpiUtRemoveReference (ObjDesc); 459 1.1 jruoho return_ACPI_STATUS (Status); 460 1.1 jruoho } 461 1.1 jruoho 462 1.1 jruoho 463 1.1 jruoho /******************************************************************************* 464 1.1 jruoho * 465 1.1 jruoho * FUNCTION: AcpiDsInitObjectFromOp 466 1.1 jruoho * 467 1.1 jruoho * PARAMETERS: WalkState - Current walk state 468 1.1 jruoho * Op - Parser op used to init the internal object 469 1.1 jruoho * Opcode - AML opcode associated with the object 470 1.1 jruoho * RetObjDesc - Namespace object to be initialized 471 1.1 jruoho * 472 1.1 jruoho * RETURN: Status 473 1.1 jruoho * 474 1.1 jruoho * DESCRIPTION: Initialize a namespace object from a parser Op and its 475 1.1.1.3 christos * associated arguments. The namespace object is a more compact 476 1.1 jruoho * representation of the Op and its arguments. 477 1.1 jruoho * 478 1.1 jruoho ******************************************************************************/ 479 1.1 jruoho 480 1.1 jruoho ACPI_STATUS 481 1.1 jruoho AcpiDsInitObjectFromOp ( 482 1.1 jruoho ACPI_WALK_STATE *WalkState, 483 1.1 jruoho ACPI_PARSE_OBJECT *Op, 484 1.1 jruoho UINT16 Opcode, 485 1.1 jruoho ACPI_OPERAND_OBJECT **RetObjDesc) 486 1.1 jruoho { 487 1.1 jruoho const ACPI_OPCODE_INFO *OpInfo; 488 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc; 489 1.1 jruoho ACPI_STATUS Status = AE_OK; 490 1.1 jruoho 491 1.1 jruoho 492 1.1 jruoho ACPI_FUNCTION_TRACE (DsInitObjectFromOp); 493 1.1 jruoho 494 1.1 jruoho 495 1.1 jruoho ObjDesc = *RetObjDesc; 496 1.1 jruoho OpInfo = AcpiPsGetOpcodeInfo (Opcode); 497 1.1 jruoho if (OpInfo->Class == AML_CLASS_UNKNOWN) 498 1.1 jruoho { 499 1.1 jruoho /* Unknown opcode */ 500 1.1 jruoho 501 1.1 jruoho return_ACPI_STATUS (AE_TYPE); 502 1.1 jruoho } 503 1.1 jruoho 504 1.1 jruoho /* Perform per-object initialization */ 505 1.1 jruoho 506 1.1 jruoho switch (ObjDesc->Common.Type) 507 1.1 jruoho { 508 1.1 jruoho case ACPI_TYPE_BUFFER: 509 1.1 jruoho /* 510 1.1 jruoho * Defer evaluation of Buffer TermArg operand 511 1.1 jruoho */ 512 1.1.1.7 christos ObjDesc->Buffer.Node = ACPI_CAST_PTR ( 513 1.1.1.7 christos ACPI_NAMESPACE_NODE, WalkState->Operands[0]); 514 1.1.1.7 christos ObjDesc->Buffer.AmlStart = Op->Named.Data; 515 1.1 jruoho ObjDesc->Buffer.AmlLength = Op->Named.Length; 516 1.1 jruoho break; 517 1.1 jruoho 518 1.1 jruoho case ACPI_TYPE_PACKAGE: 519 1.1 jruoho /* 520 1.1.1.11 christos * Defer evaluation of Package TermArg operand and all 521 1.1.1.11 christos * package elements. (01/2017): We defer the element 522 1.1.1.11 christos * resolution to allow forward references from the package 523 1.1.1.11 christos * in order to provide compatibility with other ACPI 524 1.1.1.11 christos * implementations. 525 1.1 jruoho */ 526 1.1.1.7 christos ObjDesc->Package.Node = ACPI_CAST_PTR ( 527 1.1.1.7 christos ACPI_NAMESPACE_NODE, WalkState->Operands[0]); 528 1.1.1.11 christos 529 1.1.1.11 christos if (!Op->Named.Data) 530 1.1.1.11 christos { 531 1.1.1.11 christos return_ACPI_STATUS (AE_OK); 532 1.1.1.11 christos } 533 1.1.1.11 christos 534 1.1.1.7 christos ObjDesc->Package.AmlStart = Op->Named.Data; 535 1.1 jruoho ObjDesc->Package.AmlLength = Op->Named.Length; 536 1.1 jruoho break; 537 1.1 jruoho 538 1.1 jruoho case ACPI_TYPE_INTEGER: 539 1.1 jruoho 540 1.1 jruoho switch (OpInfo->Type) 541 1.1 jruoho { 542 1.1 jruoho case AML_TYPE_CONSTANT: 543 1.1 jruoho /* 544 1.1 jruoho * Resolve AML Constants here - AND ONLY HERE! 545 1.1 jruoho * All constants are integers. 546 1.1 jruoho * We mark the integer with a flag that indicates that it started 547 1.1 jruoho * life as a constant -- so that stores to constants will perform 548 1.1 jruoho * as expected (noop). ZeroOp is used as a placeholder for optional 549 1.1 jruoho * target operands. 550 1.1 jruoho */ 551 1.1 jruoho ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; 552 1.1 jruoho 553 1.1 jruoho switch (Opcode) 554 1.1 jruoho { 555 1.1 jruoho case AML_ZERO_OP: 556 1.1 jruoho 557 1.1 jruoho ObjDesc->Integer.Value = 0; 558 1.1 jruoho break; 559 1.1 jruoho 560 1.1 jruoho case AML_ONE_OP: 561 1.1 jruoho 562 1.1 jruoho ObjDesc->Integer.Value = 1; 563 1.1 jruoho break; 564 1.1 jruoho 565 1.1 jruoho case AML_ONES_OP: 566 1.1 jruoho 567 1.1 jruoho ObjDesc->Integer.Value = ACPI_UINT64_MAX; 568 1.1 jruoho 569 1.1 jruoho /* Truncate value if we are executing from a 32-bit ACPI table */ 570 1.1 jruoho 571 1.1.1.3 christos (void) AcpiExTruncateFor32bitTable (ObjDesc); 572 1.1 jruoho break; 573 1.1 jruoho 574 1.1 jruoho case AML_REVISION_OP: 575 1.1 jruoho 576 1.1 jruoho ObjDesc->Integer.Value = ACPI_CA_VERSION; 577 1.1 jruoho break; 578 1.1 jruoho 579 1.1 jruoho default: 580 1.1 jruoho 581 1.1 jruoho ACPI_ERROR ((AE_INFO, 582 1.1 jruoho "Unknown constant opcode 0x%X", Opcode)); 583 1.1 jruoho Status = AE_AML_OPERAND_TYPE; 584 1.1 jruoho break; 585 1.1 jruoho } 586 1.1 jruoho break; 587 1.1 jruoho 588 1.1 jruoho case AML_TYPE_LITERAL: 589 1.1 jruoho 590 1.1 jruoho ObjDesc->Integer.Value = Op->Common.Value.Integer; 591 1.1.1.3 christos 592 1.1.1.3 christos if (AcpiExTruncateFor32bitTable (ObjDesc)) 593 1.1.1.3 christos { 594 1.1.1.3 christos /* Warn if we found a 64-bit constant in a 32-bit table */ 595 1.1.1.3 christos 596 1.1.1.3 christos ACPI_WARNING ((AE_INFO, 597 1.1.1.3 christos "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X", 598 1.1.1.3 christos ACPI_FORMAT_UINT64 (Op->Common.Value.Integer), 599 1.1.1.3 christos (UINT32) ObjDesc->Integer.Value)); 600 1.1.1.3 christos } 601 1.1 jruoho break; 602 1.1 jruoho 603 1.1 jruoho default: 604 1.1.1.3 christos 605 1.1 jruoho ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X", 606 1.1 jruoho OpInfo->Type)); 607 1.1 jruoho Status = AE_AML_OPERAND_TYPE; 608 1.1 jruoho break; 609 1.1 jruoho } 610 1.1 jruoho break; 611 1.1 jruoho 612 1.1 jruoho case ACPI_TYPE_STRING: 613 1.1 jruoho 614 1.1 jruoho ObjDesc->String.Pointer = Op->Common.Value.String; 615 1.1.1.6 christos ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String); 616 1.1 jruoho 617 1.1 jruoho /* 618 1.1 jruoho * The string is contained in the ACPI table, don't ever try 619 1.1 jruoho * to delete it 620 1.1 jruoho */ 621 1.1 jruoho ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; 622 1.1 jruoho break; 623 1.1 jruoho 624 1.1 jruoho case ACPI_TYPE_METHOD: 625 1.1 jruoho break; 626 1.1 jruoho 627 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE: 628 1.1 jruoho 629 1.1 jruoho switch (OpInfo->Type) 630 1.1 jruoho { 631 1.1 jruoho case AML_TYPE_LOCAL_VARIABLE: 632 1.1 jruoho 633 1.1.1.10 christos /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */ 634 1.1 jruoho 635 1.1.1.10 christos ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_LOCAL_OP; 636 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL; 637 1.1 jruoho 638 1.1 jruoho Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL, 639 1.1.1.7 christos ObjDesc->Reference.Value, WalkState, 640 1.1.1.7 christos ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, 641 1.1.1.7 christos &ObjDesc->Reference.Object)); 642 1.1 jruoho break; 643 1.1 jruoho 644 1.1 jruoho case AML_TYPE_METHOD_ARGUMENT: 645 1.1 jruoho 646 1.1.1.10 christos /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */ 647 1.1 jruoho 648 1.1.1.10 christos ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_ARG_OP; 649 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_ARG; 650 1.1 jruoho 651 1.1 jruoho Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG, 652 1.1.1.7 christos ObjDesc->Reference.Value, WalkState, 653 1.1.1.7 christos ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, 654 1.1.1.7 christos &ObjDesc->Reference.Object)); 655 1.1 jruoho break; 656 1.1 jruoho 657 1.1 jruoho default: /* Object name or Debug object */ 658 1.1 jruoho 659 1.1 jruoho switch (Op->Common.AmlOpcode) 660 1.1 jruoho { 661 1.1 jruoho case AML_INT_NAMEPATH_OP: 662 1.1 jruoho 663 1.1 jruoho /* Node was saved in Op */ 664 1.1 jruoho 665 1.1 jruoho ObjDesc->Reference.Node = Op->Common.Node; 666 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_NAME; 667 1.1.1.11 christos if (Op->Common.Node) 668 1.1.1.11 christos { 669 1.1.1.11 christos ObjDesc->Reference.Object = Op->Common.Node->Object; 670 1.1.1.11 christos } 671 1.1 jruoho break; 672 1.1 jruoho 673 1.1 jruoho case AML_DEBUG_OP: 674 1.1 jruoho 675 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG; 676 1.1 jruoho break; 677 1.1 jruoho 678 1.1 jruoho default: 679 1.1 jruoho 680 1.1 jruoho ACPI_ERROR ((AE_INFO, 681 1.1 jruoho "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode)); 682 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 683 1.1 jruoho } 684 1.1 jruoho break; 685 1.1 jruoho } 686 1.1 jruoho break; 687 1.1 jruoho 688 1.1 jruoho default: 689 1.1 jruoho 690 1.1 jruoho ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X", 691 1.1 jruoho ObjDesc->Common.Type)); 692 1.1 jruoho 693 1.1 jruoho Status = AE_AML_OPERAND_TYPE; 694 1.1 jruoho break; 695 1.1 jruoho } 696 1.1 jruoho 697 1.1 jruoho return_ACPI_STATUS (Status); 698 1.1 jruoho } 699