Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/utglobal.c need to be fixed.

0001 /******************************************************************************
0002  *
0003  * Module Name: utglobal - Global variables for the ACPI subsystem
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights.  You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code.  No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision.  In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change.  Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee.  Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution.  In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government.  In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************/
0115 
0116 #define __UTGLOBAL_C__
0117 #define DEFINE_ACPI_GLOBALS
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acnamesp.h"
0122 
0123 #define _COMPONENT          ACPI_UTILITIES
0124         ACPI_MODULE_NAME    ("utglobal")
0125 
0126 
0127 /*******************************************************************************
0128  *
0129  * Static global variable initialization.
0130  *
0131  ******************************************************************************/
0132 
0133 /*
0134  * We want the debug switches statically initialized so they
0135  * are already set when the debugger is entered.
0136  */
0137 
0138 /* Debug switch - level and trace mask */
0139 
0140 #ifdef ACPI_DEBUG_OUTPUT
0141 UINT32                      AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
0142 #else
0143 UINT32                      AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
0144 #endif
0145 
0146 /* Debug switch - layer (component) mask */
0147 
0148 UINT32                      AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
0149 UINT32                      AcpiGbl_NestingLevel = 0;
0150 
0151 /* Debugger globals */
0152 
0153 BOOLEAN                     AcpiGbl_DbTerminateThreads = FALSE;
0154 BOOLEAN                     AcpiGbl_AbortMethod = FALSE;
0155 BOOLEAN                     AcpiGbl_MethodExecuting = FALSE;
0156 
0157 /* System flags */
0158 
0159 UINT32                      AcpiGbl_StartupFlags = 0;
0160 
0161 /* System starts uninitialized */
0162 
0163 BOOLEAN                     AcpiGbl_Shutdown = TRUE;
0164 
0165 const char                  *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
0166 {
0167     "\\_S0_",
0168     "\\_S1_",
0169     "\\_S2_",
0170     "\\_S3_",
0171     "\\_S4_",
0172     "\\_S5_"
0173 };
0174 
0175 const char                  *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] =
0176 {
0177     "_S0W",
0178     "_S1W",
0179     "_S2W",
0180     "_S3W",
0181     "_S4W"
0182 };
0183 
0184 const char                  *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] =
0185 {
0186     "_S1D",
0187     "_S2D",
0188     "_S3D",
0189     "_S4D"
0190 };
0191 
0192 
0193 /*******************************************************************************
0194  *
0195  * FUNCTION:    AcpiFormatException
0196  *
0197  * PARAMETERS:  Status       - The ACPI_STATUS code to be formatted
0198  *
0199  * RETURN:      A string containing the exception text. A valid pointer is
0200  *              always returned.
0201  *
0202  * DESCRIPTION: This function translates an ACPI exception into an ASCII string
0203  *              It is here instead of utxface.c so it is always present.
0204  *
0205  ******************************************************************************/
0206 
0207 const char *
0208 AcpiFormatException (
0209     ACPI_STATUS             Status)
0210 {
0211     const char              *Exception = NULL;
0212 
0213 
0214     ACPI_FUNCTION_ENTRY ();
0215 
0216 
0217     Exception = AcpiUtValidateException (Status);
0218     if (!Exception)
0219     {
0220         /* Exception code was not recognized */
0221 
0222         ACPI_ERROR ((AE_INFO,
0223             "Unknown exception code: 0x%8.8X", Status));
0224 
0225         Exception = "UNKNOWN_STATUS_CODE";
0226     }
0227 
0228     return (ACPI_CAST_PTR (const char, Exception));
0229 }
0230 
0231 ACPI_EXPORT_SYMBOL (AcpiFormatException)
0232 
0233 
0234 /*******************************************************************************
0235  *
0236  * Namespace globals
0237  *
0238  ******************************************************************************/
0239 
0240 /*
0241  * Predefined ACPI Names (Built-in to the Interpreter)
0242  *
0243  * NOTES:
0244  * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
0245  *    during the initialization sequence.
0246  * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
0247  *    perform a Notify() operation on it.
0248  */
0249 const ACPI_PREDEFINED_NAMES     AcpiGbl_PreDefinedNames[] =
0250 {
0251     {"_GPE",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
0252     {"_PR_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
0253     {"_SB_",    ACPI_TYPE_DEVICE,           NULL},
0254     {"_SI_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
0255     {"_TZ_",    ACPI_TYPE_THERMAL,          NULL},
0256     {"_REV",    ACPI_TYPE_INTEGER,          (char *) ACPI_CA_SUPPORT_LEVEL},
0257     {"_OS_",    ACPI_TYPE_STRING,           ACPI_OS_NAME},
0258     {"_GL_",    ACPI_TYPE_MUTEX,            (char *) 1},
0259 
0260 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
0261     {"_OSI",    ACPI_TYPE_METHOD,           (char *) 1},
0262 #endif
0263 
0264     /* Table terminator */
0265 
0266     {NULL,      ACPI_TYPE_ANY,              NULL}
0267 };
0268 
0269 /*
0270  * Properties of the ACPI Object Types, both internal and external.
0271  * The table is indexed by values of ACPI_OBJECT_TYPE
0272  */
0273 const UINT8                     AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
0274 {
0275     ACPI_NS_NORMAL,                     /* 00 Any              */
0276     ACPI_NS_NORMAL,                     /* 01 Number           */
0277     ACPI_NS_NORMAL,                     /* 02 String           */
0278     ACPI_NS_NORMAL,                     /* 03 Buffer           */
0279     ACPI_NS_NORMAL,                     /* 04 Package          */
0280     ACPI_NS_NORMAL,                     /* 05 FieldUnit        */
0281     ACPI_NS_NEWSCOPE,                   /* 06 Device           */
0282     ACPI_NS_NORMAL,                     /* 07 Event            */
0283     ACPI_NS_NEWSCOPE,                   /* 08 Method           */
0284     ACPI_NS_NORMAL,                     /* 09 Mutex            */
0285     ACPI_NS_NORMAL,                     /* 10 Region           */
0286     ACPI_NS_NEWSCOPE,                   /* 11 Power            */
0287     ACPI_NS_NEWSCOPE,                   /* 12 Processor        */
0288     ACPI_NS_NEWSCOPE,                   /* 13 Thermal          */
0289     ACPI_NS_NORMAL,                     /* 14 BufferField      */
0290     ACPI_NS_NORMAL,                     /* 15 DdbHandle        */
0291     ACPI_NS_NORMAL,                     /* 16 Debug Object     */
0292     ACPI_NS_NORMAL,                     /* 17 DefField         */
0293     ACPI_NS_NORMAL,                     /* 18 BankField        */
0294     ACPI_NS_NORMAL,                     /* 19 IndexField       */
0295     ACPI_NS_NORMAL,                     /* 20 Reference        */
0296     ACPI_NS_NORMAL,                     /* 21 Alias            */
0297     ACPI_NS_NORMAL,                     /* 22 MethodAlias      */
0298     ACPI_NS_NORMAL,                     /* 23 Notify           */
0299     ACPI_NS_NORMAL,                     /* 24 Address Handler  */
0300     ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 25 Resource Desc    */
0301     ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 26 Resource Field   */
0302     ACPI_NS_NEWSCOPE,                   /* 27 Scope            */
0303     ACPI_NS_NORMAL,                     /* 28 Extra            */
0304     ACPI_NS_NORMAL,                     /* 29 Data             */
0305     ACPI_NS_NORMAL                      /* 30 Invalid          */
0306 };
0307 
0308 
0309 /* Hex to ASCII conversion table */
0310 
0311 static const char           AcpiGbl_HexToAscii[] =
0312 {
0313     '0','1','2','3','4','5','6','7',
0314     '8','9','A','B','C','D','E','F'
0315 };
0316 
0317 
0318 /*******************************************************************************
0319  *
0320  * FUNCTION:    AcpiUtHexToAsciiChar
0321  *
0322  * PARAMETERS:  Integer             - Contains the hex digit
0323  *              Position            - bit position of the digit within the
0324  *                                    integer (multiple of 4)
0325  *
0326  * RETURN:      The converted Ascii character
0327  *
0328  * DESCRIPTION: Convert a hex digit to an Ascii character
0329  *
0330  ******************************************************************************/
0331 
0332 char
0333 AcpiUtHexToAsciiChar (
0334     ACPI_INTEGER            Integer,
0335     UINT32                  Position)
0336 {
0337 
0338     return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
0339 }
0340 
0341 
0342 /******************************************************************************
0343  *
0344  * Event and Hardware globals
0345  *
0346  ******************************************************************************/
0347 
0348 ACPI_BIT_REGISTER_INFO      AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
0349 {
0350     /* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
0351 
0352     /* ACPI_BITREG_TIMER_STATUS         */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_TIMER_STATUS,          ACPI_BITMASK_TIMER_STATUS},
0353     /* ACPI_BITREG_BUS_MASTER_STATUS    */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_BUS_MASTER_STATUS,     ACPI_BITMASK_BUS_MASTER_STATUS},
0354     /* ACPI_BITREG_GLOBAL_LOCK_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_STATUS},
0355     /* ACPI_BITREG_POWER_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_STATUS},
0356     /* ACPI_BITREG_SLEEP_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_STATUS},
0357     /* ACPI_BITREG_RT_CLOCK_STATUS      */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_STATUS},
0358     /* ACPI_BITREG_WAKE_STATUS          */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_WAKE_STATUS,           ACPI_BITMASK_WAKE_STATUS},
0359     /* ACPI_BITREG_PCIEXP_WAKE_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,    ACPI_BITMASK_PCIEXP_WAKE_STATUS},
0360 
0361     /* ACPI_BITREG_TIMER_ENABLE         */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_TIMER_ENABLE,          ACPI_BITMASK_TIMER_ENABLE},
0362     /* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
0363     /* ACPI_BITREG_POWER_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_POWER_BUTTON_ENABLE,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
0364     /* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
0365     /* ACPI_BITREG_RT_CLOCK_ENABLE      */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_RT_CLOCK_ENABLE,       ACPI_BITMASK_RT_CLOCK_ENABLE},
0366     /* ACPI_BITREG_PCIEXP_WAKE_DISABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,   ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
0367 
0368     /* ACPI_BITREG_SCI_ENABLE           */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SCI_ENABLE,            ACPI_BITMASK_SCI_ENABLE},
0369     /* ACPI_BITREG_BUS_MASTER_RLD       */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_BUS_MASTER_RLD,        ACPI_BITMASK_BUS_MASTER_RLD},
0370     /* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,   ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
0371     /* ACPI_BITREG_SLEEP_TYPE           */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE,            ACPI_BITMASK_SLEEP_TYPE},
0372     /* ACPI_BITREG_SLEEP_ENABLE         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_ENABLE,          ACPI_BITMASK_SLEEP_ENABLE},
0373 
0374     /* ACPI_BITREG_ARB_DIS              */   {ACPI_REGISTER_PM2_CONTROL,  ACPI_BITPOSITION_ARB_DISABLE,           ACPI_BITMASK_ARB_DISABLE}
0375 };
0376 
0377 
0378 ACPI_FIXED_EVENT_INFO       AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
0379 {
0380     /* ACPI_EVENT_PMTIMER       */  {ACPI_BITREG_TIMER_STATUS,          ACPI_BITREG_TIMER_ENABLE,        ACPI_BITMASK_TIMER_STATUS,          ACPI_BITMASK_TIMER_ENABLE},
0381     /* ACPI_EVENT_GLOBAL        */  {ACPI_BITREG_GLOBAL_LOCK_STATUS,    ACPI_BITREG_GLOBAL_LOCK_ENABLE,  ACPI_BITMASK_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
0382     /* ACPI_EVENT_POWER_BUTTON  */  {ACPI_BITREG_POWER_BUTTON_STATUS,   ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
0383     /* ACPI_EVENT_SLEEP_BUTTON  */  {ACPI_BITREG_SLEEP_BUTTON_STATUS,   ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
0384     /* ACPI_EVENT_RTC           */  {ACPI_BITREG_RT_CLOCK_STATUS,       ACPI_BITREG_RT_CLOCK_ENABLE,     ACPI_BITMASK_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_ENABLE},
0385 };
0386 
0387 /*******************************************************************************
0388  *
0389  * FUNCTION:    AcpiUtGetRegionName
0390  *
0391  * PARAMETERS:  None.
0392  *
0393  * RETURN:      Status
0394  *
0395  * DESCRIPTION: Translate a Space ID into a name string (Debug only)
0396  *
0397  ******************************************************************************/
0398 
0399 /* Region type decoding */
0400 
0401 const char        *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
0402 {
0403     "SystemMemory",
0404     "SystemIO",
0405     "PCI_Config",
0406     "EmbeddedControl",
0407     "SMBus",
0408     "SystemCMOS",
0409     "PCIBARTarget",
0410     "IPMI",
0411     "DataTable"
0412 };
0413 
0414 
0415 char *
0416 AcpiUtGetRegionName (
0417     UINT8                   SpaceId)
0418 {
0419 
0420     if (SpaceId >= ACPI_USER_REGION_BEGIN)
0421     {
0422         return ("UserDefinedRegion");
0423     }
0424     else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
0425     {
0426         return ("InvalidSpaceId");
0427     }
0428 
0429     return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
0430 }
0431 
0432 
0433 /*******************************************************************************
0434  *
0435  * FUNCTION:    AcpiUtGetEventName
0436  *
0437  * PARAMETERS:  None.
0438  *
0439  * RETURN:      Status
0440  *
0441  * DESCRIPTION: Translate a Event ID into a name string (Debug only)
0442  *
0443  ******************************************************************************/
0444 
0445 /* Event type decoding */
0446 
0447 static const char        *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
0448 {
0449     "PM_Timer",
0450     "GlobalLock",
0451     "PowerButton",
0452     "SleepButton",
0453     "RealTimeClock",
0454 };
0455 
0456 
0457 char *
0458 AcpiUtGetEventName (
0459     UINT32                  EventId)
0460 {
0461 
0462     if (EventId > ACPI_EVENT_MAX)
0463     {
0464         return ("InvalidEventID");
0465     }
0466 
0467     return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
0468 }
0469 
0470 
0471 /*******************************************************************************
0472  *
0473  * FUNCTION:    AcpiUtGetTypeName
0474  *
0475  * PARAMETERS:  None.
0476  *
0477  * RETURN:      Status
0478  *
0479  * DESCRIPTION: Translate a Type ID into a name string (Debug only)
0480  *
0481  ******************************************************************************/
0482 
0483 /*
0484  * Elements of AcpiGbl_NsTypeNames below must match
0485  * one-to-one with values of ACPI_OBJECT_TYPE
0486  *
0487  * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
0488  * when stored in a table it really means that we have thus far seen no
0489  * evidence to indicate what type is actually going to be stored for this entry.
0490  */
0491 static const char           AcpiGbl_BadType[] = "UNDEFINED";
0492 
0493 /* Printable names of the ACPI object types */
0494 
0495 static const char           *AcpiGbl_NsTypeNames[] =
0496 {
0497     /* 00 */ "Untyped",
0498     /* 01 */ "Integer",
0499     /* 02 */ "String",
0500     /* 03 */ "Buffer",
0501     /* 04 */ "Package",
0502     /* 05 */ "FieldUnit",
0503     /* 06 */ "Device",
0504     /* 07 */ "Event",
0505     /* 08 */ "Method",
0506     /* 09 */ "Mutex",
0507     /* 10 */ "Region",
0508     /* 11 */ "Power",
0509     /* 12 */ "Processor",
0510     /* 13 */ "Thermal",
0511     /* 14 */ "BufferField",
0512     /* 15 */ "DdbHandle",
0513     /* 16 */ "DebugObject",
0514     /* 17 */ "RegionField",
0515     /* 18 */ "BankField",
0516     /* 19 */ "IndexField",
0517     /* 20 */ "Reference",
0518     /* 21 */ "Alias",
0519     /* 22 */ "MethodAlias",
0520     /* 23 */ "Notify",
0521     /* 24 */ "AddrHandler",
0522     /* 25 */ "ResourceDesc",
0523     /* 26 */ "ResourceFld",
0524     /* 27 */ "Scope",
0525     /* 28 */ "Extra",
0526     /* 29 */ "Data",
0527     /* 30 */ "Invalid"
0528 };
0529 
0530 
0531 char *
0532 AcpiUtGetTypeName (
0533     ACPI_OBJECT_TYPE        Type)
0534 {
0535 
0536     if (Type > ACPI_TYPE_INVALID)
0537     {
0538         return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
0539     }
0540 
0541     return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
0542 }
0543 
0544 
0545 char *
0546 AcpiUtGetObjectTypeName (
0547     ACPI_OPERAND_OBJECT     *ObjDesc)
0548 {
0549 
0550     if (!ObjDesc)
0551     {
0552         return ("[NULL Object Descriptor]");
0553     }
0554 
0555     return (AcpiUtGetTypeName (ObjDesc->Common.Type));
0556 }
0557 
0558 
0559 /*******************************************************************************
0560  *
0561  * FUNCTION:    AcpiUtGetNodeName
0562  *
0563  * PARAMETERS:  Object               - A namespace node
0564  *
0565  * RETURN:      Pointer to a string
0566  *
0567  * DESCRIPTION: Validate the node and return the node's ACPI name.
0568  *
0569  ******************************************************************************/
0570 
0571 char *
0572 AcpiUtGetNodeName (
0573     void                    *Object)
0574 {
0575     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) Object;
0576 
0577 
0578     /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
0579 
0580     if (!Object)
0581     {
0582         return ("NULL");
0583     }
0584 
0585     /* Check for Root node */
0586 
0587     if ((Object == ACPI_ROOT_OBJECT) ||
0588         (Object == AcpiGbl_RootNode))
0589     {
0590         return ("\"\\\" ");
0591     }
0592 
0593     /* Descriptor must be a namespace node */
0594 
0595     if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
0596     {
0597         return ("####");
0598     }
0599 
0600     /*
0601      * Ensure name is valid. The name was validated/repaired when the node
0602      * was created, but make sure it has not been corrupted.
0603      */
0604     AcpiUtRepairName (Node->Name.Ascii);
0605 
0606     /* Return the name */
0607 
0608     return (Node->Name.Ascii);
0609 }
0610 
0611 
0612 /*******************************************************************************
0613  *
0614  * FUNCTION:    AcpiUtGetDescriptorName
0615  *
0616  * PARAMETERS:  Object               - An ACPI object
0617  *
0618  * RETURN:      Pointer to a string
0619  *
0620  * DESCRIPTION: Validate object and return the descriptor type
0621  *
0622  ******************************************************************************/
0623 
0624 /* Printable names of object descriptor types */
0625 
0626 static const char           *AcpiGbl_DescTypeNames[] =
0627 {
0628     /* 00 */ "Invalid",
0629     /* 01 */ "Cached",
0630     /* 02 */ "State-Generic",
0631     /* 03 */ "State-Update",
0632     /* 04 */ "State-Package",
0633     /* 05 */ "State-Control",
0634     /* 06 */ "State-RootParseScope",
0635     /* 07 */ "State-ParseScope",
0636     /* 08 */ "State-WalkScope",
0637     /* 09 */ "State-Result",
0638     /* 10 */ "State-Notify",
0639     /* 11 */ "State-Thread",
0640     /* 12 */ "Walk",
0641     /* 13 */ "Parser",
0642     /* 14 */ "Operand",
0643     /* 15 */ "Node"
0644 };
0645 
0646 
0647 char *
0648 AcpiUtGetDescriptorName (
0649     void                    *Object)
0650 {
0651 
0652     if (!Object)
0653     {
0654         return ("NULL OBJECT");
0655     }
0656 
0657     if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
0658     {
0659         return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
0660     }
0661 
0662     return (ACPI_CAST_PTR (char,
0663         AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
0664 
0665 }
0666 
0667 
0668 /*******************************************************************************
0669  *
0670  * FUNCTION:    AcpiUtGetReferenceName
0671  *
0672  * PARAMETERS:  Object               - An ACPI reference object
0673  *
0674  * RETURN:      Pointer to a string
0675  *
0676  * DESCRIPTION: Decode a reference object sub-type to a string.
0677  *
0678  ******************************************************************************/
0679 
0680 /* Printable names of reference object sub-types */
0681 
0682 static const char           *AcpiGbl_RefClassNames[] =
0683 {
0684     /* 00 */ "Local",
0685     /* 01 */ "Argument",
0686     /* 02 */ "RefOf",
0687     /* 03 */ "Index",
0688     /* 04 */ "DdbHandle",
0689     /* 05 */ "Named Object",
0690     /* 06 */ "Debug"
0691 };
0692 
0693 const char *
0694 AcpiUtGetReferenceName (
0695     ACPI_OPERAND_OBJECT     *Object)
0696 {
0697 
0698     if (!Object)
0699     {
0700         return ("NULL Object");
0701     }
0702 
0703     if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
0704     {
0705         return ("Not an Operand object");
0706     }
0707 
0708     if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
0709     {
0710         return ("Not a Reference object");
0711     }
0712 
0713     if (Object->Reference.Class > ACPI_REFCLASS_MAX)
0714     {
0715         return ("Unknown Reference class");
0716     }
0717 
0718     return (AcpiGbl_RefClassNames[Object->Reference.Class]);
0719 }
0720 
0721 
0722 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
0723 /*
0724  * Strings and procedures used for debug only
0725  */
0726 
0727 /*******************************************************************************
0728  *
0729  * FUNCTION:    AcpiUtGetMutexName
0730  *
0731  * PARAMETERS:  MutexId         - The predefined ID for this mutex.
0732  *
0733  * RETURN:      String containing the name of the mutex. Always returns a valid
0734  *              pointer.
0735  *
0736  * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
0737  *
0738  ******************************************************************************/
0739 
0740 char *
0741 AcpiUtGetMutexName (
0742     UINT32                  MutexId)
0743 {
0744 
0745     if (MutexId > ACPI_MAX_MUTEX)
0746     {
0747         return ("Invalid Mutex ID");
0748     }
0749 
0750     return (AcpiGbl_MutexNames[MutexId]);
0751 }
0752 
0753 
0754 /*******************************************************************************
0755  *
0756  * FUNCTION:    AcpiUtGetNotifyName
0757  *
0758  * PARAMETERS:  NotifyValue     - Value from the Notify() request
0759  *
0760  * RETURN:      String corresponding to the Notify Value.
0761  *
0762  * DESCRIPTION: Translate a Notify Value to a notify namestring.
0763  *
0764  ******************************************************************************/
0765 
0766 /* Names for Notify() values, used for debug output */
0767 
0768 static const char        *AcpiGbl_NotifyValueNames[] =
0769 {
0770     "Bus Check",
0771     "Device Check",
0772     "Device Wake",
0773     "Eject Request",
0774     "Device Check Light",
0775     "Frequency Mismatch",
0776     "Bus Mode Mismatch",
0777     "Power Fault",
0778     "Capabilities Check",
0779     "Device PLD Check",
0780     "Reserved",
0781     "System Locality Update"
0782 };
0783 
0784 const char *
0785 AcpiUtGetNotifyName (
0786     UINT32                  NotifyValue)
0787 {
0788 
0789     if (NotifyValue <= ACPI_NOTIFY_MAX)
0790     {
0791         return (AcpiGbl_NotifyValueNames[NotifyValue]);
0792     }
0793     else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
0794     {
0795         return ("Reserved");
0796     }
0797     else /* Greater or equal to 0x80 */
0798     {
0799         return ("**Device Specific**");
0800     }
0801 }
0802 #endif
0803 
0804 
0805 /*******************************************************************************
0806  *
0807  * FUNCTION:    AcpiUtValidObjectType
0808  *
0809  * PARAMETERS:  Type            - Object type to be validated
0810  *
0811  * RETURN:      TRUE if valid object type, FALSE otherwise
0812  *
0813  * DESCRIPTION: Validate an object type
0814  *
0815  ******************************************************************************/
0816 
0817 BOOLEAN
0818 AcpiUtValidObjectType (
0819     ACPI_OBJECT_TYPE        Type)
0820 {
0821 
0822     if (Type > ACPI_TYPE_LOCAL_MAX)
0823     {
0824         /* Note: Assumes all TYPEs are contiguous (external/local) */
0825 
0826         return (FALSE);
0827     }
0828 
0829     return (TRUE);
0830 }
0831 
0832 
0833 /*******************************************************************************
0834  *
0835  * FUNCTION:    AcpiUtInitGlobals
0836  *
0837  * PARAMETERS:  None
0838  *
0839  * RETURN:      Status
0840  *
0841  * DESCRIPTION: Init library globals.  All globals that require specific
0842  *              initialization should be initialized here!
0843  *
0844  ******************************************************************************/
0845 
0846 ACPI_STATUS
0847 AcpiUtInitGlobals (
0848     void)
0849 {
0850     ACPI_STATUS             Status;
0851     UINT32                  i;
0852 
0853 
0854     ACPI_FUNCTION_TRACE (UtInitGlobals);
0855 
0856 
0857     /* Create all memory caches */
0858 
0859     Status = AcpiUtCreateCaches ();
0860     if (ACPI_FAILURE (Status))
0861     {
0862         return_ACPI_STATUS (Status);
0863     }
0864 
0865     /* Mutex locked flags */
0866 
0867     for (i = 0; i < ACPI_NUM_MUTEX; i++)
0868     {
0869         AcpiGbl_MutexInfo[i].Mutex          = NULL;
0870         AcpiGbl_MutexInfo[i].ThreadId       = ACPI_MUTEX_NOT_ACQUIRED;
0871         AcpiGbl_MutexInfo[i].UseCount       = 0;
0872     }
0873 
0874     for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
0875     {
0876         AcpiGbl_OwnerIdMask[i]              = 0;
0877     }
0878 
0879     /* Last OwnerID is never valid */
0880 
0881     AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
0882 
0883     /* Event counters */
0884 
0885     AcpiMethodCount                     = 0;
0886     AcpiSciCount                        = 0;
0887     AcpiGpeCount                        = 0;
0888 
0889     for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
0890     {
0891         AcpiFixedEventCount[i]              = 0;
0892     }
0893 
0894     /* GPE support */
0895 
0896     AcpiGbl_GpeXruptListHead            = NULL;
0897     AcpiGbl_GpeFadtBlocks[0]            = NULL;
0898     AcpiGbl_GpeFadtBlocks[1]            = NULL;
0899     AcpiCurrentGpeCount                 = 0;
0900 
0901     /* Global handlers */
0902 
0903     AcpiGbl_SystemNotify.Handler        = NULL;
0904     AcpiGbl_DeviceNotify.Handler        = NULL;
0905     AcpiGbl_ExceptionHandler            = NULL;
0906     AcpiGbl_InitHandler                 = NULL;
0907     AcpiGbl_TableHandler                = NULL;
0908 
0909     /* Global Lock support */
0910 
0911     AcpiGbl_GlobalLockSemaphore         = NULL;
0912     AcpiGbl_GlobalLockMutex             = NULL;
0913     AcpiGbl_GlobalLockAcquired          = FALSE;
0914     AcpiGbl_GlobalLockHandle            = 0;
0915     AcpiGbl_GlobalLockPresent           = FALSE;
0916 
0917     /* Miscellaneous variables */
0918 
0919     AcpiGbl_CmSingleStep                = FALSE;
0920     AcpiGbl_DbTerminateThreads          = FALSE;
0921     AcpiGbl_Shutdown                    = FALSE;
0922     AcpiGbl_NsLookupCount               = 0;
0923     AcpiGbl_PsFindCount                 = 0;
0924     AcpiGbl_AcpiHardwarePresent         = TRUE;
0925     AcpiGbl_LastOwnerIdIndex            = 0;
0926     AcpiGbl_NextOwnerIdOffset           = 0;
0927     AcpiGbl_TraceMethodName             = 0;
0928     AcpiGbl_TraceDbgLevel               = 0;
0929     AcpiGbl_TraceDbgLayer               = 0;
0930     AcpiGbl_DebuggerConfiguration       = DEBUGGER_THREADING;
0931     AcpiGbl_DbOutputFlags               = ACPI_DB_CONSOLE_OUTPUT;
0932     AcpiGbl_OsiData                     = 0;
0933 
0934     /* Hardware oriented */
0935 
0936     AcpiGbl_EventsInitialized           = FALSE;
0937     AcpiGbl_SystemAwakeAndRunning       = TRUE;
0938 
0939     /* Namespace */
0940 
0941     AcpiGbl_RootNode                    = NULL;
0942     AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
0943     AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
0944     AcpiGbl_RootNodeStruct.Type         = ACPI_TYPE_DEVICE;
0945     AcpiGbl_RootNodeStruct.Child        = NULL;
0946     AcpiGbl_RootNodeStruct.Peer         = NULL;
0947     AcpiGbl_RootNodeStruct.Object       = NULL;
0948     AcpiGbl_RootNodeStruct.Flags        = ANOBJ_END_OF_PEER_LIST;
0949 
0950 
0951 #ifdef ACPI_DEBUG_OUTPUT
0952     AcpiGbl_LowestStackPointer          = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX);
0953 #endif
0954 
0955 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
0956     AcpiGbl_DisplayFinalMemStats        = FALSE;
0957 #endif
0958 
0959     return_ACPI_STATUS (AE_OK);
0960 }
0961 
0962 /* Public globals */
0963 
0964 ACPI_EXPORT_SYMBOL (AcpiGbl_FADT)
0965 ACPI_EXPORT_SYMBOL (AcpiDbgLevel)
0966 ACPI_EXPORT_SYMBOL (AcpiDbgLayer)
0967 ACPI_EXPORT_SYMBOL (AcpiGpeCount)
0968 ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount)
0969 
0970