diff options
Diffstat (limited to 'source/components')
-rw-r--r-- | source/components/debugger/dbmethod.c | 2 | ||||
-rw-r--r-- | source/components/debugger/dbnames.c | 8 | ||||
-rw-r--r-- | source/components/dispatcher/dsopcode.c | 2 | ||||
-rw-r--r-- | source/components/dispatcher/dswexec.c | 2 | ||||
-rw-r--r-- | source/components/events/evevent.c | 2 | ||||
-rw-r--r-- | source/components/executer/exoparg2.c | 10 | ||||
-rw-r--r-- | source/components/namespace/nseval.c | 26 | ||||
-rw-r--r-- | source/components/namespace/nspredef.c | 121 | ||||
-rw-r--r-- | source/components/tables/tbfadt.c | 4 | ||||
-rw-r--r-- | source/components/tables/tbxface.c | 22 | ||||
-rw-r--r-- | source/components/utilities/utdelete.c | 96 | ||||
-rw-r--r-- | source/components/utilities/utmutex.c | 10 | ||||
-rw-r--r-- | source/components/utilities/utosi.c | 29 | ||||
-rw-r--r-- | source/components/utilities/utpredef.c | 451 | ||||
-rw-r--r-- | source/components/utilities/utxface.c | 20 |
15 files changed, 599 insertions, 206 deletions
diff --git a/source/components/debugger/dbmethod.c b/source/components/debugger/dbmethod.c index f8f831f..90c0aad 100644 --- a/source/components/debugger/dbmethod.c +++ b/source/components/debugger/dbmethod.c @@ -445,7 +445,7 @@ AcpiDbWalkForExecute ( const ACPI_PREDEFINED_INFO *Predefined; - Predefined = AcpiNsCheckForPredefinedName (Node); + Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); if (!Predefined) { return (AE_OK); diff --git a/source/components/debugger/dbnames.c b/source/components/debugger/dbnames.c index 2d2a088..68a92d5 100644 --- a/source/components/debugger/dbnames.c +++ b/source/components/debugger/dbnames.c @@ -46,6 +46,7 @@ #include "accommon.h" #include "acnamesp.h" #include "acdebug.h" +#include "acpredef.h" #ifdef ACPI_DEBUGGER @@ -436,7 +437,7 @@ AcpiDbWalkForPredefinedNames ( char *Pathname; - Predefined = AcpiNsCheckForPredefinedName (Node); + Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); if (!Predefined) { return (AE_OK); @@ -450,13 +451,14 @@ AcpiDbWalkForPredefinedNames ( /* If method returns a package, the info is in the next table entry */ - if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE) + if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) { Package = Predefined + 1; } AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname, - Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes); + (Predefined->Info.ArgumentList & METHOD_ARG_MASK), + Predefined->Info.ExpectedBtypes); if (Package) { diff --git a/source/components/dispatcher/dsopcode.c b/source/components/dispatcher/dsopcode.c index 3ecb288..8415bec 100644 --- a/source/components/dispatcher/dsopcode.c +++ b/source/components/dispatcher/dsopcode.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dsopcode - Dispatcher suport for regions and fields + * Module Name: dsopcode - Dispatcher support for regions and fields * *****************************************************************************/ diff --git a/source/components/dispatcher/dswexec.c b/source/components/dispatcher/dswexec.c index 76cee7f..0336635 100644 --- a/source/components/dispatcher/dswexec.c +++ b/source/components/dispatcher/dswexec.c @@ -727,7 +727,7 @@ AcpiDsExecEndOp ( default: ACPI_ERROR ((AE_INFO, - "Unimplemented opcode, class=0x%X type=0x%X Opcode=-0x%X Op=%p", + "Unimplemented opcode, class=0x%X type=0x%X Opcode=0x%X Op=%p", OpClass, OpType, Op->Common.AmlOpcode, Op)); Status = AE_NOT_IMPLEMENTED; diff --git a/source/components/events/evevent.c b/source/components/events/evevent.c index fd0b5fb..b6d75e6 100644 --- a/source/components/events/evevent.c +++ b/source/components/events/evevent.c @@ -292,7 +292,7 @@ AcpiEvFixedEventDetect ( * DESCRIPTION: Clears the status bit for the requested event, calls the * handler that previously registered for the event. * NOTE: If there is no handler for the event, the event is - * disabled to prevent futher interrupts. + * disabled to prevent further interrupts. * ******************************************************************************/ diff --git a/source/components/executer/exoparg2.c b/source/components/executer/exoparg2.c index ada9266..6151fa8 100644 --- a/source/components/executer/exoparg2.c +++ b/source/components/executer/exoparg2.c @@ -286,7 +286,7 @@ AcpiExOpcode_2A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; UINT64 Index; ACPI_STATUS Status = AE_OK; - ACPI_SIZE Length; + ACPI_SIZE Length = 0; ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, @@ -356,7 +356,6 @@ AcpiExOpcode_2A_1T_1R ( * NOTE: A length of zero is ok, and will create a zero-length, null * terminated string. */ - Length = 0; while ((Length < Operand[0]->Buffer.Length) && (Length < Operand[1]->Integer.Value) && (Operand[0]->Buffer.Pointer[Length])) @@ -418,6 +417,7 @@ AcpiExOpcode_2A_1T_1R ( if (Index >= Operand[0]->String.Length) { + Length = Operand[0]->String.Length; Status = AE_AML_STRING_LIMIT; } @@ -428,6 +428,7 @@ AcpiExOpcode_2A_1T_1R ( if (Index >= Operand[0]->Buffer.Length) { + Length = Operand[0]->Buffer.Length; Status = AE_AML_BUFFER_LIMIT; } @@ -438,6 +439,7 @@ AcpiExOpcode_2A_1T_1R ( if (Index >= Operand[0]->Package.Count) { + Length = Operand[0]->Package.Count; Status = AE_AML_PACKAGE_LIMIT; } @@ -456,8 +458,8 @@ AcpiExOpcode_2A_1T_1R ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Index (0x%8.8X%8.8X) is beyond end of object", - ACPI_FORMAT_UINT64 (Index))); + "Index (0x%X%8.8X) is beyond end of object (length 0x%X)", + ACPI_FORMAT_UINT64 (Index), (UINT32) Length)); goto Cleanup; } diff --git a/source/components/namespace/nseval.c b/source/components/namespace/nseval.c index cdd6a9f..1de341c 100644 --- a/source/components/namespace/nseval.c +++ b/source/components/namespace/nseval.c @@ -109,18 +109,22 @@ AcpiNsEvaluate ( Info->ReturnObject = NULL; Info->ParamCount = 0; - /* - * Get the actual namespace node for the target object. Handles these cases: - * - * 1) Null node, Pathname (absolute path) - * 2) Node, Pathname (path relative to Node) - * 3) Node, Null Pathname - */ - Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, - ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); - if (ACPI_FAILURE (Status)) + if (!Info->ResolvedNode) { - return_ACPI_STATUS (Status); + /* + * Get the actual namespace node for the target object if we need to. + * Handles these cases: + * + * 1) Null node, Pathname (absolute path) + * 2) Node, Pathname (path relative to Node) + * 3) Node, Null Pathname + */ + Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, + ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } /* diff --git a/source/components/namespace/nspredef.c b/source/components/namespace/nspredef.c index f12bc15..a9250e3 100644 --- a/source/components/namespace/nspredef.c +++ b/source/components/namespace/nspredef.c @@ -82,30 +82,11 @@ AcpiNsCheckReference ( ACPI_PREDEFINED_DATA *Data, ACPI_OPERAND_OBJECT *ReturnObject); -static void -AcpiNsGetExpectedTypes ( - char *Buffer, - UINT32 ExpectedBtypes); - static UINT32 AcpiNsGetBitmappedType ( ACPI_OPERAND_OBJECT *ReturnObject); -/* - * Names for the types that can be returned by the predefined objects. - * Used for warning messages. Must be in the same order as the ACPI_RTYPEs - */ -static const char *AcpiRtypeNames[] = -{ - "/Integer", - "/String", - "/Buffer", - "/Package", - "/Reference", -}; - - /******************************************************************************* * * FUNCTION: AcpiNsCheckPredefinedNames @@ -137,7 +118,7 @@ AcpiNsCheckPredefinedNames ( /* Match the name for this method/object against the predefined list */ - Predefined = AcpiNsCheckForPredefinedName (Node); + Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); /* Get the full pathname to the object, for use in warning messages */ @@ -321,8 +302,8 @@ AcpiNsCheckParameterCount ( * Validate the user-supplied parameter count. * Allow two different legal argument counts (_SCP, etc.) */ - RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F; - RequiredParamsOld = Predefined->Info.ParamCount >> 4; + RequiredParamsCurrent = Predefined->Info.ArgumentList & METHOD_ARG_MASK; + RequiredParamsOld = Predefined->Info.ArgumentList >> METHOD_ARG_BIT_WIDTH; if (UserParamCount != ACPI_UINT32_MAX) { @@ -353,58 +334,6 @@ AcpiNsCheckParameterCount ( /******************************************************************************* * - * FUNCTION: AcpiNsCheckForPredefinedName - * - * PARAMETERS: Node - Namespace node for the method/object - * - * RETURN: Pointer to entry in predefined table. NULL indicates not found. - * - * DESCRIPTION: Check an object name against the predefined object list. - * - ******************************************************************************/ - -const ACPI_PREDEFINED_INFO * -AcpiNsCheckForPredefinedName ( - ACPI_NAMESPACE_NODE *Node) -{ - const ACPI_PREDEFINED_INFO *ThisName; - - - /* Quick check for a predefined name, first character must be underscore */ - - if (Node->Name.Ascii[0] != '_') - { - return (NULL); - } - - /* Search info table for a predefined method/object name */ - - ThisName = PredefinedNames; - while (ThisName->Info.Name[0]) - { - if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name)) - { - return (ThisName); - } - - /* - * Skip next entry in the table if this name returns a Package - * (next entry contains the package info) - */ - if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) - { - ThisName++; - } - - ThisName++; - } - - return (NULL); /* Not found */ -} - - -/******************************************************************************* - * * FUNCTION: AcpiNsCheckObjectType * * PARAMETERS: Data - Pointer to validation data structure @@ -480,7 +409,7 @@ TypeErrorExit: /* Create a string with all expected types for this predefined object */ - AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); + AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes); if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) { @@ -600,45 +529,3 @@ AcpiNsGetBitmappedType ( return (ReturnBtype); } - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetExpectedTypes - * - * PARAMETERS: Buffer - Pointer to where the string is returned - * ExpectedBtypes - Bitmap of expected return type(s) - * - * RETURN: Buffer is populated with type names. - * - * DESCRIPTION: Translate the expected types bitmap into a string of ascii - * names of expected types, for use in warning messages. - * - ******************************************************************************/ - -static void -AcpiNsGetExpectedTypes ( - char *Buffer, - UINT32 ExpectedBtypes) -{ - UINT32 ThisRtype; - UINT32 i; - UINT32 j; - - - j = 1; - Buffer[0] = 0; - ThisRtype = ACPI_RTYPE_INTEGER; - - for (i = 0; i < ACPI_NUM_RTYPES; i++) - { - /* If one of the expected types, concatenate the name of this type */ - - if (ExpectedBtypes & ThisRtype) - { - ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); - j = 0; /* Use name separator from now on */ - } - ThisRtype <<= 1; /* Next Rtype */ - } -} diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index 772e077..6f41c46 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -590,8 +590,12 @@ AcpiTbValidateFadt ( /* * For each extended field, check for length mismatch between the * legacy length field and the corresponding 64-bit X length field. + * Note: If the legacy length field is > 0xFF bits, ignore this + * check. (GPE registers can be larger than the 64-bit GAS structure + * can accomodate, 0xFF bits). */ if (Address64->Address && + (ACPI_MUL_8 (Length) <= ACPI_UINT8_MAX) && (Address64->BitWidth != ACPI_MUL_8 (Length))) { ACPI_BIOS_WARNING ((AE_INFO, diff --git a/source/components/tables/tbxface.c b/source/components/tables/tbxface.c index 1f69069..5308162 100644 --- a/source/components/tables/tbxface.c +++ b/source/components/tables/tbxface.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: tbxface - ACPI table oriented external interfaces + * Module Name: tbxface - ACPI table-oriented external interfaces * *****************************************************************************/ @@ -86,7 +86,7 @@ AcpiAllocateRootTable ( * array is dynamically allocated. * InitialTableCount - Size of InitialTableArray, in number of * ACPI_TABLE_DESC structures - * AllowRealloc - Flag to tell Table Manager if resize of + * AllowResize - Flag to tell Table Manager if resize of * pre-allocated array is allowed. Ignored * if InitialTableArray is NULL. * @@ -117,8 +117,8 @@ AcpiInitializeTables ( /* - * Set up the Root Table Array - * Allocate the table array if requested + * Setup the Root Table Array and allocate the table array + * if requested */ if (!InitialTableArray) { @@ -304,9 +304,10 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) * Instance - Which instance (for SSDTs) * OutTable - Where the pointer to the table is returned * - * RETURN: Status and pointer to table + * RETURN: Status and pointer to the requested table * - * DESCRIPTION: Finds and verifies an ACPI table. + * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the + * RSDT/XSDT. * ******************************************************************************/ @@ -365,9 +366,10 @@ ACPI_EXPORT_SYMBOL (AcpiGetTable) * PARAMETERS: TableIndex - Table index * Table - Where the pointer to the table is returned * - * RETURN: Status and pointer to the table + * RETURN: Status and pointer to the requested table * - * DESCRIPTION: Obtain a table by an index into the global table list. + * DESCRIPTION: Obtain a table by an index into the global table list. Used + * internally also. * ******************************************************************************/ @@ -428,7 +430,7 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) * * RETURN: Status * - * DESCRIPTION: Install table event handler + * DESCRIPTION: Install a global table event handler. * ******************************************************************************/ @@ -484,7 +486,7 @@ ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) * * RETURN: Status * - * DESCRIPTION: Remove table event handler + * DESCRIPTION: Remove a table event handler * ******************************************************************************/ diff --git a/source/components/utilities/utdelete.c b/source/components/utilities/utdelete.c index a100713..f18d556 100644 --- a/source/components/utilities/utdelete.c +++ b/source/components/utilities/utdelete.c @@ -390,11 +390,11 @@ AcpiUtDeleteInternalObjectList ( * FUNCTION: AcpiUtUpdateRefCount * * PARAMETERS: Object - Object whose ref count is to be updated - * Action - What to do + * Action - What to do (REF_INCREMENT or REF_DECREMENT) * - * RETURN: New ref count + * RETURN: None. Sets new reference count within the object * - * DESCRIPTION: Modify the ref count and return it. + * DESCRIPTION: Modify the reference count for an internal acpi object * ******************************************************************************/ @@ -403,8 +403,9 @@ AcpiUtUpdateRefCount ( ACPI_OPERAND_OBJECT *Object, UINT32 Action) { - UINT16 Count; - UINT16 NewCount; + UINT16 OriginalCount; + UINT16 NewCount = 0; + ACPI_CPU_FLAGS LockFlags; ACPI_FUNCTION_NAME (UtUpdateRefCount); @@ -415,80 +416,85 @@ AcpiUtUpdateRefCount ( return; } - Count = Object->Common.ReferenceCount; - NewCount = Count; - /* - * Perform the reference count action (increment, decrement, force delete) + * Always get the reference count lock. Note: Interpreter and/or + * Namespace is not always locked when this function is called. */ + LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock); + OriginalCount = Object->Common.ReferenceCount; + + /* Perform the reference count action (increment, decrement) */ + switch (Action) { case REF_INCREMENT: - NewCount++; + NewCount = OriginalCount + 1; Object->Common.ReferenceCount = NewCount; + AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); + + /* The current reference count should never be zero here */ + + if (!OriginalCount) + { + ACPI_WARNING ((AE_INFO, + "Obj %p, Reference Count was zero before increment\n", + Object)); + } ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, [Incremented]\n", - Object, NewCount)); + "Obj %p Type %.2X Refs %.2X [Incremented]\n", + Object, Object->Common.Type, NewCount)); break; case REF_DECREMENT: - if (Count < 1) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, can't decrement! (Set to 0)\n", - Object, NewCount)); + /* The current reference count must be non-zero */ - NewCount = 0; - } - else + if (OriginalCount) { - NewCount--; - - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, [Decremented]\n", - Object, NewCount)); + NewCount = OriginalCount - 1; + Object->Common.ReferenceCount = NewCount; } - if (Object->Common.Type == ACPI_TYPE_METHOD) + AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); + + if (!OriginalCount) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); + ACPI_WARNING ((AE_INFO, + "Obj %p, Reference Count is already zero, cannot decrement\n", + Object)); } - Object->Common.ReferenceCount = NewCount; + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Type %.2X Refs %.2X [Decremented]\n", + Object, Object->Common.Type, NewCount)); + + /* Actually delete the object on a reference count of zero */ + if (NewCount == 0) { AcpiUtDeleteInternalObj (Object); } break; - case REF_FORCE_DELETE: - - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); - - NewCount = 0; - Object->Common.ReferenceCount = NewCount; - AcpiUtDeleteInternalObj (Object); - break; - default: - ACPI_ERROR ((AE_INFO, "Unknown action (0x%X)", Action)); - break; + AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags); + ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)", + Action)); + return; } /* * Sanity check the reference count, for debug purposes only. * (A deleted object will have a huge reference count) */ - if (Count > ACPI_MAX_REFERENCE_COUNT) + if (NewCount > ACPI_MAX_REFERENCE_COUNT) { ACPI_WARNING ((AE_INFO, - "Large Reference Count (0x%X) in object %p", Count, Object)); + "Large Reference Count (0x%X) in object %p, Type=0x%.2X", + NewCount, Object, Object->Common.Type)); } } @@ -499,8 +505,7 @@ AcpiUtUpdateRefCount ( * * PARAMETERS: Object - Increment ref count for this object * and all sub-objects - * Action - Either REF_INCREMENT or REF_DECREMENT or - * REF_FORCE_DELETE + * Action - Either REF_INCREMENT or REF_DECREMENT * * RETURN: Status * @@ -771,7 +776,6 @@ AcpiUtRemoveReference ( /* * Allow a NULL pointer to be passed in, just ignore it. This saves * each caller from having to check. Also, ignore NS nodes. - * */ if (!Object || (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) diff --git a/source/components/utilities/utmutex.c b/source/components/utilities/utmutex.c index 7755c9b..a74ef81 100644 --- a/source/components/utilities/utmutex.c +++ b/source/components/utilities/utmutex.c @@ -96,7 +96,7 @@ AcpiUtMutexInitialize ( } } - /* Create the spinlocks for use at interrupt level */ + /* Create the spinlocks for use at interrupt level or for speed */ Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); if (ACPI_FAILURE (Status)) @@ -110,7 +110,14 @@ AcpiUtMutexInitialize ( return_ACPI_STATUS (Status); } + Status = AcpiOsCreateLock (&AcpiGbl_ReferenceCountLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Mutex for _OSI support */ + Status = AcpiOsCreateMutex (&AcpiGbl_OsiMutex); if (ACPI_FAILURE (Status)) { @@ -160,6 +167,7 @@ AcpiUtMutexTerminate ( AcpiOsDeleteLock (AcpiGbl_GpeLock); AcpiOsDeleteLock (AcpiGbl_HardwareLock); + AcpiOsDeleteLock (AcpiGbl_ReferenceCountLock); /* Delete the reader/writer lock */ diff --git a/source/components/utilities/utosi.c b/source/components/utilities/utosi.c index 7449b26..81d648b 100644 --- a/source/components/utilities/utosi.c +++ b/source/components/utilities/utosi.c @@ -115,10 +115,16 @@ ACPI_STATUS AcpiUtInitializeInterfaces ( void) { + ACPI_STATUS Status; UINT32 i; - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces; /* Link the static list of supported interfaces */ @@ -140,23 +146,28 @@ AcpiUtInitializeInterfaces ( * * PARAMETERS: None * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Delete all interfaces in the global list. Sets * AcpiGbl_SupportedInterfaces to NULL. * ******************************************************************************/ -void +ACPI_STATUS AcpiUtInterfaceTerminate ( void) { + ACPI_STATUS Status; ACPI_INTERFACE_INFO *NextInterface; - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); - NextInterface = AcpiGbl_SupportedInterfaces; + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + NextInterface = AcpiGbl_SupportedInterfaces; while (NextInterface) { AcpiGbl_SupportedInterfaces = NextInterface->Next; @@ -173,6 +184,7 @@ AcpiUtInterfaceTerminate ( } AcpiOsReleaseMutex (AcpiGbl_OsiMutex); + return (AE_OK); } @@ -350,6 +362,7 @@ AcpiUtOsiImplementation ( ACPI_OPERAND_OBJECT *ReturnDesc; ACPI_INTERFACE_INFO *InterfaceInfo; ACPI_INTERFACE_HANDLER InterfaceHandler; + ACPI_STATUS Status; UINT32 ReturnValue; @@ -376,7 +389,11 @@ AcpiUtOsiImplementation ( /* Default return value is 0, NOT SUPPORTED */ ReturnValue = 0; - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } /* Lookup the interface in the global _OSI list */ diff --git a/source/components/utilities/utpredef.c b/source/components/utilities/utpredef.c new file mode 100644 index 0000000..4d85497 --- /dev/null +++ b/source/components/utilities/utpredef.c @@ -0,0 +1,451 @@ +/****************************************************************************** + * + * Module Name: utpredef - support functions for predefined names + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#define __UTPREDEF_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acpredef.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utpredef") + + +/* + * Names for the types that can be returned by the predefined objects. + * Used for warning messages. Must be in the same order as the ACPI_RTYPEs + */ +static const char *UtRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetNextPredefinedMethod + * + * PARAMETERS: ThisName - Entry in the predefined method/name table + * + * RETURN: Pointer to next entry in predefined table. + * + * DESCRIPTION: Get the next entry in the predefine method table. Handles the + * cases where a package info entry follows a method name that + * returns a package. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiUtGetNextPredefinedMethod ( + const ACPI_PREDEFINED_INFO *ThisName) +{ + + /* + * Skip next entry in the table if this name returns a Package + * (next entry contains the package info) + */ + if ((ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) && + (ThisName->Info.ExpectedBtypes != ACPI_RTYPE_ALL)) + { + ThisName++; + } + + ThisName++; + return (ThisName); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMatchPredefinedMethod + * + * PARAMETERS: Name - Name to find + * + * RETURN: Pointer to entry in predefined table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the predefined object list. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiUtMatchPredefinedMethod ( + char *Name) +{ + const ACPI_PREDEFINED_INFO *ThisName; + + + /* Quick check for a predefined name, first character must be underscore */ + + if (Name[0] != '_') + { + return (NULL); + } + + /* Search info table for a predefined method/object name */ + + ThisName = AcpiGbl_PredefinedMethods; + while (ThisName->Info.Name[0]) + { + if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name)) + { + return (ThisName); + } + + ThisName = AcpiUtGetNextPredefinedMethod (ThisName); + } + + return (NULL); /* Not found */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetExpectedReturnTypes + * + * PARAMETERS: Buffer - Where the formatted string is returned + * ExpectedBTypes - Bitfield of expected data types + * + * RETURN: Formatted string in Buffer. + * + * DESCRIPTION: Format the expected object types into a printable string. + * + ******************************************************************************/ + +void +AcpiUtGetExpectedReturnTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + ACPI_STRCAT (Buffer, &UtRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + + ThisRtype <<= 1; /* Next Rtype */ + } +} + + +/******************************************************************************* + * + * The remaining functions are used by iASL and AcpiHelp only + * + ******************************************************************************/ + +#if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP) +#include <stdio.h> +#include <string.h> + +/* Local prototypes */ + +static UINT32 +AcpiUtGetArgumentTypes ( + char *Buffer, + UINT16 ArgumentTypes); + + +/* Types that can be returned externally by a predefined name */ + +static const char *UtExternalTypeNames[] = /* Indexed by ACPI_TYPE_* */ +{ + ", UNSUPPORTED-TYPE", + ", Integer", + ", String", + ", Buffer", + ", Package" +}; + +/* Bit widths for resource descriptor predefined names */ + +static const char *UtResourceTypeNames[] = +{ + "/1", + "/2", + "/3", + "/8", + "/16", + "/32", + "/64", + "/variable", +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMatchResourceName + * + * PARAMETERS: Name - Name to find + * + * RETURN: Pointer to entry in the resource table. NULL indicates not + * found. + * + * DESCRIPTION: Check an object name against the predefined resource + * descriptor object list. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiUtMatchResourceName ( + char *Name) +{ + const ACPI_PREDEFINED_INFO *ThisName; + + + /* Quick check for a predefined name, first character must be underscore */ + + if (Name[0] != '_') + { + return (NULL); + } + + /* Search info table for a predefined method/object name */ + + ThisName = AcpiGbl_ResourceNames; + while (ThisName->Info.Name[0]) + { + if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name)) + { + return (ThisName); + } + + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDisplayPredefinedMethod + * + * PARAMETERS: Buffer - Scratch buffer for this function + * ThisName - Entry in the predefined method/name table + * MultiLine - TRUE if output should be on >1 line + * + * RETURN: None + * + * DESCRIPTION: Display information about a predefined method. Number and + * type of the input arguments, and expected type(s) for the + * return value, if any. + * + ******************************************************************************/ + +void +AcpiUtDisplayPredefinedMethod ( + char *Buffer, + const ACPI_PREDEFINED_INFO *ThisName, + BOOLEAN MultiLine) +{ + UINT32 ArgCount; + + /* + * Get the argument count and the string buffer + * containing all argument types + */ + ArgCount = AcpiUtGetArgumentTypes (Buffer, + ThisName->Info.ArgumentList); + + if (MultiLine) + { + printf (" "); + } + + printf ("%4.4s Requires %s%u argument%s", + ThisName->Info.Name, + (ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM) ? + "(at least) " : "", + ArgCount, ArgCount != 1 ? "s" : ""); + + /* Display the types for any arguments */ + + if (ArgCount > 0) + { + printf (" (%s)", Buffer); + } + + if (MultiLine) + { + printf ("\n "); + } + + /* Get the return value type(s) allowed */ + + if (ThisName->Info.ExpectedBtypes) + { + AcpiUtGetExpectedReturnTypes (Buffer, ThisName->Info.ExpectedBtypes); + printf (" Return value types: %s\n", Buffer); + } + else + { + printf (" No return value\n"); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetArgumentTypes + * + * PARAMETERS: Buffer - Where to return the formatted types + * ArgumentTypes - Types field for this method + * + * RETURN: Count - the number of arguments required for this method + * + * DESCRIPTION: Format the required data types for this method (Integer, + * String, Buffer, or Package) and return the required argument + * count. + * + ******************************************************************************/ + +static UINT32 +AcpiUtGetArgumentTypes ( + char *Buffer, + UINT16 ArgumentTypes) +{ + UINT16 ThisArgumentType; + UINT16 SubIndex; + UINT16 ArgCount; + UINT32 i; + + + *Buffer = 0; + SubIndex = 2; + + /* First field in the types list is the count of args to follow */ + + ArgCount = (ArgumentTypes & METHOD_ARG_MASK); + ArgumentTypes >>= METHOD_ARG_BIT_WIDTH; + + if (ArgCount > METHOD_PREDEF_ARGS_MAX) + { + printf ("**** Invalid argument count (%u) " + "in predefined info structure\n", ArgCount); + return (ArgCount); + } + + /* Get each argument from the list, convert to ascii, store to buffer */ + + for (i = 0; i < ArgCount; i++) + { + ThisArgumentType = (ArgumentTypes & METHOD_ARG_MASK); + if (!ThisArgumentType || (ThisArgumentType > METHOD_MAX_ARG_TYPE)) + { + printf ("**** Invalid argument type (%u) " + "in predefined info structure\n", ThisArgumentType); + return (ArgCount); + } + + strcat (Buffer, UtExternalTypeNames[ThisArgumentType] + SubIndex); + + /* Shift to next argument type field */ + + ArgumentTypes >>= METHOD_ARG_BIT_WIDTH; + SubIndex = 0; + } + + return (ArgCount); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceBitWidth + * + * PARAMETERS: Buffer - Where the formatted string is returned + * Types - Bitfield of expected data types + * + * RETURN: Count of return types. Formatted string in Buffer. + * + * DESCRIPTION: Format the resource bit widths into a printable string. + * + ******************************************************************************/ + +UINT32 +AcpiUtGetResourceBitWidth ( + char *Buffer, + UINT16 Types) +{ + UINT32 i; + UINT16 SubIndex; + UINT32 Found; + + + *Buffer = 0; + SubIndex = 1; + Found = 0; + + for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) + { + if (Types & 1) + { + strcat (Buffer, &(UtResourceTypeNames[i][SubIndex])); + SubIndex = 0; + Found++; + } + + Types >>= 1; + } + + return (Found); +} +#endif diff --git a/source/components/utilities/utxface.c b/source/components/utilities/utxface.c index 60405aa..4506980 100644 --- a/source/components/utilities/utxface.c +++ b/source/components/utilities/utxface.c @@ -373,7 +373,11 @@ AcpiInstallInterface ( return (AE_BAD_PARAMETER); } - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } /* Check if the interface name is already in the global list */ @@ -434,7 +438,11 @@ AcpiRemoveInterface ( return (AE_BAD_PARAMETER); } - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } Status = AcpiUtRemoveInterface (InterfaceName); @@ -464,10 +472,14 @@ ACPI_STATUS AcpiInstallInterfaceHandler ( ACPI_INTERFACE_HANDLER Handler) { - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status; - (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } if (Handler && AcpiGbl_InterfaceHandler) { |