1 /****************************************************************************** 2 * 3 * Module Name: utglobal - Global variables for the ACPI subsystem 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2014, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #define __UTGLOBAL_C__ 45 #define EXPORT_ACPI_INTERFACES 46 #define DEFINE_ACPI_GLOBALS 47 48 #include "acpi.h" 49 #include "accommon.h" 50 51 #define _COMPONENT ACPI_UTILITIES 52 ACPI_MODULE_NAME ("utglobal") 53 54 55 /******************************************************************************* 56 * 57 * Static global variable initialization. 58 * 59 ******************************************************************************/ 60 61 /* Debug output control masks */ 62 63 #ifdef ACPI_DEBUG_OUTPUT 64 UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; 65 #else 66 UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; 67 #endif 68 69 UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; 70 71 /* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ 72 73 ACPI_TABLE_FADT AcpiGbl_FADT; 74 UINT32 AcpiGbl_TraceFlags; 75 ACPI_NAME AcpiGbl_TraceMethodName; 76 BOOLEAN AcpiGbl_SystemAwakeAndRunning; 77 UINT32 AcpiCurrentGpeCount; 78 79 /* 80 * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning 81 * that the ACPI hardware is no longer required. A flag in the FADT indicates 82 * a reduced HW machine, and that flag is duplicated here for convenience. 83 */ 84 BOOLEAN AcpiGbl_ReducedHardware; 85 86 /* Various state name strings */ 87 88 const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = 89 { 90 "\\_S0_", 91 "\\_S1_", 92 "\\_S2_", 93 "\\_S3_", 94 "\\_S4_", 95 "\\_S5_" 96 }; 97 98 const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] = 99 { 100 "_S0W", 101 "_S1W", 102 "_S2W", 103 "_S3W", 104 "_S4W" 105 }; 106 107 const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = 108 { 109 "_S1D", 110 "_S2D", 111 "_S3D", 112 "_S4D" 113 }; 114 115 116 /******************************************************************************* 117 * 118 * Namespace globals 119 * 120 ******************************************************************************/ 121 122 /* 123 * Predefined ACPI Names (Built-in to the Interpreter) 124 * 125 * NOTES: 126 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run 127 * during the initialization sequence. 128 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 129 * perform a Notify() operation on it. 09/2010: Changed to type Device. 130 * This still allows notifies, but does not confuse host code that 131 * searches for valid ThermalZone objects. 132 */ 133 const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = 134 { 135 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 136 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 137 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 138 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 139 {"_TZ_", ACPI_TYPE_DEVICE, NULL}, 140 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, 141 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 142 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, 143 144 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 145 {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 146 #endif 147 148 /* Table terminator */ 149 150 {NULL, ACPI_TYPE_ANY, NULL} 151 }; 152 153 154 #if (!ACPI_REDUCED_HARDWARE) 155 /****************************************************************************** 156 * 157 * Event and Hardware globals 158 * 159 ******************************************************************************/ 160 161 ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = 162 { 163 /* Name Parent Register Register Bit Position Register Bit Mask */ 164 165 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 166 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 167 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 168 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 169 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 170 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 171 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 172 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, 173 174 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 175 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 176 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 177 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 178 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 179 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 180 181 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 182 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 183 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 184 /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, 185 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 186 187 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 188 }; 189 190 191 ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = 192 { 193 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 194 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 195 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 196 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 197 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 198 }; 199 #endif /* !ACPI_REDUCED_HARDWARE */ 200 201 202 /******************************************************************************* 203 * 204 * FUNCTION: AcpiUtInitGlobals 205 * 206 * PARAMETERS: None 207 * 208 * RETURN: Status 209 * 210 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific 211 * initialization should be initialized here. This allows for 212 * a warm restart. 213 * 214 ******************************************************************************/ 215 216 ACPI_STATUS 217 AcpiUtInitGlobals ( 218 void) 219 { 220 ACPI_STATUS Status; 221 UINT32 i; 222 223 224 ACPI_FUNCTION_TRACE (UtInitGlobals); 225 226 227 /* Create all memory caches */ 228 229 Status = AcpiUtCreateCaches (); 230 if (ACPI_FAILURE (Status)) 231 { 232 return_ACPI_STATUS (Status); 233 } 234 235 /* Address Range lists */ 236 237 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) 238 { 239 AcpiGbl_AddressRangeList[i] = NULL; 240 } 241 242 /* Mutex locked flags */ 243 244 for (i = 0; i < ACPI_NUM_MUTEX; i++) 245 { 246 AcpiGbl_MutexInfo[i].Mutex = NULL; 247 AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; 248 AcpiGbl_MutexInfo[i].UseCount = 0; 249 } 250 251 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) 252 { 253 AcpiGbl_OwnerIdMask[i] = 0; 254 } 255 256 /* Last OwnerID is never valid */ 257 258 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; 259 260 /* Event counters */ 261 262 AcpiMethodCount = 0; 263 AcpiSciCount = 0; 264 AcpiGpeCount = 0; 265 266 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) 267 { 268 AcpiFixedEventCount[i] = 0; 269 } 270 271 #if (!ACPI_REDUCED_HARDWARE) 272 273 /* GPE/SCI support */ 274 275 AcpiGbl_AllGpesInitialized = FALSE; 276 AcpiGbl_GpeXruptListHead = NULL; 277 AcpiGbl_GpeFadtBlocks[0] = NULL; 278 AcpiGbl_GpeFadtBlocks[1] = NULL; 279 AcpiCurrentGpeCount = 0; 280 281 AcpiGbl_GlobalEventHandler = NULL; 282 AcpiGbl_SciHandlerList = NULL; 283 284 #endif /* !ACPI_REDUCED_HARDWARE */ 285 286 /* Global handlers */ 287 288 AcpiGbl_GlobalNotify[0].Handler = NULL; 289 AcpiGbl_GlobalNotify[1].Handler = NULL; 290 AcpiGbl_ExceptionHandler = NULL; 291 AcpiGbl_InitHandler = NULL; 292 AcpiGbl_TableHandler = NULL; 293 AcpiGbl_InterfaceHandler = NULL; 294 295 /* Global Lock support */ 296 297 AcpiGbl_GlobalLockSemaphore = NULL; 298 AcpiGbl_GlobalLockMutex = NULL; 299 AcpiGbl_GlobalLockAcquired = FALSE; 300 AcpiGbl_GlobalLockHandle = 0; 301 AcpiGbl_GlobalLockPresent = FALSE; 302 303 /* Miscellaneous variables */ 304 305 AcpiGbl_DSDT = NULL; 306 AcpiGbl_CmSingleStep = FALSE; 307 AcpiGbl_Shutdown = FALSE; 308 AcpiGbl_NsLookupCount = 0; 309 AcpiGbl_PsFindCount = 0; 310 AcpiGbl_AcpiHardwarePresent = TRUE; 311 AcpiGbl_LastOwnerIdIndex = 0; 312 AcpiGbl_NextOwnerIdOffset = 0; 313 AcpiGbl_TraceMethodName = 0; 314 AcpiGbl_TraceDbgLevel = 0; 315 AcpiGbl_TraceDbgLayer = 0; 316 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; 317 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 318 AcpiGbl_OsiMutex = NULL; 319 AcpiGbl_RegMethodsExecuted = FALSE; 320 321 /* Hardware oriented */ 322 323 AcpiGbl_EventsInitialized = FALSE; 324 AcpiGbl_SystemAwakeAndRunning = TRUE; 325 326 /* Namespace */ 327 328 AcpiGbl_ModuleCodeList = NULL; 329 AcpiGbl_RootNode = NULL; 330 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 331 AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; 332 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; 333 AcpiGbl_RootNodeStruct.Parent = NULL; 334 AcpiGbl_RootNodeStruct.Child = NULL; 335 AcpiGbl_RootNodeStruct.Peer = NULL; 336 AcpiGbl_RootNodeStruct.Object = NULL; 337 338 339 #ifdef ACPI_DISASSEMBLER 340 AcpiGbl_ExternalList = NULL; 341 AcpiGbl_NumExternalMethods = 0; 342 AcpiGbl_ResolvedExternalMethods = 0; 343 #endif 344 345 #ifdef ACPI_DEBUG_OUTPUT 346 AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); 347 #endif 348 349 #ifdef ACPI_DBG_TRACK_ALLOCATIONS 350 AcpiGbl_DisplayFinalMemStats = FALSE; 351 AcpiGbl_DisableMemTracking = FALSE; 352 #endif 353 354 #ifdef ACPI_DEBUGGER 355 AcpiGbl_DbTerminateThreads = FALSE; 356 #endif 357 358 return_ACPI_STATUS (AE_OK); 359 } 360 361 /* Public globals */ 362 363 ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) 364 ACPI_EXPORT_SYMBOL (AcpiDbgLevel) 365 ACPI_EXPORT_SYMBOL (AcpiDbgLayer) 366 ACPI_EXPORT_SYMBOL (AcpiGpeCount) 367 ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) 368