Path: blob/main/sys/contrib/dev/acpica/components/utilities/utobject.c
48406 views
/******************************************************************************1*2* Module Name: utobject - ACPI object create/delete/size/cache routines3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acnamesp.h>154155156#define _COMPONENT ACPI_UTILITIES157ACPI_MODULE_NAME ("utobject")158159/* Local prototypes */160161static ACPI_STATUS162AcpiUtGetSimpleObjectSize (163ACPI_OPERAND_OBJECT *Obj,164ACPI_SIZE *ObjLength);165166static ACPI_STATUS167AcpiUtGetPackageObjectSize (168ACPI_OPERAND_OBJECT *Obj,169ACPI_SIZE *ObjLength);170171static ACPI_STATUS172AcpiUtGetElementLength (173UINT8 ObjectType,174ACPI_OPERAND_OBJECT *SourceObject,175ACPI_GENERIC_STATE *State,176void *Context);177178179/*******************************************************************************180*181* FUNCTION: AcpiUtCreateInternalObjectDbg182*183* PARAMETERS: ModuleName - Source file name of caller184* LineNumber - Line number of caller185* ComponentId - Component type of caller186* Type - ACPI Type of the new object187*188* RETURN: A new internal object, null on failure189*190* DESCRIPTION: Create and initialize a new internal object.191*192* NOTE: We always allocate the worst-case object descriptor because193* these objects are cached, and we want them to be194* one-size-satisfies-any-request. This in itself may not be195* the most memory efficient, but the efficiency of the object196* cache should more than make up for this!197*198******************************************************************************/199200ACPI_OPERAND_OBJECT *201AcpiUtCreateInternalObjectDbg (202const char *ModuleName,203UINT32 LineNumber,204UINT32 ComponentId,205ACPI_OBJECT_TYPE Type)206{207ACPI_OPERAND_OBJECT *Object;208ACPI_OPERAND_OBJECT *SecondObject;209210211ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg,212AcpiUtGetTypeName (Type));213214215/* Allocate the raw object descriptor */216217Object = AcpiUtAllocateObjectDescDbg (218ModuleName, LineNumber, ComponentId);219if (!Object)220{221return_PTR (NULL);222}223224switch (Type)225{226case ACPI_TYPE_REGION:227case ACPI_TYPE_BUFFER_FIELD:228case ACPI_TYPE_LOCAL_BANK_FIELD:229230/* These types require a secondary object */231232SecondObject = AcpiUtAllocateObjectDescDbg (233ModuleName, LineNumber, ComponentId);234if (!SecondObject)235{236AcpiUtDeleteObjectDesc (Object);237return_PTR (NULL);238}239240SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;241SecondObject->Common.ReferenceCount = 1;242243/* Link the second object to the first */244245Object->Common.NextObject = SecondObject;246break;247248default:249250/* All others have no secondary object */251break;252}253254/* Save the object type in the object descriptor */255256Object->Common.Type = (UINT8) Type;257258/* Init the reference count */259260Object->Common.ReferenceCount = 1;261262/* Any per-type initialization should go here */263264return_PTR (Object);265}266267268/*******************************************************************************269*270* FUNCTION: AcpiUtCreatePackageObject271*272* PARAMETERS: Count - Number of package elements273*274* RETURN: Pointer to a new Package object, null on failure275*276* DESCRIPTION: Create a fully initialized package object277*278******************************************************************************/279280ACPI_OPERAND_OBJECT *281AcpiUtCreatePackageObject (282UINT32 Count)283{284ACPI_OPERAND_OBJECT *PackageDesc;285ACPI_OPERAND_OBJECT **PackageElements;286287288ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count);289290291/* Create a new Package object */292293PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);294if (!PackageDesc)295{296return_PTR (NULL);297}298299/*300* Create the element array. Count+1 allows the array to be null301* terminated.302*/303PackageElements = ACPI_ALLOCATE_ZEROED (304((ACPI_SIZE) Count + 1) * sizeof (void *));305if (!PackageElements)306{307ACPI_FREE (PackageDesc);308return_PTR (NULL);309}310311PackageDesc->Package.Count = Count;312PackageDesc->Package.Elements = PackageElements;313return_PTR (PackageDesc);314}315316317/*******************************************************************************318*319* FUNCTION: AcpiUtCreateIntegerObject320*321* PARAMETERS: InitialValue - Initial value for the integer322*323* RETURN: Pointer to a new Integer object, null on failure324*325* DESCRIPTION: Create an initialized integer object326*327******************************************************************************/328329ACPI_OPERAND_OBJECT *330AcpiUtCreateIntegerObject (331UINT64 InitialValue)332{333ACPI_OPERAND_OBJECT *IntegerDesc;334335336ACPI_FUNCTION_TRACE (UtCreateIntegerObject);337338339/* Create and initialize a new integer object */340341IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);342if (!IntegerDesc)343{344return_PTR (NULL);345}346347IntegerDesc->Integer.Value = InitialValue;348return_PTR (IntegerDesc);349}350351352/*******************************************************************************353*354* FUNCTION: AcpiUtCreateBufferObject355*356* PARAMETERS: BufferSize - Size of buffer to be created357*358* RETURN: Pointer to a new Buffer object, null on failure359*360* DESCRIPTION: Create a fully initialized buffer object361*362******************************************************************************/363364ACPI_OPERAND_OBJECT *365AcpiUtCreateBufferObject (366ACPI_SIZE BufferSize)367{368ACPI_OPERAND_OBJECT *BufferDesc;369UINT8 *Buffer = NULL;370371372ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize);373374375/* Create a new Buffer object */376377BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);378if (!BufferDesc)379{380return_PTR (NULL);381}382383/* Create an actual buffer only if size > 0 */384385if (BufferSize > 0)386{387/* Allocate the actual buffer */388389Buffer = ACPI_ALLOCATE_ZEROED (BufferSize);390if (!Buffer)391{392ACPI_ERROR ((AE_INFO, "Could not allocate size %u",393(UINT32) BufferSize));394395AcpiUtRemoveReference (BufferDesc);396return_PTR (NULL);397}398}399400/* Complete buffer object initialization */401402BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;403BufferDesc->Buffer.Pointer = Buffer;404BufferDesc->Buffer.Length = (UINT32) BufferSize;405406/* Return the new buffer descriptor */407408return_PTR (BufferDesc);409}410411412/*******************************************************************************413*414* FUNCTION: AcpiUtCreateStringObject415*416* PARAMETERS: StringSize - Size of string to be created. Does not417* include NULL terminator, this is added418* automatically.419*420* RETURN: Pointer to a new String object421*422* DESCRIPTION: Create a fully initialized string object423*424******************************************************************************/425426ACPI_OPERAND_OBJECT *427AcpiUtCreateStringObject (428ACPI_SIZE StringSize)429{430ACPI_OPERAND_OBJECT *StringDesc;431char *String;432433434ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize);435436437/* Create a new String object */438439StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);440if (!StringDesc)441{442return_PTR (NULL);443}444445/*446* Allocate the actual string buffer -- (Size + 1) for NULL terminator.447* NOTE: Zero-length strings are NULL terminated448*/449String = ACPI_ALLOCATE_ZEROED (StringSize + 1);450if (!String)451{452ACPI_ERROR ((AE_INFO, "Could not allocate size %u",453(UINT32) StringSize));454455AcpiUtRemoveReference (StringDesc);456return_PTR (NULL);457}458459/* Complete string object initialization */460461StringDesc->String.Pointer = String;462StringDesc->String.Length = (UINT32) StringSize;463464/* Return the new string descriptor */465466return_PTR (StringDesc);467}468469470/*******************************************************************************471*472* FUNCTION: AcpiUtValidInternalObject473*474* PARAMETERS: Object - Object to be validated475*476* RETURN: TRUE if object is valid, FALSE otherwise477*478* DESCRIPTION: Validate a pointer to be of type ACPI_OPERAND_OBJECT479*480******************************************************************************/481482BOOLEAN483AcpiUtValidInternalObject (484void *Object)485{486487ACPI_FUNCTION_NAME (UtValidInternalObject);488489490/* Check for a null pointer */491492if (!Object)493{494ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));495return (FALSE);496}497498/* Check the descriptor type field */499500switch (ACPI_GET_DESCRIPTOR_TYPE (Object))501{502case ACPI_DESC_TYPE_OPERAND:503504/* The object appears to be a valid ACPI_OPERAND_OBJECT */505506return (TRUE);507508default:509510ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,511"%p is not an ACPI operand obj [%s]\n",512Object, AcpiUtGetDescriptorName (Object)));513break;514}515516return (FALSE);517}518519520/*******************************************************************************521*522* FUNCTION: AcpiUtAllocateObjectDescDbg523*524* PARAMETERS: ModuleName - Caller's module name (for error output)525* LineNumber - Caller's line number (for error output)526* ComponentId - Caller's component ID (for error output)527*528* RETURN: Pointer to newly allocated object descriptor. Null on error529*530* DESCRIPTION: Allocate a new object descriptor. Gracefully handle531* error conditions.532*533******************************************************************************/534535void *536AcpiUtAllocateObjectDescDbg (537const char *ModuleName,538UINT32 LineNumber,539UINT32 ComponentId)540{541ACPI_OPERAND_OBJECT *Object;542543544ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg);545546547Object = AcpiOsAcquireObject (AcpiGbl_OperandCache);548if (!Object)549{550ACPI_ERROR ((ModuleName, LineNumber,551"Could not allocate an object descriptor"));552553return_PTR (NULL);554}555556/* Mark the descriptor type */557558ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND);559560ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",561Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT)));562563return_PTR (Object);564}565566567/*******************************************************************************568*569* FUNCTION: AcpiUtDeleteObjectDesc570*571* PARAMETERS: Object - An Acpi internal object to be deleted572*573* RETURN: None.574*575* DESCRIPTION: Free an ACPI object descriptor or add it to the object cache576*577******************************************************************************/578579void580AcpiUtDeleteObjectDesc (581ACPI_OPERAND_OBJECT *Object)582{583ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);584585586/* Object must be of type ACPI_OPERAND_OBJECT */587588if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)589{590ACPI_ERROR ((AE_INFO,591"%p is not an ACPI Operand object [%s]", Object,592AcpiUtGetDescriptorName (Object)));593return_VOID;594}595596(void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);597return_VOID;598}599600601/*******************************************************************************602*603* FUNCTION: AcpiUtGetSimpleObjectSize604*605* PARAMETERS: InternalObject - An ACPI operand object606* ObjLength - Where the length is returned607*608* RETURN: Status609*610* DESCRIPTION: This function is called to determine the space required to611* contain a simple object for return to an external user.612*613* The length includes the object structure plus any additional614* needed space.615*616******************************************************************************/617618static ACPI_STATUS619AcpiUtGetSimpleObjectSize (620ACPI_OPERAND_OBJECT *InternalObject,621ACPI_SIZE *ObjLength)622{623ACPI_SIZE Length;624ACPI_SIZE Size;625ACPI_STATUS Status = AE_OK;626627628ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject);629630631/* Start with the length of the (external) Acpi object */632633Length = sizeof (ACPI_OBJECT);634635/* A NULL object is allowed, can be a legal uninitialized package element */636637if (!InternalObject)638{639/*640* Object is NULL, just return the length of ACPI_OBJECT641* (A NULL ACPI_OBJECT is an object of all zeroes.)642*/643*ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);644return_ACPI_STATUS (AE_OK);645}646647/* A Namespace Node should never appear here */648649if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)650{651/* A namespace node should never get here */652653ACPI_ERROR ((AE_INFO,654"Received a namespace node [%4.4s] "655"where an operand object is required",656ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, InternalObject)->Name.Ascii));657return_ACPI_STATUS (AE_AML_INTERNAL);658}659660/*661* The final length depends on the object type662* Strings and Buffers are packed right up against the parent object and663* must be accessed bytewise or there may be alignment problems on664* certain processors665*/666switch (InternalObject->Common.Type)667{668case ACPI_TYPE_STRING:669670Length += (ACPI_SIZE) InternalObject->String.Length + 1;671break;672673case ACPI_TYPE_BUFFER:674675Length += (ACPI_SIZE) InternalObject->Buffer.Length;676break;677678case ACPI_TYPE_INTEGER:679case ACPI_TYPE_PROCESSOR:680case ACPI_TYPE_POWER:681682/* No extra data for these types */683684break;685686case ACPI_TYPE_LOCAL_REFERENCE:687688switch (InternalObject->Reference.Class)689{690case ACPI_REFCLASS_NAME:691/*692* Get the actual length of the full pathname to this object.693* The reference will be converted to the pathname to the object694*/695Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);696if (!Size)697{698return_ACPI_STATUS (AE_BAD_PARAMETER);699}700701Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);702break;703704default:705/*706* No other reference opcodes are supported.707* Notably, Locals and Args are not supported, but this may be708* required eventually.709*/710ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "711"unsupported Reference Class [%s] 0x%X in object %p",712AcpiUtGetReferenceName (InternalObject),713InternalObject->Reference.Class, InternalObject));714Status = AE_TYPE;715break;716}717break;718719default:720721ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "722"unsupported type [%s] 0x%X in object %p",723AcpiUtGetObjectTypeName (InternalObject),724InternalObject->Common.Type, InternalObject));725Status = AE_TYPE;726break;727}728729/*730* Account for the space required by the object rounded up to the next731* multiple of the machine word size. This keeps each object aligned732* on a machine word boundary. (preventing alignment faults on some733* machines.)734*/735*ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);736return_ACPI_STATUS (Status);737}738739740/*******************************************************************************741*742* FUNCTION: AcpiUtGetElementLength743*744* PARAMETERS: ACPI_PKG_CALLBACK745*746* RETURN: Status747*748* DESCRIPTION: Get the length of one package element.749*750******************************************************************************/751752static ACPI_STATUS753AcpiUtGetElementLength (754UINT8 ObjectType,755ACPI_OPERAND_OBJECT *SourceObject,756ACPI_GENERIC_STATE *State,757void *Context)758{759ACPI_STATUS Status = AE_OK;760ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;761ACPI_SIZE ObjectSpace;762763764switch (ObjectType)765{766case ACPI_COPY_TYPE_SIMPLE:767/*768* Simple object - just get the size (Null object/entry is handled769* here also) and sum it into the running package length770*/771Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);772if (ACPI_FAILURE (Status))773{774return (Status);775}776777Info->Length += ObjectSpace;778break;779780case ACPI_COPY_TYPE_PACKAGE:781782/* Package object - nothing much to do here, let the walk handle it */783784Info->NumPackages++;785State->Pkg.ThisTargetObj = NULL;786break;787788default:789790/* No other types allowed */791792return (AE_BAD_PARAMETER);793}794795return (Status);796}797798799/*******************************************************************************800*801* FUNCTION: AcpiUtGetPackageObjectSize802*803* PARAMETERS: InternalObject - An ACPI internal object804* ObjLength - Where the length is returned805*806* RETURN: Status807*808* DESCRIPTION: This function is called to determine the space required to809* contain a package object for return to an external user.810*811* This is moderately complex since a package contains other812* objects including packages.813*814******************************************************************************/815816static ACPI_STATUS817AcpiUtGetPackageObjectSize (818ACPI_OPERAND_OBJECT *InternalObject,819ACPI_SIZE *ObjLength)820{821ACPI_STATUS Status;822ACPI_PKG_INFO Info;823824825ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject);826827828Info.Length = 0;829Info.ObjectSpace = 0;830Info.NumPackages = 1;831832Status = AcpiUtWalkPackageTree (833InternalObject, NULL, AcpiUtGetElementLength, &Info);834if (ACPI_FAILURE (Status))835{836return_ACPI_STATUS (Status);837}838839/*840* We have handled all of the objects in all levels of the package.841* just add the length of the package objects themselves.842* Round up to the next machine word.843*/844Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (845sizeof (ACPI_OBJECT)) * (ACPI_SIZE) Info.NumPackages;846847/* Return the total package length */848849*ObjLength = Info.Length;850return_ACPI_STATUS (Status);851}852853854/*******************************************************************************855*856* FUNCTION: AcpiUtGetObjectSize857*858* PARAMETERS: InternalObject - An ACPI internal object859* ObjLength - Where the length will be returned860*861* RETURN: Status862*863* DESCRIPTION: This function is called to determine the space required to864* contain an object for return to an API user.865*866******************************************************************************/867868ACPI_STATUS869AcpiUtGetObjectSize (870ACPI_OPERAND_OBJECT *InternalObject,871ACPI_SIZE *ObjLength)872{873ACPI_STATUS Status;874875876ACPI_FUNCTION_ENTRY ();877878879if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) ==880ACPI_DESC_TYPE_OPERAND) &&881(InternalObject->Common.Type == ACPI_TYPE_PACKAGE))882{883Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);884}885else886{887Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);888}889890return (Status);891}892893894