1 /****************************************************************************** 2 * 3 * Module Name: utglobal - Global variables for the ACPI subsystem 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2013, 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 DEFINE_ACPI_GLOBALS 46 47 #include <contrib/dev/acpica/include/acpi.h> 48 #include <contrib/dev/acpica/include/accommon.h> 49 50 #define _COMPONENT ACPI_UTILITIES 51 ACPI_MODULE_NAME ("utglobal") 52 53 54 /******************************************************************************* 55 * 56 * Static global variable initialization. 57 * 58 ******************************************************************************/ 59 60 /* 61 * We want the debug switches statically initialized so they 62 * are already set when the debugger is entered. 63 */ 64 65 /* Debug switch - level and trace mask */ 66 67 #ifdef ACPI_DEBUG_OUTPUT 68 UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; 69 #else 70 UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; 71 #endif 72 73 /* Debug switch - layer (component) mask */ 74 75 UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; 76 UINT32 AcpiGbl_NestingLevel = 0; 77 78 /* Debugger globals */ 79 80 BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; 81 BOOLEAN AcpiGbl_AbortMethod = FALSE; 82 BOOLEAN AcpiGbl_MethodExecuting = FALSE; 83 84 /* System flags */ 85 86 UINT32 AcpiGbl_StartupFlags = 0; 87 88 /* System starts uninitialized */ 89 90 BOOLEAN AcpiGbl_Shutdown = TRUE; 91 92 const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = 93 { 94 "\\_S0_", 95 "\\_S1_", 96 "\\_S2_", 97 "\\_S3_", 98 "\\_S4_", 99 "\\_S5_" 100 }; 101 102 const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] = 103 { 104 "_S0W", 105 "_S1W", 106 "_S2W", 107 "_S3W", 108 "_S4W" 109 }; 110 111 const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = 112 { 113 "_S1D", 114 "_S2D", 115 "_S3D", 116 "_S4D" 117 }; 118 119 120 /******************************************************************************* 121 * 122 * Namespace globals 123 * 124 ******************************************************************************/ 125 126 /* 127 * Predefined ACPI Names (Built-in to the Interpreter) 128 * 129 * NOTES: 130 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run 131 * during the initialization sequence. 132 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 133 * perform a Notify() operation on it. 09/2010: Changed to type Device. 134 * This still allows notifies, but does not confuse host code that 135 * searches for valid ThermalZone objects. 136 */ 137 const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = 138 { 139 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 140 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 141 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 142 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 143 {"_TZ_", ACPI_TYPE_DEVICE, NULL}, 144 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, 145 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 146 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, 147 148 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 149 {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 150 #endif 151 152 /* Table terminator */ 153 154 {NULL, ACPI_TYPE_ANY, NULL} 155 }; 156 157 158 #if (!ACPI_REDUCED_HARDWARE) 159 /****************************************************************************** 160 * 161 * Event and Hardware globals 162 * 163 ******************************************************************************/ 164 165 ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = 166 { 167 /* Name Parent Register Register Bit Position Register Bit Mask */ 168 169 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 170 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 171 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 172 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 173 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 174 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 175 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 176 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, 177 178 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 179 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 180 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 181 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 182 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 183 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 184 185 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 186 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 187 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 188 /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE}, 189 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 190 191 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 192 }; 193 194 195 ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = 196 { 197 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 198 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 199 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 200 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 201 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 202 }; 203 #endif /* !ACPI_REDUCED_HARDWARE */ 204 205 206 /******************************************************************************* 207 * 208 * FUNCTION: AcpiUtInitGlobals 209 * 210 * PARAMETERS: None 211 * 212 * RETURN: Status 213 * 214 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific 215 * initialization should be initialized here. This allows for 216 * a warm restart. 217 * 218 ******************************************************************************/ 219 220 ACPI_STATUS 221 AcpiUtInitGlobals ( 222 void) 223 { 224 ACPI_STATUS Status; 225 UINT32 i; 226 227 228 ACPI_FUNCTION_TRACE (UtInitGlobals); 229 230 231 /* Create all memory caches */ 232 233 Status = AcpiUtCreateCaches (); 234 if (ACPI_FAILURE (Status)) 235 { 236 return_ACPI_STATUS (Status); 237 } 238 239 /* Address Range lists */ 240 241 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) 242 { 243 AcpiGbl_AddressRangeList[i] = NULL; 244 } 245 246 /* Mutex locked flags */ 247 248 for (i = 0; i < ACPI_NUM_MUTEX; i++) 249 { 250 AcpiGbl_MutexInfo[i].Mutex = NULL; 251 AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; 252 AcpiGbl_MutexInfo[i].UseCount = 0; 253 } 254 255 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) 256 { 257 AcpiGbl_OwnerIdMask[i] = 0; 258 } 259 260 /* Last OwnerID is never valid */ 261 262 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; 263 264 /* Event counters */ 265 266 AcpiMethodCount = 0; 267 AcpiSciCount = 0; 268 AcpiGpeCount = 0; 269 270 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) 271 { 272 AcpiFixedEventCount[i] = 0; 273 } 274 275 #if (!ACPI_REDUCED_HARDWARE) 276 277 /* GPE/SCI support */ 278 279 AcpiGbl_AllGpesInitialized = FALSE; 280 AcpiGbl_GpeXruptListHead = NULL; 281 AcpiGbl_GpeFadtBlocks[0] = NULL; 282 AcpiGbl_GpeFadtBlocks[1] = NULL; 283 AcpiCurrentGpeCount = 0; 284 285 AcpiGbl_GlobalEventHandler = NULL; 286 AcpiGbl_SciHandlerList = NULL; 287 288 #endif /* !ACPI_REDUCED_HARDWARE */ 289 290 /* Global handlers */ 291 292 AcpiGbl_GlobalNotify[0].Handler = NULL; 293 AcpiGbl_GlobalNotify[1].Handler = NULL; 294 AcpiGbl_ExceptionHandler = NULL; 295 AcpiGbl_InitHandler = NULL; 296 AcpiGbl_TableHandler = NULL; 297 AcpiGbl_InterfaceHandler = NULL; 298 299 /* Global Lock support */ 300 301 AcpiGbl_GlobalLockSemaphore = NULL; 302 AcpiGbl_GlobalLockMutex = NULL; 303 AcpiGbl_GlobalLockAcquired = FALSE; 304 AcpiGbl_GlobalLockHandle = 0; 305 AcpiGbl_GlobalLockPresent = FALSE; 306 307 /* Miscellaneous variables */ 308 309 AcpiGbl_DSDT = NULL; 310 AcpiGbl_CmSingleStep = FALSE; 311 AcpiGbl_DbTerminateThreads = FALSE; 312 AcpiGbl_Shutdown = FALSE; 313 AcpiGbl_NsLookupCount = 0; 314 AcpiGbl_PsFindCount = 0; 315 AcpiGbl_AcpiHardwarePresent = TRUE; 316 AcpiGbl_LastOwnerIdIndex = 0; 317 AcpiGbl_NextOwnerIdOffset = 0; 318 AcpiGbl_TraceMethodName = 0; 319 AcpiGbl_TraceDbgLevel = 0; 320 AcpiGbl_TraceDbgLayer = 0; 321 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; 322 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 323 AcpiGbl_OsiMutex = NULL; 324 AcpiGbl_RegMethodsExecuted = FALSE; 325 326 /* Hardware oriented */ 327 328 AcpiGbl_EventsInitialized = FALSE; 329 AcpiGbl_SystemAwakeAndRunning = TRUE; 330 331 /* Namespace */ 332 333 AcpiGbl_ModuleCodeList = NULL; 334 AcpiGbl_RootNode = NULL; 335 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 336 AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; 337 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; 338 AcpiGbl_RootNodeStruct.Parent = NULL; 339 AcpiGbl_RootNodeStruct.Child = NULL; 340 AcpiGbl_RootNodeStruct.Peer = NULL; 341 AcpiGbl_RootNodeStruct.Object = NULL; 342 343 344 #ifdef ACPI_DISASSEMBLER 345 AcpiGbl_ExternalList = NULL; 346 AcpiGbl_NumExternalMethods = 0; 347 AcpiGbl_ResolvedExternalMethods = 0; 348 #endif 349 350 #ifdef ACPI_DEBUG_OUTPUT 351 AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); 352 #endif 353 354 #ifdef ACPI_DBG_TRACK_ALLOCATIONS 355 AcpiGbl_DisplayFinalMemStats = FALSE; 356 AcpiGbl_DisableMemTracking = FALSE; 357 #endif 358 359 return_ACPI_STATUS (AE_OK); 360 } 361 362 /* Public globals */ 363 364 ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) 365 ACPI_EXPORT_SYMBOL (AcpiDbgLevel) 366 ACPI_EXPORT_SYMBOL (AcpiDbgLayer) 367 ACPI_EXPORT_SYMBOL (AcpiGpeCount) 368 ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount) 369