|
||||
Warning, cross-references for /kernel/drivers/acpica/utobject.c need to be fixed.
0001 /****************************************************************************** 0002 * 0003 * Module Name: utobject - ACPI object create/delete/size/cache routines 0004 * 0005 *****************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 *****************************************************************************/ 0115 0116 #define __UTOBJECT_C__ 0117 0118 #include "acpi.h" 0119 #include "accommon.h" 0120 #include "acnamesp.h" 0121 0122 0123 #define _COMPONENT ACPI_UTILITIES 0124 ACPI_MODULE_NAME ("utobject") 0125 0126 /* Local prototypes */ 0127 0128 static ACPI_STATUS 0129 AcpiUtGetSimpleObjectSize ( 0130 ACPI_OPERAND_OBJECT *Obj, 0131 ACPI_SIZE *ObjLength); 0132 0133 static ACPI_STATUS 0134 AcpiUtGetPackageObjectSize ( 0135 ACPI_OPERAND_OBJECT *Obj, 0136 ACPI_SIZE *ObjLength); 0137 0138 static ACPI_STATUS 0139 AcpiUtGetElementLength ( 0140 UINT8 ObjectType, 0141 ACPI_OPERAND_OBJECT *SourceObject, 0142 ACPI_GENERIC_STATE *State, 0143 void *Context); 0144 0145 0146 /******************************************************************************* 0147 * 0148 * FUNCTION: AcpiUtCreateInternalObjectDbg 0149 * 0150 * PARAMETERS: ModuleName - Source file name of caller 0151 * LineNumber - Line number of caller 0152 * ComponentId - Component type of caller 0153 * Type - ACPI Type of the new object 0154 * 0155 * RETURN: A new internal object, null on failure 0156 * 0157 * DESCRIPTION: Create and initialize a new internal object. 0158 * 0159 * NOTE: We always allocate the worst-case object descriptor because 0160 * these objects are cached, and we want them to be 0161 * one-size-satisifies-any-request. This in itself may not be 0162 * the most memory efficient, but the efficiency of the object 0163 * cache should more than make up for this! 0164 * 0165 ******************************************************************************/ 0166 0167 ACPI_OPERAND_OBJECT * 0168 AcpiUtCreateInternalObjectDbg ( 0169 const char *ModuleName, 0170 UINT32 LineNumber, 0171 UINT32 ComponentId, 0172 ACPI_OBJECT_TYPE Type) 0173 { 0174 ACPI_OPERAND_OBJECT *Object; 0175 ACPI_OPERAND_OBJECT *SecondObject; 0176 0177 0178 ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg, 0179 AcpiUtGetTypeName (Type)); 0180 0181 0182 /* Allocate the raw object descriptor */ 0183 0184 Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); 0185 if (!Object) 0186 { 0187 return_PTR (NULL); 0188 } 0189 0190 switch (Type) 0191 { 0192 case ACPI_TYPE_REGION: 0193 case ACPI_TYPE_BUFFER_FIELD: 0194 case ACPI_TYPE_LOCAL_BANK_FIELD: 0195 0196 /* These types require a secondary object */ 0197 0198 SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, 0199 LineNumber, ComponentId); 0200 if (!SecondObject) 0201 { 0202 AcpiUtDeleteObjectDesc (Object); 0203 return_PTR (NULL); 0204 } 0205 0206 SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA; 0207 SecondObject->Common.ReferenceCount = 1; 0208 0209 /* Link the second object to the first */ 0210 0211 Object->Common.NextObject = SecondObject; 0212 break; 0213 0214 default: 0215 /* All others have no secondary object */ 0216 break; 0217 } 0218 0219 /* Save the object type in the object descriptor */ 0220 0221 Object->Common.Type = (UINT8) Type; 0222 0223 /* Init the reference count */ 0224 0225 Object->Common.ReferenceCount = 1; 0226 0227 /* Any per-type initialization should go here */ 0228 0229 return_PTR (Object); 0230 } 0231 0232 0233 /******************************************************************************* 0234 * 0235 * FUNCTION: AcpiUtCreatePackageObject 0236 * 0237 * PARAMETERS: Count - Number of package elements 0238 * 0239 * RETURN: Pointer to a new Package object, null on failure 0240 * 0241 * DESCRIPTION: Create a fully initialized package object 0242 * 0243 ******************************************************************************/ 0244 0245 ACPI_OPERAND_OBJECT * 0246 AcpiUtCreatePackageObject ( 0247 UINT32 Count) 0248 { 0249 ACPI_OPERAND_OBJECT *PackageDesc; 0250 ACPI_OPERAND_OBJECT **PackageElements; 0251 0252 0253 ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count); 0254 0255 0256 /* Create a new Package object */ 0257 0258 PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); 0259 if (!PackageDesc) 0260 { 0261 return_PTR (NULL); 0262 } 0263 0264 /* 0265 * Create the element array. Count+1 allows the array to be null 0266 * terminated. 0267 */ 0268 PackageElements = ACPI_ALLOCATE_ZEROED ( 0269 ((ACPI_SIZE) Count + 1) * sizeof (void *)); 0270 if (!PackageElements) 0271 { 0272 ACPI_FREE (PackageDesc); 0273 return_PTR (NULL); 0274 } 0275 0276 PackageDesc->Package.Count = Count; 0277 PackageDesc->Package.Elements = PackageElements; 0278 return_PTR (PackageDesc); 0279 } 0280 0281 0282 /******************************************************************************* 0283 * 0284 * FUNCTION: AcpiUtCreateBufferObject 0285 * 0286 * PARAMETERS: BufferSize - Size of buffer to be created 0287 * 0288 * RETURN: Pointer to a new Buffer object, null on failure 0289 * 0290 * DESCRIPTION: Create a fully initialized buffer object 0291 * 0292 ******************************************************************************/ 0293 0294 ACPI_OPERAND_OBJECT * 0295 AcpiUtCreateBufferObject ( 0296 ACPI_SIZE BufferSize) 0297 { 0298 ACPI_OPERAND_OBJECT *BufferDesc; 0299 UINT8 *Buffer = NULL; 0300 0301 0302 ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize); 0303 0304 0305 /* Create a new Buffer object */ 0306 0307 BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); 0308 if (!BufferDesc) 0309 { 0310 return_PTR (NULL); 0311 } 0312 0313 /* Create an actual buffer only if size > 0 */ 0314 0315 if (BufferSize > 0) 0316 { 0317 /* Allocate the actual buffer */ 0318 0319 Buffer = ACPI_ALLOCATE_ZEROED (BufferSize); 0320 if (!Buffer) 0321 { 0322 ACPI_ERROR ((AE_INFO, "Could not allocate size %X", 0323 (UINT32) BufferSize)); 0324 AcpiUtRemoveReference (BufferDesc); 0325 return_PTR (NULL); 0326 } 0327 } 0328 0329 /* Complete buffer object initialization */ 0330 0331 BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; 0332 BufferDesc->Buffer.Pointer = Buffer; 0333 BufferDesc->Buffer.Length = (UINT32) BufferSize; 0334 0335 /* Return the new buffer descriptor */ 0336 0337 return_PTR (BufferDesc); 0338 } 0339 0340 0341 /******************************************************************************* 0342 * 0343 * FUNCTION: AcpiUtCreateStringObject 0344 * 0345 * PARAMETERS: StringSize - Size of string to be created. Does not 0346 * include NULL terminator, this is added 0347 * automatically. 0348 * 0349 * RETURN: Pointer to a new String object 0350 * 0351 * DESCRIPTION: Create a fully initialized string object 0352 * 0353 ******************************************************************************/ 0354 0355 ACPI_OPERAND_OBJECT * 0356 AcpiUtCreateStringObject ( 0357 ACPI_SIZE StringSize) 0358 { 0359 ACPI_OPERAND_OBJECT *StringDesc; 0360 char *String; 0361 0362 0363 ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize); 0364 0365 0366 /* Create a new String object */ 0367 0368 StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); 0369 if (!StringDesc) 0370 { 0371 return_PTR (NULL); 0372 } 0373 0374 /* 0375 * Allocate the actual string buffer -- (Size + 1) for NULL terminator. 0376 * NOTE: Zero-length strings are NULL terminated 0377 */ 0378 String = ACPI_ALLOCATE_ZEROED (StringSize + 1); 0379 if (!String) 0380 { 0381 ACPI_ERROR ((AE_INFO, "Could not allocate size %X", 0382 (UINT32) StringSize)); 0383 AcpiUtRemoveReference (StringDesc); 0384 return_PTR (NULL); 0385 } 0386 0387 /* Complete string object initialization */ 0388 0389 StringDesc->String.Pointer = String; 0390 StringDesc->String.Length = (UINT32) StringSize; 0391 0392 /* Return the new string descriptor */ 0393 0394 return_PTR (StringDesc); 0395 } 0396 0397 0398 /******************************************************************************* 0399 * 0400 * FUNCTION: AcpiUtValidInternalObject 0401 * 0402 * PARAMETERS: Object - Object to be validated 0403 * 0404 * RETURN: TRUE if object is valid, FALSE otherwise 0405 * 0406 * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT 0407 * 0408 ******************************************************************************/ 0409 0410 BOOLEAN 0411 AcpiUtValidInternalObject ( 0412 void *Object) 0413 { 0414 0415 ACPI_FUNCTION_NAME (UtValidInternalObject); 0416 0417 0418 /* Check for a null pointer */ 0419 0420 if (!Object) 0421 { 0422 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n")); 0423 return (FALSE); 0424 } 0425 0426 /* Check the descriptor type field */ 0427 0428 switch (ACPI_GET_DESCRIPTOR_TYPE (Object)) 0429 { 0430 case ACPI_DESC_TYPE_OPERAND: 0431 0432 /* The object appears to be a valid ACPI_OPERAND_OBJECT */ 0433 0434 return (TRUE); 0435 0436 default: 0437 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0438 "%p is not not an ACPI operand obj [%s]\n", 0439 Object, AcpiUtGetDescriptorName (Object))); 0440 break; 0441 } 0442 0443 return (FALSE); 0444 } 0445 0446 0447 /******************************************************************************* 0448 * 0449 * FUNCTION: AcpiUtAllocateObjectDescDbg 0450 * 0451 * PARAMETERS: ModuleName - Caller's module name (for error output) 0452 * LineNumber - Caller's line number (for error output) 0453 * ComponentId - Caller's component ID (for error output) 0454 * 0455 * RETURN: Pointer to newly allocated object descriptor. Null on error 0456 * 0457 * DESCRIPTION: Allocate a new object descriptor. Gracefully handle 0458 * error conditions. 0459 * 0460 ******************************************************************************/ 0461 0462 void * 0463 AcpiUtAllocateObjectDescDbg ( 0464 const char *ModuleName, 0465 UINT32 LineNumber, 0466 UINT32 ComponentId) 0467 { 0468 ACPI_OPERAND_OBJECT *Object; 0469 0470 0471 ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg); 0472 0473 0474 Object = AcpiOsAcquireObject (AcpiGbl_OperandCache); 0475 if (!Object) 0476 { 0477 ACPI_ERROR ((ModuleName, LineNumber, 0478 "Could not allocate an object descriptor")); 0479 0480 return_PTR (NULL); 0481 } 0482 0483 /* Mark the descriptor type */ 0484 0485 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND); 0486 0487 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", 0488 Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); 0489 0490 return_PTR (Object); 0491 } 0492 0493 0494 /******************************************************************************* 0495 * 0496 * FUNCTION: AcpiUtDeleteObjectDesc 0497 * 0498 * PARAMETERS: Object - An Acpi internal object to be deleted 0499 * 0500 * RETURN: None. 0501 * 0502 * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache 0503 * 0504 ******************************************************************************/ 0505 0506 void 0507 AcpiUtDeleteObjectDesc ( 0508 ACPI_OPERAND_OBJECT *Object) 0509 { 0510 ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object); 0511 0512 0513 /* Object must be an ACPI_OPERAND_OBJECT */ 0514 0515 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 0516 { 0517 ACPI_ERROR ((AE_INFO, 0518 "%p is not an ACPI Operand object [%s]", Object, 0519 AcpiUtGetDescriptorName (Object))); 0520 return_VOID; 0521 } 0522 0523 (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object); 0524 return_VOID; 0525 } 0526 0527 0528 /******************************************************************************* 0529 * 0530 * FUNCTION: AcpiUtGetSimpleObjectSize 0531 * 0532 * PARAMETERS: InternalObject - An ACPI operand object 0533 * ObjLength - Where the length is returned 0534 * 0535 * RETURN: Status 0536 * 0537 * DESCRIPTION: This function is called to determine the space required to 0538 * contain a simple object for return to an external user. 0539 * 0540 * The length includes the object structure plus any additional 0541 * needed space. 0542 * 0543 ******************************************************************************/ 0544 0545 static ACPI_STATUS 0546 AcpiUtGetSimpleObjectSize ( 0547 ACPI_OPERAND_OBJECT *InternalObject, 0548 ACPI_SIZE *ObjLength) 0549 { 0550 ACPI_SIZE Length; 0551 ACPI_SIZE Size; 0552 ACPI_STATUS Status = AE_OK; 0553 0554 0555 ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject); 0556 0557 0558 /* Start with the length of the (external) Acpi object */ 0559 0560 Length = sizeof (ACPI_OBJECT); 0561 0562 /* A NULL object is allowed, can be a legal uninitialized package element */ 0563 0564 if (!InternalObject) 0565 { 0566 /* 0567 * Object is NULL, just return the length of ACPI_OBJECT 0568 * (A NULL ACPI_OBJECT is an object of all zeroes.) 0569 */ 0570 *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); 0571 return_ACPI_STATUS (AE_OK); 0572 } 0573 0574 /* A Namespace Node should never appear here */ 0575 0576 if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED) 0577 { 0578 /* A namespace node should never get here */ 0579 0580 return_ACPI_STATUS (AE_AML_INTERNAL); 0581 } 0582 0583 /* 0584 * The final length depends on the object type 0585 * Strings and Buffers are packed right up against the parent object and 0586 * must be accessed bytewise or there may be alignment problems on 0587 * certain processors 0588 */ 0589 switch (InternalObject->Common.Type) 0590 { 0591 case ACPI_TYPE_STRING: 0592 0593 Length += (ACPI_SIZE) InternalObject->String.Length + 1; 0594 break; 0595 0596 0597 case ACPI_TYPE_BUFFER: 0598 0599 Length += (ACPI_SIZE) InternalObject->Buffer.Length; 0600 break; 0601 0602 0603 case ACPI_TYPE_INTEGER: 0604 case ACPI_TYPE_PROCESSOR: 0605 case ACPI_TYPE_POWER: 0606 0607 /* No extra data for these types */ 0608 0609 break; 0610 0611 0612 case ACPI_TYPE_LOCAL_REFERENCE: 0613 0614 switch (InternalObject->Reference.Class) 0615 { 0616 case ACPI_REFCLASS_NAME: 0617 0618 /* 0619 * Get the actual length of the full pathname to this object. 0620 * The reference will be converted to the pathname to the object 0621 */ 0622 Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node); 0623 if (!Size) 0624 { 0625 return_ACPI_STATUS (AE_BAD_PARAMETER); 0626 } 0627 0628 Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size); 0629 break; 0630 0631 default: 0632 0633 /* 0634 * No other reference opcodes are supported. 0635 * Notably, Locals and Args are not supported, but this may be 0636 * required eventually. 0637 */ 0638 ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " 0639 "unsupported Reference Class [%s] %X in object %p", 0640 AcpiUtGetReferenceName (InternalObject), 0641 InternalObject->Reference.Class, InternalObject)); 0642 Status = AE_TYPE; 0643 break; 0644 } 0645 break; 0646 0647 0648 default: 0649 0650 ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " 0651 "unsupported type [%s] %X in object %p", 0652 AcpiUtGetObjectTypeName (InternalObject), 0653 InternalObject->Common.Type, InternalObject)); 0654 Status = AE_TYPE; 0655 break; 0656 } 0657 0658 /* 0659 * Account for the space required by the object rounded up to the next 0660 * multiple of the machine word size. This keeps each object aligned 0661 * on a machine word boundary. (preventing alignment faults on some 0662 * machines.) 0663 */ 0664 *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); 0665 return_ACPI_STATUS (Status); 0666 } 0667 0668 0669 /******************************************************************************* 0670 * 0671 * FUNCTION: AcpiUtGetElementLength 0672 * 0673 * PARAMETERS: ACPI_PKG_CALLBACK 0674 * 0675 * RETURN: Status 0676 * 0677 * DESCRIPTION: Get the length of one package element. 0678 * 0679 ******************************************************************************/ 0680 0681 static ACPI_STATUS 0682 AcpiUtGetElementLength ( 0683 UINT8 ObjectType, 0684 ACPI_OPERAND_OBJECT *SourceObject, 0685 ACPI_GENERIC_STATE *State, 0686 void *Context) 0687 { 0688 ACPI_STATUS Status = AE_OK; 0689 ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; 0690 ACPI_SIZE ObjectSpace; 0691 0692 0693 switch (ObjectType) 0694 { 0695 case ACPI_COPY_TYPE_SIMPLE: 0696 0697 /* 0698 * Simple object - just get the size (Null object/entry is handled 0699 * here also) and sum it into the running package length 0700 */ 0701 Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace); 0702 if (ACPI_FAILURE (Status)) 0703 { 0704 return (Status); 0705 } 0706 0707 Info->Length += ObjectSpace; 0708 break; 0709 0710 0711 case ACPI_COPY_TYPE_PACKAGE: 0712 0713 /* Package object - nothing much to do here, let the walk handle it */ 0714 0715 Info->NumPackages++; 0716 State->Pkg.ThisTargetObj = NULL; 0717 break; 0718 0719 0720 default: 0721 0722 /* No other types allowed */ 0723 0724 return (AE_BAD_PARAMETER); 0725 } 0726 0727 return (Status); 0728 } 0729 0730 0731 /******************************************************************************* 0732 * 0733 * FUNCTION: AcpiUtGetPackageObjectSize 0734 * 0735 * PARAMETERS: InternalObject - An ACPI internal object 0736 * ObjLength - Where the length is returned 0737 * 0738 * RETURN: Status 0739 * 0740 * DESCRIPTION: This function is called to determine the space required to 0741 * contain a package object for return to an external user. 0742 * 0743 * This is moderately complex since a package contains other 0744 * objects including packages. 0745 * 0746 ******************************************************************************/ 0747 0748 static ACPI_STATUS 0749 AcpiUtGetPackageObjectSize ( 0750 ACPI_OPERAND_OBJECT *InternalObject, 0751 ACPI_SIZE *ObjLength) 0752 { 0753 ACPI_STATUS Status; 0754 ACPI_PKG_INFO Info; 0755 0756 0757 ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject); 0758 0759 0760 Info.Length = 0; 0761 Info.ObjectSpace = 0; 0762 Info.NumPackages = 1; 0763 0764 Status = AcpiUtWalkPackageTree (InternalObject, NULL, 0765 AcpiUtGetElementLength, &Info); 0766 if (ACPI_FAILURE (Status)) 0767 { 0768 return_ACPI_STATUS (Status); 0769 } 0770 0771 /* 0772 * We have handled all of the objects in all levels of the package. 0773 * just add the length of the package objects themselves. 0774 * Round up to the next machine word. 0775 */ 0776 Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * 0777 (ACPI_SIZE) Info.NumPackages; 0778 0779 /* Return the total package length */ 0780 0781 *ObjLength = Info.Length; 0782 return_ACPI_STATUS (Status); 0783 } 0784 0785 0786 /******************************************************************************* 0787 * 0788 * FUNCTION: AcpiUtGetObjectSize 0789 * 0790 * PARAMETERS: InternalObject - An ACPI internal object 0791 * ObjLength - Where the length will be returned 0792 * 0793 * RETURN: Status 0794 * 0795 * DESCRIPTION: This function is called to determine the space required to 0796 * contain an object for return to an API user. 0797 * 0798 ******************************************************************************/ 0799 0800 ACPI_STATUS 0801 AcpiUtGetObjectSize ( 0802 ACPI_OPERAND_OBJECT *InternalObject, 0803 ACPI_SIZE *ObjLength) 0804 { 0805 ACPI_STATUS Status; 0806 0807 0808 ACPI_FUNCTION_ENTRY (); 0809 0810 0811 if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && 0812 (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)) 0813 { 0814 Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); 0815 } 0816 else 0817 { 0818 Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength); 0819 } 0820 0821 return (Status); 0822 } 0823 0824
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |