Home | History | Annotate | Line # | Download | only in utilities
utmisc.c revision 1.3.4.2
      1  1.3.4.2  rmind /*******************************************************************************
      2  1.3.4.2  rmind  *
      3  1.3.4.2  rmind  * Module Name: utmisc - common utility procedures
      4  1.3.4.2  rmind  *
      5  1.3.4.2  rmind  ******************************************************************************/
      6  1.3.4.2  rmind 
      7  1.3.4.2  rmind /*
      8  1.3.4.2  rmind  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.3.4.2  rmind  * All rights reserved.
     10  1.3.4.2  rmind  *
     11  1.3.4.2  rmind  * Redistribution and use in source and binary forms, with or without
     12  1.3.4.2  rmind  * modification, are permitted provided that the following conditions
     13  1.3.4.2  rmind  * are met:
     14  1.3.4.2  rmind  * 1. Redistributions of source code must retain the above copyright
     15  1.3.4.2  rmind  *    notice, this list of conditions, and the following disclaimer,
     16  1.3.4.2  rmind  *    without modification.
     17  1.3.4.2  rmind  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.3.4.2  rmind  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.3.4.2  rmind  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.3.4.2  rmind  *    including a substantially similar Disclaimer requirement for further
     21  1.3.4.2  rmind  *    binary redistribution.
     22  1.3.4.2  rmind  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.3.4.2  rmind  *    of any contributors may be used to endorse or promote products derived
     24  1.3.4.2  rmind  *    from this software without specific prior written permission.
     25  1.3.4.2  rmind  *
     26  1.3.4.2  rmind  * Alternatively, this software may be distributed under the terms of the
     27  1.3.4.2  rmind  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.3.4.2  rmind  * Software Foundation.
     29  1.3.4.2  rmind  *
     30  1.3.4.2  rmind  * NO WARRANTY
     31  1.3.4.2  rmind  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.3.4.2  rmind  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.3.4.2  rmind  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.3.4.2  rmind  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.3.4.2  rmind  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.3.4.2  rmind  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.3.4.2  rmind  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.3.4.2  rmind  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.3.4.2  rmind  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.3.4.2  rmind  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.3.4.2  rmind  * POSSIBILITY OF SUCH DAMAGES.
     42  1.3.4.2  rmind  */
     43  1.3.4.2  rmind 
     44  1.3.4.2  rmind 
     45  1.3.4.2  rmind #define __UTMISC_C__
     46  1.3.4.2  rmind 
     47  1.3.4.2  rmind #include "acpi.h"
     48  1.3.4.2  rmind #include "accommon.h"
     49  1.3.4.2  rmind #include "acnamesp.h"
     50  1.3.4.2  rmind 
     51  1.3.4.2  rmind 
     52  1.3.4.2  rmind #define _COMPONENT          ACPI_UTILITIES
     53  1.3.4.2  rmind         ACPI_MODULE_NAME    ("utmisc")
     54  1.3.4.2  rmind 
     55  1.3.4.2  rmind 
     56  1.3.4.2  rmind /*******************************************************************************
     57  1.3.4.2  rmind  *
     58  1.3.4.2  rmind  * FUNCTION:    AcpiUtValidateException
     59  1.3.4.2  rmind  *
     60  1.3.4.2  rmind  * PARAMETERS:  Status       - The ACPI_STATUS code to be formatted
     61  1.3.4.2  rmind  *
     62  1.3.4.2  rmind  * RETURN:      A string containing the exception text. NULL if exception is
     63  1.3.4.2  rmind  *              not valid.
     64  1.3.4.2  rmind  *
     65  1.3.4.2  rmind  * DESCRIPTION: This function validates and translates an ACPI exception into
     66  1.3.4.2  rmind  *              an ASCII string.
     67  1.3.4.2  rmind  *
     68  1.3.4.2  rmind  ******************************************************************************/
     69  1.3.4.2  rmind 
     70  1.3.4.2  rmind const char *
     71  1.3.4.2  rmind AcpiUtValidateException (
     72  1.3.4.2  rmind     ACPI_STATUS             Status)
     73  1.3.4.2  rmind {
     74  1.3.4.2  rmind     UINT32                  SubStatus;
     75  1.3.4.2  rmind     const char              *Exception = NULL;
     76  1.3.4.2  rmind 
     77  1.3.4.2  rmind 
     78  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
     79  1.3.4.2  rmind 
     80  1.3.4.2  rmind 
     81  1.3.4.2  rmind     /*
     82  1.3.4.2  rmind      * Status is composed of two parts, a "type" and an actual code
     83  1.3.4.2  rmind      */
     84  1.3.4.2  rmind     SubStatus = (Status & ~AE_CODE_MASK);
     85  1.3.4.2  rmind 
     86  1.3.4.2  rmind     switch (Status & AE_CODE_MASK)
     87  1.3.4.2  rmind     {
     88  1.3.4.2  rmind     case AE_CODE_ENVIRONMENTAL:
     89  1.3.4.2  rmind 
     90  1.3.4.2  rmind         if (SubStatus <= AE_CODE_ENV_MAX)
     91  1.3.4.2  rmind         {
     92  1.3.4.2  rmind             Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
     93  1.3.4.2  rmind         }
     94  1.3.4.2  rmind         break;
     95  1.3.4.2  rmind 
     96  1.3.4.2  rmind     case AE_CODE_PROGRAMMER:
     97  1.3.4.2  rmind 
     98  1.3.4.2  rmind         if (SubStatus <= AE_CODE_PGM_MAX)
     99  1.3.4.2  rmind         {
    100  1.3.4.2  rmind             Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
    101  1.3.4.2  rmind         }
    102  1.3.4.2  rmind         break;
    103  1.3.4.2  rmind 
    104  1.3.4.2  rmind     case AE_CODE_ACPI_TABLES:
    105  1.3.4.2  rmind 
    106  1.3.4.2  rmind         if (SubStatus <= AE_CODE_TBL_MAX)
    107  1.3.4.2  rmind         {
    108  1.3.4.2  rmind             Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
    109  1.3.4.2  rmind         }
    110  1.3.4.2  rmind         break;
    111  1.3.4.2  rmind 
    112  1.3.4.2  rmind     case AE_CODE_AML:
    113  1.3.4.2  rmind 
    114  1.3.4.2  rmind         if (SubStatus <= AE_CODE_AML_MAX)
    115  1.3.4.2  rmind         {
    116  1.3.4.2  rmind             Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
    117  1.3.4.2  rmind         }
    118  1.3.4.2  rmind         break;
    119  1.3.4.2  rmind 
    120  1.3.4.2  rmind     case AE_CODE_CONTROL:
    121  1.3.4.2  rmind 
    122  1.3.4.2  rmind         if (SubStatus <= AE_CODE_CTRL_MAX)
    123  1.3.4.2  rmind         {
    124  1.3.4.2  rmind             Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
    125  1.3.4.2  rmind         }
    126  1.3.4.2  rmind         break;
    127  1.3.4.2  rmind 
    128  1.3.4.2  rmind     default:
    129  1.3.4.2  rmind         break;
    130  1.3.4.2  rmind     }
    131  1.3.4.2  rmind 
    132  1.3.4.2  rmind     return (ACPI_CAST_PTR (const char, Exception));
    133  1.3.4.2  rmind }
    134  1.3.4.2  rmind 
    135  1.3.4.2  rmind 
    136  1.3.4.2  rmind /*******************************************************************************
    137  1.3.4.2  rmind  *
    138  1.3.4.2  rmind  * FUNCTION:    AcpiUtIsPciRootBridge
    139  1.3.4.2  rmind  *
    140  1.3.4.2  rmind  * PARAMETERS:  Id              - The HID/CID in string format
    141  1.3.4.2  rmind  *
    142  1.3.4.2  rmind  * RETURN:      TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
    143  1.3.4.2  rmind  *
    144  1.3.4.2  rmind  * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
    145  1.3.4.2  rmind  *
    146  1.3.4.2  rmind  ******************************************************************************/
    147  1.3.4.2  rmind 
    148  1.3.4.2  rmind BOOLEAN
    149  1.3.4.2  rmind AcpiUtIsPciRootBridge (
    150  1.3.4.2  rmind     char                    *Id)
    151  1.3.4.2  rmind {
    152  1.3.4.2  rmind 
    153  1.3.4.2  rmind     /*
    154  1.3.4.2  rmind      * Check if this is a PCI root bridge.
    155  1.3.4.2  rmind      * ACPI 3.0+: check for a PCI Express root also.
    156  1.3.4.2  rmind      */
    157  1.3.4.2  rmind     if (!(ACPI_STRCMP (Id,
    158  1.3.4.2  rmind             PCI_ROOT_HID_STRING)) ||
    159  1.3.4.2  rmind 
    160  1.3.4.2  rmind         !(ACPI_STRCMP (Id,
    161  1.3.4.2  rmind             PCI_EXPRESS_ROOT_HID_STRING)))
    162  1.3.4.2  rmind     {
    163  1.3.4.2  rmind         return (TRUE);
    164  1.3.4.2  rmind     }
    165  1.3.4.2  rmind 
    166  1.3.4.2  rmind     return (FALSE);
    167  1.3.4.2  rmind }
    168  1.3.4.2  rmind 
    169  1.3.4.2  rmind 
    170  1.3.4.2  rmind /*******************************************************************************
    171  1.3.4.2  rmind  *
    172  1.3.4.2  rmind  * FUNCTION:    AcpiUtIsAmlTable
    173  1.3.4.2  rmind  *
    174  1.3.4.2  rmind  * PARAMETERS:  Table               - An ACPI table
    175  1.3.4.2  rmind  *
    176  1.3.4.2  rmind  * RETURN:      TRUE if table contains executable AML; FALSE otherwise
    177  1.3.4.2  rmind  *
    178  1.3.4.2  rmind  * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
    179  1.3.4.2  rmind  *              Currently, these are DSDT,SSDT,PSDT. All other table types are
    180  1.3.4.2  rmind  *              data tables that do not contain AML code.
    181  1.3.4.2  rmind  *
    182  1.3.4.2  rmind  ******************************************************************************/
    183  1.3.4.2  rmind 
    184  1.3.4.2  rmind BOOLEAN
    185  1.3.4.2  rmind AcpiUtIsAmlTable (
    186  1.3.4.2  rmind     ACPI_TABLE_HEADER       *Table)
    187  1.3.4.2  rmind {
    188  1.3.4.2  rmind 
    189  1.3.4.2  rmind     /* These are the only tables that contain executable AML */
    190  1.3.4.2  rmind 
    191  1.3.4.2  rmind     if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
    192  1.3.4.2  rmind         ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
    193  1.3.4.2  rmind         ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
    194  1.3.4.2  rmind     {
    195  1.3.4.2  rmind         return (TRUE);
    196  1.3.4.2  rmind     }
    197  1.3.4.2  rmind 
    198  1.3.4.2  rmind     return (FALSE);
    199  1.3.4.2  rmind }
    200  1.3.4.2  rmind 
    201  1.3.4.2  rmind 
    202  1.3.4.2  rmind /*******************************************************************************
    203  1.3.4.2  rmind  *
    204  1.3.4.2  rmind  * FUNCTION:    AcpiUtAllocateOwnerId
    205  1.3.4.2  rmind  *
    206  1.3.4.2  rmind  * PARAMETERS:  OwnerId         - Where the new owner ID is returned
    207  1.3.4.2  rmind  *
    208  1.3.4.2  rmind  * RETURN:      Status
    209  1.3.4.2  rmind  *
    210  1.3.4.2  rmind  * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
    211  1.3.4.2  rmind  *              track objects created by the table or method, to be deleted
    212  1.3.4.2  rmind  *              when the method exits or the table is unloaded.
    213  1.3.4.2  rmind  *
    214  1.3.4.2  rmind  ******************************************************************************/
    215  1.3.4.2  rmind 
    216  1.3.4.2  rmind ACPI_STATUS
    217  1.3.4.2  rmind AcpiUtAllocateOwnerId (
    218  1.3.4.2  rmind     ACPI_OWNER_ID           *OwnerId)
    219  1.3.4.2  rmind {
    220  1.3.4.2  rmind     UINT32                  i;
    221  1.3.4.2  rmind     UINT32                  j;
    222  1.3.4.2  rmind     UINT32                  k;
    223  1.3.4.2  rmind     ACPI_STATUS             Status;
    224  1.3.4.2  rmind 
    225  1.3.4.2  rmind 
    226  1.3.4.2  rmind     ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
    227  1.3.4.2  rmind 
    228  1.3.4.2  rmind 
    229  1.3.4.2  rmind     /* Guard against multiple allocations of ID to the same location */
    230  1.3.4.2  rmind 
    231  1.3.4.2  rmind     if (*OwnerId)
    232  1.3.4.2  rmind     {
    233  1.3.4.2  rmind         ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId));
    234  1.3.4.2  rmind         return_ACPI_STATUS (AE_ALREADY_EXISTS);
    235  1.3.4.2  rmind     }
    236  1.3.4.2  rmind 
    237  1.3.4.2  rmind     /* Mutex for the global ID mask */
    238  1.3.4.2  rmind 
    239  1.3.4.2  rmind     Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
    240  1.3.4.2  rmind     if (ACPI_FAILURE (Status))
    241  1.3.4.2  rmind     {
    242  1.3.4.2  rmind         return_ACPI_STATUS (Status);
    243  1.3.4.2  rmind     }
    244  1.3.4.2  rmind 
    245  1.3.4.2  rmind     /*
    246  1.3.4.2  rmind      * Find a free owner ID, cycle through all possible IDs on repeated
    247  1.3.4.2  rmind      * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
    248  1.3.4.2  rmind      * to be scanned twice.
    249  1.3.4.2  rmind      */
    250  1.3.4.2  rmind     for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
    251  1.3.4.2  rmind          i < (ACPI_NUM_OWNERID_MASKS + 1);
    252  1.3.4.2  rmind          i++, j++)
    253  1.3.4.2  rmind     {
    254  1.3.4.2  rmind         if (j >= ACPI_NUM_OWNERID_MASKS)
    255  1.3.4.2  rmind         {
    256  1.3.4.2  rmind             j = 0;  /* Wraparound to start of mask array */
    257  1.3.4.2  rmind         }
    258  1.3.4.2  rmind 
    259  1.3.4.2  rmind         for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
    260  1.3.4.2  rmind         {
    261  1.3.4.2  rmind             if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
    262  1.3.4.2  rmind             {
    263  1.3.4.2  rmind                 /* There are no free IDs in this mask */
    264  1.3.4.2  rmind 
    265  1.3.4.2  rmind                 break;
    266  1.3.4.2  rmind             }
    267  1.3.4.2  rmind 
    268  1.3.4.2  rmind             if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
    269  1.3.4.2  rmind             {
    270  1.3.4.2  rmind                 /*
    271  1.3.4.2  rmind                  * Found a free ID. The actual ID is the bit index plus one,
    272  1.3.4.2  rmind                  * making zero an invalid Owner ID. Save this as the last ID
    273  1.3.4.2  rmind                  * allocated and update the global ID mask.
    274  1.3.4.2  rmind                  */
    275  1.3.4.2  rmind                 AcpiGbl_OwnerIdMask[j] |= (1 << k);
    276  1.3.4.2  rmind 
    277  1.3.4.2  rmind                 AcpiGbl_LastOwnerIdIndex = (UINT8) j;
    278  1.3.4.2  rmind                 AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
    279  1.3.4.2  rmind 
    280  1.3.4.2  rmind                 /*
    281  1.3.4.2  rmind                  * Construct encoded ID from the index and bit position
    282  1.3.4.2  rmind                  *
    283  1.3.4.2  rmind                  * Note: Last [j].k (bit 255) is never used and is marked
    284  1.3.4.2  rmind                  * permanently allocated (prevents +1 overflow)
    285  1.3.4.2  rmind                  */
    286  1.3.4.2  rmind                 *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
    287  1.3.4.2  rmind 
    288  1.3.4.2  rmind                 ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
    289  1.3.4.2  rmind                     "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
    290  1.3.4.2  rmind                 goto Exit;
    291  1.3.4.2  rmind             }
    292  1.3.4.2  rmind         }
    293  1.3.4.2  rmind 
    294  1.3.4.2  rmind         AcpiGbl_NextOwnerIdOffset = 0;
    295  1.3.4.2  rmind     }
    296  1.3.4.2  rmind 
    297  1.3.4.2  rmind     /*
    298  1.3.4.2  rmind      * All OwnerIds have been allocated. This typically should
    299  1.3.4.2  rmind      * not happen since the IDs are reused after deallocation. The IDs are
    300  1.3.4.2  rmind      * allocated upon table load (one per table) and method execution, and
    301  1.3.4.2  rmind      * they are released when a table is unloaded or a method completes
    302  1.3.4.2  rmind      * execution.
    303  1.3.4.2  rmind      *
    304  1.3.4.2  rmind      * If this error happens, there may be very deep nesting of invoked control
    305  1.3.4.2  rmind      * methods, or there may be a bug where the IDs are not released.
    306  1.3.4.2  rmind      */
    307  1.3.4.2  rmind     Status = AE_OWNER_ID_LIMIT;
    308  1.3.4.2  rmind     ACPI_ERROR ((AE_INFO,
    309  1.3.4.2  rmind         "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
    310  1.3.4.2  rmind 
    311  1.3.4.2  rmind Exit:
    312  1.3.4.2  rmind     (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
    313  1.3.4.2  rmind     return_ACPI_STATUS (Status);
    314  1.3.4.2  rmind }
    315  1.3.4.2  rmind 
    316  1.3.4.2  rmind 
    317  1.3.4.2  rmind /*******************************************************************************
    318  1.3.4.2  rmind  *
    319  1.3.4.2  rmind  * FUNCTION:    AcpiUtReleaseOwnerId
    320  1.3.4.2  rmind  *
    321  1.3.4.2  rmind  * PARAMETERS:  OwnerIdPtr          - Pointer to a previously allocated OwnerID
    322  1.3.4.2  rmind  *
    323  1.3.4.2  rmind  * RETURN:      None. No error is returned because we are either exiting a
    324  1.3.4.2  rmind  *              control method or unloading a table. Either way, we would
    325  1.3.4.2  rmind  *              ignore any error anyway.
    326  1.3.4.2  rmind  *
    327  1.3.4.2  rmind  * DESCRIPTION: Release a table or method owner ID.  Valid IDs are 1 - 255
    328  1.3.4.2  rmind  *
    329  1.3.4.2  rmind  ******************************************************************************/
    330  1.3.4.2  rmind 
    331  1.3.4.2  rmind void
    332  1.3.4.2  rmind AcpiUtReleaseOwnerId (
    333  1.3.4.2  rmind     ACPI_OWNER_ID           *OwnerIdPtr)
    334  1.3.4.2  rmind {
    335  1.3.4.2  rmind     ACPI_OWNER_ID           OwnerId = *OwnerIdPtr;
    336  1.3.4.2  rmind     ACPI_STATUS             Status;
    337  1.3.4.2  rmind     UINT32                  Index;
    338  1.3.4.2  rmind     UINT32                  Bit;
    339  1.3.4.2  rmind 
    340  1.3.4.2  rmind 
    341  1.3.4.2  rmind     ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
    342  1.3.4.2  rmind 
    343  1.3.4.2  rmind 
    344  1.3.4.2  rmind     /* Always clear the input OwnerId (zero is an invalid ID) */
    345  1.3.4.2  rmind 
    346  1.3.4.2  rmind     *OwnerIdPtr = 0;
    347  1.3.4.2  rmind 
    348  1.3.4.2  rmind     /* Zero is not a valid OwnerID */
    349  1.3.4.2  rmind 
    350  1.3.4.2  rmind     if (OwnerId == 0)
    351  1.3.4.2  rmind     {
    352  1.3.4.2  rmind         ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId));
    353  1.3.4.2  rmind         return_VOID;
    354  1.3.4.2  rmind     }
    355  1.3.4.2  rmind 
    356  1.3.4.2  rmind     /* Mutex for the global ID mask */
    357  1.3.4.2  rmind 
    358  1.3.4.2  rmind     Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
    359  1.3.4.2  rmind     if (ACPI_FAILURE (Status))
    360  1.3.4.2  rmind     {
    361  1.3.4.2  rmind         return_VOID;
    362  1.3.4.2  rmind     }
    363  1.3.4.2  rmind 
    364  1.3.4.2  rmind     /* Normalize the ID to zero */
    365  1.3.4.2  rmind 
    366  1.3.4.2  rmind     OwnerId--;
    367  1.3.4.2  rmind 
    368  1.3.4.2  rmind     /* Decode ID to index/offset pair */
    369  1.3.4.2  rmind 
    370  1.3.4.2  rmind     Index = ACPI_DIV_32 (OwnerId);
    371  1.3.4.2  rmind     Bit = 1 << ACPI_MOD_32 (OwnerId);
    372  1.3.4.2  rmind 
    373  1.3.4.2  rmind     /* Free the owner ID only if it is valid */
    374  1.3.4.2  rmind 
    375  1.3.4.2  rmind     if (AcpiGbl_OwnerIdMask[Index] & Bit)
    376  1.3.4.2  rmind     {
    377  1.3.4.2  rmind         AcpiGbl_OwnerIdMask[Index] ^= Bit;
    378  1.3.4.2  rmind     }
    379  1.3.4.2  rmind     else
    380  1.3.4.2  rmind     {
    381  1.3.4.2  rmind         ACPI_ERROR ((AE_INFO,
    382  1.3.4.2  rmind             "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1));
    383  1.3.4.2  rmind     }
    384  1.3.4.2  rmind 
    385  1.3.4.2  rmind     (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
    386  1.3.4.2  rmind     return_VOID;
    387  1.3.4.2  rmind }
    388  1.3.4.2  rmind 
    389  1.3.4.2  rmind 
    390  1.3.4.2  rmind /*******************************************************************************
    391  1.3.4.2  rmind  *
    392  1.3.4.2  rmind  * FUNCTION:    AcpiUtStrupr (strupr)
    393  1.3.4.2  rmind  *
    394  1.3.4.2  rmind  * PARAMETERS:  SrcString       - The source string to convert
    395  1.3.4.2  rmind  *
    396  1.3.4.2  rmind  * RETURN:      None
    397  1.3.4.2  rmind  *
    398  1.3.4.2  rmind  * DESCRIPTION: Convert string to uppercase
    399  1.3.4.2  rmind  *
    400  1.3.4.2  rmind  * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
    401  1.3.4.2  rmind  *
    402  1.3.4.2  rmind  ******************************************************************************/
    403  1.3.4.2  rmind 
    404  1.3.4.2  rmind void
    405  1.3.4.2  rmind AcpiUtStrupr (
    406  1.3.4.2  rmind     char                    *SrcString)
    407  1.3.4.2  rmind {
    408  1.3.4.2  rmind     char                    *String;
    409  1.3.4.2  rmind 
    410  1.3.4.2  rmind 
    411  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
    412  1.3.4.2  rmind 
    413  1.3.4.2  rmind 
    414  1.3.4.2  rmind     if (!SrcString)
    415  1.3.4.2  rmind     {
    416  1.3.4.2  rmind         return;
    417  1.3.4.2  rmind     }
    418  1.3.4.2  rmind 
    419  1.3.4.2  rmind     /* Walk entire string, uppercasing the letters */
    420  1.3.4.2  rmind 
    421  1.3.4.2  rmind     for (String = SrcString; *String; String++)
    422  1.3.4.2  rmind     {
    423  1.3.4.2  rmind         *String = (char) ACPI_TOUPPER (*String);
    424  1.3.4.2  rmind     }
    425  1.3.4.2  rmind 
    426  1.3.4.2  rmind     return;
    427  1.3.4.2  rmind }
    428  1.3.4.2  rmind 
    429  1.3.4.2  rmind 
    430  1.3.4.2  rmind #ifdef ACPI_ASL_COMPILER
    431  1.3.4.2  rmind /*******************************************************************************
    432  1.3.4.2  rmind  *
    433  1.3.4.2  rmind  * FUNCTION:    AcpiUtStrlwr (strlwr)
    434  1.3.4.2  rmind  *
    435  1.3.4.2  rmind  * PARAMETERS:  SrcString       - The source string to convert
    436  1.3.4.2  rmind  *
    437  1.3.4.2  rmind  * RETURN:      None
    438  1.3.4.2  rmind  *
    439  1.3.4.2  rmind  * DESCRIPTION: Convert string to lowercase
    440  1.3.4.2  rmind  *
    441  1.3.4.2  rmind  * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
    442  1.3.4.2  rmind  *
    443  1.3.4.2  rmind  ******************************************************************************/
    444  1.3.4.2  rmind 
    445  1.3.4.2  rmind void
    446  1.3.4.2  rmind AcpiUtStrlwr (
    447  1.3.4.2  rmind     char                    *SrcString)
    448  1.3.4.2  rmind {
    449  1.3.4.2  rmind     char                    *String;
    450  1.3.4.2  rmind 
    451  1.3.4.2  rmind 
    452  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
    453  1.3.4.2  rmind 
    454  1.3.4.2  rmind 
    455  1.3.4.2  rmind     if (!SrcString)
    456  1.3.4.2  rmind     {
    457  1.3.4.2  rmind         return;
    458  1.3.4.2  rmind     }
    459  1.3.4.2  rmind 
    460  1.3.4.2  rmind     /* Walk entire string, lowercasing the letters */
    461  1.3.4.2  rmind 
    462  1.3.4.2  rmind     for (String = SrcString; *String; String++)
    463  1.3.4.2  rmind     {
    464  1.3.4.2  rmind         *String = (char) ACPI_TOLOWER (*String);
    465  1.3.4.2  rmind     }
    466  1.3.4.2  rmind 
    467  1.3.4.2  rmind     return;
    468  1.3.4.2  rmind }
    469  1.3.4.2  rmind #endif
    470  1.3.4.2  rmind 
    471  1.3.4.2  rmind 
    472  1.3.4.2  rmind /*******************************************************************************
    473  1.3.4.2  rmind  *
    474  1.3.4.2  rmind  * FUNCTION:    AcpiUtPrintString
    475  1.3.4.2  rmind  *
    476  1.3.4.2  rmind  * PARAMETERS:  String          - Null terminated ASCII string
    477  1.3.4.2  rmind  *              MaxLength       - Maximum output length
    478  1.3.4.2  rmind  *
    479  1.3.4.2  rmind  * RETURN:      None
    480  1.3.4.2  rmind  *
    481  1.3.4.2  rmind  * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
    482  1.3.4.2  rmind  *              sequences.
    483  1.3.4.2  rmind  *
    484  1.3.4.2  rmind  ******************************************************************************/
    485  1.3.4.2  rmind 
    486  1.3.4.2  rmind void
    487  1.3.4.2  rmind AcpiUtPrintString (
    488  1.3.4.2  rmind     char                    *String,
    489  1.3.4.2  rmind     UINT8                   MaxLength)
    490  1.3.4.2  rmind {
    491  1.3.4.2  rmind     UINT32                  i;
    492  1.3.4.2  rmind 
    493  1.3.4.2  rmind 
    494  1.3.4.2  rmind     if (!String)
    495  1.3.4.2  rmind     {
    496  1.3.4.2  rmind         AcpiOsPrintf ("<\"NULL STRING PTR\">");
    497  1.3.4.2  rmind         return;
    498  1.3.4.2  rmind     }
    499  1.3.4.2  rmind 
    500  1.3.4.2  rmind     AcpiOsPrintf ("\"");
    501  1.3.4.2  rmind     for (i = 0; String[i] && (i < MaxLength); i++)
    502  1.3.4.2  rmind     {
    503  1.3.4.2  rmind         /* Escape sequences */
    504  1.3.4.2  rmind 
    505  1.3.4.2  rmind         switch (String[i])
    506  1.3.4.2  rmind         {
    507  1.3.4.2  rmind         case 0x07:
    508  1.3.4.2  rmind             AcpiOsPrintf ("\\a");       /* BELL */
    509  1.3.4.2  rmind             break;
    510  1.3.4.2  rmind 
    511  1.3.4.2  rmind         case 0x08:
    512  1.3.4.2  rmind             AcpiOsPrintf ("\\b");       /* BACKSPACE */
    513  1.3.4.2  rmind             break;
    514  1.3.4.2  rmind 
    515  1.3.4.2  rmind         case 0x0C:
    516  1.3.4.2  rmind             AcpiOsPrintf ("\\f");       /* FORMFEED */
    517  1.3.4.2  rmind             break;
    518  1.3.4.2  rmind 
    519  1.3.4.2  rmind         case 0x0A:
    520  1.3.4.2  rmind             AcpiOsPrintf ("\\n");       /* LINEFEED */
    521  1.3.4.2  rmind             break;
    522  1.3.4.2  rmind 
    523  1.3.4.2  rmind         case 0x0D:
    524  1.3.4.2  rmind             AcpiOsPrintf ("\\r");       /* CARRIAGE RETURN*/
    525  1.3.4.2  rmind             break;
    526  1.3.4.2  rmind 
    527  1.3.4.2  rmind         case 0x09:
    528  1.3.4.2  rmind             AcpiOsPrintf ("\\t");       /* HORIZONTAL TAB */
    529  1.3.4.2  rmind             break;
    530  1.3.4.2  rmind 
    531  1.3.4.2  rmind         case 0x0B:
    532  1.3.4.2  rmind             AcpiOsPrintf ("\\v");       /* VERTICAL TAB */
    533  1.3.4.2  rmind             break;
    534  1.3.4.2  rmind 
    535  1.3.4.2  rmind         case '\'':                      /* Single Quote */
    536  1.3.4.2  rmind         case '\"':                      /* Double Quote */
    537  1.3.4.2  rmind         case '\\':                      /* Backslash */
    538  1.3.4.2  rmind             AcpiOsPrintf ("\\%c", (int) String[i]);
    539  1.3.4.2  rmind             break;
    540  1.3.4.2  rmind 
    541  1.3.4.2  rmind         default:
    542  1.3.4.2  rmind 
    543  1.3.4.2  rmind             /* Check for printable character or hex escape */
    544  1.3.4.2  rmind 
    545  1.3.4.2  rmind             if (ACPI_IS_PRINT (String[i]))
    546  1.3.4.2  rmind             {
    547  1.3.4.2  rmind                 /* This is a normal character */
    548  1.3.4.2  rmind 
    549  1.3.4.2  rmind                 AcpiOsPrintf ("%c", (int) String[i]);
    550  1.3.4.2  rmind             }
    551  1.3.4.2  rmind             else
    552  1.3.4.2  rmind             {
    553  1.3.4.2  rmind                 /* All others will be Hex escapes */
    554  1.3.4.2  rmind 
    555  1.3.4.2  rmind                 AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
    556  1.3.4.2  rmind             }
    557  1.3.4.2  rmind             break;
    558  1.3.4.2  rmind         }
    559  1.3.4.2  rmind     }
    560  1.3.4.2  rmind     AcpiOsPrintf ("\"");
    561  1.3.4.2  rmind 
    562  1.3.4.2  rmind     if (i == MaxLength && String[i])
    563  1.3.4.2  rmind     {
    564  1.3.4.2  rmind         AcpiOsPrintf ("...");
    565  1.3.4.2  rmind     }
    566  1.3.4.2  rmind }
    567  1.3.4.2  rmind 
    568  1.3.4.2  rmind 
    569  1.3.4.2  rmind /*******************************************************************************
    570  1.3.4.2  rmind  *
    571  1.3.4.2  rmind  * FUNCTION:    AcpiUtDwordByteSwap
    572  1.3.4.2  rmind  *
    573  1.3.4.2  rmind  * PARAMETERS:  Value           - Value to be converted
    574  1.3.4.2  rmind  *
    575  1.3.4.2  rmind  * RETURN:      UINT32 integer with bytes swapped
    576  1.3.4.2  rmind  *
    577  1.3.4.2  rmind  * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
    578  1.3.4.2  rmind  *
    579  1.3.4.2  rmind  ******************************************************************************/
    580  1.3.4.2  rmind 
    581  1.3.4.2  rmind UINT32
    582  1.3.4.2  rmind AcpiUtDwordByteSwap (
    583  1.3.4.2  rmind     UINT32                  Value)
    584  1.3.4.2  rmind {
    585  1.3.4.2  rmind     union
    586  1.3.4.2  rmind     {
    587  1.3.4.2  rmind         UINT32              Value;
    588  1.3.4.2  rmind         UINT8               Bytes[4];
    589  1.3.4.2  rmind     } Out;
    590  1.3.4.2  rmind     union
    591  1.3.4.2  rmind     {
    592  1.3.4.2  rmind         UINT32              Value;
    593  1.3.4.2  rmind         UINT8               Bytes[4];
    594  1.3.4.2  rmind     } In;
    595  1.3.4.2  rmind 
    596  1.3.4.2  rmind 
    597  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
    598  1.3.4.2  rmind 
    599  1.3.4.2  rmind 
    600  1.3.4.2  rmind     In.Value = Value;
    601  1.3.4.2  rmind 
    602  1.3.4.2  rmind     Out.Bytes[0] = In.Bytes[3];
    603  1.3.4.2  rmind     Out.Bytes[1] = In.Bytes[2];
    604  1.3.4.2  rmind     Out.Bytes[2] = In.Bytes[1];
    605  1.3.4.2  rmind     Out.Bytes[3] = In.Bytes[0];
    606  1.3.4.2  rmind 
    607  1.3.4.2  rmind     return (Out.Value);
    608  1.3.4.2  rmind }
    609  1.3.4.2  rmind 
    610  1.3.4.2  rmind 
    611  1.3.4.2  rmind /*******************************************************************************
    612  1.3.4.2  rmind  *
    613  1.3.4.2  rmind  * FUNCTION:    AcpiUtSetIntegerWidth
    614  1.3.4.2  rmind  *
    615  1.3.4.2  rmind  * PARAMETERS:  Revision            From DSDT header
    616  1.3.4.2  rmind  *
    617  1.3.4.2  rmind  * RETURN:      None
    618  1.3.4.2  rmind  *
    619  1.3.4.2  rmind  * DESCRIPTION: Set the global integer bit width based upon the revision
    620  1.3.4.2  rmind  *              of the DSDT.  For Revision 1 and 0, Integers are 32 bits.
    621  1.3.4.2  rmind  *              For Revision 2 and above, Integers are 64 bits.  Yes, this
    622  1.3.4.2  rmind  *              makes a difference.
    623  1.3.4.2  rmind  *
    624  1.3.4.2  rmind  ******************************************************************************/
    625  1.3.4.2  rmind 
    626  1.3.4.2  rmind void
    627  1.3.4.2  rmind AcpiUtSetIntegerWidth (
    628  1.3.4.2  rmind     UINT8                   Revision)
    629  1.3.4.2  rmind {
    630  1.3.4.2  rmind 
    631  1.3.4.2  rmind     if (Revision < 2)
    632  1.3.4.2  rmind     {
    633  1.3.4.2  rmind         /* 32-bit case */
    634  1.3.4.2  rmind 
    635  1.3.4.2  rmind         AcpiGbl_IntegerBitWidth    = 32;
    636  1.3.4.2  rmind         AcpiGbl_IntegerNybbleWidth = 8;
    637  1.3.4.2  rmind         AcpiGbl_IntegerByteWidth   = 4;
    638  1.3.4.2  rmind     }
    639  1.3.4.2  rmind     else
    640  1.3.4.2  rmind     {
    641  1.3.4.2  rmind         /* 64-bit case (ACPI 2.0+) */
    642  1.3.4.2  rmind 
    643  1.3.4.2  rmind         AcpiGbl_IntegerBitWidth    = 64;
    644  1.3.4.2  rmind         AcpiGbl_IntegerNybbleWidth = 16;
    645  1.3.4.2  rmind         AcpiGbl_IntegerByteWidth   = 8;
    646  1.3.4.2  rmind     }
    647  1.3.4.2  rmind }
    648  1.3.4.2  rmind 
    649  1.3.4.2  rmind 
    650  1.3.4.2  rmind #ifdef ACPI_DEBUG_OUTPUT
    651  1.3.4.2  rmind /*******************************************************************************
    652  1.3.4.2  rmind  *
    653  1.3.4.2  rmind  * FUNCTION:    AcpiUtDisplayInitPathname
    654  1.3.4.2  rmind  *
    655  1.3.4.2  rmind  * PARAMETERS:  Type                - Object type of the node
    656  1.3.4.2  rmind  *              ObjHandle           - Handle whose pathname will be displayed
    657  1.3.4.2  rmind  *              Path                - Additional path string to be appended.
    658  1.3.4.2  rmind  *                                      (NULL if no extra path)
    659  1.3.4.2  rmind  *
    660  1.3.4.2  rmind  * RETURN:      ACPI_STATUS
    661  1.3.4.2  rmind  *
    662  1.3.4.2  rmind  * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
    663  1.3.4.2  rmind  *
    664  1.3.4.2  rmind  ******************************************************************************/
    665  1.3.4.2  rmind 
    666  1.3.4.2  rmind void
    667  1.3.4.2  rmind AcpiUtDisplayInitPathname (
    668  1.3.4.2  rmind     UINT8                   Type,
    669  1.3.4.2  rmind     ACPI_NAMESPACE_NODE     *ObjHandle,
    670  1.3.4.2  rmind     const char              *Path)
    671  1.3.4.2  rmind {
    672  1.3.4.2  rmind     ACPI_STATUS             Status;
    673  1.3.4.2  rmind     ACPI_BUFFER             Buffer;
    674  1.3.4.2  rmind 
    675  1.3.4.2  rmind 
    676  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
    677  1.3.4.2  rmind 
    678  1.3.4.2  rmind 
    679  1.3.4.2  rmind     /* Only print the path if the appropriate debug level is enabled */
    680  1.3.4.2  rmind 
    681  1.3.4.2  rmind     if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
    682  1.3.4.2  rmind     {
    683  1.3.4.2  rmind         return;
    684  1.3.4.2  rmind     }
    685  1.3.4.2  rmind 
    686  1.3.4.2  rmind     /* Get the full pathname to the node */
    687  1.3.4.2  rmind 
    688  1.3.4.2  rmind     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
    689  1.3.4.2  rmind     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
    690  1.3.4.2  rmind     if (ACPI_FAILURE (Status))
    691  1.3.4.2  rmind     {
    692  1.3.4.2  rmind         return;
    693  1.3.4.2  rmind     }
    694  1.3.4.2  rmind 
    695  1.3.4.2  rmind     /* Print what we're doing */
    696  1.3.4.2  rmind 
    697  1.3.4.2  rmind     switch (Type)
    698  1.3.4.2  rmind     {
    699  1.3.4.2  rmind     case ACPI_TYPE_METHOD:
    700  1.3.4.2  rmind         AcpiOsPrintf ("Executing    ");
    701  1.3.4.2  rmind         break;
    702  1.3.4.2  rmind 
    703  1.3.4.2  rmind     default:
    704  1.3.4.2  rmind         AcpiOsPrintf ("Initializing ");
    705  1.3.4.2  rmind         break;
    706  1.3.4.2  rmind     }
    707  1.3.4.2  rmind 
    708  1.3.4.2  rmind     /* Print the object type and pathname */
    709  1.3.4.2  rmind 
    710  1.3.4.2  rmind     AcpiOsPrintf ("%-12s  %s",
    711  1.3.4.2  rmind         AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
    712  1.3.4.2  rmind 
    713  1.3.4.2  rmind     /* Extra path is used to append names like _STA, _INI, etc. */
    714  1.3.4.2  rmind 
    715  1.3.4.2  rmind     if (Path)
    716  1.3.4.2  rmind     {
    717  1.3.4.2  rmind         AcpiOsPrintf (".%s", Path);
    718  1.3.4.2  rmind     }
    719  1.3.4.2  rmind     AcpiOsPrintf ("\n");
    720  1.3.4.2  rmind 
    721  1.3.4.2  rmind     ACPI_FREE (Buffer.Pointer);
    722  1.3.4.2  rmind }
    723  1.3.4.2  rmind #endif
    724  1.3.4.2  rmind 
    725  1.3.4.2  rmind 
    726  1.3.4.2  rmind /*******************************************************************************
    727  1.3.4.2  rmind  *
    728  1.3.4.2  rmind  * FUNCTION:    AcpiUtValidAcpiChar
    729  1.3.4.2  rmind  *
    730  1.3.4.2  rmind  * PARAMETERS:  Char            - The character to be examined
    731  1.3.4.2  rmind  *              Position        - Byte position (0-3)
    732  1.3.4.2  rmind  *
    733  1.3.4.2  rmind  * RETURN:      TRUE if the character is valid, FALSE otherwise
    734  1.3.4.2  rmind  *
    735  1.3.4.2  rmind  * DESCRIPTION: Check for a valid ACPI character. Must be one of:
    736  1.3.4.2  rmind  *              1) Upper case alpha
    737  1.3.4.2  rmind  *              2) numeric
    738  1.3.4.2  rmind  *              3) underscore
    739  1.3.4.2  rmind  *
    740  1.3.4.2  rmind  *              We allow a '!' as the last character because of the ASF! table
    741  1.3.4.2  rmind  *
    742  1.3.4.2  rmind  ******************************************************************************/
    743  1.3.4.2  rmind 
    744  1.3.4.2  rmind BOOLEAN
    745  1.3.4.2  rmind AcpiUtValidAcpiChar (
    746  1.3.4.2  rmind     char                    Character,
    747  1.3.4.2  rmind     UINT32                  Position)
    748  1.3.4.2  rmind {
    749  1.3.4.2  rmind 
    750  1.3.4.2  rmind     if (!((Character >= 'A' && Character <= 'Z') ||
    751  1.3.4.2  rmind           (Character >= '0' && Character <= '9') ||
    752  1.3.4.2  rmind           (Character == '_')))
    753  1.3.4.2  rmind     {
    754  1.3.4.2  rmind         /* Allow a '!' in the last position */
    755  1.3.4.2  rmind 
    756  1.3.4.2  rmind         if (Character == '!' && Position == 3)
    757  1.3.4.2  rmind         {
    758  1.3.4.2  rmind             return (TRUE);
    759  1.3.4.2  rmind         }
    760  1.3.4.2  rmind 
    761  1.3.4.2  rmind         return (FALSE);
    762  1.3.4.2  rmind     }
    763  1.3.4.2  rmind 
    764  1.3.4.2  rmind     return (TRUE);
    765  1.3.4.2  rmind }
    766  1.3.4.2  rmind 
    767  1.3.4.2  rmind 
    768  1.3.4.2  rmind /*******************************************************************************
    769  1.3.4.2  rmind  *
    770  1.3.4.2  rmind  * FUNCTION:    AcpiUtValidAcpiName
    771  1.3.4.2  rmind  *
    772  1.3.4.2  rmind  * PARAMETERS:  Name            - The name to be examined
    773  1.3.4.2  rmind  *
    774  1.3.4.2  rmind  * RETURN:      TRUE if the name is valid, FALSE otherwise
    775  1.3.4.2  rmind  *
    776  1.3.4.2  rmind  * DESCRIPTION: Check for a valid ACPI name.  Each character must be one of:
    777  1.3.4.2  rmind  *              1) Upper case alpha
    778  1.3.4.2  rmind  *              2) numeric
    779  1.3.4.2  rmind  *              3) underscore
    780  1.3.4.2  rmind  *
    781  1.3.4.2  rmind  ******************************************************************************/
    782  1.3.4.2  rmind 
    783  1.3.4.2  rmind BOOLEAN
    784  1.3.4.2  rmind AcpiUtValidAcpiName (
    785  1.3.4.2  rmind     UINT32                  Name)
    786  1.3.4.2  rmind {
    787  1.3.4.2  rmind     UINT32                  i;
    788  1.3.4.2  rmind 
    789  1.3.4.2  rmind 
    790  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
    791  1.3.4.2  rmind 
    792  1.3.4.2  rmind 
    793  1.3.4.2  rmind     for (i = 0; i < ACPI_NAME_SIZE; i++)
    794  1.3.4.2  rmind     {
    795  1.3.4.2  rmind         if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
    796  1.3.4.2  rmind         {
    797  1.3.4.2  rmind             return (FALSE);
    798  1.3.4.2  rmind         }
    799  1.3.4.2  rmind     }
    800  1.3.4.2  rmind 
    801  1.3.4.2  rmind     return (TRUE);
    802  1.3.4.2  rmind }
    803  1.3.4.2  rmind 
    804  1.3.4.2  rmind 
    805  1.3.4.2  rmind /*******************************************************************************
    806  1.3.4.2  rmind  *
    807  1.3.4.2  rmind  * FUNCTION:    AcpiUtRepairName
    808  1.3.4.2  rmind  *
    809  1.3.4.2  rmind  * PARAMETERS:  Name            - The ACPI name to be repaired
    810  1.3.4.2  rmind  *
    811  1.3.4.2  rmind  * RETURN:      Repaired version of the name
    812  1.3.4.2  rmind  *
    813  1.3.4.2  rmind  * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
    814  1.3.4.2  rmind  *              return the new name. NOTE: the Name parameter must reside in
    815  1.3.4.2  rmind  *              read/write memory, cannot be a const.
    816  1.3.4.2  rmind  *
    817  1.3.4.2  rmind  * An ACPI Name must consist of valid ACPI characters. We will repair the name
    818  1.3.4.2  rmind  * if necessary because we don't want to abort because of this, but we want
    819  1.3.4.2  rmind  * all namespace names to be printable. A warning message is appropriate.
    820  1.3.4.2  rmind  *
    821  1.3.4.2  rmind  * This issue came up because there are in fact machines that exhibit
    822  1.3.4.2  rmind  * this problem, and we want to be able to enable ACPI support for them,
    823  1.3.4.2  rmind  * even though there are a few bad names.
    824  1.3.4.2  rmind  *
    825  1.3.4.2  rmind  ******************************************************************************/
    826  1.3.4.2  rmind 
    827  1.3.4.2  rmind void
    828  1.3.4.2  rmind AcpiUtRepairName (
    829  1.3.4.2  rmind     char                    *Name)
    830  1.3.4.2  rmind {
    831  1.3.4.2  rmind     UINT32                  i;
    832  1.3.4.2  rmind     BOOLEAN                 FoundBadChar = FALSE;
    833  1.3.4.2  rmind 
    834  1.3.4.2  rmind 
    835  1.3.4.2  rmind     ACPI_FUNCTION_NAME (UtRepairName);
    836  1.3.4.2  rmind 
    837  1.3.4.2  rmind 
    838  1.3.4.2  rmind     /* Check each character in the name */
    839  1.3.4.2  rmind 
    840  1.3.4.2  rmind     for (i = 0; i < ACPI_NAME_SIZE; i++)
    841  1.3.4.2  rmind     {
    842  1.3.4.2  rmind         if (AcpiUtValidAcpiChar (Name[i], i))
    843  1.3.4.2  rmind         {
    844  1.3.4.2  rmind             continue;
    845  1.3.4.2  rmind         }
    846  1.3.4.2  rmind 
    847  1.3.4.2  rmind         /*
    848  1.3.4.2  rmind          * Replace a bad character with something printable, yet technically
    849  1.3.4.2  rmind          * still invalid. This prevents any collisions with existing "good"
    850  1.3.4.2  rmind          * names in the namespace.
    851  1.3.4.2  rmind          */
    852  1.3.4.2  rmind         Name[i] = '*';
    853  1.3.4.2  rmind         FoundBadChar = TRUE;
    854  1.3.4.2  rmind     }
    855  1.3.4.2  rmind 
    856  1.3.4.2  rmind     if (FoundBadChar)
    857  1.3.4.2  rmind     {
    858  1.3.4.2  rmind         /* Report warning only if in strict mode or debug mode */
    859  1.3.4.2  rmind 
    860  1.3.4.2  rmind         if (!AcpiGbl_EnableInterpreterSlack)
    861  1.3.4.2  rmind         {
    862  1.3.4.2  rmind             ACPI_WARNING ((AE_INFO,
    863  1.3.4.2  rmind                 "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
    864  1.3.4.2  rmind         }
    865  1.3.4.2  rmind         else
    866  1.3.4.2  rmind         {
    867  1.3.4.2  rmind             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
    868  1.3.4.2  rmind                 "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
    869  1.3.4.2  rmind         }
    870  1.3.4.2  rmind     }
    871  1.3.4.2  rmind }
    872  1.3.4.2  rmind 
    873  1.3.4.2  rmind 
    874  1.3.4.2  rmind /*******************************************************************************
    875  1.3.4.2  rmind  *
    876  1.3.4.2  rmind  * FUNCTION:    AcpiUtStrtoul64
    877  1.3.4.2  rmind  *
    878  1.3.4.2  rmind  * PARAMETERS:  String          - Null terminated string
    879  1.3.4.2  rmind  *              Base            - Radix of the string: 16 or ACPI_ANY_BASE;
    880  1.3.4.2  rmind  *                                ACPI_ANY_BASE means 'in behalf of ToInteger'
    881  1.3.4.2  rmind  *              RetInteger      - Where the converted integer is returned
    882  1.3.4.2  rmind  *
    883  1.3.4.2  rmind  * RETURN:      Status and Converted value
    884  1.3.4.2  rmind  *
    885  1.3.4.2  rmind  * DESCRIPTION: Convert a string into an unsigned value. Performs either a
    886  1.3.4.2  rmind  *              32-bit or 64-bit conversion, depending on the current mode
    887  1.3.4.2  rmind  *              of the interpreter.
    888  1.3.4.2  rmind  *              NOTE: Does not support Octal strings, not needed.
    889  1.3.4.2  rmind  *
    890  1.3.4.2  rmind  ******************************************************************************/
    891  1.3.4.2  rmind 
    892  1.3.4.2  rmind ACPI_STATUS
    893  1.3.4.2  rmind AcpiUtStrtoul64 (
    894  1.3.4.2  rmind     char                    *String,
    895  1.3.4.2  rmind     UINT32                  Base,
    896  1.3.4.2  rmind     UINT64                  *RetInteger)
    897  1.3.4.2  rmind {
    898  1.3.4.2  rmind     UINT32                  ThisDigit = 0;
    899  1.3.4.2  rmind     UINT64                  ReturnValue = 0;
    900  1.3.4.2  rmind     UINT64                  Quotient;
    901  1.3.4.2  rmind     UINT64                  Dividend;
    902  1.3.4.2  rmind     UINT32                  ToIntegerOp = (Base == ACPI_ANY_BASE);
    903  1.3.4.2  rmind     UINT32                  Mode32 = (AcpiGbl_IntegerByteWidth == 4);
    904  1.3.4.2  rmind     UINT8                   ValidDigits = 0;
    905  1.3.4.2  rmind     UINT8                   SignOf0x = 0;
    906  1.3.4.2  rmind     UINT8                   Term = 0;
    907  1.3.4.2  rmind 
    908  1.3.4.2  rmind 
    909  1.3.4.2  rmind     ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
    910  1.3.4.2  rmind 
    911  1.3.4.2  rmind 
    912  1.3.4.2  rmind     switch (Base)
    913  1.3.4.2  rmind     {
    914  1.3.4.2  rmind     case ACPI_ANY_BASE:
    915  1.3.4.2  rmind     case 16:
    916  1.3.4.2  rmind         break;
    917  1.3.4.2  rmind 
    918  1.3.4.2  rmind     default:
    919  1.3.4.2  rmind         /* Invalid Base */
    920  1.3.4.2  rmind         return_ACPI_STATUS (AE_BAD_PARAMETER);
    921  1.3.4.2  rmind     }
    922  1.3.4.2  rmind 
    923  1.3.4.2  rmind     if (!String)
    924  1.3.4.2  rmind     {
    925  1.3.4.2  rmind         goto ErrorExit;
    926  1.3.4.2  rmind     }
    927  1.3.4.2  rmind 
    928  1.3.4.2  rmind     /* Skip over any white space in the buffer */
    929  1.3.4.2  rmind 
    930  1.3.4.2  rmind     while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
    931  1.3.4.2  rmind     {
    932  1.3.4.2  rmind         String++;
    933  1.3.4.2  rmind     }
    934  1.3.4.2  rmind 
    935  1.3.4.2  rmind     if (ToIntegerOp)
    936  1.3.4.2  rmind     {
    937  1.3.4.2  rmind         /*
    938  1.3.4.2  rmind          * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
    939  1.3.4.2  rmind          * We need to determine if it is decimal or hexadecimal.
    940  1.3.4.2  rmind          */
    941  1.3.4.2  rmind         if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
    942  1.3.4.2  rmind         {
    943  1.3.4.2  rmind             SignOf0x = 1;
    944  1.3.4.2  rmind             Base = 16;
    945  1.3.4.2  rmind 
    946  1.3.4.2  rmind             /* Skip over the leading '0x' */
    947  1.3.4.2  rmind             String += 2;
    948  1.3.4.2  rmind         }
    949  1.3.4.2  rmind         else
    950  1.3.4.2  rmind         {
    951  1.3.4.2  rmind             Base = 10;
    952  1.3.4.2  rmind         }
    953  1.3.4.2  rmind     }
    954  1.3.4.2  rmind 
    955  1.3.4.2  rmind     /* Any string left? Check that '0x' is not followed by white space. */
    956  1.3.4.2  rmind 
    957  1.3.4.2  rmind     if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
    958  1.3.4.2  rmind     {
    959  1.3.4.2  rmind         if (ToIntegerOp)
    960  1.3.4.2  rmind         {
    961  1.3.4.2  rmind             goto ErrorExit;
    962  1.3.4.2  rmind         }
    963  1.3.4.2  rmind         else
    964  1.3.4.2  rmind         {
    965  1.3.4.2  rmind             goto AllDone;
    966  1.3.4.2  rmind         }
    967  1.3.4.2  rmind     }
    968  1.3.4.2  rmind 
    969  1.3.4.2  rmind     /*
    970  1.3.4.2  rmind      * Perform a 32-bit or 64-bit conversion, depending upon the current
    971  1.3.4.2  rmind      * execution mode of the interpreter
    972  1.3.4.2  rmind      */
    973  1.3.4.2  rmind     Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
    974  1.3.4.2  rmind 
    975  1.3.4.2  rmind     /* Main loop: convert the string to a 32- or 64-bit integer */
    976  1.3.4.2  rmind 
    977  1.3.4.2  rmind     while (*String)
    978  1.3.4.2  rmind     {
    979  1.3.4.2  rmind         if (ACPI_IS_DIGIT (*String))
    980  1.3.4.2  rmind         {
    981  1.3.4.2  rmind             /* Convert ASCII 0-9 to Decimal value */
    982  1.3.4.2  rmind 
    983  1.3.4.2  rmind             ThisDigit = ((UINT8) *String) - '0';
    984  1.3.4.2  rmind         }
    985  1.3.4.2  rmind         else if (Base == 10)
    986  1.3.4.2  rmind         {
    987  1.3.4.2  rmind             /* Digit is out of range; possible in ToInteger case only */
    988  1.3.4.2  rmind 
    989  1.3.4.2  rmind             Term = 1;
    990  1.3.4.2  rmind         }
    991  1.3.4.2  rmind         else
    992  1.3.4.2  rmind         {
    993  1.3.4.2  rmind             ThisDigit = (UINT8) ACPI_TOUPPER (*String);
    994  1.3.4.2  rmind             if (ACPI_IS_XDIGIT ((char) ThisDigit))
    995  1.3.4.2  rmind             {
    996  1.3.4.2  rmind                 /* Convert ASCII Hex char to value */
    997  1.3.4.2  rmind 
    998  1.3.4.2  rmind                 ThisDigit = ThisDigit - 'A' + 10;
    999  1.3.4.2  rmind             }
   1000  1.3.4.2  rmind             else
   1001  1.3.4.2  rmind             {
   1002  1.3.4.2  rmind                 Term = 1;
   1003  1.3.4.2  rmind             }
   1004  1.3.4.2  rmind         }
   1005  1.3.4.2  rmind 
   1006  1.3.4.2  rmind         if (Term)
   1007  1.3.4.2  rmind         {
   1008  1.3.4.2  rmind             if (ToIntegerOp)
   1009  1.3.4.2  rmind             {
   1010  1.3.4.2  rmind                 goto ErrorExit;
   1011  1.3.4.2  rmind             }
   1012  1.3.4.2  rmind             else
   1013  1.3.4.2  rmind             {
   1014  1.3.4.2  rmind                 break;
   1015  1.3.4.2  rmind             }
   1016  1.3.4.2  rmind         }
   1017  1.3.4.2  rmind         else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
   1018  1.3.4.2  rmind         {
   1019  1.3.4.2  rmind             /* Skip zeros */
   1020  1.3.4.2  rmind             String++;
   1021  1.3.4.2  rmind             continue;
   1022  1.3.4.2  rmind         }
   1023  1.3.4.2  rmind 
   1024  1.3.4.2  rmind         ValidDigits++;
   1025  1.3.4.2  rmind 
   1026  1.3.4.2  rmind         if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
   1027  1.3.4.2  rmind         {
   1028  1.3.4.2  rmind             /*
   1029  1.3.4.2  rmind              * This is ToInteger operation case.
   1030  1.3.4.2  rmind              * No any restrictions for string-to-integer conversion,
   1031  1.3.4.2  rmind              * see ACPI spec.
   1032  1.3.4.2  rmind              */
   1033  1.3.4.2  rmind             goto ErrorExit;
   1034  1.3.4.2  rmind         }
   1035  1.3.4.2  rmind 
   1036  1.3.4.2  rmind         /* Divide the digit into the correct position */
   1037  1.3.4.2  rmind 
   1038  1.3.4.2  rmind         (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit),
   1039  1.3.4.2  rmind                     Base, &Quotient, NULL);
   1040  1.3.4.2  rmind 
   1041  1.3.4.2  rmind         if (ReturnValue > Quotient)
   1042  1.3.4.2  rmind         {
   1043  1.3.4.2  rmind             if (ToIntegerOp)
   1044  1.3.4.2  rmind             {
   1045  1.3.4.2  rmind                 goto ErrorExit;
   1046  1.3.4.2  rmind             }
   1047  1.3.4.2  rmind             else
   1048  1.3.4.2  rmind             {
   1049  1.3.4.2  rmind                 break;
   1050  1.3.4.2  rmind             }
   1051  1.3.4.2  rmind         }
   1052  1.3.4.2  rmind 
   1053  1.3.4.2  rmind         ReturnValue *= Base;
   1054  1.3.4.2  rmind         ReturnValue += ThisDigit;
   1055  1.3.4.2  rmind         String++;
   1056  1.3.4.2  rmind     }
   1057  1.3.4.2  rmind 
   1058  1.3.4.2  rmind     /* All done, normal exit */
   1059  1.3.4.2  rmind 
   1060  1.3.4.2  rmind AllDone:
   1061  1.3.4.2  rmind 
   1062  1.3.4.2  rmind     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
   1063  1.3.4.2  rmind         ACPI_FORMAT_UINT64 (ReturnValue)));
   1064  1.3.4.2  rmind 
   1065  1.3.4.2  rmind     *RetInteger = ReturnValue;
   1066  1.3.4.2  rmind     return_ACPI_STATUS (AE_OK);
   1067  1.3.4.2  rmind 
   1068  1.3.4.2  rmind 
   1069  1.3.4.2  rmind ErrorExit:
   1070  1.3.4.2  rmind     /* Base was set/validated above */
   1071  1.3.4.2  rmind 
   1072  1.3.4.2  rmind     if (Base == 10)
   1073  1.3.4.2  rmind     {
   1074  1.3.4.2  rmind         return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
   1075  1.3.4.2  rmind     }
   1076  1.3.4.2  rmind     else
   1077  1.3.4.2  rmind     {
   1078  1.3.4.2  rmind         return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
   1079  1.3.4.2  rmind     }
   1080  1.3.4.2  rmind }
   1081  1.3.4.2  rmind 
   1082  1.3.4.2  rmind 
   1083  1.3.4.2  rmind /*******************************************************************************
   1084  1.3.4.2  rmind  *
   1085  1.3.4.2  rmind  * FUNCTION:    AcpiUtCreateUpdateStateAndPush
   1086  1.3.4.2  rmind  *
   1087  1.3.4.2  rmind  * PARAMETERS:  Object          - Object to be added to the new state
   1088  1.3.4.2  rmind  *              Action          - Increment/Decrement
   1089  1.3.4.2  rmind  *              StateList       - List the state will be added to
   1090  1.3.4.2  rmind  *
   1091  1.3.4.2  rmind  * RETURN:      Status
   1092  1.3.4.2  rmind  *
   1093  1.3.4.2  rmind  * DESCRIPTION: Create a new state and push it
   1094  1.3.4.2  rmind  *
   1095  1.3.4.2  rmind  ******************************************************************************/
   1096  1.3.4.2  rmind 
   1097  1.3.4.2  rmind ACPI_STATUS
   1098  1.3.4.2  rmind AcpiUtCreateUpdateStateAndPush (
   1099  1.3.4.2  rmind     ACPI_OPERAND_OBJECT     *Object,
   1100  1.3.4.2  rmind     UINT16                  Action,
   1101  1.3.4.2  rmind     ACPI_GENERIC_STATE      **StateList)
   1102  1.3.4.2  rmind {
   1103  1.3.4.2  rmind     ACPI_GENERIC_STATE       *State;
   1104  1.3.4.2  rmind 
   1105  1.3.4.2  rmind 
   1106  1.3.4.2  rmind     ACPI_FUNCTION_ENTRY ();
   1107  1.3.4.2  rmind 
   1108  1.3.4.2  rmind 
   1109  1.3.4.2  rmind     /* Ignore null objects; these are expected */
   1110  1.3.4.2  rmind 
   1111  1.3.4.2  rmind     if (!Object)
   1112  1.3.4.2  rmind     {
   1113  1.3.4.2  rmind         return (AE_OK);
   1114  1.3.4.2  rmind     }
   1115  1.3.4.2  rmind 
   1116  1.3.4.2  rmind     State = AcpiUtCreateUpdateState (Object, Action);
   1117  1.3.4.2  rmind     if (!State)
   1118  1.3.4.2  rmind     {
   1119  1.3.4.2  rmind         return (AE_NO_MEMORY);
   1120  1.3.4.2  rmind     }
   1121  1.3.4.2  rmind 
   1122  1.3.4.2  rmind     AcpiUtPushGenericState (StateList, State);
   1123  1.3.4.2  rmind     return (AE_OK);
   1124  1.3.4.2  rmind }
   1125  1.3.4.2  rmind 
   1126  1.3.4.2  rmind 
   1127  1.3.4.2  rmind /*******************************************************************************
   1128  1.3.4.2  rmind  *
   1129  1.3.4.2  rmind  * FUNCTION:    AcpiUtWalkPackageTree
   1130  1.3.4.2  rmind  *
   1131  1.3.4.2  rmind  * PARAMETERS:  SourceObject        - The package to walk
   1132  1.3.4.2  rmind  *              TargetObject        - Target object (if package is being copied)
   1133  1.3.4.2  rmind  *              WalkCallback        - Called once for each package element
   1134  1.3.4.2  rmind  *              Context             - Passed to the callback function
   1135  1.3.4.2  rmind  *
   1136  1.3.4.2  rmind  * RETURN:      Status
   1137  1.3.4.2  rmind  *
   1138  1.3.4.2  rmind  * DESCRIPTION: Walk through a package
   1139  1.3.4.2  rmind  *
   1140  1.3.4.2  rmind  ******************************************************************************/
   1141  1.3.4.2  rmind 
   1142  1.3.4.2  rmind ACPI_STATUS
   1143  1.3.4.2  rmind AcpiUtWalkPackageTree (
   1144  1.3.4.2  rmind     ACPI_OPERAND_OBJECT     *SourceObject,
   1145  1.3.4.2  rmind     void                    *TargetObject,
   1146  1.3.4.2  rmind     ACPI_PKG_CALLBACK       WalkCallback,
   1147  1.3.4.2  rmind     void                    *Context)
   1148  1.3.4.2  rmind {
   1149  1.3.4.2  rmind     ACPI_STATUS             Status = AE_OK;
   1150  1.3.4.2  rmind     ACPI_GENERIC_STATE      *StateList = NULL;
   1151  1.3.4.2  rmind     ACPI_GENERIC_STATE      *State;
   1152  1.3.4.2  rmind     UINT32                  ThisIndex;
   1153  1.3.4.2  rmind     ACPI_OPERAND_OBJECT     *ThisSourceObj;
   1154  1.3.4.2  rmind 
   1155  1.3.4.2  rmind 
   1156  1.3.4.2  rmind     ACPI_FUNCTION_TRACE (UtWalkPackageTree);
   1157  1.3.4.2  rmind 
   1158  1.3.4.2  rmind 
   1159  1.3.4.2  rmind     State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
   1160  1.3.4.2  rmind     if (!State)
   1161  1.3.4.2  rmind     {
   1162  1.3.4.2  rmind         return_ACPI_STATUS (AE_NO_MEMORY);
   1163  1.3.4.2  rmind     }
   1164  1.3.4.2  rmind 
   1165  1.3.4.2  rmind     while (State)
   1166  1.3.4.2  rmind     {
   1167  1.3.4.2  rmind         /* Get one element of the package */
   1168  1.3.4.2  rmind 
   1169  1.3.4.2  rmind         ThisIndex     = State->Pkg.Index;
   1170  1.3.4.2  rmind         ThisSourceObj = (ACPI_OPERAND_OBJECT *)
   1171  1.3.4.2  rmind                         State->Pkg.SourceObject->Package.Elements[ThisIndex];
   1172  1.3.4.2  rmind 
   1173  1.3.4.2  rmind         /*
   1174  1.3.4.2  rmind          * Check for:
   1175  1.3.4.2  rmind          * 1) An uninitialized package element.  It is completely
   1176  1.3.4.2  rmind          *    legal to declare a package and leave it uninitialized
   1177  1.3.4.2  rmind          * 2) Not an internal object - can be a namespace node instead
   1178  1.3.4.2  rmind          * 3) Any type other than a package.  Packages are handled in else
   1179  1.3.4.2  rmind          *    case below.
   1180  1.3.4.2  rmind          */
   1181  1.3.4.2  rmind         if ((!ThisSourceObj) ||
   1182  1.3.4.2  rmind             (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
   1183  1.3.4.2  rmind             (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
   1184  1.3.4.2  rmind         {
   1185  1.3.4.2  rmind             Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
   1186  1.3.4.2  rmind                                     State, Context);
   1187  1.3.4.2  rmind             if (ACPI_FAILURE (Status))
   1188  1.3.4.2  rmind             {
   1189  1.3.4.2  rmind                 return_ACPI_STATUS (Status);
   1190  1.3.4.2  rmind             }
   1191  1.3.4.2  rmind 
   1192  1.3.4.2  rmind             State->Pkg.Index++;
   1193  1.3.4.2  rmind             while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
   1194  1.3.4.2  rmind             {
   1195  1.3.4.2  rmind                 /*
   1196  1.3.4.2  rmind                  * We've handled all of the objects at this level,  This means
   1197  1.3.4.2  rmind                  * that we have just completed a package.  That package may
   1198  1.3.4.2  rmind                  * have contained one or more packages itself.
   1199  1.3.4.2  rmind                  *
   1200  1.3.4.2  rmind                  * Delete this state and pop the previous state (package).
   1201  1.3.4.2  rmind                  */
   1202  1.3.4.2  rmind                 AcpiUtDeleteGenericState (State);
   1203  1.3.4.2  rmind                 State = AcpiUtPopGenericState (&StateList);
   1204  1.3.4.2  rmind 
   1205  1.3.4.2  rmind                 /* Finished when there are no more states */
   1206  1.3.4.2  rmind 
   1207  1.3.4.2  rmind                 if (!State)
   1208  1.3.4.2  rmind                 {
   1209  1.3.4.2  rmind                     /*
   1210  1.3.4.2  rmind                      * We have handled all of the objects in the top level
   1211  1.3.4.2  rmind                      * package just add the length of the package objects
   1212  1.3.4.2  rmind                      * and exit
   1213  1.3.4.2  rmind                      */
   1214  1.3.4.2  rmind                     return_ACPI_STATUS (AE_OK);
   1215  1.3.4.2  rmind                 }
   1216  1.3.4.2  rmind 
   1217  1.3.4.2  rmind                 /*
   1218  1.3.4.2  rmind                  * Go back up a level and move the index past the just
   1219  1.3.4.2  rmind                  * completed package object.
   1220  1.3.4.2  rmind                  */
   1221  1.3.4.2  rmind                 State->Pkg.Index++;
   1222  1.3.4.2  rmind             }
   1223  1.3.4.2  rmind         }
   1224  1.3.4.2  rmind         else
   1225  1.3.4.2  rmind         {
   1226  1.3.4.2  rmind             /* This is a subobject of type package */
   1227  1.3.4.2  rmind 
   1228  1.3.4.2  rmind             Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
   1229  1.3.4.2  rmind                                         State, Context);
   1230  1.3.4.2  rmind             if (ACPI_FAILURE (Status))
   1231  1.3.4.2  rmind             {
   1232  1.3.4.2  rmind                 return_ACPI_STATUS (Status);
   1233  1.3.4.2  rmind             }
   1234  1.3.4.2  rmind 
   1235  1.3.4.2  rmind             /*
   1236  1.3.4.2  rmind              * Push the current state and create a new one
   1237  1.3.4.2  rmind              * The callback above returned a new target package object.
   1238  1.3.4.2  rmind              */
   1239  1.3.4.2  rmind             AcpiUtPushGenericState (&StateList, State);
   1240  1.3.4.2  rmind             State = AcpiUtCreatePkgState (ThisSourceObj,
   1241  1.3.4.2  rmind                                             State->Pkg.ThisTargetObj, 0);
   1242  1.3.4.2  rmind             if (!State)
   1243  1.3.4.2  rmind             {
   1244  1.3.4.2  rmind                 /* Free any stacked Update State objects */
   1245  1.3.4.2  rmind 
   1246  1.3.4.2  rmind                 while (StateList)
   1247  1.3.4.2  rmind                 {
   1248  1.3.4.2  rmind                     State = AcpiUtPopGenericState (&StateList);
   1249  1.3.4.2  rmind                     AcpiUtDeleteGenericState (State);
   1250  1.3.4.2  rmind                 }
   1251  1.3.4.2  rmind                 return_ACPI_STATUS (AE_NO_MEMORY);
   1252  1.3.4.2  rmind             }
   1253  1.3.4.2  rmind         }
   1254  1.3.4.2  rmind     }
   1255  1.3.4.2  rmind 
   1256  1.3.4.2  rmind     /* We should never get here */
   1257  1.3.4.2  rmind 
   1258  1.3.4.2  rmind     return_ACPI_STATUS (AE_AML_INTERNAL);
   1259  1.3.4.2  rmind }
   1260  1.3.4.2  rmind 
   1261  1.3.4.2  rmind 
   1262