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