diff options
Diffstat (limited to 'sys/contrib/dev/acpica/utglobal.c')
-rw-r--r-- | sys/contrib/dev/acpica/utglobal.c | 260 |
1 files changed, 100 insertions, 160 deletions
diff --git a/sys/contrib/dev/acpica/utglobal.c b/sys/contrib/dev/acpica/utglobal.c index 35215c27..03321fd 100644 --- a/sys/contrib/dev/acpica/utglobal.c +++ b/sys/contrib/dev/acpica/utglobal.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,13 +124,14 @@ ACPI_MODULE_NAME ("utglobal") -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiFormatException * * PARAMETERS: Status - The ACPI_STATUS code to be formatted * - * RETURN: A string containing the exception text + * RETURN: A string containing the exception text. A valid pointer is + * always returned. * * DESCRIPTION: This function translates an ACPI exception into an ASCII string. * @@ -140,8 +141,8 @@ const char * AcpiFormatException ( ACPI_STATUS Status) { - const char *Exception = "UNKNOWN_STATUS_CODE"; ACPI_STATUS SubStatus; + const char *Exception = NULL; ACPI_FUNCTION_NAME ("FormatException"); @@ -156,61 +157,60 @@ AcpiFormatException ( if (SubStatus <= AE_CODE_ENV_MAX) { Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; - break; } - goto Unknown; + break; case AE_CODE_PROGRAMMER: if (SubStatus <= AE_CODE_PGM_MAX) { Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_ACPI_TABLES: if (SubStatus <= AE_CODE_TBL_MAX) { Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_AML: if (SubStatus <= AE_CODE_AML_MAX) { Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_CONTROL: if (SubStatus <= AE_CODE_CTRL_MAX) { Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; - break; } - goto Unknown; + break; default: - goto Unknown; + break; } + if (!Exception) + { + /* Exception code was not recognized */ - return ((const char *) Exception); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown exception code: 0x%8.8X\n", Status)); -Unknown: + return ((const char *) "UNKNOWN_STATUS_CODE"); + } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status)); return ((const char *) Exception); } -/****************************************************************************** +/******************************************************************************* * * Static global variable initialization. * @@ -275,6 +275,8 @@ const char *AcpiGbl_HighestDstateNames[4] = */ const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = { + /* Operating System Vendor Strings */ + "Linux", "Windows 2000", "Windows 2001", @@ -283,23 +285,28 @@ const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = "Windows 2001 SP1", "Windows 2001 SP2", "Windows 2001 SP3", - "Windows 2001 SP4" + "Windows 2001 SP4", + + /* Feature Group Strings */ + + "Extended Address Space Descriptor" }; -/****************************************************************************** +/******************************************************************************* * * Namespace globals * ******************************************************************************/ - /* * Predefined ACPI Names (Built-in to the Interpreter) * * NOTES: * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run * during the initialization sequence. + * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to + * perform a Notify() operation on it. */ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = { @@ -308,16 +315,18 @@ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = {"_SB_", ACPI_TYPE_DEVICE, NULL}, {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_TZ_", ACPI_TYPE_THERMAL, NULL}, - {"_REV", ACPI_TYPE_INTEGER, "2"}, + {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, "0"}, + {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - {"_OSI", ACPI_TYPE_METHOD, "1"}, + {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, #endif - {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */ -}; + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY, NULL} +}; /* * Properties of the ACPI Object Types, both internal and external. @@ -362,22 +371,25 @@ const UINT8 AcpiGbl_NsProperties[] = /* Hex to ASCII conversion table */ static const char AcpiGbl_HexToAscii[] = - {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; +{ + '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' +}; + -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtHexToAsciiChar * * PARAMETERS: Integer - Contains the hex digit * Position - bit position of the digit within the - * integer + * integer (multiple of 4) * - * RETURN: Ascii character + * RETURN: The converted Ascii character * - * DESCRIPTION: Convert a hex digit to an ascii character + * DESCRIPTION: Convert a hex digit to an Ascii character * - ****************************************************************************/ + ******************************************************************************/ char AcpiUtHexToAsciiChar ( @@ -389,7 +401,7 @@ AcpiUtHexToAsciiChar ( } -/****************************************************************************** +/******************************************************************************* * * Table name globals * @@ -398,7 +410,7 @@ AcpiUtHexToAsciiChar ( * that are not used by the subsystem are simply ignored. * * Do NOT add any table to this list that is not consumed directly by this - * subsystem. + * subsystem (No MADT, ECDT, SBST, etc.) * ******************************************************************************/ @@ -435,6 +447,7 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, @@ -442,6 +455,7 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, @@ -463,7 +477,7 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, }; -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetRegionName * @@ -473,7 +487,7 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = * * DESCRIPTION: Translate a Space ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* Region type decoding */ @@ -501,7 +515,6 @@ AcpiUtGetRegionName ( { return ("UserDefinedRegion"); } - else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) { return ("InvalidSpaceId"); @@ -511,7 +524,7 @@ AcpiUtGetRegionName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetEventName * @@ -521,17 +534,19 @@ AcpiUtGetRegionName ( * * DESCRIPTION: Translate a Event ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* Event type decoding */ static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = { +/*! [Begin] no source code translation (keep these strings as-is) */ "PM_Timer", "GlobalLock", "PowerButton", "SleepButton", "RealTimeClock", +/*! [End] no source code translation !*/ }; @@ -549,7 +564,7 @@ AcpiUtGetEventName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetTypeName * @@ -559,21 +574,23 @@ AcpiUtGetEventName ( * * DESCRIPTION: Translate a Type ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* * Elements of AcpiGbl_NsTypeNames below must match * one-to-one with values of ACPI_OBJECT_TYPE * - * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when - * stored in a table it really means that we have thus far seen no evidence to - * indicate what type is actually going to be stored for this entry. + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; + * when stored in a table it really means that we have thus far seen no + * evidence to indicate what type is actually going to be stored for this entry. */ static const char AcpiGbl_BadType[] = "UNDEFINED"; -#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */ -static const char *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ +/* Printable names of the ACPI object types */ + +static const char *AcpiGbl_NsTypeNames[] = { +/*! [Begin] no source code translation (keep these strings as-is) */ /* 00 */ "Untyped", /* 01 */ "Integer", /* 02 */ "String", @@ -605,6 +622,7 @@ static const char *AcpiGbl_NsTypeNames[] = /* printable names of AC /* 28 */ "Extra", /* 29 */ "Data", /* 30 */ "Invalid" +/*! [End] no source code translation !*/ }; @@ -636,7 +654,7 @@ AcpiUtGetObjectTypeName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetNodeName * @@ -646,7 +664,7 @@ AcpiUtGetObjectTypeName ( * * DESCRIPTION: Validate the node and return the node's ACPI name. * - ****************************************************************************/ + ******************************************************************************/ char * AcpiUtGetNodeName ( @@ -690,7 +708,7 @@ AcpiUtGetNodeName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetDescriptorName * @@ -700,10 +718,13 @@ AcpiUtGetNodeName ( * * DESCRIPTION: Validate object and return the descriptor type * - ****************************************************************************/ + ******************************************************************************/ -static const char *AcpiGbl_DescTypeNames[] = /* printable names of descriptor types */ +/* Printable names of object descriptor types */ + +static const char *AcpiGbl_DescTypeNames[] = { +/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ /* 00 */ "Invalid", /* 01 */ "Cached", /* 02 */ "State-Generic", @@ -720,6 +741,7 @@ static const char *AcpiGbl_DescTypeNames[] = /* printable names of /* 13 */ "Parser", /* 14 */ "Operand", /* 15 */ "Node" +/*! [End] no source code translation !*/ }; @@ -748,17 +770,18 @@ AcpiUtGetDescriptorName ( * Strings and procedures used for debug only */ -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetMutexName * - * PARAMETERS: None. + * PARAMETERS: MutexId - The predefined ID for this mutex. * - * RETURN: Status + * RETURN: String containing the name of the mutex. Always returns a valid + * pointer. * * DESCRIPTION: Translate a mutex ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ char * AcpiUtGetMutexName ( @@ -772,21 +795,20 @@ AcpiUtGetMutexName ( return (AcpiGbl_MutexNames[MutexId]); } - #endif -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtValidObjectType * * PARAMETERS: Type - Object type to be validated * - * RETURN: TRUE if valid object type + * RETURN: TRUE if valid object type, FALSE otherwise * * DESCRIPTION: Validate an object type * - ****************************************************************************/ + ******************************************************************************/ BOOLEAN AcpiUtValidObjectType ( @@ -804,121 +826,37 @@ AcpiUtValidObjectType ( } -/**************************************************************************** - * - * FUNCTION: AcpiUtAllocateOwnerId - * - * PARAMETERS: IdType - Type of ID (method or table) - * - * DESCRIPTION: Allocate a table or method owner id - * - ***************************************************************************/ - -ACPI_OWNER_ID -AcpiUtAllocateOwnerId ( - UINT32 IdType) -{ - ACPI_OWNER_ID OwnerId = 0xFFFF; - - - ACPI_FUNCTION_TRACE ("UtAllocateOwnerId"); - - - if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) - { - return (0); - } - - switch (IdType) - { - case ACPI_OWNER_TYPE_TABLE: - - OwnerId = AcpiGbl_NextTableOwnerId; - AcpiGbl_NextTableOwnerId++; - - /* Check for wraparound */ - - if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID) - { - AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; - ACPI_REPORT_WARNING (("Table owner ID wraparound\n")); - } - break; - - - case ACPI_OWNER_TYPE_METHOD: - - OwnerId = AcpiGbl_NextMethodOwnerId; - AcpiGbl_NextMethodOwnerId++; - - if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID) - { - /* Check for wraparound */ - - AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; - } - break; - - default: - break; - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); - return_VALUE (OwnerId); -} - - -/**************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtInitGlobals * - * PARAMETERS: none + * PARAMETERS: None + * + * RETURN: None * * DESCRIPTION: Init library globals. All globals that require specific * initialization should be initialized here! * - ***************************************************************************/ + ******************************************************************************/ void AcpiUtInitGlobals ( void) { + ACPI_STATUS Status; UINT32 i; ACPI_FUNCTION_TRACE ("UtInitGlobals"); - /* Memory allocation and cache lists */ - - ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS); + /* Create all memory caches */ - AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL); - - AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize = sizeof (ACPI_NAMESPACE_NODE); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize = sizeof (ACPI_GENERIC_STATE); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize = sizeof (ACPI_PARSE_OBJ_COMMON); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize = sizeof (ACPI_PARSE_OBJ_NAMED); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize = sizeof (ACPI_OPERAND_OBJECT); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize = sizeof (ACPI_WALK_STATE); - - AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth = ACPI_MAX_STATE_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth = ACPI_MAX_PARSE_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = ACPI_MAX_EXTPARSE_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth = ACPI_MAX_OBJECT_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth = ACPI_MAX_WALK_CACHE_DEPTH; - - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName = "Global Memory Allocation"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName = "Namespace Nodes"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName = "State Object Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName = "Parse Node Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName = "Extended Parse Node Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName = "Operand Object Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName = "Tree Walk Node Cache"); + Status = AcpiUtCreateCaches (); + if (ACPI_FAILURE (Status)) + { + return; + } /* ACPI table structure */ @@ -933,7 +871,7 @@ AcpiUtInitGlobals ( for (i = 0; i < NUM_MUTEX; i++) { AcpiGbl_MutexInfo[i].Mutex = NULL; - AcpiGbl_MutexInfo[i].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; AcpiGbl_MutexInfo[i].UseCount = 0; } @@ -974,8 +912,10 @@ AcpiUtInitGlobals ( AcpiGbl_NsLookupCount = 0; AcpiGbl_PsFindCount = 0; AcpiGbl_AcpiHardwarePresent = TRUE; - AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; - AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; + AcpiGbl_OwnerIdMask = 0; + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; |