![]() |
|
|||
File indexing completed on 2025-05-11 08:24:02
0001 /****************************************************************************** 0002 * 0003 * Module Name: dsargs - Support for execution of dynamic arguments for static 0004 * objects (regions, fields, buffer fields, etc.) 0005 * 0006 *****************************************************************************/ 0007 0008 /****************************************************************************** 0009 * 0010 * 1. Copyright Notice 0011 * 0012 * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 0013 * All rights reserved. 0014 * 0015 * 2. License 0016 * 0017 * 2.1. This is your license from Intel Corp. under its intellectual property 0018 * rights. You may have additional license terms from the party that provided 0019 * you this software, covering your right to use that party's intellectual 0020 * property rights. 0021 * 0022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0023 * copy of the source code appearing in this file ("Covered Code") an 0024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0025 * base code distributed originally by Intel ("Original Intel Code") to copy, 0026 * make derivatives, distribute, use and display any portion of the Covered 0027 * Code in any form, with the right to sublicense such rights; and 0028 * 0029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0030 * license (with the right to sublicense), under only those claims of Intel 0031 * patents that are infringed by the Original Intel Code, to make, use, sell, 0032 * offer to sell, and import the Covered Code and derivative works thereof 0033 * solely to the minimum extent necessary to exercise the above copyright 0034 * license, and in no event shall the patent license extend to any additions 0035 * to or modifications of the Original Intel Code. No other license or right 0036 * is granted directly or by implication, estoppel or otherwise; 0037 * 0038 * The above copyright and patent license is granted only if the following 0039 * conditions are met: 0040 * 0041 * 3. Conditions 0042 * 0043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0044 * Redistribution of source code of any substantial portion of the Covered 0045 * Code or modification with rights to further distribute source must include 0046 * the above Copyright Notice, the above License, this list of Conditions, 0047 * and the following Disclaimer and Export Compliance provision. In addition, 0048 * Licensee must cause all Covered Code to which Licensee contributes to 0049 * contain a file documenting the changes Licensee made to create that Covered 0050 * Code and the date of any change. Licensee must include in that file the 0051 * documentation of any changes made by any predecessor Licensee. Licensee 0052 * must include a prominent statement that the modification is derived, 0053 * directly or indirectly, from Original Intel Code. 0054 * 0055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0056 * Redistribution of source code of any substantial portion of the Covered 0057 * Code or modification without rights to further distribute source must 0058 * include the following Disclaimer and Export Compliance provision in the 0059 * documentation and/or other materials provided with distribution. In 0060 * addition, Licensee may not authorize further sublicense of source of any 0061 * portion of the Covered Code, and must include terms to the effect that the 0062 * license from Licensee to its licensee is limited to the intellectual 0063 * property embodied in the software Licensee provides to its licensee, and 0064 * not to intellectual property embodied in modifications its licensee may 0065 * make. 0066 * 0067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0068 * substantial portion of the Covered Code or modification must reproduce the 0069 * above Copyright Notice, and the following Disclaimer and Export Compliance 0070 * provision in the documentation and/or other materials provided with the 0071 * distribution. 0072 * 0073 * 3.4. Intel retains all right, title, and interest in and to the Original 0074 * Intel Code. 0075 * 0076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0077 * Intel shall be used in advertising or otherwise to promote the sale, use or 0078 * other dealings in products derived from or relating to the Covered Code 0079 * without prior written authorization from Intel. 0080 * 0081 * 4. Disclaimer and Export Compliance 0082 * 0083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0087 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0088 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0089 * PARTICULAR PURPOSE. 0090 * 0091 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0092 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0093 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0094 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0095 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0096 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0097 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0098 * LIMITED REMEDY. 0099 * 0100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0101 * software or system incorporating such software without first obtaining any 0102 * required license or other approval from the U. S. Department of Commerce or 0103 * any other agency or department of the United States Government. In the 0104 * event Licensee exports any such software from the United States or 0105 * re-exports any such software from a foreign destination, Licensee shall 0106 * ensure that the distribution and export/re-export of the software is in 0107 * compliance with all laws, regulations, orders, or other restrictions of the 0108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0109 * any of its subsidiaries will export/re-export any technical data, process, 0110 * software, or service, directly or indirectly, to any country for which the 0111 * United States government or any agency thereof requires an export license, 0112 * other governmental approval, or letter of assurance, without first obtaining 0113 * such license, approval or letter. 0114 * 0115 ***************************************************************************** 0116 * 0117 * Alternatively, you may choose to be licensed under the terms of the 0118 * following license: 0119 * 0120 * Redistribution and use in source and binary forms, with or without 0121 * modification, are permitted provided that the following conditions 0122 * are met: 0123 * 1. Redistributions of source code must retain the above copyright 0124 * notice, this list of conditions, and the following disclaimer, 0125 * without modification. 0126 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 0127 * substantially similar to the "NO WARRANTY" disclaimer below 0128 * ("Disclaimer") and any redistribution must be conditioned upon 0129 * including a substantially similar Disclaimer requirement for further 0130 * binary redistribution. 0131 * 3. Neither the names of the above-listed copyright holders nor the names 0132 * of any contributors may be used to endorse or promote products derived 0133 * from this software without specific prior written permission. 0134 * 0135 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0136 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0137 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0138 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0139 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0140 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0141 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0142 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0143 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0145 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0146 * 0147 * Alternatively, you may choose to be licensed under the terms of the 0148 * GNU General Public License ("GPL") version 2 as published by the Free 0149 * Software Foundation. 0150 * 0151 *****************************************************************************/ 0152 0153 #include "acpi.h" 0154 #include "accommon.h" 0155 #include "acparser.h" 0156 #include "amlcode.h" 0157 #include "acdispat.h" 0158 #include "acnamesp.h" 0159 0160 #define _COMPONENT ACPI_DISPATCHER 0161 ACPI_MODULE_NAME ("dsargs") 0162 0163 /* Local prototypes */ 0164 0165 static ACPI_STATUS 0166 AcpiDsExecuteArguments ( 0167 ACPI_NAMESPACE_NODE *Node, 0168 ACPI_NAMESPACE_NODE *ScopeNode, 0169 UINT32 AmlLength, 0170 UINT8 *AmlStart); 0171 0172 0173 /******************************************************************************* 0174 * 0175 * FUNCTION: AcpiDsExecuteArguments 0176 * 0177 * PARAMETERS: Node - Object NS node 0178 * ScopeNode - Parent NS node 0179 * AmlLength - Length of executable AML 0180 * AmlStart - Pointer to the AML 0181 * 0182 * RETURN: Status. 0183 * 0184 * DESCRIPTION: Late (deferred) execution of region or field arguments 0185 * 0186 ******************************************************************************/ 0187 0188 static ACPI_STATUS 0189 AcpiDsExecuteArguments ( 0190 ACPI_NAMESPACE_NODE *Node, 0191 ACPI_NAMESPACE_NODE *ScopeNode, 0192 UINT32 AmlLength, 0193 UINT8 *AmlStart) 0194 { 0195 ACPI_STATUS Status; 0196 ACPI_PARSE_OBJECT *Op; 0197 ACPI_WALK_STATE *WalkState; 0198 0199 0200 ACPI_FUNCTION_TRACE_PTR (DsExecuteArguments, AmlStart); 0201 0202 0203 /* Allocate a new parser op to be the root of the parsed tree */ 0204 0205 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP, AmlStart); 0206 if (!Op) 0207 { 0208 return_ACPI_STATUS (AE_NO_MEMORY); 0209 } 0210 0211 /* Save the Node for use in AcpiPsParseAml */ 0212 0213 Op->Common.Node = ScopeNode; 0214 0215 /* Create and initialize a new parser state */ 0216 0217 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 0218 if (!WalkState) 0219 { 0220 Status = AE_NO_MEMORY; 0221 goto Cleanup; 0222 } 0223 0224 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 0225 AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); 0226 if (ACPI_FAILURE (Status)) 0227 { 0228 AcpiDsDeleteWalkState (WalkState); 0229 goto Cleanup; 0230 } 0231 0232 /* Mark this parse as a deferred opcode */ 0233 0234 WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; 0235 WalkState->DeferredNode = Node; 0236 0237 /* Pass1: Parse the entire declaration */ 0238 0239 Status = AcpiPsParseAml (WalkState); 0240 if (ACPI_FAILURE (Status)) 0241 { 0242 goto Cleanup; 0243 } 0244 0245 /* Get and init the Op created above */ 0246 0247 Op->Common.Node = Node; 0248 AcpiPsDeleteParseTree (Op); 0249 0250 /* Evaluate the deferred arguments */ 0251 0252 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP, AmlStart); 0253 if (!Op) 0254 { 0255 return_ACPI_STATUS (AE_NO_MEMORY); 0256 } 0257 0258 Op->Common.Node = ScopeNode; 0259 0260 /* Create and initialize a new parser state */ 0261 0262 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 0263 if (!WalkState) 0264 { 0265 Status = AE_NO_MEMORY; 0266 goto Cleanup; 0267 } 0268 0269 /* Execute the opcode and arguments */ 0270 0271 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 0272 AmlLength, NULL, ACPI_IMODE_EXECUTE); 0273 if (ACPI_FAILURE (Status)) 0274 { 0275 AcpiDsDeleteWalkState (WalkState); 0276 goto Cleanup; 0277 } 0278 0279 /* Mark this execution as a deferred opcode */ 0280 0281 WalkState->DeferredNode = Node; 0282 Status = AcpiPsParseAml (WalkState); 0283 0284 Cleanup: 0285 AcpiPsDeleteParseTree (Op); 0286 return_ACPI_STATUS (Status); 0287 } 0288 0289 0290 /******************************************************************************* 0291 * 0292 * FUNCTION: AcpiDsGetBufferFieldArguments 0293 * 0294 * PARAMETERS: ObjDesc - A valid BufferField object 0295 * 0296 * RETURN: Status. 0297 * 0298 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late 0299 * evaluation of these field attributes. 0300 * 0301 ******************************************************************************/ 0302 0303 ACPI_STATUS 0304 AcpiDsGetBufferFieldArguments ( 0305 ACPI_OPERAND_OBJECT *ObjDesc) 0306 { 0307 ACPI_OPERAND_OBJECT *ExtraDesc; 0308 ACPI_NAMESPACE_NODE *Node; 0309 ACPI_STATUS Status; 0310 0311 0312 ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc); 0313 0314 0315 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 0316 { 0317 return_ACPI_STATUS (AE_OK); 0318 } 0319 0320 /* Get the AML pointer (method object) and BufferField node */ 0321 0322 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 0323 Node = ObjDesc->BufferField.Node; 0324 0325 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 0326 ACPI_TYPE_BUFFER_FIELD, Node, NULL)); 0327 0328 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", 0329 AcpiUtGetNodeName (Node))); 0330 0331 /* Execute the AML code for the TermArg arguments */ 0332 0333 Status = AcpiDsExecuteArguments (Node, Node->Parent, 0334 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 0335 return_ACPI_STATUS (Status); 0336 } 0337 0338 0339 /******************************************************************************* 0340 * 0341 * FUNCTION: AcpiDsGetBankFieldArguments 0342 * 0343 * PARAMETERS: ObjDesc - A valid BankField object 0344 * 0345 * RETURN: Status. 0346 * 0347 * DESCRIPTION: Get BankField BankValue. This implements the late 0348 * evaluation of these field attributes. 0349 * 0350 ******************************************************************************/ 0351 0352 ACPI_STATUS 0353 AcpiDsGetBankFieldArguments ( 0354 ACPI_OPERAND_OBJECT *ObjDesc) 0355 { 0356 ACPI_OPERAND_OBJECT *ExtraDesc; 0357 ACPI_NAMESPACE_NODE *Node; 0358 ACPI_STATUS Status; 0359 0360 0361 ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc); 0362 0363 0364 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 0365 { 0366 return_ACPI_STATUS (AE_OK); 0367 } 0368 0369 /* Get the AML pointer (method object) and BankField node */ 0370 0371 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 0372 Node = ObjDesc->BankField.Node; 0373 0374 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 0375 ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL)); 0376 0377 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", 0378 AcpiUtGetNodeName (Node))); 0379 0380 /* Execute the AML code for the TermArg arguments */ 0381 0382 Status = AcpiDsExecuteArguments (Node, Node->Parent, 0383 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 0384 return_ACPI_STATUS (Status); 0385 } 0386 0387 0388 /******************************************************************************* 0389 * 0390 * FUNCTION: AcpiDsGetBufferArguments 0391 * 0392 * PARAMETERS: ObjDesc - A valid Buffer object 0393 * 0394 * RETURN: Status. 0395 * 0396 * DESCRIPTION: Get Buffer length and initializer byte list. This implements 0397 * the late evaluation of these attributes. 0398 * 0399 ******************************************************************************/ 0400 0401 ACPI_STATUS 0402 AcpiDsGetBufferArguments ( 0403 ACPI_OPERAND_OBJECT *ObjDesc) 0404 { 0405 ACPI_NAMESPACE_NODE *Node; 0406 ACPI_STATUS Status; 0407 0408 0409 ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc); 0410 0411 0412 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 0413 { 0414 return_ACPI_STATUS (AE_OK); 0415 } 0416 0417 /* Get the Buffer node */ 0418 0419 Node = ObjDesc->Buffer.Node; 0420 if (!Node) 0421 { 0422 ACPI_ERROR ((AE_INFO, 0423 "No pointer back to namespace node in buffer object %p", 0424 ObjDesc)); 0425 return_ACPI_STATUS (AE_AML_INTERNAL); 0426 } 0427 0428 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); 0429 0430 /* Execute the AML code for the TermArg arguments */ 0431 0432 Status = AcpiDsExecuteArguments (Node, Node, 0433 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); 0434 return_ACPI_STATUS (Status); 0435 } 0436 0437 0438 /******************************************************************************* 0439 * 0440 * FUNCTION: AcpiDsGetPackageArguments 0441 * 0442 * PARAMETERS: ObjDesc - A valid Package object 0443 * 0444 * RETURN: Status. 0445 * 0446 * DESCRIPTION: Get Package length and initializer byte list. This implements 0447 * the late evaluation of these attributes. 0448 * 0449 ******************************************************************************/ 0450 0451 ACPI_STATUS 0452 AcpiDsGetPackageArguments ( 0453 ACPI_OPERAND_OBJECT *ObjDesc) 0454 { 0455 ACPI_NAMESPACE_NODE *Node; 0456 ACPI_STATUS Status; 0457 0458 0459 ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc); 0460 0461 0462 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 0463 { 0464 return_ACPI_STATUS (AE_OK); 0465 } 0466 0467 /* Get the Package node */ 0468 0469 Node = ObjDesc->Package.Node; 0470 if (!Node) 0471 { 0472 ACPI_ERROR ((AE_INFO, 0473 "No pointer back to namespace node in package %p", ObjDesc)); 0474 return_ACPI_STATUS (AE_AML_INTERNAL); 0475 } 0476 0477 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Argument Init, AML Ptr: %p\n", 0478 ObjDesc->Package.AmlStart)); 0479 0480 /* Execute the AML code for the TermArg arguments */ 0481 0482 Status = AcpiDsExecuteArguments (Node, Node, 0483 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); 0484 0485 return_ACPI_STATUS (Status); 0486 } 0487 0488 0489 /******************************************************************************* 0490 * 0491 * FUNCTION: AcpiDsGetRegionArguments 0492 * 0493 * PARAMETERS: ObjDesc - A valid region object 0494 * 0495 * RETURN: Status. 0496 * 0497 * DESCRIPTION: Get region address and length. This implements the late 0498 * evaluation of these region attributes. 0499 * 0500 ******************************************************************************/ 0501 0502 ACPI_STATUS 0503 AcpiDsGetRegionArguments ( 0504 ACPI_OPERAND_OBJECT *ObjDesc) 0505 { 0506 ACPI_NAMESPACE_NODE *Node; 0507 ACPI_STATUS Status; 0508 ACPI_OPERAND_OBJECT *ExtraDesc; 0509 0510 0511 ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc); 0512 0513 0514 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) 0515 { 0516 return_ACPI_STATUS (AE_OK); 0517 } 0518 0519 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 0520 if (!ExtraDesc) 0521 { 0522 return_ACPI_STATUS (AE_NOT_EXIST); 0523 } 0524 0525 /* Get the Region node */ 0526 0527 Node = ObjDesc->Region.Node; 0528 0529 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( 0530 ACPI_TYPE_REGION, Node, NULL)); 0531 0532 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0533 "[%4.4s] OpRegion Arg Init at AML %p\n", 0534 AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); 0535 0536 /* Execute the argument AML */ 0537 0538 Status = AcpiDsExecuteArguments (Node, ExtraDesc->Extra.ScopeNode, 0539 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 0540 if (ACPI_FAILURE (Status)) 0541 { 0542 return_ACPI_STATUS (Status); 0543 } 0544 0545 Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId, 0546 ObjDesc->Region.Address, ObjDesc->Region.Length, Node); 0547 return_ACPI_STATUS (Status); 0548 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |