Home | History | Annotate | Line # | Download | only in utilities
utobject.c revision 1.1.1.2.4.2
      1  1.1.1.2.4.2  rmind /******************************************************************************
      2  1.1.1.2.4.2  rmind  *
      3  1.1.1.2.4.2  rmind  * Module Name: utobject - ACPI object create/delete/size/cache routines
      4  1.1.1.2.4.2  rmind  *
      5  1.1.1.2.4.2  rmind  *****************************************************************************/
      6  1.1.1.2.4.2  rmind 
      7  1.1.1.2.4.2  rmind /*
      8  1.1.1.2.4.2  rmind  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.1.1.2.4.2  rmind  * All rights reserved.
     10  1.1.1.2.4.2  rmind  *
     11  1.1.1.2.4.2  rmind  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2.4.2  rmind  * modification, are permitted provided that the following conditions
     13  1.1.1.2.4.2  rmind  * are met:
     14  1.1.1.2.4.2  rmind  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2.4.2  rmind  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2.4.2  rmind  *    without modification.
     17  1.1.1.2.4.2  rmind  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2.4.2  rmind  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2.4.2  rmind  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2.4.2  rmind  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2.4.2  rmind  *    binary redistribution.
     22  1.1.1.2.4.2  rmind  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2.4.2  rmind  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2.4.2  rmind  *    from this software without specific prior written permission.
     25  1.1.1.2.4.2  rmind  *
     26  1.1.1.2.4.2  rmind  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2.4.2  rmind  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2.4.2  rmind  * Software Foundation.
     29  1.1.1.2.4.2  rmind  *
     30  1.1.1.2.4.2  rmind  * NO WARRANTY
     31  1.1.1.2.4.2  rmind  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2.4.2  rmind  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2.4.2  rmind  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2.4.2  rmind  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2.4.2  rmind  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2.4.2  rmind  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2.4.2  rmind  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2.4.2  rmind  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2.4.2  rmind  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2.4.2  rmind  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2.4.2  rmind  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2.4.2  rmind  */
     43  1.1.1.2.4.2  rmind 
     44  1.1.1.2.4.2  rmind #define __UTOBJECT_C__
     45  1.1.1.2.4.2  rmind 
     46  1.1.1.2.4.2  rmind #include "acpi.h"
     47  1.1.1.2.4.2  rmind #include "accommon.h"
     48  1.1.1.2.4.2  rmind #include "acnamesp.h"
     49  1.1.1.2.4.2  rmind 
     50  1.1.1.2.4.2  rmind 
     51  1.1.1.2.4.2  rmind #define _COMPONENT          ACPI_UTILITIES
     52  1.1.1.2.4.2  rmind         ACPI_MODULE_NAME    ("utobject")
     53  1.1.1.2.4.2  rmind 
     54  1.1.1.2.4.2  rmind /* Local prototypes */
     55  1.1.1.2.4.2  rmind 
     56  1.1.1.2.4.2  rmind static ACPI_STATUS
     57  1.1.1.2.4.2  rmind AcpiUtGetSimpleObjectSize (
     58  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *Obj,
     59  1.1.1.2.4.2  rmind     ACPI_SIZE               *ObjLength);
     60  1.1.1.2.4.2  rmind 
     61  1.1.1.2.4.2  rmind static ACPI_STATUS
     62  1.1.1.2.4.2  rmind AcpiUtGetPackageObjectSize (
     63  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *Obj,
     64  1.1.1.2.4.2  rmind     ACPI_SIZE               *ObjLength);
     65  1.1.1.2.4.2  rmind 
     66  1.1.1.2.4.2  rmind static ACPI_STATUS
     67  1.1.1.2.4.2  rmind AcpiUtGetElementLength (
     68  1.1.1.2.4.2  rmind     UINT8                   ObjectType,
     69  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *SourceObject,
     70  1.1.1.2.4.2  rmind     ACPI_GENERIC_STATE      *State,
     71  1.1.1.2.4.2  rmind     void                    *Context);
     72  1.1.1.2.4.2  rmind 
     73  1.1.1.2.4.2  rmind 
     74  1.1.1.2.4.2  rmind /*******************************************************************************
     75  1.1.1.2.4.2  rmind  *
     76  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtCreateInternalObjectDbg
     77  1.1.1.2.4.2  rmind  *
     78  1.1.1.2.4.2  rmind  * PARAMETERS:  ModuleName          - Source file name of caller
     79  1.1.1.2.4.2  rmind  *              LineNumber          - Line number of caller
     80  1.1.1.2.4.2  rmind  *              ComponentId         - Component type of caller
     81  1.1.1.2.4.2  rmind  *              Type                - ACPI Type of the new object
     82  1.1.1.2.4.2  rmind  *
     83  1.1.1.2.4.2  rmind  * RETURN:      A new internal object, null on failure
     84  1.1.1.2.4.2  rmind  *
     85  1.1.1.2.4.2  rmind  * DESCRIPTION: Create and initialize a new internal object.
     86  1.1.1.2.4.2  rmind  *
     87  1.1.1.2.4.2  rmind  * NOTE:        We always allocate the worst-case object descriptor because
     88  1.1.1.2.4.2  rmind  *              these objects are cached, and we want them to be
     89  1.1.1.2.4.2  rmind  *              one-size-satisifies-any-request.  This in itself may not be
     90  1.1.1.2.4.2  rmind  *              the most memory efficient, but the efficiency of the object
     91  1.1.1.2.4.2  rmind  *              cache should more than make up for this!
     92  1.1.1.2.4.2  rmind  *
     93  1.1.1.2.4.2  rmind  ******************************************************************************/
     94  1.1.1.2.4.2  rmind 
     95  1.1.1.2.4.2  rmind ACPI_OPERAND_OBJECT  *
     96  1.1.1.2.4.2  rmind AcpiUtCreateInternalObjectDbg (
     97  1.1.1.2.4.2  rmind     const char              *ModuleName,
     98  1.1.1.2.4.2  rmind     UINT32                  LineNumber,
     99  1.1.1.2.4.2  rmind     UINT32                  ComponentId,
    100  1.1.1.2.4.2  rmind     ACPI_OBJECT_TYPE        Type)
    101  1.1.1.2.4.2  rmind {
    102  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *Object;
    103  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *SecondObject;
    104  1.1.1.2.4.2  rmind 
    105  1.1.1.2.4.2  rmind 
    106  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg,
    107  1.1.1.2.4.2  rmind         AcpiUtGetTypeName (Type));
    108  1.1.1.2.4.2  rmind 
    109  1.1.1.2.4.2  rmind 
    110  1.1.1.2.4.2  rmind     /* Allocate the raw object descriptor */
    111  1.1.1.2.4.2  rmind 
    112  1.1.1.2.4.2  rmind     Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId);
    113  1.1.1.2.4.2  rmind     if (!Object)
    114  1.1.1.2.4.2  rmind     {
    115  1.1.1.2.4.2  rmind         return_PTR (NULL);
    116  1.1.1.2.4.2  rmind     }
    117  1.1.1.2.4.2  rmind 
    118  1.1.1.2.4.2  rmind     switch (Type)
    119  1.1.1.2.4.2  rmind     {
    120  1.1.1.2.4.2  rmind     case ACPI_TYPE_REGION:
    121  1.1.1.2.4.2  rmind     case ACPI_TYPE_BUFFER_FIELD:
    122  1.1.1.2.4.2  rmind     case ACPI_TYPE_LOCAL_BANK_FIELD:
    123  1.1.1.2.4.2  rmind 
    124  1.1.1.2.4.2  rmind         /* These types require a secondary object */
    125  1.1.1.2.4.2  rmind 
    126  1.1.1.2.4.2  rmind         SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
    127  1.1.1.2.4.2  rmind                             LineNumber, ComponentId);
    128  1.1.1.2.4.2  rmind         if (!SecondObject)
    129  1.1.1.2.4.2  rmind         {
    130  1.1.1.2.4.2  rmind             AcpiUtDeleteObjectDesc (Object);
    131  1.1.1.2.4.2  rmind             return_PTR (NULL);
    132  1.1.1.2.4.2  rmind         }
    133  1.1.1.2.4.2  rmind 
    134  1.1.1.2.4.2  rmind         SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
    135  1.1.1.2.4.2  rmind         SecondObject->Common.ReferenceCount = 1;
    136  1.1.1.2.4.2  rmind 
    137  1.1.1.2.4.2  rmind         /* Link the second object to the first */
    138  1.1.1.2.4.2  rmind 
    139  1.1.1.2.4.2  rmind         Object->Common.NextObject = SecondObject;
    140  1.1.1.2.4.2  rmind         break;
    141  1.1.1.2.4.2  rmind 
    142  1.1.1.2.4.2  rmind     default:
    143  1.1.1.2.4.2  rmind         /* All others have no secondary object */
    144  1.1.1.2.4.2  rmind         break;
    145  1.1.1.2.4.2  rmind     }
    146  1.1.1.2.4.2  rmind 
    147  1.1.1.2.4.2  rmind     /* Save the object type in the object descriptor */
    148  1.1.1.2.4.2  rmind 
    149  1.1.1.2.4.2  rmind     Object->Common.Type = (UINT8) Type;
    150  1.1.1.2.4.2  rmind 
    151  1.1.1.2.4.2  rmind     /* Init the reference count */
    152  1.1.1.2.4.2  rmind 
    153  1.1.1.2.4.2  rmind     Object->Common.ReferenceCount = 1;
    154  1.1.1.2.4.2  rmind 
    155  1.1.1.2.4.2  rmind     /* Any per-type initialization should go here */
    156  1.1.1.2.4.2  rmind 
    157  1.1.1.2.4.2  rmind     return_PTR (Object);
    158  1.1.1.2.4.2  rmind }
    159  1.1.1.2.4.2  rmind 
    160  1.1.1.2.4.2  rmind 
    161  1.1.1.2.4.2  rmind /*******************************************************************************
    162  1.1.1.2.4.2  rmind  *
    163  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtCreatePackageObject
    164  1.1.1.2.4.2  rmind  *
    165  1.1.1.2.4.2  rmind  * PARAMETERS:  Count               - Number of package elements
    166  1.1.1.2.4.2  rmind  *
    167  1.1.1.2.4.2  rmind  * RETURN:      Pointer to a new Package object, null on failure
    168  1.1.1.2.4.2  rmind  *
    169  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a fully initialized package object
    170  1.1.1.2.4.2  rmind  *
    171  1.1.1.2.4.2  rmind  ******************************************************************************/
    172  1.1.1.2.4.2  rmind 
    173  1.1.1.2.4.2  rmind ACPI_OPERAND_OBJECT *
    174  1.1.1.2.4.2  rmind AcpiUtCreatePackageObject (
    175  1.1.1.2.4.2  rmind     UINT32                  Count)
    176  1.1.1.2.4.2  rmind {
    177  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *PackageDesc;
    178  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     **PackageElements;
    179  1.1.1.2.4.2  rmind 
    180  1.1.1.2.4.2  rmind 
    181  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count);
    182  1.1.1.2.4.2  rmind 
    183  1.1.1.2.4.2  rmind 
    184  1.1.1.2.4.2  rmind     /* Create a new Package object */
    185  1.1.1.2.4.2  rmind 
    186  1.1.1.2.4.2  rmind     PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
    187  1.1.1.2.4.2  rmind     if (!PackageDesc)
    188  1.1.1.2.4.2  rmind     {
    189  1.1.1.2.4.2  rmind         return_PTR (NULL);
    190  1.1.1.2.4.2  rmind     }
    191  1.1.1.2.4.2  rmind 
    192  1.1.1.2.4.2  rmind     /*
    193  1.1.1.2.4.2  rmind      * Create the element array. Count+1 allows the array to be null
    194  1.1.1.2.4.2  rmind      * terminated.
    195  1.1.1.2.4.2  rmind      */
    196  1.1.1.2.4.2  rmind     PackageElements = ACPI_ALLOCATE_ZEROED (
    197  1.1.1.2.4.2  rmind                         ((ACPI_SIZE) Count + 1) * sizeof (void *));
    198  1.1.1.2.4.2  rmind     if (!PackageElements)
    199  1.1.1.2.4.2  rmind     {
    200  1.1.1.2.4.2  rmind         ACPI_FREE (PackageDesc);
    201  1.1.1.2.4.2  rmind         return_PTR (NULL);
    202  1.1.1.2.4.2  rmind     }
    203  1.1.1.2.4.2  rmind 
    204  1.1.1.2.4.2  rmind     PackageDesc->Package.Count = Count;
    205  1.1.1.2.4.2  rmind     PackageDesc->Package.Elements = PackageElements;
    206  1.1.1.2.4.2  rmind     return_PTR (PackageDesc);
    207  1.1.1.2.4.2  rmind }
    208  1.1.1.2.4.2  rmind 
    209  1.1.1.2.4.2  rmind 
    210  1.1.1.2.4.2  rmind /*******************************************************************************
    211  1.1.1.2.4.2  rmind  *
    212  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtCreateIntegerObject
    213  1.1.1.2.4.2  rmind  *
    214  1.1.1.2.4.2  rmind  * PARAMETERS:  InitialValue        - Initial value for the integer
    215  1.1.1.2.4.2  rmind  *
    216  1.1.1.2.4.2  rmind  * RETURN:      Pointer to a new Integer object, null on failure
    217  1.1.1.2.4.2  rmind  *
    218  1.1.1.2.4.2  rmind  * DESCRIPTION: Create an initialized integer object
    219  1.1.1.2.4.2  rmind  *
    220  1.1.1.2.4.2  rmind  ******************************************************************************/
    221  1.1.1.2.4.2  rmind 
    222  1.1.1.2.4.2  rmind ACPI_OPERAND_OBJECT *
    223  1.1.1.2.4.2  rmind AcpiUtCreateIntegerObject (
    224  1.1.1.2.4.2  rmind     UINT64                  InitialValue)
    225  1.1.1.2.4.2  rmind {
    226  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *IntegerDesc;
    227  1.1.1.2.4.2  rmind 
    228  1.1.1.2.4.2  rmind 
    229  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE (UtCreateIntegerObject);
    230  1.1.1.2.4.2  rmind 
    231  1.1.1.2.4.2  rmind 
    232  1.1.1.2.4.2  rmind     /* Create and initialize a new integer object */
    233  1.1.1.2.4.2  rmind 
    234  1.1.1.2.4.2  rmind     IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
    235  1.1.1.2.4.2  rmind     if (!IntegerDesc)
    236  1.1.1.2.4.2  rmind     {
    237  1.1.1.2.4.2  rmind         return_PTR (NULL);
    238  1.1.1.2.4.2  rmind     }
    239  1.1.1.2.4.2  rmind 
    240  1.1.1.2.4.2  rmind     IntegerDesc->Integer.Value = InitialValue;
    241  1.1.1.2.4.2  rmind     return_PTR (IntegerDesc);
    242  1.1.1.2.4.2  rmind }
    243  1.1.1.2.4.2  rmind 
    244  1.1.1.2.4.2  rmind 
    245  1.1.1.2.4.2  rmind /*******************************************************************************
    246  1.1.1.2.4.2  rmind  *
    247  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtCreateBufferObject
    248  1.1.1.2.4.2  rmind  *
    249  1.1.1.2.4.2  rmind  * PARAMETERS:  BufferSize             - Size of buffer to be created
    250  1.1.1.2.4.2  rmind  *
    251  1.1.1.2.4.2  rmind  * RETURN:      Pointer to a new Buffer object, null on failure
    252  1.1.1.2.4.2  rmind  *
    253  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a fully initialized buffer object
    254  1.1.1.2.4.2  rmind  *
    255  1.1.1.2.4.2  rmind  ******************************************************************************/
    256  1.1.1.2.4.2  rmind 
    257  1.1.1.2.4.2  rmind ACPI_OPERAND_OBJECT *
    258  1.1.1.2.4.2  rmind AcpiUtCreateBufferObject (
    259  1.1.1.2.4.2  rmind     ACPI_SIZE               BufferSize)
    260  1.1.1.2.4.2  rmind {
    261  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *BufferDesc;
    262  1.1.1.2.4.2  rmind     UINT8                   *Buffer = NULL;
    263  1.1.1.2.4.2  rmind 
    264  1.1.1.2.4.2  rmind 
    265  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize);
    266  1.1.1.2.4.2  rmind 
    267  1.1.1.2.4.2  rmind 
    268  1.1.1.2.4.2  rmind     /* Create a new Buffer object */
    269  1.1.1.2.4.2  rmind 
    270  1.1.1.2.4.2  rmind     BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
    271  1.1.1.2.4.2  rmind     if (!BufferDesc)
    272  1.1.1.2.4.2  rmind     {
    273  1.1.1.2.4.2  rmind         return_PTR (NULL);
    274  1.1.1.2.4.2  rmind     }
    275  1.1.1.2.4.2  rmind 
    276  1.1.1.2.4.2  rmind     /* Create an actual buffer only if size > 0 */
    277  1.1.1.2.4.2  rmind 
    278  1.1.1.2.4.2  rmind     if (BufferSize > 0)
    279  1.1.1.2.4.2  rmind     {
    280  1.1.1.2.4.2  rmind         /* Allocate the actual buffer */
    281  1.1.1.2.4.2  rmind 
    282  1.1.1.2.4.2  rmind         Buffer = ACPI_ALLOCATE_ZEROED (BufferSize);
    283  1.1.1.2.4.2  rmind         if (!Buffer)
    284  1.1.1.2.4.2  rmind         {
    285  1.1.1.2.4.2  rmind             ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
    286  1.1.1.2.4.2  rmind                 (UINT32) BufferSize));
    287  1.1.1.2.4.2  rmind             AcpiUtRemoveReference (BufferDesc);
    288  1.1.1.2.4.2  rmind             return_PTR (NULL);
    289  1.1.1.2.4.2  rmind         }
    290  1.1.1.2.4.2  rmind     }
    291  1.1.1.2.4.2  rmind 
    292  1.1.1.2.4.2  rmind     /* Complete buffer object initialization */
    293  1.1.1.2.4.2  rmind 
    294  1.1.1.2.4.2  rmind     BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
    295  1.1.1.2.4.2  rmind     BufferDesc->Buffer.Pointer = Buffer;
    296  1.1.1.2.4.2  rmind     BufferDesc->Buffer.Length = (UINT32) BufferSize;
    297  1.1.1.2.4.2  rmind 
    298  1.1.1.2.4.2  rmind     /* Return the new buffer descriptor */
    299  1.1.1.2.4.2  rmind 
    300  1.1.1.2.4.2  rmind     return_PTR (BufferDesc);
    301  1.1.1.2.4.2  rmind }
    302  1.1.1.2.4.2  rmind 
    303  1.1.1.2.4.2  rmind 
    304  1.1.1.2.4.2  rmind /*******************************************************************************
    305  1.1.1.2.4.2  rmind  *
    306  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtCreateStringObject
    307  1.1.1.2.4.2  rmind  *
    308  1.1.1.2.4.2  rmind  * PARAMETERS:  StringSize          - Size of string to be created. Does not
    309  1.1.1.2.4.2  rmind  *                                    include NULL terminator, this is added
    310  1.1.1.2.4.2  rmind  *                                    automatically.
    311  1.1.1.2.4.2  rmind  *
    312  1.1.1.2.4.2  rmind  * RETURN:      Pointer to a new String object
    313  1.1.1.2.4.2  rmind  *
    314  1.1.1.2.4.2  rmind  * DESCRIPTION: Create a fully initialized string object
    315  1.1.1.2.4.2  rmind  *
    316  1.1.1.2.4.2  rmind  ******************************************************************************/
    317  1.1.1.2.4.2  rmind 
    318  1.1.1.2.4.2  rmind ACPI_OPERAND_OBJECT *
    319  1.1.1.2.4.2  rmind AcpiUtCreateStringObject (
    320  1.1.1.2.4.2  rmind     ACPI_SIZE               StringSize)
    321  1.1.1.2.4.2  rmind {
    322  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *StringDesc;
    323  1.1.1.2.4.2  rmind     char                    *String;
    324  1.1.1.2.4.2  rmind 
    325  1.1.1.2.4.2  rmind 
    326  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize);
    327  1.1.1.2.4.2  rmind 
    328  1.1.1.2.4.2  rmind 
    329  1.1.1.2.4.2  rmind     /* Create a new String object */
    330  1.1.1.2.4.2  rmind 
    331  1.1.1.2.4.2  rmind     StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
    332  1.1.1.2.4.2  rmind     if (!StringDesc)
    333  1.1.1.2.4.2  rmind     {
    334  1.1.1.2.4.2  rmind         return_PTR (NULL);
    335  1.1.1.2.4.2  rmind     }
    336  1.1.1.2.4.2  rmind 
    337  1.1.1.2.4.2  rmind     /*
    338  1.1.1.2.4.2  rmind      * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
    339  1.1.1.2.4.2  rmind      * NOTE: Zero-length strings are NULL terminated
    340  1.1.1.2.4.2  rmind      */
    341  1.1.1.2.4.2  rmind     String = ACPI_ALLOCATE_ZEROED (StringSize + 1);
    342  1.1.1.2.4.2  rmind     if (!String)
    343  1.1.1.2.4.2  rmind     {
    344  1.1.1.2.4.2  rmind         ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
    345  1.1.1.2.4.2  rmind             (UINT32) StringSize));
    346  1.1.1.2.4.2  rmind         AcpiUtRemoveReference (StringDesc);
    347  1.1.1.2.4.2  rmind         return_PTR (NULL);
    348  1.1.1.2.4.2  rmind     }
    349  1.1.1.2.4.2  rmind 
    350  1.1.1.2.4.2  rmind     /* Complete string object initialization */
    351  1.1.1.2.4.2  rmind 
    352  1.1.1.2.4.2  rmind     StringDesc->String.Pointer = String;
    353  1.1.1.2.4.2  rmind     StringDesc->String.Length = (UINT32) StringSize;
    354  1.1.1.2.4.2  rmind 
    355  1.1.1.2.4.2  rmind     /* Return the new string descriptor */
    356  1.1.1.2.4.2  rmind 
    357  1.1.1.2.4.2  rmind     return_PTR (StringDesc);
    358  1.1.1.2.4.2  rmind }
    359  1.1.1.2.4.2  rmind 
    360  1.1.1.2.4.2  rmind 
    361  1.1.1.2.4.2  rmind /*******************************************************************************
    362  1.1.1.2.4.2  rmind  *
    363  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtValidInternalObject
    364  1.1.1.2.4.2  rmind  *
    365  1.1.1.2.4.2  rmind  * PARAMETERS:  Object              - Object to be validated
    366  1.1.1.2.4.2  rmind  *
    367  1.1.1.2.4.2  rmind  * RETURN:      TRUE if object is valid, FALSE otherwise
    368  1.1.1.2.4.2  rmind  *
    369  1.1.1.2.4.2  rmind  * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT
    370  1.1.1.2.4.2  rmind  *
    371  1.1.1.2.4.2  rmind  ******************************************************************************/
    372  1.1.1.2.4.2  rmind 
    373  1.1.1.2.4.2  rmind BOOLEAN
    374  1.1.1.2.4.2  rmind AcpiUtValidInternalObject (
    375  1.1.1.2.4.2  rmind     void                    *Object)
    376  1.1.1.2.4.2  rmind {
    377  1.1.1.2.4.2  rmind 
    378  1.1.1.2.4.2  rmind     ACPI_FUNCTION_NAME (UtValidInternalObject);
    379  1.1.1.2.4.2  rmind 
    380  1.1.1.2.4.2  rmind 
    381  1.1.1.2.4.2  rmind     /* Check for a null pointer */
    382  1.1.1.2.4.2  rmind 
    383  1.1.1.2.4.2  rmind     if (!Object)
    384  1.1.1.2.4.2  rmind     {
    385  1.1.1.2.4.2  rmind         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
    386  1.1.1.2.4.2  rmind         return (FALSE);
    387  1.1.1.2.4.2  rmind     }
    388  1.1.1.2.4.2  rmind 
    389  1.1.1.2.4.2  rmind     /* Check the descriptor type field */
    390  1.1.1.2.4.2  rmind 
    391  1.1.1.2.4.2  rmind     switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
    392  1.1.1.2.4.2  rmind     {
    393  1.1.1.2.4.2  rmind     case ACPI_DESC_TYPE_OPERAND:
    394  1.1.1.2.4.2  rmind 
    395  1.1.1.2.4.2  rmind         /* The object appears to be a valid ACPI_OPERAND_OBJECT  */
    396  1.1.1.2.4.2  rmind 
    397  1.1.1.2.4.2  rmind         return (TRUE);
    398  1.1.1.2.4.2  rmind 
    399  1.1.1.2.4.2  rmind     default:
    400  1.1.1.2.4.2  rmind         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
    401  1.1.1.2.4.2  rmind                 "%p is not not an ACPI operand obj [%s]\n",
    402  1.1.1.2.4.2  rmind                 Object, AcpiUtGetDescriptorName (Object)));
    403  1.1.1.2.4.2  rmind         break;
    404  1.1.1.2.4.2  rmind     }
    405  1.1.1.2.4.2  rmind 
    406  1.1.1.2.4.2  rmind     return (FALSE);
    407  1.1.1.2.4.2  rmind }
    408  1.1.1.2.4.2  rmind 
    409  1.1.1.2.4.2  rmind 
    410  1.1.1.2.4.2  rmind /*******************************************************************************
    411  1.1.1.2.4.2  rmind  *
    412  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtAllocateObjectDescDbg
    413  1.1.1.2.4.2  rmind  *
    414  1.1.1.2.4.2  rmind  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
    415  1.1.1.2.4.2  rmind  *              LineNumber          - Caller's line number (for error output)
    416  1.1.1.2.4.2  rmind  *              ComponentId         - Caller's component ID (for error output)
    417  1.1.1.2.4.2  rmind  *
    418  1.1.1.2.4.2  rmind  * RETURN:      Pointer to newly allocated object descriptor.  Null on error
    419  1.1.1.2.4.2  rmind  *
    420  1.1.1.2.4.2  rmind  * DESCRIPTION: Allocate a new object descriptor.  Gracefully handle
    421  1.1.1.2.4.2  rmind  *              error conditions.
    422  1.1.1.2.4.2  rmind  *
    423  1.1.1.2.4.2  rmind  ******************************************************************************/
    424  1.1.1.2.4.2  rmind 
    425  1.1.1.2.4.2  rmind void *
    426  1.1.1.2.4.2  rmind AcpiUtAllocateObjectDescDbg (
    427  1.1.1.2.4.2  rmind     const char              *ModuleName,
    428  1.1.1.2.4.2  rmind     UINT32                  LineNumber,
    429  1.1.1.2.4.2  rmind     UINT32                  ComponentId)
    430  1.1.1.2.4.2  rmind {
    431  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *Object;
    432  1.1.1.2.4.2  rmind 
    433  1.1.1.2.4.2  rmind 
    434  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg);
    435  1.1.1.2.4.2  rmind 
    436  1.1.1.2.4.2  rmind 
    437  1.1.1.2.4.2  rmind     Object = AcpiOsAcquireObject (AcpiGbl_OperandCache);
    438  1.1.1.2.4.2  rmind     if (!Object)
    439  1.1.1.2.4.2  rmind     {
    440  1.1.1.2.4.2  rmind         ACPI_ERROR ((ModuleName, LineNumber,
    441  1.1.1.2.4.2  rmind             "Could not allocate an object descriptor"));
    442  1.1.1.2.4.2  rmind 
    443  1.1.1.2.4.2  rmind         return_PTR (NULL);
    444  1.1.1.2.4.2  rmind     }
    445  1.1.1.2.4.2  rmind 
    446  1.1.1.2.4.2  rmind     /* Mark the descriptor type */
    447  1.1.1.2.4.2  rmind 
    448  1.1.1.2.4.2  rmind     ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND);
    449  1.1.1.2.4.2  rmind 
    450  1.1.1.2.4.2  rmind     ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
    451  1.1.1.2.4.2  rmind             Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT)));
    452  1.1.1.2.4.2  rmind 
    453  1.1.1.2.4.2  rmind     return_PTR (Object);
    454  1.1.1.2.4.2  rmind }
    455  1.1.1.2.4.2  rmind 
    456  1.1.1.2.4.2  rmind 
    457  1.1.1.2.4.2  rmind /*******************************************************************************
    458  1.1.1.2.4.2  rmind  *
    459  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtDeleteObjectDesc
    460  1.1.1.2.4.2  rmind  *
    461  1.1.1.2.4.2  rmind  * PARAMETERS:  Object          - An Acpi internal object to be deleted
    462  1.1.1.2.4.2  rmind  *
    463  1.1.1.2.4.2  rmind  * RETURN:      None.
    464  1.1.1.2.4.2  rmind  *
    465  1.1.1.2.4.2  rmind  * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
    466  1.1.1.2.4.2  rmind  *
    467  1.1.1.2.4.2  rmind  ******************************************************************************/
    468  1.1.1.2.4.2  rmind 
    469  1.1.1.2.4.2  rmind void
    470  1.1.1.2.4.2  rmind AcpiUtDeleteObjectDesc (
    471  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *Object)
    472  1.1.1.2.4.2  rmind {
    473  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
    474  1.1.1.2.4.2  rmind 
    475  1.1.1.2.4.2  rmind 
    476  1.1.1.2.4.2  rmind     /* Object must be an ACPI_OPERAND_OBJECT  */
    477  1.1.1.2.4.2  rmind 
    478  1.1.1.2.4.2  rmind     if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
    479  1.1.1.2.4.2  rmind     {
    480  1.1.1.2.4.2  rmind         ACPI_ERROR ((AE_INFO,
    481  1.1.1.2.4.2  rmind             "%p is not an ACPI Operand object [%s]", Object,
    482  1.1.1.2.4.2  rmind             AcpiUtGetDescriptorName (Object)));
    483  1.1.1.2.4.2  rmind         return_VOID;
    484  1.1.1.2.4.2  rmind     }
    485  1.1.1.2.4.2  rmind 
    486  1.1.1.2.4.2  rmind     (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
    487  1.1.1.2.4.2  rmind     return_VOID;
    488  1.1.1.2.4.2  rmind }
    489  1.1.1.2.4.2  rmind 
    490  1.1.1.2.4.2  rmind 
    491  1.1.1.2.4.2  rmind /*******************************************************************************
    492  1.1.1.2.4.2  rmind  *
    493  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtGetSimpleObjectSize
    494  1.1.1.2.4.2  rmind  *
    495  1.1.1.2.4.2  rmind  * PARAMETERS:  InternalObject     - An ACPI operand object
    496  1.1.1.2.4.2  rmind  *              ObjLength          - Where the length is returned
    497  1.1.1.2.4.2  rmind  *
    498  1.1.1.2.4.2  rmind  * RETURN:      Status
    499  1.1.1.2.4.2  rmind  *
    500  1.1.1.2.4.2  rmind  * DESCRIPTION: This function is called to determine the space required to
    501  1.1.1.2.4.2  rmind  *              contain a simple object for return to an external user.
    502  1.1.1.2.4.2  rmind  *
    503  1.1.1.2.4.2  rmind  *              The length includes the object structure plus any additional
    504  1.1.1.2.4.2  rmind  *              needed space.
    505  1.1.1.2.4.2  rmind  *
    506  1.1.1.2.4.2  rmind  ******************************************************************************/
    507  1.1.1.2.4.2  rmind 
    508  1.1.1.2.4.2  rmind static ACPI_STATUS
    509  1.1.1.2.4.2  rmind AcpiUtGetSimpleObjectSize (
    510  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *InternalObject,
    511  1.1.1.2.4.2  rmind     ACPI_SIZE               *ObjLength)
    512  1.1.1.2.4.2  rmind {
    513  1.1.1.2.4.2  rmind     ACPI_SIZE               Length;
    514  1.1.1.2.4.2  rmind     ACPI_SIZE               Size;
    515  1.1.1.2.4.2  rmind     ACPI_STATUS             Status = AE_OK;
    516  1.1.1.2.4.2  rmind 
    517  1.1.1.2.4.2  rmind 
    518  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject);
    519  1.1.1.2.4.2  rmind 
    520  1.1.1.2.4.2  rmind 
    521  1.1.1.2.4.2  rmind     /* Start with the length of the (external) Acpi object */
    522  1.1.1.2.4.2  rmind 
    523  1.1.1.2.4.2  rmind     Length = sizeof (ACPI_OBJECT);
    524  1.1.1.2.4.2  rmind 
    525  1.1.1.2.4.2  rmind     /* A NULL object is allowed, can be a legal uninitialized package element */
    526  1.1.1.2.4.2  rmind 
    527  1.1.1.2.4.2  rmind     if (!InternalObject)
    528  1.1.1.2.4.2  rmind     {
    529  1.1.1.2.4.2  rmind         /*
    530  1.1.1.2.4.2  rmind          * Object is NULL, just return the length of ACPI_OBJECT
    531  1.1.1.2.4.2  rmind          * (A NULL ACPI_OBJECT is an object of all zeroes.)
    532  1.1.1.2.4.2  rmind          */
    533  1.1.1.2.4.2  rmind         *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
    534  1.1.1.2.4.2  rmind         return_ACPI_STATUS (AE_OK);
    535  1.1.1.2.4.2  rmind     }
    536  1.1.1.2.4.2  rmind 
    537  1.1.1.2.4.2  rmind     /* A Namespace Node should never appear here */
    538  1.1.1.2.4.2  rmind 
    539  1.1.1.2.4.2  rmind     if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
    540  1.1.1.2.4.2  rmind     {
    541  1.1.1.2.4.2  rmind         /* A namespace node should never get here */
    542  1.1.1.2.4.2  rmind 
    543  1.1.1.2.4.2  rmind         return_ACPI_STATUS (AE_AML_INTERNAL);
    544  1.1.1.2.4.2  rmind     }
    545  1.1.1.2.4.2  rmind 
    546  1.1.1.2.4.2  rmind     /*
    547  1.1.1.2.4.2  rmind      * The final length depends on the object type
    548  1.1.1.2.4.2  rmind      * Strings and Buffers are packed right up against the parent object and
    549  1.1.1.2.4.2  rmind      * must be accessed bytewise or there may be alignment problems on
    550  1.1.1.2.4.2  rmind      * certain processors
    551  1.1.1.2.4.2  rmind      */
    552  1.1.1.2.4.2  rmind     switch (InternalObject->Common.Type)
    553  1.1.1.2.4.2  rmind     {
    554  1.1.1.2.4.2  rmind     case ACPI_TYPE_STRING:
    555  1.1.1.2.4.2  rmind 
    556  1.1.1.2.4.2  rmind         Length += (ACPI_SIZE) InternalObject->String.Length + 1;
    557  1.1.1.2.4.2  rmind         break;
    558  1.1.1.2.4.2  rmind 
    559  1.1.1.2.4.2  rmind 
    560  1.1.1.2.4.2  rmind     case ACPI_TYPE_BUFFER:
    561  1.1.1.2.4.2  rmind 
    562  1.1.1.2.4.2  rmind         Length += (ACPI_SIZE) InternalObject->Buffer.Length;
    563  1.1.1.2.4.2  rmind         break;
    564  1.1.1.2.4.2  rmind 
    565  1.1.1.2.4.2  rmind 
    566  1.1.1.2.4.2  rmind     case ACPI_TYPE_INTEGER:
    567  1.1.1.2.4.2  rmind     case ACPI_TYPE_PROCESSOR:
    568  1.1.1.2.4.2  rmind     case ACPI_TYPE_POWER:
    569  1.1.1.2.4.2  rmind 
    570  1.1.1.2.4.2  rmind         /* No extra data for these types */
    571  1.1.1.2.4.2  rmind 
    572  1.1.1.2.4.2  rmind         break;
    573  1.1.1.2.4.2  rmind 
    574  1.1.1.2.4.2  rmind 
    575  1.1.1.2.4.2  rmind     case ACPI_TYPE_LOCAL_REFERENCE:
    576  1.1.1.2.4.2  rmind 
    577  1.1.1.2.4.2  rmind         switch (InternalObject->Reference.Class)
    578  1.1.1.2.4.2  rmind         {
    579  1.1.1.2.4.2  rmind         case ACPI_REFCLASS_NAME:
    580  1.1.1.2.4.2  rmind 
    581  1.1.1.2.4.2  rmind             /*
    582  1.1.1.2.4.2  rmind              * Get the actual length of the full pathname to this object.
    583  1.1.1.2.4.2  rmind              * The reference will be converted to the pathname to the object
    584  1.1.1.2.4.2  rmind              */
    585  1.1.1.2.4.2  rmind             Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
    586  1.1.1.2.4.2  rmind             if (!Size)
    587  1.1.1.2.4.2  rmind             {
    588  1.1.1.2.4.2  rmind                 return_ACPI_STATUS (AE_BAD_PARAMETER);
    589  1.1.1.2.4.2  rmind             }
    590  1.1.1.2.4.2  rmind 
    591  1.1.1.2.4.2  rmind             Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
    592  1.1.1.2.4.2  rmind             break;
    593  1.1.1.2.4.2  rmind 
    594  1.1.1.2.4.2  rmind         default:
    595  1.1.1.2.4.2  rmind 
    596  1.1.1.2.4.2  rmind             /*
    597  1.1.1.2.4.2  rmind              * No other reference opcodes are supported.
    598  1.1.1.2.4.2  rmind              * Notably, Locals and Args are not supported, but this may be
    599  1.1.1.2.4.2  rmind              * required eventually.
    600  1.1.1.2.4.2  rmind              */
    601  1.1.1.2.4.2  rmind             ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
    602  1.1.1.2.4.2  rmind                 "unsupported Reference Class [%s] 0x%X in object %p",
    603  1.1.1.2.4.2  rmind                 AcpiUtGetReferenceName (InternalObject),
    604  1.1.1.2.4.2  rmind                 InternalObject->Reference.Class, InternalObject));
    605  1.1.1.2.4.2  rmind             Status = AE_TYPE;
    606  1.1.1.2.4.2  rmind             break;
    607  1.1.1.2.4.2  rmind         }
    608  1.1.1.2.4.2  rmind         break;
    609  1.1.1.2.4.2  rmind 
    610  1.1.1.2.4.2  rmind 
    611  1.1.1.2.4.2  rmind     default:
    612  1.1.1.2.4.2  rmind 
    613  1.1.1.2.4.2  rmind         ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
    614  1.1.1.2.4.2  rmind             "unsupported type [%s] 0x%X in object %p",
    615  1.1.1.2.4.2  rmind             AcpiUtGetObjectTypeName (InternalObject),
    616  1.1.1.2.4.2  rmind             InternalObject->Common.Type, InternalObject));
    617  1.1.1.2.4.2  rmind         Status = AE_TYPE;
    618  1.1.1.2.4.2  rmind         break;
    619  1.1.1.2.4.2  rmind     }
    620  1.1.1.2.4.2  rmind 
    621  1.1.1.2.4.2  rmind     /*
    622  1.1.1.2.4.2  rmind      * Account for the space required by the object rounded up to the next
    623  1.1.1.2.4.2  rmind      * multiple of the machine word size.  This keeps each object aligned
    624  1.1.1.2.4.2  rmind      * on a machine word boundary. (preventing alignment faults on some
    625  1.1.1.2.4.2  rmind      * machines.)
    626  1.1.1.2.4.2  rmind      */
    627  1.1.1.2.4.2  rmind     *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
    628  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    629  1.1.1.2.4.2  rmind }
    630  1.1.1.2.4.2  rmind 
    631  1.1.1.2.4.2  rmind 
    632  1.1.1.2.4.2  rmind /*******************************************************************************
    633  1.1.1.2.4.2  rmind  *
    634  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtGetElementLength
    635  1.1.1.2.4.2  rmind  *
    636  1.1.1.2.4.2  rmind  * PARAMETERS:  ACPI_PKG_CALLBACK
    637  1.1.1.2.4.2  rmind  *
    638  1.1.1.2.4.2  rmind  * RETURN:      Status
    639  1.1.1.2.4.2  rmind  *
    640  1.1.1.2.4.2  rmind  * DESCRIPTION: Get the length of one package element.
    641  1.1.1.2.4.2  rmind  *
    642  1.1.1.2.4.2  rmind  ******************************************************************************/
    643  1.1.1.2.4.2  rmind 
    644  1.1.1.2.4.2  rmind static ACPI_STATUS
    645  1.1.1.2.4.2  rmind AcpiUtGetElementLength (
    646  1.1.1.2.4.2  rmind     UINT8                   ObjectType,
    647  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *SourceObject,
    648  1.1.1.2.4.2  rmind     ACPI_GENERIC_STATE      *State,
    649  1.1.1.2.4.2  rmind     void                    *Context)
    650  1.1.1.2.4.2  rmind {
    651  1.1.1.2.4.2  rmind     ACPI_STATUS             Status = AE_OK;
    652  1.1.1.2.4.2  rmind     ACPI_PKG_INFO           *Info = (ACPI_PKG_INFO *) Context;
    653  1.1.1.2.4.2  rmind     ACPI_SIZE               ObjectSpace;
    654  1.1.1.2.4.2  rmind 
    655  1.1.1.2.4.2  rmind 
    656  1.1.1.2.4.2  rmind     switch (ObjectType)
    657  1.1.1.2.4.2  rmind     {
    658  1.1.1.2.4.2  rmind     case ACPI_COPY_TYPE_SIMPLE:
    659  1.1.1.2.4.2  rmind 
    660  1.1.1.2.4.2  rmind         /*
    661  1.1.1.2.4.2  rmind          * Simple object - just get the size (Null object/entry is handled
    662  1.1.1.2.4.2  rmind          * here also) and sum it into the running package length
    663  1.1.1.2.4.2  rmind          */
    664  1.1.1.2.4.2  rmind         Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
    665  1.1.1.2.4.2  rmind         if (ACPI_FAILURE (Status))
    666  1.1.1.2.4.2  rmind         {
    667  1.1.1.2.4.2  rmind             return (Status);
    668  1.1.1.2.4.2  rmind         }
    669  1.1.1.2.4.2  rmind 
    670  1.1.1.2.4.2  rmind         Info->Length += ObjectSpace;
    671  1.1.1.2.4.2  rmind         break;
    672  1.1.1.2.4.2  rmind 
    673  1.1.1.2.4.2  rmind 
    674  1.1.1.2.4.2  rmind     case ACPI_COPY_TYPE_PACKAGE:
    675  1.1.1.2.4.2  rmind 
    676  1.1.1.2.4.2  rmind         /* Package object - nothing much to do here, let the walk handle it */
    677  1.1.1.2.4.2  rmind 
    678  1.1.1.2.4.2  rmind         Info->NumPackages++;
    679  1.1.1.2.4.2  rmind         State->Pkg.ThisTargetObj = NULL;
    680  1.1.1.2.4.2  rmind         break;
    681  1.1.1.2.4.2  rmind 
    682  1.1.1.2.4.2  rmind 
    683  1.1.1.2.4.2  rmind     default:
    684  1.1.1.2.4.2  rmind 
    685  1.1.1.2.4.2  rmind         /* No other types allowed */
    686  1.1.1.2.4.2  rmind 
    687  1.1.1.2.4.2  rmind         return (AE_BAD_PARAMETER);
    688  1.1.1.2.4.2  rmind     }
    689  1.1.1.2.4.2  rmind 
    690  1.1.1.2.4.2  rmind     return (Status);
    691  1.1.1.2.4.2  rmind }
    692  1.1.1.2.4.2  rmind 
    693  1.1.1.2.4.2  rmind 
    694  1.1.1.2.4.2  rmind /*******************************************************************************
    695  1.1.1.2.4.2  rmind  *
    696  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtGetPackageObjectSize
    697  1.1.1.2.4.2  rmind  *
    698  1.1.1.2.4.2  rmind  * PARAMETERS:  InternalObject      - An ACPI internal object
    699  1.1.1.2.4.2  rmind  *              ObjLength           - Where the length is returned
    700  1.1.1.2.4.2  rmind  *
    701  1.1.1.2.4.2  rmind  * RETURN:      Status
    702  1.1.1.2.4.2  rmind  *
    703  1.1.1.2.4.2  rmind  * DESCRIPTION: This function is called to determine the space required to
    704  1.1.1.2.4.2  rmind  *              contain a package object for return to an external user.
    705  1.1.1.2.4.2  rmind  *
    706  1.1.1.2.4.2  rmind  *              This is moderately complex since a package contains other
    707  1.1.1.2.4.2  rmind  *              objects including packages.
    708  1.1.1.2.4.2  rmind  *
    709  1.1.1.2.4.2  rmind  ******************************************************************************/
    710  1.1.1.2.4.2  rmind 
    711  1.1.1.2.4.2  rmind static ACPI_STATUS
    712  1.1.1.2.4.2  rmind AcpiUtGetPackageObjectSize (
    713  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *InternalObject,
    714  1.1.1.2.4.2  rmind     ACPI_SIZE               *ObjLength)
    715  1.1.1.2.4.2  rmind {
    716  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    717  1.1.1.2.4.2  rmind     ACPI_PKG_INFO           Info;
    718  1.1.1.2.4.2  rmind 
    719  1.1.1.2.4.2  rmind 
    720  1.1.1.2.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject);
    721  1.1.1.2.4.2  rmind 
    722  1.1.1.2.4.2  rmind 
    723  1.1.1.2.4.2  rmind     Info.Length      = 0;
    724  1.1.1.2.4.2  rmind     Info.ObjectSpace = 0;
    725  1.1.1.2.4.2  rmind     Info.NumPackages = 1;
    726  1.1.1.2.4.2  rmind 
    727  1.1.1.2.4.2  rmind     Status = AcpiUtWalkPackageTree (InternalObject, NULL,
    728  1.1.1.2.4.2  rmind                             AcpiUtGetElementLength, &Info);
    729  1.1.1.2.4.2  rmind     if (ACPI_FAILURE (Status))
    730  1.1.1.2.4.2  rmind     {
    731  1.1.1.2.4.2  rmind         return_ACPI_STATUS (Status);
    732  1.1.1.2.4.2  rmind     }
    733  1.1.1.2.4.2  rmind 
    734  1.1.1.2.4.2  rmind     /*
    735  1.1.1.2.4.2  rmind      * We have handled all of the objects in all levels of the package.
    736  1.1.1.2.4.2  rmind      * just add the length of the package objects themselves.
    737  1.1.1.2.4.2  rmind      * Round up to the next machine word.
    738  1.1.1.2.4.2  rmind      */
    739  1.1.1.2.4.2  rmind     Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) *
    740  1.1.1.2.4.2  rmind                     (ACPI_SIZE) Info.NumPackages;
    741  1.1.1.2.4.2  rmind 
    742  1.1.1.2.4.2  rmind     /* Return the total package length */
    743  1.1.1.2.4.2  rmind 
    744  1.1.1.2.4.2  rmind     *ObjLength = Info.Length;
    745  1.1.1.2.4.2  rmind     return_ACPI_STATUS (Status);
    746  1.1.1.2.4.2  rmind }
    747  1.1.1.2.4.2  rmind 
    748  1.1.1.2.4.2  rmind 
    749  1.1.1.2.4.2  rmind /*******************************************************************************
    750  1.1.1.2.4.2  rmind  *
    751  1.1.1.2.4.2  rmind  * FUNCTION:    AcpiUtGetObjectSize
    752  1.1.1.2.4.2  rmind  *
    753  1.1.1.2.4.2  rmind  * PARAMETERS:  InternalObject      - An ACPI internal object
    754  1.1.1.2.4.2  rmind  *              ObjLength           - Where the length will be returned
    755  1.1.1.2.4.2  rmind  *
    756  1.1.1.2.4.2  rmind  * RETURN:      Status
    757  1.1.1.2.4.2  rmind  *
    758  1.1.1.2.4.2  rmind  * DESCRIPTION: This function is called to determine the space required to
    759  1.1.1.2.4.2  rmind  *              contain an object for return to an API user.
    760  1.1.1.2.4.2  rmind  *
    761  1.1.1.2.4.2  rmind  ******************************************************************************/
    762  1.1.1.2.4.2  rmind 
    763  1.1.1.2.4.2  rmind ACPI_STATUS
    764  1.1.1.2.4.2  rmind AcpiUtGetObjectSize (
    765  1.1.1.2.4.2  rmind     ACPI_OPERAND_OBJECT     *InternalObject,
    766  1.1.1.2.4.2  rmind     ACPI_SIZE               *ObjLength)
    767  1.1.1.2.4.2  rmind {
    768  1.1.1.2.4.2  rmind     ACPI_STATUS             Status;
    769  1.1.1.2.4.2  rmind 
    770  1.1.1.2.4.2  rmind 
    771  1.1.1.2.4.2  rmind     ACPI_FUNCTION_ENTRY ();
    772  1.1.1.2.4.2  rmind 
    773  1.1.1.2.4.2  rmind 
    774  1.1.1.2.4.2  rmind     if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
    775  1.1.1.2.4.2  rmind         (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
    776  1.1.1.2.4.2  rmind     {
    777  1.1.1.2.4.2  rmind         Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
    778  1.1.1.2.4.2  rmind     }
    779  1.1.1.2.4.2  rmind     else
    780  1.1.1.2.4.2  rmind     {
    781  1.1.1.2.4.2  rmind         Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
    782  1.1.1.2.4.2  rmind     }
    783  1.1.1.2.4.2  rmind 
    784  1.1.1.2.4.2  rmind     return (Status);
    785  1.1.1.2.4.2  rmind }
    786  1.1.1.2.4.2  rmind 
    787  1.1.1.2.4.2  rmind 
    788