![]() |
|
|||
File indexing completed on 2025-05-11 08:24:02
0001 /****************************************************************************** 0002 * 0003 * Module Name: exstoren - AML Interpreter object store support, 0004 * Store to Node (namespace object) 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 "acinterp.h" 0156 #include "amlcode.h" 0157 0158 0159 #define _COMPONENT ACPI_EXECUTER 0160 ACPI_MODULE_NAME ("exstoren") 0161 0162 0163 /******************************************************************************* 0164 * 0165 * FUNCTION: AcpiExResolveObject 0166 * 0167 * PARAMETERS: SourceDescPtr - Pointer to the source object 0168 * TargetType - Current type of the target 0169 * WalkState - Current walk state 0170 * 0171 * RETURN: Status, resolved object in SourceDescPtr. 0172 * 0173 * DESCRIPTION: Resolve an object. If the object is a reference, dereference 0174 * it and return the actual object in the SourceDescPtr. 0175 * 0176 ******************************************************************************/ 0177 0178 ACPI_STATUS 0179 AcpiExResolveObject ( 0180 ACPI_OPERAND_OBJECT **SourceDescPtr, 0181 ACPI_OBJECT_TYPE TargetType, 0182 ACPI_WALK_STATE *WalkState) 0183 { 0184 ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; 0185 ACPI_STATUS Status = AE_OK; 0186 0187 0188 ACPI_FUNCTION_TRACE (ExResolveObject); 0189 0190 0191 /* Ensure we have a Target that can be stored to */ 0192 0193 switch (TargetType) 0194 { 0195 case ACPI_TYPE_BUFFER_FIELD: 0196 case ACPI_TYPE_LOCAL_REGION_FIELD: 0197 case ACPI_TYPE_LOCAL_BANK_FIELD: 0198 case ACPI_TYPE_LOCAL_INDEX_FIELD: 0199 /* 0200 * These cases all require only Integers or values that 0201 * can be converted to Integers (Strings or Buffers) 0202 */ 0203 case ACPI_TYPE_INTEGER: 0204 case ACPI_TYPE_STRING: 0205 case ACPI_TYPE_BUFFER: 0206 /* 0207 * Stores into a Field/Region or into a Integer/Buffer/String 0208 * are all essentially the same. This case handles the 0209 * "interchangeable" types Integer, String, and Buffer. 0210 */ 0211 if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) 0212 { 0213 /* Resolve a reference object first */ 0214 0215 Status = AcpiExResolveToValue (SourceDescPtr, WalkState); 0216 if (ACPI_FAILURE (Status)) 0217 { 0218 break; 0219 } 0220 } 0221 0222 /* For CopyObject, no further validation necessary */ 0223 0224 if (WalkState->Opcode == AML_COPY_OBJECT_OP) 0225 { 0226 break; 0227 } 0228 0229 /* Must have a Integer, Buffer, or String */ 0230 0231 if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && 0232 (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && 0233 (SourceDesc->Common.Type != ACPI_TYPE_STRING) && 0234 !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && 0235 (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) 0236 { 0237 /* Conversion successful but still not a valid type */ 0238 0239 ACPI_ERROR ((AE_INFO, 0240 "Cannot assign type [%s] to [%s] (must be type Int/Str/Buf)", 0241 AcpiUtGetObjectTypeName (SourceDesc), 0242 AcpiUtGetTypeName (TargetType))); 0243 0244 Status = AE_AML_OPERAND_TYPE; 0245 } 0246 break; 0247 0248 case ACPI_TYPE_LOCAL_ALIAS: 0249 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 0250 /* 0251 * All aliases should have been resolved earlier, during the 0252 * operand resolution phase. 0253 */ 0254 ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); 0255 Status = AE_AML_INTERNAL; 0256 break; 0257 0258 case ACPI_TYPE_PACKAGE: 0259 default: 0260 /* 0261 * All other types than Alias and the various Fields come here, 0262 * including the untyped case - ACPI_TYPE_ANY. 0263 */ 0264 break; 0265 } 0266 0267 return_ACPI_STATUS (Status); 0268 } 0269 0270 0271 /******************************************************************************* 0272 * 0273 * FUNCTION: AcpiExStoreObjectToObject 0274 * 0275 * PARAMETERS: SourceDesc - Object to store 0276 * DestDesc - Object to receive a copy of the source 0277 * NewDesc - New object if DestDesc is obsoleted 0278 * WalkState - Current walk state 0279 * 0280 * RETURN: Status 0281 * 0282 * DESCRIPTION: "Store" an object to another object. This may include 0283 * converting the source type to the target type (implicit 0284 * conversion), and a copy of the value of the source to 0285 * the target. 0286 * 0287 * The Assignment of an object to another (not named) object 0288 * is handled here. 0289 * The Source passed in will replace the current value (if any) 0290 * with the input value. 0291 * 0292 * When storing into an object the data is converted to the 0293 * target object type then stored in the object. This means 0294 * that the target object type (for an initialized target) will 0295 * not be changed by a store operation. 0296 * 0297 * This module allows destination types of Number, String, 0298 * Buffer, and Package. 0299 * 0300 * Assumes parameters are already validated. NOTE: SourceDesc 0301 * resolution (from a reference object) must be performed by 0302 * the caller if necessary. 0303 * 0304 ******************************************************************************/ 0305 0306 ACPI_STATUS 0307 AcpiExStoreObjectToObject ( 0308 ACPI_OPERAND_OBJECT *SourceDesc, 0309 ACPI_OPERAND_OBJECT *DestDesc, 0310 ACPI_OPERAND_OBJECT **NewDesc, 0311 ACPI_WALK_STATE *WalkState) 0312 { 0313 ACPI_OPERAND_OBJECT *ActualSrcDesc; 0314 ACPI_STATUS Status = AE_OK; 0315 0316 0317 ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); 0318 0319 0320 ActualSrcDesc = SourceDesc; 0321 if (!DestDesc) 0322 { 0323 /* 0324 * There is no destination object (An uninitialized node or 0325 * package element), so we can simply copy the source object 0326 * creating a new destination object 0327 */ 0328 Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); 0329 return_ACPI_STATUS (Status); 0330 } 0331 0332 if (SourceDesc->Common.Type != DestDesc->Common.Type) 0333 { 0334 /* 0335 * The source type does not match the type of the destination. 0336 * Perform the "implicit conversion" of the source to the current type 0337 * of the target as per the ACPI specification. 0338 * 0339 * If no conversion performed, ActualSrcDesc = SourceDesc. 0340 * Otherwise, ActualSrcDesc is a temporary object to hold the 0341 * converted object. 0342 */ 0343 Status = AcpiExConvertToTargetType (DestDesc->Common.Type, 0344 SourceDesc, &ActualSrcDesc, WalkState); 0345 if (ACPI_FAILURE (Status)) 0346 { 0347 return_ACPI_STATUS (Status); 0348 } 0349 0350 if (SourceDesc == ActualSrcDesc) 0351 { 0352 /* 0353 * No conversion was performed. Return the SourceDesc as the 0354 * new object. 0355 */ 0356 *NewDesc = SourceDesc; 0357 return_ACPI_STATUS (AE_OK); 0358 } 0359 } 0360 0361 /* 0362 * We now have two objects of identical types, and we can perform a 0363 * copy of the *value* of the source object. 0364 */ 0365 switch (DestDesc->Common.Type) 0366 { 0367 case ACPI_TYPE_INTEGER: 0368 0369 DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; 0370 0371 /* Truncate value if we are executing from a 32-bit ACPI table */ 0372 0373 (void) AcpiExTruncateFor32bitTable (DestDesc); 0374 break; 0375 0376 case ACPI_TYPE_STRING: 0377 0378 Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); 0379 break; 0380 0381 case ACPI_TYPE_BUFFER: 0382 0383 Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); 0384 break; 0385 0386 case ACPI_TYPE_PACKAGE: 0387 0388 Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, 0389 WalkState); 0390 break; 0391 0392 default: 0393 /* 0394 * All other types come here. 0395 */ 0396 ACPI_WARNING ((AE_INFO, "Store into type [%s] not implemented", 0397 AcpiUtGetObjectTypeName (DestDesc))); 0398 0399 Status = AE_NOT_IMPLEMENTED; 0400 break; 0401 } 0402 0403 if (ActualSrcDesc != SourceDesc) 0404 { 0405 /* Delete the intermediate (temporary) source object */ 0406 0407 AcpiUtRemoveReference (ActualSrcDesc); 0408 } 0409 0410 *NewDesc = DestDesc; 0411 return_ACPI_STATUS (Status); 0412 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |