Home | History | Annotate | Line # | Download | only in executer
exutils.c revision 1.1.1.2.20.1
      1           1.1  jruoho /******************************************************************************
      2           1.1  jruoho  *
      3           1.1  jruoho  * Module Name: exutils - interpreter/scanner utilities
      4           1.1  jruoho  *
      5           1.1  jruoho  *****************************************************************************/
      6           1.1  jruoho 
      7       1.1.1.2  jruoho /*
      8  1.1.1.2.20.1     tls  * Copyright (C) 2000 - 2013, Intel Corp.
      9           1.1  jruoho  * All rights reserved.
     10           1.1  jruoho  *
     11       1.1.1.2  jruoho  * Redistribution and use in source and binary forms, with or without
     12       1.1.1.2  jruoho  * modification, are permitted provided that the following conditions
     13       1.1.1.2  jruoho  * are met:
     14       1.1.1.2  jruoho  * 1. Redistributions of source code must retain the above copyright
     15       1.1.1.2  jruoho  *    notice, this list of conditions, and the following disclaimer,
     16       1.1.1.2  jruoho  *    without modification.
     17       1.1.1.2  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18       1.1.1.2  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19       1.1.1.2  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20       1.1.1.2  jruoho  *    including a substantially similar Disclaimer requirement for further
     21       1.1.1.2  jruoho  *    binary redistribution.
     22       1.1.1.2  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23       1.1.1.2  jruoho  *    of any contributors may be used to endorse or promote products derived
     24       1.1.1.2  jruoho  *    from this software without specific prior written permission.
     25       1.1.1.2  jruoho  *
     26       1.1.1.2  jruoho  * Alternatively, this software may be distributed under the terms of the
     27       1.1.1.2  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28       1.1.1.2  jruoho  * Software Foundation.
     29       1.1.1.2  jruoho  *
     30       1.1.1.2  jruoho  * NO WARRANTY
     31       1.1.1.2  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32       1.1.1.2  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33       1.1.1.2  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34       1.1.1.2  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35       1.1.1.2  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36       1.1.1.2  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37       1.1.1.2  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38       1.1.1.2  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39       1.1.1.2  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40       1.1.1.2  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41       1.1.1.2  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42       1.1.1.2  jruoho  */
     43           1.1  jruoho 
     44           1.1  jruoho #define __EXUTILS_C__
     45           1.1  jruoho 
     46           1.1  jruoho /*
     47           1.1  jruoho  * DEFINE_AML_GLOBALS is tested in amlcode.h
     48           1.1  jruoho  * to determine whether certain global names should be "defined" or only
     49  1.1.1.2.20.1     tls  * "declared" in the current compilation. This enhances maintainability
     50           1.1  jruoho  * by enabling a single header file to embody all knowledge of the names
     51           1.1  jruoho  * in question.
     52           1.1  jruoho  *
     53           1.1  jruoho  * Exactly one module of any executable should #define DEFINE_GLOBALS
     54  1.1.1.2.20.1     tls  * before #including the header files which use this convention. The
     55           1.1  jruoho  * names in question will be defined and initialized in that module,
     56           1.1  jruoho  * and declared as extern in all other modules which #include those
     57           1.1  jruoho  * header files.
     58           1.1  jruoho  */
     59           1.1  jruoho 
     60           1.1  jruoho #define DEFINE_AML_GLOBALS
     61           1.1  jruoho 
     62           1.1  jruoho #include "acpi.h"
     63           1.1  jruoho #include "accommon.h"
     64           1.1  jruoho #include "acinterp.h"
     65           1.1  jruoho #include "amlcode.h"
     66           1.1  jruoho 
     67           1.1  jruoho #define _COMPONENT          ACPI_EXECUTER
     68           1.1  jruoho         ACPI_MODULE_NAME    ("exutils")
     69           1.1  jruoho 
     70           1.1  jruoho /* Local prototypes */
     71           1.1  jruoho 
     72           1.1  jruoho static UINT32
     73           1.1  jruoho AcpiExDigitsNeeded (
     74           1.1  jruoho     UINT64                  Value,
     75           1.1  jruoho     UINT32                  Base);
     76           1.1  jruoho 
     77           1.1  jruoho 
     78           1.1  jruoho #ifndef ACPI_NO_METHOD_EXECUTION
     79           1.1  jruoho /*******************************************************************************
     80           1.1  jruoho  *
     81           1.1  jruoho  * FUNCTION:    AcpiExEnterInterpreter
     82           1.1  jruoho  *
     83           1.1  jruoho  * PARAMETERS:  None
     84           1.1  jruoho  *
     85           1.1  jruoho  * RETURN:      None
     86           1.1  jruoho  *
     87           1.1  jruoho  * DESCRIPTION: Enter the interpreter execution region. Failure to enter
     88           1.1  jruoho  *              the interpreter region is a fatal system error. Used in
     89           1.1  jruoho  *              conjunction with ExitInterpreter.
     90           1.1  jruoho  *
     91           1.1  jruoho  ******************************************************************************/
     92           1.1  jruoho 
     93           1.1  jruoho void
     94           1.1  jruoho AcpiExEnterInterpreter (
     95           1.1  jruoho     void)
     96           1.1  jruoho {
     97           1.1  jruoho     ACPI_STATUS             Status;
     98           1.1  jruoho 
     99           1.1  jruoho 
    100           1.1  jruoho     ACPI_FUNCTION_TRACE (ExEnterInterpreter);
    101           1.1  jruoho 
    102           1.1  jruoho 
    103           1.1  jruoho     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
    104           1.1  jruoho     if (ACPI_FAILURE (Status))
    105           1.1  jruoho     {
    106           1.1  jruoho         ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
    107           1.1  jruoho     }
    108           1.1  jruoho 
    109           1.1  jruoho     return_VOID;
    110           1.1  jruoho }
    111           1.1  jruoho 
    112           1.1  jruoho 
    113           1.1  jruoho /*******************************************************************************
    114           1.1  jruoho  *
    115           1.1  jruoho  * FUNCTION:    AcpiExReacquireInterpreter
    116           1.1  jruoho  *
    117           1.1  jruoho  * PARAMETERS:  None
    118           1.1  jruoho  *
    119           1.1  jruoho  * RETURN:      None
    120           1.1  jruoho  *
    121           1.1  jruoho  * DESCRIPTION: Reacquire the interpreter execution region from within the
    122           1.1  jruoho  *              interpreter code. Failure to enter the interpreter region is a
    123  1.1.1.2.20.1     tls  *              fatal system error. Used in conjunction with
    124           1.1  jruoho  *              RelinquishInterpreter
    125           1.1  jruoho  *
    126           1.1  jruoho  ******************************************************************************/
    127           1.1  jruoho 
    128           1.1  jruoho void
    129           1.1  jruoho AcpiExReacquireInterpreter (
    130           1.1  jruoho     void)
    131           1.1  jruoho {
    132           1.1  jruoho     ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
    133           1.1  jruoho 
    134           1.1  jruoho 
    135           1.1  jruoho     /*
    136           1.1  jruoho      * If the global serialized flag is set, do not release the interpreter,
    137           1.1  jruoho      * since it was not actually released by AcpiExRelinquishInterpreter.
    138           1.1  jruoho      * This forces the interpreter to be single threaded.
    139           1.1  jruoho      */
    140           1.1  jruoho     if (!AcpiGbl_AllMethodsSerialized)
    141           1.1  jruoho     {
    142           1.1  jruoho         AcpiExEnterInterpreter ();
    143           1.1  jruoho     }
    144           1.1  jruoho 
    145           1.1  jruoho     return_VOID;
    146           1.1  jruoho }
    147           1.1  jruoho 
    148           1.1  jruoho 
    149           1.1  jruoho /*******************************************************************************
    150           1.1  jruoho  *
    151           1.1  jruoho  * FUNCTION:    AcpiExExitInterpreter
    152           1.1  jruoho  *
    153           1.1  jruoho  * PARAMETERS:  None
    154           1.1  jruoho  *
    155           1.1  jruoho  * RETURN:      None
    156           1.1  jruoho  *
    157           1.1  jruoho  * DESCRIPTION: Exit the interpreter execution region. This is the top level
    158           1.1  jruoho  *              routine used to exit the interpreter when all processing has
    159           1.1  jruoho  *              been completed.
    160           1.1  jruoho  *
    161           1.1  jruoho  ******************************************************************************/
    162           1.1  jruoho 
    163           1.1  jruoho void
    164           1.1  jruoho AcpiExExitInterpreter (
    165           1.1  jruoho     void)
    166           1.1  jruoho {
    167           1.1  jruoho     ACPI_STATUS             Status;
    168           1.1  jruoho 
    169           1.1  jruoho 
    170           1.1  jruoho     ACPI_FUNCTION_TRACE (ExExitInterpreter);
    171           1.1  jruoho 
    172           1.1  jruoho 
    173           1.1  jruoho     Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
    174           1.1  jruoho     if (ACPI_FAILURE (Status))
    175           1.1  jruoho     {
    176           1.1  jruoho         ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex"));
    177           1.1  jruoho     }
    178           1.1  jruoho 
    179           1.1  jruoho     return_VOID;
    180           1.1  jruoho }
    181           1.1  jruoho 
    182           1.1  jruoho 
    183           1.1  jruoho /*******************************************************************************
    184           1.1  jruoho  *
    185           1.1  jruoho  * FUNCTION:    AcpiExRelinquishInterpreter
    186           1.1  jruoho  *
    187           1.1  jruoho  * PARAMETERS:  None
    188           1.1  jruoho  *
    189           1.1  jruoho  * RETURN:      None
    190           1.1  jruoho  *
    191           1.1  jruoho  * DESCRIPTION: Exit the interpreter execution region, from within the
    192           1.1  jruoho  *              interpreter - before attempting an operation that will possibly
    193           1.1  jruoho  *              block the running thread.
    194           1.1  jruoho  *
    195           1.1  jruoho  * Cases where the interpreter is unlocked internally
    196           1.1  jruoho  *      1) Method to be blocked on a Sleep() AML opcode
    197           1.1  jruoho  *      2) Method to be blocked on an Acquire() AML opcode
    198           1.1  jruoho  *      3) Method to be blocked on a Wait() AML opcode
    199           1.1  jruoho  *      4) Method to be blocked to acquire the global lock
    200           1.1  jruoho  *      5) Method to be blocked waiting to execute a serialized control method
    201           1.1  jruoho  *          that is currently executing
    202           1.1  jruoho  *      6) About to invoke a user-installed opregion handler
    203           1.1  jruoho  *
    204           1.1  jruoho  ******************************************************************************/
    205           1.1  jruoho 
    206           1.1  jruoho void
    207           1.1  jruoho AcpiExRelinquishInterpreter (
    208           1.1  jruoho     void)
    209           1.1  jruoho {
    210           1.1  jruoho     ACPI_FUNCTION_TRACE (ExRelinquishInterpreter);
    211           1.1  jruoho 
    212           1.1  jruoho 
    213           1.1  jruoho     /*
    214           1.1  jruoho      * If the global serialized flag is set, do not release the interpreter.
    215           1.1  jruoho      * This forces the interpreter to be single threaded.
    216           1.1  jruoho      */
    217           1.1  jruoho     if (!AcpiGbl_AllMethodsSerialized)
    218           1.1  jruoho     {
    219           1.1  jruoho         AcpiExExitInterpreter ();
    220           1.1  jruoho     }
    221           1.1  jruoho 
    222           1.1  jruoho     return_VOID;
    223           1.1  jruoho }
    224           1.1  jruoho 
    225           1.1  jruoho 
    226           1.1  jruoho /*******************************************************************************
    227           1.1  jruoho  *
    228           1.1  jruoho  * FUNCTION:    AcpiExTruncateFor32bitTable
    229           1.1  jruoho  *
    230           1.1  jruoho  * PARAMETERS:  ObjDesc         - Object to be truncated
    231           1.1  jruoho  *
    232  1.1.1.2.20.1     tls  * RETURN:      TRUE if a truncation was performed, FALSE otherwise.
    233           1.1  jruoho  *
    234           1.1  jruoho  * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
    235           1.1  jruoho  *              32-bit, as determined by the revision of the DSDT.
    236           1.1  jruoho  *
    237           1.1  jruoho  ******************************************************************************/
    238           1.1  jruoho 
    239  1.1.1.2.20.1     tls BOOLEAN
    240           1.1  jruoho AcpiExTruncateFor32bitTable (
    241           1.1  jruoho     ACPI_OPERAND_OBJECT     *ObjDesc)
    242           1.1  jruoho {
    243           1.1  jruoho 
    244           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    245           1.1  jruoho 
    246           1.1  jruoho 
    247           1.1  jruoho     /*
    248           1.1  jruoho      * Object must be a valid number and we must be executing
    249  1.1.1.2.20.1     tls      * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
    250           1.1  jruoho      */
    251           1.1  jruoho     if ((!ObjDesc) ||
    252           1.1  jruoho         (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
    253           1.1  jruoho         (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
    254           1.1  jruoho     {
    255  1.1.1.2.20.1     tls         return (FALSE);
    256           1.1  jruoho     }
    257           1.1  jruoho 
    258  1.1.1.2.20.1     tls     if ((AcpiGbl_IntegerByteWidth == 4) &&
    259  1.1.1.2.20.1     tls         (ObjDesc->Integer.Value > (UINT64) ACPI_UINT32_MAX))
    260           1.1  jruoho     {
    261           1.1  jruoho         /*
    262  1.1.1.2.20.1     tls          * We are executing in a 32-bit ACPI table.
    263           1.1  jruoho          * Truncate the value to 32 bits by zeroing out the upper 32-bit field
    264           1.1  jruoho          */
    265           1.1  jruoho         ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
    266  1.1.1.2.20.1     tls         return (TRUE);
    267           1.1  jruoho     }
    268  1.1.1.2.20.1     tls 
    269  1.1.1.2.20.1     tls     return (FALSE);
    270           1.1  jruoho }
    271           1.1  jruoho 
    272           1.1  jruoho 
    273           1.1  jruoho /*******************************************************************************
    274           1.1  jruoho  *
    275           1.1  jruoho  * FUNCTION:    AcpiExAcquireGlobalLock
    276           1.1  jruoho  *
    277           1.1  jruoho  * PARAMETERS:  FieldFlags            - Flags with Lock rule:
    278           1.1  jruoho  *                                      AlwaysLock or NeverLock
    279           1.1  jruoho  *
    280           1.1  jruoho  * RETURN:      None
    281           1.1  jruoho  *
    282           1.1  jruoho  * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
    283           1.1  jruoho  *              flags specifiy that it is to be obtained before field access.
    284           1.1  jruoho  *
    285           1.1  jruoho  ******************************************************************************/
    286           1.1  jruoho 
    287           1.1  jruoho void
    288           1.1  jruoho AcpiExAcquireGlobalLock (
    289           1.1  jruoho     UINT32                  FieldFlags)
    290           1.1  jruoho {
    291           1.1  jruoho     ACPI_STATUS             Status;
    292           1.1  jruoho 
    293           1.1  jruoho 
    294           1.1  jruoho     ACPI_FUNCTION_TRACE (ExAcquireGlobalLock);
    295           1.1  jruoho 
    296           1.1  jruoho 
    297           1.1  jruoho     /* Only use the lock if the AlwaysLock bit is set */
    298           1.1  jruoho 
    299           1.1  jruoho     if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
    300           1.1  jruoho     {
    301           1.1  jruoho         return_VOID;
    302           1.1  jruoho     }
    303           1.1  jruoho 
    304           1.1  jruoho     /* Attempt to get the global lock, wait forever */
    305           1.1  jruoho 
    306           1.1  jruoho     Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER,
    307           1.1  jruoho                 AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
    308           1.1  jruoho 
    309           1.1  jruoho     if (ACPI_FAILURE (Status))
    310           1.1  jruoho     {
    311           1.1  jruoho         ACPI_EXCEPTION ((AE_INFO, Status,
    312           1.1  jruoho             "Could not acquire Global Lock"));
    313           1.1  jruoho     }
    314           1.1  jruoho 
    315           1.1  jruoho     return_VOID;
    316           1.1  jruoho }
    317           1.1  jruoho 
    318           1.1  jruoho 
    319           1.1  jruoho /*******************************************************************************
    320           1.1  jruoho  *
    321           1.1  jruoho  * FUNCTION:    AcpiExReleaseGlobalLock
    322           1.1  jruoho  *
    323           1.1  jruoho  * PARAMETERS:  FieldFlags            - Flags with Lock rule:
    324           1.1  jruoho  *                                      AlwaysLock or NeverLock
    325           1.1  jruoho  *
    326           1.1  jruoho  * RETURN:      None
    327           1.1  jruoho  *
    328           1.1  jruoho  * DESCRIPTION: Release the ACPI hardware Global Lock
    329           1.1  jruoho  *
    330           1.1  jruoho  ******************************************************************************/
    331           1.1  jruoho 
    332           1.1  jruoho void
    333           1.1  jruoho AcpiExReleaseGlobalLock (
    334           1.1  jruoho     UINT32                  FieldFlags)
    335           1.1  jruoho {
    336           1.1  jruoho     ACPI_STATUS             Status;
    337           1.1  jruoho 
    338           1.1  jruoho 
    339           1.1  jruoho     ACPI_FUNCTION_TRACE (ExReleaseGlobalLock);
    340           1.1  jruoho 
    341           1.1  jruoho 
    342           1.1  jruoho     /* Only use the lock if the AlwaysLock bit is set */
    343           1.1  jruoho 
    344           1.1  jruoho     if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
    345           1.1  jruoho     {
    346           1.1  jruoho         return_VOID;
    347           1.1  jruoho     }
    348           1.1  jruoho 
    349           1.1  jruoho     /* Release the global lock */
    350           1.1  jruoho 
    351           1.1  jruoho     Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
    352           1.1  jruoho     if (ACPI_FAILURE (Status))
    353           1.1  jruoho     {
    354           1.1  jruoho         /* Report the error, but there isn't much else we can do */
    355           1.1  jruoho 
    356           1.1  jruoho         ACPI_EXCEPTION ((AE_INFO, Status,
    357           1.1  jruoho             "Could not release Global Lock"));
    358           1.1  jruoho     }
    359           1.1  jruoho 
    360           1.1  jruoho     return_VOID;
    361           1.1  jruoho }
    362           1.1  jruoho 
    363           1.1  jruoho 
    364           1.1  jruoho /*******************************************************************************
    365           1.1  jruoho  *
    366           1.1  jruoho  * FUNCTION:    AcpiExDigitsNeeded
    367           1.1  jruoho  *
    368           1.1  jruoho  * PARAMETERS:  Value           - Value to be represented
    369           1.1  jruoho  *              Base            - Base of representation
    370           1.1  jruoho  *
    371           1.1  jruoho  * RETURN:      The number of digits.
    372           1.1  jruoho  *
    373           1.1  jruoho  * DESCRIPTION: Calculate the number of digits needed to represent the Value
    374           1.1  jruoho  *              in the given Base (Radix)
    375           1.1  jruoho  *
    376           1.1  jruoho  ******************************************************************************/
    377           1.1  jruoho 
    378           1.1  jruoho static UINT32
    379           1.1  jruoho AcpiExDigitsNeeded (
    380           1.1  jruoho     UINT64                  Value,
    381           1.1  jruoho     UINT32                  Base)
    382           1.1  jruoho {
    383           1.1  jruoho     UINT32                  NumDigits;
    384           1.1  jruoho     UINT64                  CurrentValue;
    385           1.1  jruoho 
    386           1.1  jruoho 
    387           1.1  jruoho     ACPI_FUNCTION_TRACE (ExDigitsNeeded);
    388           1.1  jruoho 
    389           1.1  jruoho 
    390           1.1  jruoho     /* UINT64 is unsigned, so we don't worry about a '-' prefix */
    391           1.1  jruoho 
    392           1.1  jruoho     if (Value == 0)
    393           1.1  jruoho     {
    394           1.1  jruoho         return_UINT32 (1);
    395           1.1  jruoho     }
    396           1.1  jruoho 
    397           1.1  jruoho     CurrentValue = Value;
    398           1.1  jruoho     NumDigits = 0;
    399           1.1  jruoho 
    400           1.1  jruoho     /* Count the digits in the requested base */
    401           1.1  jruoho 
    402           1.1  jruoho     while (CurrentValue)
    403           1.1  jruoho     {
    404           1.1  jruoho         (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL);
    405           1.1  jruoho         NumDigits++;
    406           1.1  jruoho     }
    407           1.1  jruoho 
    408           1.1  jruoho     return_UINT32 (NumDigits);
    409           1.1  jruoho }
    410           1.1  jruoho 
    411           1.1  jruoho 
    412           1.1  jruoho /*******************************************************************************
    413           1.1  jruoho  *
    414           1.1  jruoho  * FUNCTION:    AcpiExEisaIdToString
    415           1.1  jruoho  *
    416           1.1  jruoho  * PARAMETERS:  CompressedId    - EISAID to be converted
    417           1.1  jruoho  *              OutString       - Where to put the converted string (8 bytes)
    418           1.1  jruoho  *
    419           1.1  jruoho  * RETURN:      None
    420           1.1  jruoho  *
    421           1.1  jruoho  * DESCRIPTION: Convert a numeric EISAID to string representation. Return
    422           1.1  jruoho  *              buffer must be large enough to hold the string. The string
    423           1.1  jruoho  *              returned is always exactly of length ACPI_EISAID_STRING_SIZE
    424           1.1  jruoho  *              (includes null terminator). The EISAID is always 32 bits.
    425           1.1  jruoho  *
    426           1.1  jruoho  ******************************************************************************/
    427           1.1  jruoho 
    428           1.1  jruoho void
    429           1.1  jruoho AcpiExEisaIdToString (
    430           1.1  jruoho     char                    *OutString,
    431           1.1  jruoho     UINT64                  CompressedId)
    432           1.1  jruoho {
    433           1.1  jruoho     UINT32                  SwappedId;
    434           1.1  jruoho 
    435           1.1  jruoho 
    436           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    437           1.1  jruoho 
    438           1.1  jruoho 
    439           1.1  jruoho     /* The EISAID should be a 32-bit integer */
    440           1.1  jruoho 
    441           1.1  jruoho     if (CompressedId > ACPI_UINT32_MAX)
    442           1.1  jruoho     {
    443           1.1  jruoho         ACPI_WARNING ((AE_INFO,
    444           1.1  jruoho             "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating",
    445           1.1  jruoho             ACPI_FORMAT_UINT64 (CompressedId)));
    446           1.1  jruoho     }
    447           1.1  jruoho 
    448           1.1  jruoho     /* Swap ID to big-endian to get contiguous bits */
    449           1.1  jruoho 
    450           1.1  jruoho     SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId);
    451           1.1  jruoho 
    452           1.1  jruoho     /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
    453           1.1  jruoho 
    454           1.1  jruoho     OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F));
    455           1.1  jruoho     OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F));
    456           1.1  jruoho     OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F));
    457           1.1  jruoho     OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12);
    458           1.1  jruoho     OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8);
    459           1.1  jruoho     OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4);
    460           1.1  jruoho     OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0);
    461           1.1  jruoho     OutString[7] = 0;
    462           1.1  jruoho }
    463           1.1  jruoho 
    464           1.1  jruoho 
    465           1.1  jruoho /*******************************************************************************
    466           1.1  jruoho  *
    467           1.1  jruoho  * FUNCTION:    AcpiExIntegerToString
    468           1.1  jruoho  *
    469           1.1  jruoho  * PARAMETERS:  OutString       - Where to put the converted string. At least
    470           1.1  jruoho  *                                21 bytes are needed to hold the largest
    471           1.1  jruoho  *                                possible 64-bit integer.
    472           1.1  jruoho  *              Value           - Value to be converted
    473           1.1  jruoho  *
    474           1.1  jruoho  * RETURN:      None, string
    475           1.1  jruoho  *
    476           1.1  jruoho  * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
    477           1.1  jruoho  *              Assumes string buffer is large enough to hold the string. The
    478           1.1  jruoho  *              largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
    479           1.1  jruoho  *
    480           1.1  jruoho  ******************************************************************************/
    481           1.1  jruoho 
    482           1.1  jruoho void
    483           1.1  jruoho AcpiExIntegerToString (
    484           1.1  jruoho     char                    *OutString,
    485           1.1  jruoho     UINT64                  Value)
    486           1.1  jruoho {
    487           1.1  jruoho     UINT32                  Count;
    488           1.1  jruoho     UINT32                  DigitsNeeded;
    489           1.1  jruoho     UINT32                  Remainder;
    490           1.1  jruoho 
    491           1.1  jruoho 
    492           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    493           1.1  jruoho 
    494           1.1  jruoho 
    495           1.1  jruoho     DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
    496           1.1  jruoho     OutString[DigitsNeeded] = 0;
    497           1.1  jruoho 
    498           1.1  jruoho     for (Count = DigitsNeeded; Count > 0; Count--)
    499           1.1  jruoho     {
    500           1.1  jruoho         (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
    501           1.1  jruoho         OutString[Count-1] = (char) ('0' + Remainder);\
    502           1.1  jruoho     }
    503           1.1  jruoho }
    504           1.1  jruoho 
    505  1.1.1.2.20.1     tls 
    506  1.1.1.2.20.1     tls /*******************************************************************************
    507  1.1.1.2.20.1     tls  *
    508  1.1.1.2.20.1     tls  * FUNCTION:    AcpiIsValidSpaceId
    509  1.1.1.2.20.1     tls  *
    510  1.1.1.2.20.1     tls  * PARAMETERS:  SpaceId             - ID to be validated
    511  1.1.1.2.20.1     tls  *
    512  1.1.1.2.20.1     tls  * RETURN:      TRUE if valid/supported ID.
    513  1.1.1.2.20.1     tls  *
    514  1.1.1.2.20.1     tls  * DESCRIPTION: Validate an operation region SpaceID.
    515  1.1.1.2.20.1     tls  *
    516  1.1.1.2.20.1     tls  ******************************************************************************/
    517  1.1.1.2.20.1     tls 
    518  1.1.1.2.20.1     tls BOOLEAN
    519  1.1.1.2.20.1     tls AcpiIsValidSpaceId (
    520  1.1.1.2.20.1     tls     UINT8                   SpaceId)
    521  1.1.1.2.20.1     tls {
    522  1.1.1.2.20.1     tls 
    523  1.1.1.2.20.1     tls     if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) &&
    524  1.1.1.2.20.1     tls         (SpaceId < ACPI_USER_REGION_BEGIN) &&
    525  1.1.1.2.20.1     tls         (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) &&
    526  1.1.1.2.20.1     tls         (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE))
    527  1.1.1.2.20.1     tls     {
    528  1.1.1.2.20.1     tls         return (FALSE);
    529  1.1.1.2.20.1     tls     }
    530  1.1.1.2.20.1     tls 
    531  1.1.1.2.20.1     tls     return (TRUE);
    532  1.1.1.2.20.1     tls }
    533  1.1.1.2.20.1     tls 
    534  1.1.1.2.20.1     tls 
    535           1.1  jruoho #endif
    536