utglobal.c revision 193251
167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: utglobal - Global variables for the ACPI subsystem 4167802Sjkim * $Revision: 1.249 $ 567754Smsmith * 667754Smsmith *****************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12167802Sjkim * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11777424Smsmith#define __UTGLOBAL_C__ 11867754Smsmith#define DEFINE_ACPI_GLOBALS 11967754Smsmith 120193251Sjkim#include "acpi.h" 121193251Sjkim#include "acnamesp.h" 12267754Smsmith 123167802SjkimACPI_EXPORT_SYMBOL (AcpiGbl_FADT) 124167802Sjkim 12577424Smsmith#define _COMPONENT ACPI_UTILITIES 12691116Smsmith ACPI_MODULE_NAME ("utglobal") 12767754Smsmith 12867754Smsmith 129151937Sjkim/******************************************************************************* 13067754Smsmith * 13167754Smsmith * Static global variable initialization. 13267754Smsmith * 13367754Smsmith ******************************************************************************/ 13467754Smsmith 13567754Smsmith/* 13667754Smsmith * We want the debug switches statically initialized so they 13767754Smsmith * are already set when the debugger is entered. 13867754Smsmith */ 13967754Smsmith 14067754Smsmith/* Debug switch - level and trace mask */ 14167754Smsmith 142102550Siwasaki#ifdef ACPI_DEBUG_OUTPUT 143114237SnjlUINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; 14467754Smsmith#else 145114237SnjlUINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; 14667754Smsmith#endif 14767754Smsmith 14867754Smsmith/* Debug switch - layer (component) mask */ 14967754Smsmith 15077424SmsmithUINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; 15167754SmsmithUINT32 AcpiGbl_NestingLevel = 0; 15267754Smsmith 15367754Smsmith/* Debugger globals */ 15467754Smsmith 15567754SmsmithBOOLEAN AcpiGbl_DbTerminateThreads = FALSE; 156114237SnjlBOOLEAN AcpiGbl_AbortMethod = FALSE; 15767754SmsmithBOOLEAN AcpiGbl_MethodExecuting = FALSE; 15867754Smsmith 15967754Smsmith/* System flags */ 16067754Smsmith 16167754SmsmithUINT32 AcpiGbl_StartupFlags = 0; 16267754Smsmith 16387031Smsmith/* System starts uninitialized */ 16483174Smsmith 16567754SmsmithBOOLEAN AcpiGbl_Shutdown = TRUE; 16667754Smsmith 167129684Snjlconst char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = 168129684Snjl{ 169129684Snjl "\\_S0_", 170129684Snjl "\\_S1_", 171129684Snjl "\\_S2_", 172129684Snjl "\\_S3_", 173129684Snjl "\\_S4_", 174129684Snjl "\\_S5_" 175129684Snjl}; 17669450Smsmith 177129684Snjlconst char *AcpiGbl_HighestDstateNames[4] = 178129684Snjl{ 179129684Snjl "_S1D", 180129684Snjl "_S2D", 181129684Snjl "_S3D", 182129684Snjl "_S4D" 183129684Snjl}; 18469450Smsmith 185167802Sjkim 186167802Sjkim/******************************************************************************* 187167802Sjkim * 188167802Sjkim * FUNCTION: AcpiFormatException 189167802Sjkim * 190167802Sjkim * PARAMETERS: Status - The ACPI_STATUS code to be formatted 191167802Sjkim * 192167802Sjkim * RETURN: A string containing the exception text. A valid pointer is 193167802Sjkim * always returned. 194167802Sjkim * 195167802Sjkim * DESCRIPTION: This function translates an ACPI exception into an ASCII string 196167802Sjkim * It is here instead of utxface.c so it is always present. 197167802Sjkim * 198167802Sjkim ******************************************************************************/ 199167802Sjkim 200167802Sjkimconst char * 201167802SjkimAcpiFormatException ( 202167802Sjkim ACPI_STATUS Status) 203129684Snjl{ 204167802Sjkim const char *Exception = NULL; 205151937Sjkim 206151937Sjkim 207167802Sjkim ACPI_FUNCTION_ENTRY (); 208151937Sjkim 209127175Snjl 210167802Sjkim Exception = AcpiUtValidateException (Status); 211167802Sjkim if (!Exception) 212167802Sjkim { 213167802Sjkim /* Exception code was not recognized */ 214127175Snjl 215167802Sjkim ACPI_ERROR ((AE_INFO, 216167802Sjkim "Unknown exception code: 0x%8.8X", Status)); 217167802Sjkim 218167802Sjkim Exception = "UNKNOWN_STATUS_CODE"; 219167802Sjkim } 220167802Sjkim 221167802Sjkim return (ACPI_CAST_PTR (const char, Exception)); 222167802Sjkim} 223167802Sjkim 224167802SjkimACPI_EXPORT_SYMBOL (AcpiFormatException) 225167802Sjkim 226167802Sjkim 227151937Sjkim/******************************************************************************* 22867754Smsmith * 22967754Smsmith * Namespace globals 23067754Smsmith * 23167754Smsmith ******************************************************************************/ 23267754Smsmith 23367754Smsmith/* 234104470Siwasaki * Predefined ACPI Names (Built-in to the Interpreter) 23567754Smsmith * 23677424Smsmith * NOTES: 237127175Snjl * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run 23877424Smsmith * during the initialization sequence. 239151937Sjkim * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 240151937Sjkim * perform a Notify() operation on it. 24167754Smsmith */ 24291116Smsmithconst ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = 24367754Smsmith{ 244107325Siwasaki {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 245107325Siwasaki {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 24699679Siwasaki {"_SB_", ACPI_TYPE_DEVICE, NULL}, 247107325Siwasaki {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 248129684Snjl {"_TZ_", ACPI_TYPE_THERMAL, NULL}, 249151937Sjkim {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, 25099146Siwasaki {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 251151937Sjkim {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, 252102550Siwasaki 253127175Snjl#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 254151937Sjkim {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 255102550Siwasaki#endif 256151937Sjkim 257151937Sjkim /* Table terminator */ 258151937Sjkim 259151937Sjkim {NULL, ACPI_TYPE_ANY, NULL} 26067754Smsmith}; 26167754Smsmith 26267754Smsmith/* 26367754Smsmith * Properties of the ACPI Object Types, both internal and external. 264104470Siwasaki * The table is indexed by values of ACPI_OBJECT_TYPE 26567754Smsmith */ 26691116Smsmithconst UINT8 AcpiGbl_NsProperties[] = 26767754Smsmith{ 26891116Smsmith ACPI_NS_NORMAL, /* 00 Any */ 26991116Smsmith ACPI_NS_NORMAL, /* 01 Number */ 27091116Smsmith ACPI_NS_NORMAL, /* 02 String */ 27191116Smsmith ACPI_NS_NORMAL, /* 03 Buffer */ 27299146Siwasaki ACPI_NS_NORMAL, /* 04 Package */ 27391116Smsmith ACPI_NS_NORMAL, /* 05 FieldUnit */ 27499146Siwasaki ACPI_NS_NEWSCOPE, /* 06 Device */ 27599146Siwasaki ACPI_NS_NORMAL, /* 07 Event */ 27699146Siwasaki ACPI_NS_NEWSCOPE, /* 08 Method */ 27799146Siwasaki ACPI_NS_NORMAL, /* 09 Mutex */ 27899146Siwasaki ACPI_NS_NORMAL, /* 10 Region */ 27999146Siwasaki ACPI_NS_NEWSCOPE, /* 11 Power */ 28099146Siwasaki ACPI_NS_NEWSCOPE, /* 12 Processor */ 28199146Siwasaki ACPI_NS_NEWSCOPE, /* 13 Thermal */ 28291116Smsmith ACPI_NS_NORMAL, /* 14 BufferField */ 28391116Smsmith ACPI_NS_NORMAL, /* 15 DdbHandle */ 28491116Smsmith ACPI_NS_NORMAL, /* 16 Debug Object */ 28591116Smsmith ACPI_NS_NORMAL, /* 17 DefField */ 28691116Smsmith ACPI_NS_NORMAL, /* 18 BankField */ 28791116Smsmith ACPI_NS_NORMAL, /* 19 IndexField */ 28891116Smsmith ACPI_NS_NORMAL, /* 20 Reference */ 28991116Smsmith ACPI_NS_NORMAL, /* 21 Alias */ 290128212Snjl ACPI_NS_NORMAL, /* 22 MethodAlias */ 291128212Snjl ACPI_NS_NORMAL, /* 23 Notify */ 292128212Snjl ACPI_NS_NORMAL, /* 24 Address Handler */ 293128212Snjl ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 294128212Snjl ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 295128212Snjl ACPI_NS_NEWSCOPE, /* 27 Scope */ 296128212Snjl ACPI_NS_NORMAL, /* 28 Extra */ 297128212Snjl ACPI_NS_NORMAL, /* 29 Data */ 298128212Snjl ACPI_NS_NORMAL /* 30 Invalid */ 29967754Smsmith}; 30067754Smsmith 30167754Smsmith 30271867Smsmith/* Hex to ASCII conversion table */ 30371867Smsmith 304114237Snjlstatic const char AcpiGbl_HexToAscii[] = 305151937Sjkim{ 306151937Sjkim '0','1','2','3','4','5','6','7', 307151937Sjkim '8','9','A','B','C','D','E','F' 308151937Sjkim}; 30971867Smsmith 310151937Sjkim 311151937Sjkim/******************************************************************************* 31283174Smsmith * 31383174Smsmith * FUNCTION: AcpiUtHexToAsciiChar 31483174Smsmith * 31583174Smsmith * PARAMETERS: Integer - Contains the hex digit 31683174Smsmith * Position - bit position of the digit within the 317151937Sjkim * integer (multiple of 4) 31883174Smsmith * 319151937Sjkim * RETURN: The converted Ascii character 32083174Smsmith * 321151937Sjkim * DESCRIPTION: Convert a hex digit to an Ascii character 32283174Smsmith * 323151937Sjkim ******************************************************************************/ 32483174Smsmith 32599679Siwasakichar 32682367SmsmithAcpiUtHexToAsciiChar ( 32782367Smsmith ACPI_INTEGER Integer, 32882367Smsmith UINT32 Position) 32982367Smsmith{ 33071867Smsmith 33182367Smsmith return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); 33282367Smsmith} 33382367Smsmith 33483174Smsmith 33591116Smsmith/****************************************************************************** 33691116Smsmith * 33791116Smsmith * Event and Hardware globals 33891116Smsmith * 33991116Smsmith ******************************************************************************/ 34091116Smsmith 34191116SmsmithACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = 34291116Smsmith{ 34391116Smsmith /* Name Parent Register Register Bit Position Register Bit Mask */ 34491116Smsmith 34591116Smsmith /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 34691116Smsmith /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 34791116Smsmith /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 34891116Smsmith /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 34991116Smsmith /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 35091116Smsmith /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 35191116Smsmith /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 352151937Sjkim /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, 35391116Smsmith 35491116Smsmith /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 35591116Smsmith /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 35691116Smsmith /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 35791116Smsmith /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 35891116Smsmith /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 35991116Smsmith /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, 360151937Sjkim /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 36191116Smsmith 36291116Smsmith /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 36391116Smsmith /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 36491116Smsmith /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 36591116Smsmith /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 36691116Smsmith /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 36791116Smsmith /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 36891116Smsmith 36991116Smsmith /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 37091116Smsmith}; 37191116Smsmith 37291116Smsmith 37391116SmsmithACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = 37491116Smsmith{ 37591116Smsmith /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 37691116Smsmith /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 37791116Smsmith /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 37891116Smsmith /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 379123315Snjl /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 38091116Smsmith}; 38191116Smsmith 382151937Sjkim/******************************************************************************* 38391116Smsmith * 38491116Smsmith * FUNCTION: AcpiUtGetRegionName 38591116Smsmith * 38691116Smsmith * PARAMETERS: None. 38791116Smsmith * 38891116Smsmith * RETURN: Status 38991116Smsmith * 39091116Smsmith * DESCRIPTION: Translate a Space ID into a name string (Debug only) 39191116Smsmith * 392151937Sjkim ******************************************************************************/ 39391116Smsmith 39491116Smsmith/* Region type decoding */ 39591116Smsmith 396114237Snjlconst char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = 39791116Smsmith{ 39891116Smsmith "SystemMemory", 39991116Smsmith "SystemIO", 400100966Siwasaki "PCI_Config", 40191116Smsmith "EmbeddedControl", 40291116Smsmith "SMBus", 40391116Smsmith "CMOS", 404100966Siwasaki "PCIBARTarget", 405114237Snjl "DataTable" 40691116Smsmith}; 40791116Smsmith 40891116Smsmith 409114237Snjlchar * 41091116SmsmithAcpiUtGetRegionName ( 41191116Smsmith UINT8 SpaceId) 41291116Smsmith{ 41391116Smsmith 41491116Smsmith if (SpaceId >= ACPI_USER_REGION_BEGIN) 41591116Smsmith { 41691116Smsmith return ("UserDefinedRegion"); 41791116Smsmith } 41891116Smsmith else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) 41991116Smsmith { 420114237Snjl return ("InvalidSpaceId"); 42191116Smsmith } 42291116Smsmith 423167802Sjkim return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); 42491116Smsmith} 42591116Smsmith 42691116Smsmith 427151937Sjkim/******************************************************************************* 42891116Smsmith * 42991116Smsmith * FUNCTION: AcpiUtGetEventName 43091116Smsmith * 43191116Smsmith * PARAMETERS: None. 43291116Smsmith * 43391116Smsmith * RETURN: Status 43491116Smsmith * 43591116Smsmith * DESCRIPTION: Translate a Event ID into a name string (Debug only) 43691116Smsmith * 437151937Sjkim ******************************************************************************/ 43891116Smsmith 43991116Smsmith/* Event type decoding */ 44091116Smsmith 441114237Snjlstatic const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = 44291116Smsmith{ 44391116Smsmith "PM_Timer", 44491116Smsmith "GlobalLock", 44591116Smsmith "PowerButton", 44691116Smsmith "SleepButton", 44791116Smsmith "RealTimeClock", 44891116Smsmith}; 44991116Smsmith 45091116Smsmith 451114237Snjlchar * 45291116SmsmithAcpiUtGetEventName ( 45391116Smsmith UINT32 EventId) 45491116Smsmith{ 45591116Smsmith 45691116Smsmith if (EventId > ACPI_EVENT_MAX) 45791116Smsmith { 45891116Smsmith return ("InvalidEventID"); 45991116Smsmith } 46091116Smsmith 461167802Sjkim return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); 46291116Smsmith} 46391116Smsmith 46491116Smsmith 465151937Sjkim/******************************************************************************* 46667754Smsmith * 46791116Smsmith * FUNCTION: AcpiUtGetTypeName 46891116Smsmith * 46991116Smsmith * PARAMETERS: None. 47091116Smsmith * 47191116Smsmith * RETURN: Status 47291116Smsmith * 47391116Smsmith * DESCRIPTION: Translate a Type ID into a name string (Debug only) 47491116Smsmith * 475151937Sjkim ******************************************************************************/ 47691116Smsmith 47767754Smsmith/* 47867754Smsmith * Elements of AcpiGbl_NsTypeNames below must match 47967754Smsmith * one-to-one with values of ACPI_OBJECT_TYPE 48067754Smsmith * 481151937Sjkim * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; 482151937Sjkim * when stored in a table it really means that we have thus far seen no 483151937Sjkim * evidence to indicate what type is actually going to be stored for this entry. 48467754Smsmith */ 485114237Snjlstatic const char AcpiGbl_BadType[] = "UNDEFINED"; 48667754Smsmith 487151937Sjkim/* Printable names of the ACPI object types */ 488151937Sjkim 489151937Sjkimstatic const char *AcpiGbl_NsTypeNames[] = 49067754Smsmith{ 49167754Smsmith /* 00 */ "Untyped", 49271867Smsmith /* 01 */ "Integer", 49367754Smsmith /* 02 */ "String", 49467754Smsmith /* 03 */ "Buffer", 49567754Smsmith /* 04 */ "Package", 49667754Smsmith /* 05 */ "FieldUnit", 49767754Smsmith /* 06 */ "Device", 49867754Smsmith /* 07 */ "Event", 49967754Smsmith /* 08 */ "Method", 50067754Smsmith /* 09 */ "Mutex", 50167754Smsmith /* 10 */ "Region", 50267754Smsmith /* 11 */ "Power", 50367754Smsmith /* 12 */ "Processor", 50467754Smsmith /* 13 */ "Thermal", 50585756Smsmith /* 14 */ "BufferField", 50667754Smsmith /* 15 */ "DdbHandle", 50785756Smsmith /* 16 */ "DebugObject", 50885756Smsmith /* 17 */ "RegionField", 50977424Smsmith /* 18 */ "BankField", 51085756Smsmith /* 19 */ "IndexField", 51167754Smsmith /* 20 */ "Reference", 51267754Smsmith /* 21 */ "Alias", 513128212Snjl /* 22 */ "MethodAlias", 514128212Snjl /* 23 */ "Notify", 515128212Snjl /* 24 */ "AddrHandler", 516128212Snjl /* 25 */ "ResourceDesc", 517128212Snjl /* 26 */ "ResourceFld", 518128212Snjl /* 27 */ "Scope", 519128212Snjl /* 28 */ "Extra", 520128212Snjl /* 29 */ "Data", 521128212Snjl /* 30 */ "Invalid" 52267754Smsmith}; 52367754Smsmith 52467754Smsmith 525114237Snjlchar * 52677424SmsmithAcpiUtGetTypeName ( 52791116Smsmith ACPI_OBJECT_TYPE Type) 52867754Smsmith{ 52967754Smsmith 530107325Siwasaki if (Type > ACPI_TYPE_INVALID) 53167754Smsmith { 532167802Sjkim return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); 53367754Smsmith } 53467754Smsmith 535167802Sjkim return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); 53667754Smsmith} 53767754Smsmith 53869746Smsmith 539114237Snjlchar * 54099679SiwasakiAcpiUtGetObjectTypeName ( 54199679Siwasaki ACPI_OPERAND_OBJECT *ObjDesc) 54299679Siwasaki{ 54399679Siwasaki 54499679Siwasaki if (!ObjDesc) 54599679Siwasaki { 54699679Siwasaki return ("[NULL Object Descriptor]"); 54799679Siwasaki } 54899679Siwasaki 54999679Siwasaki return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc))); 55099679Siwasaki} 55199679Siwasaki 55299679Siwasaki 553151937Sjkim/******************************************************************************* 554123315Snjl * 555123315Snjl * FUNCTION: AcpiUtGetNodeName 556123315Snjl * 557123315Snjl * PARAMETERS: Object - A namespace node 558123315Snjl * 559123315Snjl * RETURN: Pointer to a string 560123315Snjl * 561123315Snjl * DESCRIPTION: Validate the node and return the node's ACPI name. 562123315Snjl * 563151937Sjkim ******************************************************************************/ 564123315Snjl 565123315Snjlchar * 566123315SnjlAcpiUtGetNodeName ( 567123315Snjl void *Object) 568123315Snjl{ 569128212Snjl ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; 570123315Snjl 571123315Snjl 572128212Snjl /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 573128212Snjl 574123315Snjl if (!Object) 575123315Snjl { 576128212Snjl return ("NULL"); 577123315Snjl } 578123315Snjl 579128212Snjl /* Check for Root node */ 580123315Snjl 581128212Snjl if ((Object == ACPI_ROOT_OBJECT) || 582128212Snjl (Object == AcpiGbl_RootNode)) 583128212Snjl { 584128212Snjl return ("\"\\\" "); 585128212Snjl } 586128212Snjl 587128212Snjl /* Descriptor must be a namespace node */ 588128212Snjl 589167802Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 590123315Snjl { 591128212Snjl return ("####"); 592123315Snjl } 593123315Snjl 594128212Snjl /* Name must be a valid ACPI name */ 595128212Snjl 596167802Sjkim if (!AcpiUtValidAcpiName (Node->Name.Integer)) 597123315Snjl { 598167802Sjkim Node->Name.Integer = AcpiUtRepairName (Node->Name.Ascii); 599123315Snjl } 600123315Snjl 601128212Snjl /* Return the name */ 602128212Snjl 603123315Snjl return (Node->Name.Ascii); 604123315Snjl} 605123315Snjl 606123315Snjl 607151937Sjkim/******************************************************************************* 608123315Snjl * 609123315Snjl * FUNCTION: AcpiUtGetDescriptorName 610123315Snjl * 611123315Snjl * PARAMETERS: Object - An ACPI object 612123315Snjl * 613123315Snjl * RETURN: Pointer to a string 614123315Snjl * 615123315Snjl * DESCRIPTION: Validate object and return the descriptor type 616123315Snjl * 617151937Sjkim ******************************************************************************/ 618123315Snjl 619151937Sjkim/* Printable names of object descriptor types */ 620151937Sjkim 621151937Sjkimstatic const char *AcpiGbl_DescTypeNames[] = 622123315Snjl{ 623123315Snjl /* 00 */ "Invalid", 624123315Snjl /* 01 */ "Cached", 625123315Snjl /* 02 */ "State-Generic", 626123315Snjl /* 03 */ "State-Update", 627123315Snjl /* 04 */ "State-Package", 628123315Snjl /* 05 */ "State-Control", 629123315Snjl /* 06 */ "State-RootParseScope", 630123315Snjl /* 07 */ "State-ParseScope", 631123315Snjl /* 08 */ "State-WalkScope", 632123315Snjl /* 09 */ "State-Result", 633123315Snjl /* 10 */ "State-Notify", 634123315Snjl /* 11 */ "State-Thread", 635123315Snjl /* 12 */ "Walk", 636123315Snjl /* 13 */ "Parser", 637123315Snjl /* 14 */ "Operand", 638123315Snjl /* 15 */ "Node" 639123315Snjl}; 640123315Snjl 641123315Snjl 642123315Snjlchar * 643123315SnjlAcpiUtGetDescriptorName ( 644123315Snjl void *Object) 645123315Snjl{ 646123315Snjl 647123315Snjl if (!Object) 648123315Snjl { 649123315Snjl return ("NULL OBJECT"); 650123315Snjl } 651123315Snjl 652123315Snjl if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) 653123315Snjl { 654167802Sjkim return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); 655123315Snjl } 656123315Snjl 657167802Sjkim return (ACPI_CAST_PTR (char, 658167802Sjkim AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); 659123315Snjl 660123315Snjl} 661123315Snjl 662123315Snjl 663102550Siwasaki#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 664100966Siwasaki/* 665100966Siwasaki * Strings and procedures used for debug only 666100966Siwasaki */ 66799679Siwasaki 668151937Sjkim/******************************************************************************* 669100966Siwasaki * 670100966Siwasaki * FUNCTION: AcpiUtGetMutexName 671100966Siwasaki * 672151937Sjkim * PARAMETERS: MutexId - The predefined ID for this mutex. 673100966Siwasaki * 674151937Sjkim * RETURN: String containing the name of the mutex. Always returns a valid 675151937Sjkim * pointer. 676100966Siwasaki * 677100966Siwasaki * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 678100966Siwasaki * 679151937Sjkim ******************************************************************************/ 68069746Smsmith 681114237Snjlchar * 682100966SiwasakiAcpiUtGetMutexName ( 683100966Siwasaki UINT32 MutexId) 68469746Smsmith{ 68569746Smsmith 686167802Sjkim if (MutexId > ACPI_MAX_MUTEX) 687100966Siwasaki { 688100966Siwasaki return ("Invalid Mutex ID"); 689100966Siwasaki } 69069746Smsmith 691100966Siwasaki return (AcpiGbl_MutexNames[MutexId]); 692100966Siwasaki} 69367754Smsmith#endif 69467754Smsmith 69567754Smsmith 696151937Sjkim/******************************************************************************* 69767754Smsmith * 69877424Smsmith * FUNCTION: AcpiUtValidObjectType 69967754Smsmith * 700107325Siwasaki * PARAMETERS: Type - Object type to be validated 70167754Smsmith * 702151937Sjkim * RETURN: TRUE if valid object type, FALSE otherwise 70367754Smsmith * 70467754Smsmith * DESCRIPTION: Validate an object type 70567754Smsmith * 706151937Sjkim ******************************************************************************/ 70767754Smsmith 70867754SmsmithBOOLEAN 70977424SmsmithAcpiUtValidObjectType ( 71091116Smsmith ACPI_OBJECT_TYPE Type) 71167754Smsmith{ 71267754Smsmith 713107325Siwasaki if (Type > ACPI_TYPE_LOCAL_MAX) 71467754Smsmith { 715107325Siwasaki /* Note: Assumes all TYPEs are contiguous (external/local) */ 716107325Siwasaki 717107325Siwasaki return (FALSE); 71867754Smsmith } 71967754Smsmith 72067754Smsmith return (TRUE); 72167754Smsmith} 72267754Smsmith 72367754Smsmith 724151937Sjkim/******************************************************************************* 72567754Smsmith * 726151937Sjkim * FUNCTION: AcpiUtInitGlobals 72767754Smsmith * 728151937Sjkim * PARAMETERS: None 72967754Smsmith * 730151937Sjkim * RETURN: None 73167754Smsmith * 73267754Smsmith * DESCRIPTION: Init library globals. All globals that require specific 73367754Smsmith * initialization should be initialized here! 73467754Smsmith * 735151937Sjkim ******************************************************************************/ 73667754Smsmith 73767754Smsmithvoid 73877424SmsmithAcpiUtInitGlobals ( 73967754Smsmith void) 74067754Smsmith{ 741151937Sjkim ACPI_STATUS Status; 74267754Smsmith UINT32 i; 74367754Smsmith 74467754Smsmith 745167802Sjkim ACPI_FUNCTION_TRACE (UtInitGlobals); 74667754Smsmith 747127175Snjl 748151937Sjkim /* Create all memory caches */ 74982367Smsmith 750151937Sjkim Status = AcpiUtCreateCaches (); 751151937Sjkim if (ACPI_FAILURE (Status)) 752151937Sjkim { 753151937Sjkim return; 754151937Sjkim } 75582367Smsmith 75667754Smsmith /* Mutex locked flags */ 75767754Smsmith 758167802Sjkim for (i = 0; i < ACPI_NUM_MUTEX; i++) 75967754Smsmith { 760117521Snjl AcpiGbl_MutexInfo[i].Mutex = NULL; 761151937Sjkim AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; 762117521Snjl AcpiGbl_MutexInfo[i].UseCount = 0; 76367754Smsmith } 76467754Smsmith 765167802Sjkim for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) 766167802Sjkim { 767167802Sjkim AcpiGbl_OwnerIdMask[i] = 0; 768167802Sjkim } 769167802Sjkim AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */ 770167802Sjkim 771114237Snjl /* GPE support */ 772114237Snjl 773167802Sjkim AcpiGpeCount = 0; 774117521Snjl AcpiGbl_GpeXruptListHead = NULL; 775117521Snjl AcpiGbl_GpeFadtBlocks[0] = NULL; 776117521Snjl AcpiGbl_GpeFadtBlocks[1] = NULL; 777114237Snjl 77867754Smsmith /* Global notify handlers */ 77967754Smsmith 780117521Snjl AcpiGbl_SystemNotify.Handler = NULL; 781117521Snjl AcpiGbl_DeviceNotify.Handler = NULL; 782138287Smarks AcpiGbl_ExceptionHandler = NULL; 78399679Siwasaki AcpiGbl_InitHandler = NULL; 78467754Smsmith 78567754Smsmith /* Global Lock support */ 78667754Smsmith 787167802Sjkim AcpiGbl_GlobalLockSemaphore = NULL; 788167802Sjkim AcpiGbl_GlobalLockMutex = NULL; 78967754Smsmith AcpiGbl_GlobalLockAcquired = FALSE; 79091116Smsmith AcpiGbl_GlobalLockHandle = 0; 79167754Smsmith 79267754Smsmith /* Miscellaneous variables */ 79367754Smsmith 79467754Smsmith AcpiGbl_CmSingleStep = FALSE; 79567754Smsmith AcpiGbl_DbTerminateThreads = FALSE; 79667754Smsmith AcpiGbl_Shutdown = FALSE; 79767754Smsmith AcpiGbl_NsLookupCount = 0; 79867754Smsmith AcpiGbl_PsFindCount = 0; 79967754Smsmith AcpiGbl_AcpiHardwarePresent = TRUE; 800167802Sjkim AcpiGbl_LastOwnerIdIndex = 0; 801167802Sjkim AcpiGbl_NextOwnerIdOffset = 0; 802151937Sjkim AcpiGbl_TraceMethodName = 0; 803151937Sjkim AcpiGbl_TraceDbgLevel = 0; 804151937Sjkim AcpiGbl_TraceDbgLayer = 0; 80567754Smsmith AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; 80691116Smsmith AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 80767754Smsmith 80867754Smsmith /* Hardware oriented */ 80967754Smsmith 810104470Siwasaki AcpiGbl_EventsInitialized = FALSE; 811129684Snjl AcpiGbl_SystemAwakeAndRunning = TRUE; 81267754Smsmith 81367754Smsmith /* Namespace */ 81467754Smsmith 81567754Smsmith AcpiGbl_RootNode = NULL; 81699146Siwasaki AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 817167802Sjkim AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; 818107325Siwasaki AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; 81967754Smsmith AcpiGbl_RootNodeStruct.Child = NULL; 82067754Smsmith AcpiGbl_RootNodeStruct.Peer = NULL; 82167754Smsmith AcpiGbl_RootNodeStruct.Object = NULL; 82267754Smsmith AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; 82367754Smsmith 82467754Smsmith 825102550Siwasaki#ifdef ACPI_DEBUG_OUTPUT 82699679Siwasaki AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX; 82783174Smsmith#endif 82883174Smsmith 829167802Sjkim#ifdef ACPI_DBG_TRACK_ALLOCATIONS 830167802Sjkim AcpiGbl_DisplayFinalMemStats = FALSE; 831167802Sjkim#endif 832167802Sjkim 83367754Smsmith return_VOID; 83467754Smsmith} 83567754Smsmith 836167802Sjkim/* Public globals */ 83767754Smsmith 838167802SjkimACPI_EXPORT_SYMBOL (AcpiDbgLevel) 839167802SjkimACPI_EXPORT_SYMBOL (AcpiDbgLayer) 840167802SjkimACPI_EXPORT_SYMBOL (AcpiGpeCount) 841167802Sjkim 842167802Sjkim 843