From 5799101b4c1067cfa0a3b51871d02d835136e6f0 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 26 Feb 2017 00:26:24 +0000 Subject: [PATCH] [ACPICA] - Update to version 20161222 CORE-12833 svn path=/trunk/; revision=73918 --- reactos/drivers/bus/acpi/CMakeLists.txt | 1 + .../bus/acpi/acpica/dispatcher/dsinit.c | 10 +- .../bus/acpi/acpica/dispatcher/dsmethod.c | 44 +- .../bus/acpi/acpica/dispatcher/dsopcode.c | 2 +- .../bus/acpi/acpica/dispatcher/dswexec.c | 3 +- .../bus/acpi/acpica/dispatcher/dswload2.c | 21 +- .../drivers/bus/acpi/acpica/events/evgpe.c | 67 +++ .../bus/acpi/acpica/events/evgpeinit.c | 7 +- .../drivers/bus/acpi/acpica/events/evrgnini.c | 60 ++- .../drivers/bus/acpi/acpica/events/evxfgpe.c | 52 +++ .../bus/acpi/acpica/executer/exconcat.c | 3 +- .../bus/acpi/acpica/executer/exconfig.c | 156 ++----- .../bus/acpi/acpica/executer/exconvrt.c | 8 +- .../bus/acpi/acpica/executer/exfldio.c | 15 +- .../drivers/bus/acpi/acpica/executer/exmisc.c | 3 +- .../bus/acpi/acpica/executer/exoparg1.c | 7 +- .../bus/acpi/acpica/executer/exresop.c | 11 +- .../bus/acpi/acpica/executer/extrace.c | 28 -- .../bus/acpi/acpica/executer/exutils.c | 10 + .../bus/acpi/acpica/hardware/hwesleep.c | 27 +- .../drivers/bus/acpi/acpica/hardware/hwgpe.c | 22 +- .../drivers/bus/acpi/acpica/hardware/hwregs.c | 230 ++++++++-- .../bus/acpi/acpica/hardware/hwsleep.c | 10 + .../drivers/bus/acpi/acpica/include/acclib.h | 38 ++ .../bus/acpi/acpica/include/acconfig.h | 2 +- .../drivers/bus/acpi/acpica/include/acdebug.h | 7 +- .../bus/acpi/acpica/include/acdisasm.h | 11 +- .../bus/acpi/acpica/include/acevents.h | 8 +- .../drivers/bus/acpi/acpica/include/acexcep.h | 8 +- .../bus/acpi/acpica/include/acglobal.h | 10 +- .../drivers/bus/acpi/acpica/include/aclocal.h | 38 +- .../bus/acpi/acpica/include/acmacros.h | 85 +++- .../bus/acpi/acpica/include/acnamesp.h | 17 + .../bus/acpi/acpica/include/acopcode.h | 22 +- .../bus/acpi/acpica/include/acparser.h | 4 + .../drivers/bus/acpi/acpica/include/acpi.h | 2 +- .../bus/acpi/acpica/include/acpiosxf.h | 34 +- .../drivers/bus/acpi/acpica/include/acpixf.h | 41 +- .../bus/acpi/acpica/include/actables.h | 31 +- .../drivers/bus/acpi/acpica/include/actbl.h | 165 +++---- .../drivers/bus/acpi/acpica/include/actypes.h | 57 +-- .../drivers/bus/acpi/acpica/include/acutils.h | 23 +- .../drivers/bus/acpi/acpica/include/amlcode.h | 22 +- .../bus/acpi/acpica/include/platform/acefi.h | 10 +- .../acpi/acpica/include/platform/acefiex.h | 117 ++++- .../bus/acpi/acpica/include/platform/acenv.h | 5 +- .../acpi/acpica/include/platform/aclinux.h | 5 +- .../acpi/acpica/include/platform/aclinuxex.h | 14 + .../acpi/acpica/include/platform/acmacosx.h | 1 - .../bus/acpi/acpica/namespace/nsconvert.c | 2 +- .../bus/acpi/acpica/namespace/nsload.c | 32 +- .../bus/acpi/acpica/namespace/nsnames.c | 52 +++ .../bus/acpi/acpica/namespace/nsparse.c | 181 ++++++-- .../bus/acpi/acpica/namespace/nsutils.c | 68 ++- .../bus/acpi/acpica/namespace/nsxfname.c | 42 +- .../drivers/bus/acpi/acpica/parser/psargs.c | 81 +++- .../drivers/bus/acpi/acpica/parser/psloop.c | 3 + .../drivers/bus/acpi/acpica/parser/psobject.c | 8 +- .../drivers/bus/acpi/acpica/parser/psparse.c | 5 +- .../drivers/bus/acpi/acpica/parser/pstree.c | 10 +- .../drivers/bus/acpi/acpica/parser/psxface.c | 94 ++++ .../drivers/bus/acpi/acpica/tables/tbdata.c | 183 +++++++- .../drivers/bus/acpi/acpica/tables/tbfadt.c | 127 ++--- .../drivers/bus/acpi/acpica/tables/tbfind.c | 12 +- .../drivers/bus/acpi/acpica/tables/tbinstal.c | 79 +--- .../drivers/bus/acpi/acpica/tables/tbutils.c | 96 ++++ .../drivers/bus/acpi/acpica/tables/tbxface.c | 133 ++++-- .../drivers/bus/acpi/acpica/tables/tbxfload.c | 102 +---- .../bus/acpi/acpica/utilities/utaddress.c | 9 - .../bus/acpi/acpica/utilities/utclib.c | 142 ++++++ .../bus/acpi/acpica/utilities/utdecode.c | 58 ++- .../bus/acpi/acpica/utilities/utdelete.c | 5 +- .../drivers/bus/acpi/acpica/utilities/uthex.c | 51 ++- .../bus/acpi/acpica/utilities/utmutex.c | 19 - .../bus/acpi/acpica/utilities/utnonansi.c | 432 +----------------- .../drivers/bus/acpi/acpica/utilities/utosi.c | 22 +- .../bus/acpi/acpica/utilities/utresrc.c | 17 +- .../bus/acpi/acpica/utilities/utstrtoul64.c | 390 ++++++++++++++++ .../bus/acpi/acpica/utilities/utxfinit.c | 2 +- reactos/drivers/bus/acpi/osl.c | 10 + 80 files changed, 2676 insertions(+), 1365 deletions(-) create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utstrtoul64.c diff --git a/reactos/drivers/bus/acpi/CMakeLists.txt b/reactos/drivers/bus/acpi/CMakeLists.txt index abe13dcedd8..01d1eb08a68 100644 --- a/reactos/drivers/bus/acpi/CMakeLists.txt +++ b/reactos/drivers/bus/acpi/CMakeLists.txt @@ -159,6 +159,7 @@ list(APPEND ACPICA_SOURCE acpica/utilities/utresrc.c acpica/utilities/utstate.c acpica/utilities/utstring.c + acpica/utilities/utstrtoul64.c # acpica/utilities/utuuid.c acpica/utilities/uttrack.c acpica/utilities/utxface.c diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c index 74e974da031..67c8d61c028 100644 --- a/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c @@ -46,6 +46,7 @@ #include "acdispat.h" #include "acnamesp.h" #include "actables.h" +#include "acinterp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsinit") @@ -231,23 +232,16 @@ AcpiDsInitializeObjects ( /* Walk entire namespace from the supplied root */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* * We don't use AcpiWalkNamespace since we do not want to acquire * the namespace reader lock. */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); + ACPI_NS_WALK_NO_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); } - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_FAILURE (Status)) diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c index 334dadcac66..92bdb2fc80f 100644 --- a/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c @@ -777,26 +777,6 @@ AcpiDsTerminateControlMethod ( AcpiDsMethodDataDeleteAll (WalkState); - /* - * If method is serialized, release the mutex and restore the - * current sync level for this thread - */ - if (MethodDesc->Method.Mutex) - { - /* Acquisition Depth handles recursive calls */ - - MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; - if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) - { - WalkState->Thread->CurrentSyncLevel = - MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; - - AcpiOsReleaseMutex ( - MethodDesc->Method.Mutex->Mutex.OsMutex); - MethodDesc->Method.Mutex->Mutex.ThreadId = 0; - } - } - /* * Delete any namespace objects created anywhere within the * namespace by the execution of this method. Unless: @@ -810,7 +790,9 @@ AcpiDsTerminateControlMethod ( { /* Delete any direct children of (created by) this method */ + (void) AcpiExExitInterpreter (); AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode); + (void) AcpiExEnterInterpreter (); /* * Delete any objects that were created by this method @@ -821,11 +803,33 @@ AcpiDsTerminateControlMethod ( */ if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE) { + (void) AcpiExExitInterpreter (); AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + (void) AcpiExEnterInterpreter (); MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_MODIFIED_NAMESPACE; } } + + /* + * If method is serialized, release the mutex and restore the + * current sync level for this thread + */ + if (MethodDesc->Method.Mutex) + { + /* Acquisition Depth handles recursive calls */ + + MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; + if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) + { + WalkState->Thread->CurrentSyncLevel = + MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; + + AcpiOsReleaseMutex ( + MethodDesc->Method.Mutex->Mutex.OsMutex); + MethodDesc->Method.Mutex->Mutex.ThreadId = 0; + } + } } /* Decrement the thread count on the method */ diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c index 1c6b3425709..5cd9107d866 100644 --- a/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c @@ -90,7 +90,7 @@ AcpiDsInitializeRegion ( /* Namespace is NOT locked */ - Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + Status = AcpiEvInitializeRegion (ObjDesc); return (Status); } diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c index 307af607a84..e284fca5d95 100644 --- a/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c @@ -144,7 +144,8 @@ AcpiDsGetPredicateValue ( * Result of predicate evaluation must be an Integer * object. Implicitly convert the argument if necessary. */ - Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16); + Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, + ACPI_STRTOUL_BASE16); if (ACPI_FAILURE (Status)) { goto Cleanup; diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswload2.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswload2.c index 2c099ef0f03..c0e4ad47e89 100644 --- a/reactos/drivers/bus/acpi/acpica/dispatcher/dswload2.c +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswload2.c @@ -624,29 +624,10 @@ AcpiDsLoad2EndOp ( { return_ACPI_STATUS (Status); } - - AcpiExExitInterpreter (); } Status = AcpiEvInitializeRegion ( - AcpiNsGetAttachedObject (Node), FALSE); - if (WalkState->MethodNode) - { - AcpiExEnterInterpreter (); - } - - if (ACPI_FAILURE (Status)) - { - /* - * If AE_NOT_EXIST is returned, it is not fatal - * because many regions get created before a handler - * is installed for said region. - */ - if (AE_NOT_EXIST == Status) - { - Status = AE_OK; - } - } + AcpiNsGetAttachedObject (Node)); break; case AML_NAME_OP: diff --git a/reactos/drivers/bus/acpi/acpica/events/evgpe.c b/reactos/drivers/bus/acpi/acpica/events/evgpe.c index d683bfdfaa8..31228949a2a 100644 --- a/reactos/drivers/bus/acpi/acpica/events/evgpe.c +++ b/reactos/drivers/bus/acpi/acpica/events/evgpe.c @@ -147,6 +147,70 @@ AcpiEvEnableGpe ( } +/******************************************************************************* + * + * FUNCTION: AcpiEvMaskGpe + * + * PARAMETERS: GpeEventInfo - GPE to be blocked/unblocked + * IsMasked - Whether the GPE is masked or not + * + * RETURN: Status + * + * DESCRIPTION: Unconditionally mask/unmask a GPE during runtime. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvMaskGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN IsMasked) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 RegisterBit; + + + ACPI_FUNCTION_TRACE (EvMaskGpe); + + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo); + + /* Perform the action */ + + if (IsMasked) + { + if (RegisterBit & GpeRegisterInfo->MaskForRun) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); + ACPI_SET_BIT (GpeRegisterInfo->MaskForRun, (UINT8) RegisterBit); + } + else + { + if (!(RegisterBit & GpeRegisterInfo->MaskForRun)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ACPI_CLEAR_BIT (GpeRegisterInfo->MaskForRun, (UINT8) RegisterBit); + if (GpeEventInfo->RuntimeCount && + !GpeEventInfo->DisableForDispatch) + { + (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE); + } + } + + return_ACPI_STATUS (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiEvAddGpeReference @@ -715,6 +779,7 @@ AcpiEvFinishGpe ( * in the EventInfo. */ (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_CONDITIONAL_ENABLE); + GpeEventInfo->DisableForDispatch = FALSE; return (AE_OK); } @@ -784,6 +849,8 @@ AcpiEvGpeDispatch ( } } + GpeEventInfo->DisableForDispatch = TRUE; + /* * Dispatch the GPE to either an installed handler or the control * method associated with this GPE (_Lxx or _Exx). If a handler diff --git a/reactos/drivers/bus/acpi/acpica/events/evgpeinit.c b/reactos/drivers/bus/acpi/acpica/events/evgpeinit.c index 8e2fd340230..0156ee28035 100644 --- a/reactos/drivers/bus/acpi/acpica/events/evgpeinit.c +++ b/reactos/drivers/bus/acpi/acpica/events/evgpeinit.c @@ -336,7 +336,9 @@ AcpiEvMatchGpeMethod ( ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status; UINT32 GpeNumber; + UINT8 TempGpeNumber; char Name[ACPI_NAME_SIZE + 1]; UINT8 Type; @@ -395,8 +397,8 @@ AcpiEvMatchGpeMethod ( /* 4) The last two characters of the name are the hex GPE Number */ - GpeNumber = strtoul (&Name[2], NULL, 16); - if (GpeNumber == ACPI_UINT32_MAX) + Status = AcpiUtAsciiToHexByte (&Name[2], &TempGpeNumber); + if (ACPI_FAILURE (Status)) { /* Conversion failed; invalid method, just ignore it */ @@ -408,6 +410,7 @@ AcpiEvMatchGpeMethod ( /* Ensure that we have a valid GPE number for this GPE block */ + GpeNumber = (UINT32) TempGpeNumber; GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock); if (!GpeEventInfo) { diff --git a/reactos/drivers/bus/acpi/acpica/events/evrgnini.c b/reactos/drivers/bus/acpi/acpica/events/evrgnini.c index a9e6be03919..171602a59c2 100644 --- a/reactos/drivers/bus/acpi/acpica/events/evrgnini.c +++ b/reactos/drivers/bus/acpi/acpica/events/evrgnini.c @@ -45,6 +45,7 @@ #include "accommon.h" #include "acevents.h" #include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evrgnini") @@ -537,7 +538,6 @@ AcpiEvDefaultRegionSetup ( * FUNCTION: AcpiEvInitializeRegion * * PARAMETERS: RegionObj - Region we are initializing - * AcpiNsLocked - Is namespace locked? * * RETURN: Status * @@ -555,21 +555,33 @@ AcpiEvDefaultRegionSetup ( * MUTEX: Interpreter should be unlocked, because we may run the _REG * method for this region. * + * NOTE: Possible incompliance: + * There is a behavior conflict in automatic _REG execution: + * 1. When the interpreter is evaluating a method, we can only + * automatically run _REG for the following case: + * Method(_REG, 2) {} + * OperationRegion (OPR1, 0x80, 0x1000010, 0x4) + * 2. When the interpreter is loading a table, we can also + * automatically run _REG for the following case: + * OperationRegion (OPR1, 0x80, 0x1000010, 0x4) + * Method(_REG, 2) {} + * Though this may not be compliant to the de-facto standard, the + * logic is kept in order not to trigger regressions. And keeping + * this logic should be taken care by the caller of this function. + * ******************************************************************************/ ACPI_STATUS AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked) + ACPI_OPERAND_OBJECT *RegionObj) { ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_ADR_SPACE_TYPE SpaceId; ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); + ACPI_FUNCTION_TRACE (EvInitializeRegion); if (!RegionObj) @@ -618,7 +630,8 @@ AcpiEvInitializeRegion ( * * See AcpiNsExecModuleCode */ - if (ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) + if (!AcpiGbl_ParseTableAsTermList && + ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) { HandlerObj = ObjDesc->Method.Dispatch.Handler; } @@ -640,33 +653,15 @@ AcpiEvInitializeRegion ( "Found handler %p for region %p in obj %p\n", HandlerObj, RegionObj, ObjDesc)); - Status = AcpiEvAttachRegion (HandlerObj, RegionObj, - AcpiNsLocked); + (void) AcpiEvAttachRegion (HandlerObj, RegionObj, FALSE); /* * Tell all users that this region is usable by * running the _REG method */ - if (AcpiNsLocked) - { - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); - - if (AcpiNsLocked) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - + AcpiExExitInterpreter (); + (void) AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); + AcpiExEnterInterpreter (); return_ACPI_STATUS (AE_OK); } } @@ -676,11 +671,14 @@ AcpiEvInitializeRegion ( Node = Node->Parent; } - /* If we get here, there is no handler for this region */ - + /* + * If we get here, there is no handler for this region. This is not + * fatal because many regions get created before a handler is installed + * for said region. + */ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "No handler for RegionType %s(%X) (RegionObj %p)\n", AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS (AE_OK); } diff --git a/reactos/drivers/bus/acpi/acpica/events/evxfgpe.c b/reactos/drivers/bus/acpi/acpica/events/evxfgpe.c index 1d467d9abc1..e3367032b8f 100644 --- a/reactos/drivers/bus/acpi/acpica/events/evxfgpe.c +++ b/reactos/drivers/bus/acpi/acpica/events/evxfgpe.c @@ -271,11 +271,13 @@ AcpiSetGpe ( case ACPI_GPE_ENABLE: Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE); + GpeEventInfo->DisableForDispatch = FALSE; break; case ACPI_GPE_DISABLE: Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); + GpeEventInfo->DisableForDispatch = TRUE; break; default: @@ -292,6 +294,56 @@ UnlockAndExit: ACPI_EXPORT_SYMBOL (AcpiSetGpe) +/******************************************************************************* + * + * FUNCTION: AcpiMaskGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * IsMasked - Whether the GPE is masked or not + * + * RETURN: Status + * + * DESCRIPTION: Unconditionally mask/unmask the an individual GPE, ex., to + * prevent a GPE flooding. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiMaskGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + BOOLEAN IsMasked) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiMaskGpe); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiEvMaskGpe (GpeEventInfo, IsMasked); + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiMaskGpe) + + /******************************************************************************* * * FUNCTION: AcpiMarkGpeForWake diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconcat.c b/reactos/drivers/bus/acpi/acpica/executer/exconcat.c index 49b279ad05d..22091b5bde3 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exconcat.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exconcat.c @@ -164,7 +164,8 @@ AcpiExDoConcatenate ( { case ACPI_TYPE_INTEGER: - Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, 16); + Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, + ACPI_STRTOUL_BASE16); break; case ACPI_TYPE_BUFFER: diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconfig.c b/reactos/drivers/bus/acpi/acpica/executer/exconfig.c index bb0d2bb411d..c61b1489225 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exconfig.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exconfig.c @@ -59,7 +59,6 @@ static ACPI_STATUS AcpiExAddTable ( UINT32 TableIndex, - ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle); static ACPI_STATUS @@ -87,12 +86,9 @@ AcpiExRegionRead ( static ACPI_STATUS AcpiExAddTable ( UINT32 TableIndex, - ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; - ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (ExAddTable); @@ -110,42 +106,8 @@ AcpiExAddTable ( ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; - *DdbHandle = ObjDesc; - - /* Install the new table into the local data structures */ - ObjDesc->Reference.Value = TableIndex; - - /* Add the table to the namespace */ - - Status = AcpiNsLoadTable (TableIndex, ParentNode); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ObjDesc); - *DdbHandle = NULL; - return_ACPI_STATUS (Status); - } - - /* Execute any module-level code that was found in the table */ - - AcpiExExitInterpreter (); - if (AcpiGbl_GroupModuleLevelCode) - { - AcpiNsExecModuleCodeList (); - } - AcpiExEnterInterpreter (); - - /* - * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is - * responsible for discovering any new wake GPEs by running _PRW methods - * that may have been loaded by this table. - */ - Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); - if (ACPI_SUCCESS (Status)) - { - AcpiEvUpdateGpes (OwnerId); - } - + *DdbHandle = ObjDesc; return_ACPI_STATUS (AE_OK); } @@ -174,7 +136,6 @@ AcpiExLoadTableOp ( ACPI_NAMESPACE_NODE *StartNode; ACPI_NAMESPACE_NODE *ParameterNode = NULL; ACPI_OPERAND_OBJECT *DdbHandle; - ACPI_TABLE_HEADER *Table; UINT32 TableIndex; @@ -183,10 +144,12 @@ AcpiExLoadTableOp ( /* Find the ACPI table in the RSDT/XSDT */ + AcpiExExitInterpreter (); Status = AcpiTbFindTable ( Operand[0]->String.Pointer, Operand[1]->String.Pointer, Operand[2]->String.Pointer, &TableIndex); + AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) { if (Status != AE_NOT_FOUND) @@ -219,8 +182,9 @@ AcpiExLoadTableOp ( * Find the node referenced by the RootPathString. This is the * location within the namespace where the table will be loaded. */ - Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, - ACPI_NS_SEARCH_PARENT, &ParentNode); + Status = AcpiNsGetNodeUnlocked (StartNode, + Operand[3]->String.Pointer, ACPI_NS_SEARCH_PARENT, + &ParentNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -243,8 +207,9 @@ AcpiExLoadTableOp ( /* Find the node referenced by the ParameterPathString */ - Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, - ACPI_NS_SEARCH_PARENT, &ParameterNode); + Status = AcpiNsGetNodeUnlocked (StartNode, + Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT, + &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -253,7 +218,16 @@ AcpiExLoadTableOp ( /* Load the table into the namespace */ - Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); + ACPI_INFO (("Dynamic OEM Table Load:")); + AcpiExExitInterpreter (); + Status = AcpiTbLoadTable (TableIndex, ParentNode); + AcpiExEnterInterpreter (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExAddTable (TableIndex, &DdbHandle); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -276,21 +250,6 @@ AcpiExLoadTableOp ( } } - Status = AcpiGetTableByIndex (TableIndex, &Table); - if (ACPI_SUCCESS (Status)) - { - ACPI_INFO (("Dynamic OEM Table Load:")); - AcpiTbPrintTableHeader (0, Table); - } - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); - } - *ReturnDesc = DdbHandle; return_ACPI_STATUS (Status); } @@ -520,13 +479,10 @@ AcpiExLoadOp ( /* Install the new table into the local data structures */ ACPI_INFO (("Dynamic OEM Table Load:")); - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - - Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, - &TableIndex); - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + AcpiExExitInterpreter (); + Status = AcpiTbInstallAndLoadTable (ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, &TableIndex); + AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) { /* Delete allocated table buffer */ @@ -535,17 +491,6 @@ AcpiExLoadOp ( return_ACPI_STATUS (Status); } - /* - * Note: Now table is "INSTALLED", it must be validated before - * loading. - */ - Status = AcpiTbValidateTable ( - &AcpiGbl_RootTableList.Tables[TableIndex]); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* * Add the table to the namespace. * @@ -553,7 +498,7 @@ AcpiExLoadOp ( * This appears to go against the ACPI specification, but we do it for * compatibility with other ACPI implementations. */ - Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle); + Status = AcpiExAddTable (TableIndex, &DdbHandle); if (ACPI_FAILURE (Status)) { /* On error, TablePtr was deallocated above */ @@ -577,15 +522,6 @@ AcpiExLoadOp ( /* Remove the reference by added by AcpiExStore above */ AcpiUtRemoveReference (DdbHandle); - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); - } - return_ACPI_STATUS (Status); } @@ -609,7 +545,6 @@ AcpiExUnloadTable ( ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; UINT32 TableIndex; - ACPI_TABLE_HEADER *Table; ACPI_FUNCTION_TRACE (ExUnloadTable); @@ -645,40 +580,21 @@ AcpiExUnloadTable ( TableIndex = TableDesc->Reference.Value; - /* Ensure the table is still loaded */ - - if (!AcpiTbIsTableLoaded (TableIndex)) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - Status = AcpiGetTableByIndex (TableIndex, &Table); - if (ACPI_SUCCESS (Status)) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, - AcpiGbl_TableHandlerContext); - } - } - - /* Delete the portion of the namespace owned by this table */ - - Status = AcpiTbDeleteNamespaceByOwner (TableIndex); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - (void) AcpiTbReleaseOwnerId (TableIndex); - AcpiTbSetTableLoadedFlag (TableIndex, FALSE); + /* + * Release the interpreter lock so that the table lock won't have + * strict order requirement against it. + */ + AcpiExExitInterpreter (); + Status = AcpiTbUnloadTable (TableIndex); + AcpiExEnterInterpreter (); /* * Invalidate the handle. We do this because the handle may be stored * in a named object and may not be actually deleted until much later. */ - DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; - return_ACPI_STATUS (AE_OK); + if (ACPI_SUCCESS (Status)) + { + DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; + } + return_ACPI_STATUS (Status); } diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c b/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c index ea6f82620dd..ddbcc46b5b9 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c @@ -137,8 +137,8 @@ AcpiExConvertToInteger ( * of ACPI 3.0) is that the ToInteger() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ - Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, - AcpiGbl_IntegerByteWidth, &Result); + Status = AcpiUtStrtoul64 (ACPI_CAST_PTR (char, Pointer), + (AcpiGbl_IntegerByteWidth | Flags), &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -645,7 +645,6 @@ AcpiExConvertToTargetType ( switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) { case ARGI_SIMPLE_TARGET: - case ARGI_FIXED_TARGET: case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ switch (DestinationType) @@ -684,7 +683,8 @@ AcpiExConvertToTargetType ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, 16); + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, + ACPI_STRTOUL_BASE16); break; case ACPI_TYPE_STRING: diff --git a/reactos/drivers/bus/acpi/acpica/executer/exfldio.c b/reactos/drivers/bus/acpi/acpica/executer/exfldio.c index fd46a0c0236..a865a86ae1f 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exfldio.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exfldio.c @@ -946,20 +946,9 @@ AcpiExInsertIntoField ( AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); - /* - * Create the bitmasks used for bit insertion. - * Note: This if/else is used to bypass compiler differences with the - * shift operator - */ - if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE) - { - WidthMask = ACPI_UINT64_MAX; - } - else - { - WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth); - } + /* Create the bitmasks used for bit insertion */ + WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth); Mask = WidthMask & ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); diff --git a/reactos/drivers/bus/acpi/acpica/executer/exmisc.c b/reactos/drivers/bus/acpi/acpica/executer/exmisc.c index a8e5497a9de..21e30f0f570 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exmisc.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exmisc.c @@ -360,7 +360,8 @@ AcpiExDoLogicalOp ( { case ACPI_TYPE_INTEGER: - Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, + ACPI_STRTOUL_BASE16); break; case ACPI_TYPE_STRING: diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c index 5a45bead06f..d91d8c55bce 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c @@ -550,8 +550,9 @@ AcpiExOpcode_1A_1T_1R ( case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ - Status = AcpiExConvertToInteger ( - Operand[0], &ReturnDesc, ACPI_ANY_BASE); + /* Perform "explicit" conversion */ + + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, 0); if (ReturnDesc == Operand[0]) { /* No conversion performed, add ref to handle return value */ @@ -936,7 +937,7 @@ AcpiExOpcode_1A_0T_1R ( * 2) Dereference the node to an actual object. Could be a * Field, so we need to resolve the node to a value. */ - Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, + Status = AcpiNsGetNodeUnlocked (WalkState->ScopeInfo->Scope.Node, Operand[0]->String.Pointer, ACPI_NS_SEARCH_PARENT, ACPI_CAST_INDIRECT_PTR ( diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresop.c b/reactos/drivers/bus/acpi/acpica/executer/exresop.c index 32ceb6f0217..bf1edd42145 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exresop.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exresop.c @@ -321,7 +321,6 @@ AcpiExResolveOperands ( case ARGI_OBJECT_REF: case ARGI_DEVICE_REF: case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ case ARGI_STORE_TARGET: @@ -428,11 +427,13 @@ AcpiExResolveOperands ( case ARGI_INTEGER: /* - * Need an operand of type ACPI_TYPE_INTEGER, - * But we can implicitly convert from a STRING or BUFFER - * Aka - "Implicit Source Operand Conversion" + * Need an operand of type ACPI_TYPE_INTEGER, but we can + * implicitly convert from a STRING or BUFFER. + * + * Known as "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); + Status = AcpiExConvertToInteger (ObjDesc, StackPtr, + ACPI_STRTOUL_BASE16); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) diff --git a/reactos/drivers/bus/acpi/acpica/executer/extrace.c b/reactos/drivers/bus/acpi/acpica/executer/extrace.c index 6f8a707ae41..6eaf6e70d63 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/extrace.c +++ b/reactos/drivers/bus/acpi/acpica/executer/extrace.c @@ -226,7 +226,6 @@ AcpiExStartTraceMethod ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; char *Pathname = NULL; BOOLEAN Enabled = FALSE; @@ -239,12 +238,6 @@ AcpiExStartTraceMethod ( Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); } - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto Exit; - } - Enabled = AcpiExInterpreterTraceEnabled (Pathname); if (Enabled && !AcpiGbl_TraceMethodObject) { @@ -265,9 +258,6 @@ AcpiExStartTraceMethod ( } } - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - -Exit: if (Enabled) { ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE, @@ -302,7 +292,6 @@ AcpiExStopTraceMethod ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; char *Pathname = NULL; BOOLEAN Enabled; @@ -315,28 +304,14 @@ AcpiExStopTraceMethod ( Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE); } - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto ExitPath; - } - Enabled = AcpiExInterpreterTraceEnabled (NULL); - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (Enabled) { ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE, ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname); } - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto ExitPath; - } - /* Check whether the tracer should be stopped */ if (AcpiGbl_TraceMethodObject == ObjDesc) @@ -353,9 +328,6 @@ AcpiExStopTraceMethod ( AcpiGbl_TraceMethodObject = NULL; } - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - -ExitPath: if (Pathname) { ACPI_FREE (Pathname); diff --git a/reactos/drivers/bus/acpi/acpica/executer/exutils.c b/reactos/drivers/bus/acpi/acpica/executer/exutils.c index 4843a208914..edaee5526be 100644 --- a/reactos/drivers/bus/acpi/acpica/executer/exutils.c +++ b/reactos/drivers/bus/acpi/acpica/executer/exutils.c @@ -103,6 +103,11 @@ AcpiExEnterInterpreter ( { ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); } + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not acquire AML Namespace mutex")); + } return_VOID; } @@ -141,6 +146,11 @@ AcpiExExitInterpreter ( ACPI_FUNCTION_TRACE (ExExitInterpreter); + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not release AML Namespace mutex")); + } Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); if (ACPI_FAILURE (Status)) { diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwesleep.c b/reactos/drivers/bus/acpi/acpica/hardware/hwesleep.c index de914df853a..52b6964e695 100644 --- a/reactos/drivers/bus/acpi/acpica/hardware/hwesleep.c +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwesleep.c @@ -113,7 +113,7 @@ AcpiHwExtendedSleep ( UINT8 SleepState) { ACPI_STATUS Status; - UINT8 SleepTypeValue; + UINT8 SleepControl; UINT64 SleepStatus; @@ -139,10 +139,6 @@ AcpiHwExtendedSleep ( AcpiGbl_SystemAwakeAndRunning = FALSE; - /* Flush caches, as per ACPI specification */ - - ACPI_FLUSH_CPU_CACHE (); - /* * Set the SLP_TYP and SLP_EN bits. * @@ -152,11 +148,24 @@ AcpiHwExtendedSleep ( ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%u]\n", SleepState)); - SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & - ACPI_X_SLEEP_TYPE_MASK); + SleepControl = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & + ACPI_X_SLEEP_TYPE_MASK) | ACPI_X_SLEEP_ENABLE; + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE (); + + Status = AcpiOsEnterSleep (SleepState, SleepControl, 0); + if (Status == AE_CTRL_TERMINATE) + { + return_ACPI_STATUS (AE_OK); + } + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - Status = AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE), - &AcpiGbl_FADT.SleepControl); + Status = AcpiWrite ((UINT64) SleepControl, &AcpiGbl_FADT.SleepControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c b/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c index 3dbf10ba0a4..ac9934db4f1 100644 --- a/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c @@ -108,7 +108,7 @@ AcpiHwLowSetGpe ( UINT32 Action) { ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; UINT32 EnableMask; UINT32 RegisterBit; @@ -164,9 +164,12 @@ AcpiHwLowSetGpe ( return (AE_BAD_PARAMETER); } - /* Write the updated enable mask */ + if (!(RegisterBit & GpeRegisterInfo->MaskForRun)) + { + /* Write the updated enable mask */ - Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); + Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); + } return (Status); } @@ -269,6 +272,13 @@ AcpiHwGetGpeStatus ( LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; } + /* GPE currently masked? (masked for runtime?) */ + + if (RegisterBit & GpeRegisterInfo->MaskForRun) + { + LocalEventStatus |= ACPI_EVENT_FLAG_MASKED; + } + /* GPE enabled for wake? */ if (RegisterBit & GpeRegisterInfo->EnableForWake) @@ -440,6 +450,7 @@ AcpiHwEnableRuntimeGpeBlock ( UINT32 i; ACPI_STATUS Status; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT8 EnableMask; /* NOTE: assumes that all GPEs are currently disabled */ @@ -456,8 +467,9 @@ AcpiHwEnableRuntimeGpeBlock ( /* Enable all "runtime" GPEs in this register */ - Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForRun, - GpeRegisterInfo); + EnableMask = GpeRegisterInfo->EnableForRun & + ~GpeRegisterInfo->MaskForRun; + Status = AcpiHwGpeEnableWrite (EnableMask, GpeRegisterInfo); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c b/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c index bc85c96b553..744186b87c1 100644 --- a/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c @@ -54,6 +54,12 @@ /* Local Prototypes */ +static UINT8 +AcpiHwGetAccessBitWidth ( + UINT64 Address, + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth); + static ACPI_STATUS AcpiHwReadMultiple ( UINT32 *Value, @@ -69,6 +75,90 @@ AcpiHwWriteMultiple ( #endif /* !ACPI_REDUCED_HARDWARE */ +/****************************************************************************** + * + * FUNCTION: AcpiHwGetAccessBitWidth + * + * PARAMETERS: Address - GAS register address + * Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * + * RETURN: Status + * + * DESCRIPTION: Obtain optimal access bit width + * + ******************************************************************************/ + +static UINT8 +AcpiHwGetAccessBitWidth ( + UINT64 Address, + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth) +{ + UINT8 AccessBitWidth; + + + /* + * GAS format "register", used by FADT: + * 1. Detected if BitOffset is 0 and BitWidth is 8/16/32/64; + * 2. AccessSize field is ignored and BitWidth field is used for + * determining the boundary of the IO accesses. + * GAS format "region", used by APEI registers: + * 1. Detected if BitOffset is not 0 or BitWidth is not 8/16/32/64; + * 2. AccessSize field is used for determining the boundary of the + * IO accesses; + * 3. BitOffset/BitWidth fields are used to describe the "region". + * + * Note: This algorithm assumes that the "Address" fields should always + * contain aligned values. + */ + if (!Reg->BitOffset && Reg->BitWidth && + ACPI_IS_POWER_OF_TWO (Reg->BitWidth) && + ACPI_IS_ALIGNED (Reg->BitWidth, 8)) + { + AccessBitWidth = Reg->BitWidth; + } + else if (Reg->AccessWidth) + { + AccessBitWidth = (1 << (Reg->AccessWidth + 2)); + } + else + { + AccessBitWidth = ACPI_ROUND_UP_POWER_OF_TWO_8 ( + Reg->BitOffset + Reg->BitWidth); + if (AccessBitWidth <= 8) + { + AccessBitWidth = 8; + } + else + { + while (!ACPI_IS_ALIGNED (Address, AccessBitWidth >> 3)) + { + AccessBitWidth >>= 1; + } + } + } + + /* Maximum IO port access bit width is 32 */ + + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + MaxBitWidth = 32; + } + + /* + * Return access width according to the requested maximum access bit width, + * as the caller should know the format of the register and may enforce + * a 32-bit accesses. + */ + if (AccessBitWidth < MaxBitWidth) + { + return (AccessBitWidth); + } + return (MaxBitWidth); +} + + /****************************************************************************** * * FUNCTION: AcpiHwValidateRegister @@ -91,6 +181,9 @@ AcpiHwValidateRegister ( UINT8 MaxBitWidth, UINT64 *Address) { + UINT8 BitWidth; + UINT8 AccessWidth; + /* Must have a valid pointer to a GAS structure */ @@ -120,24 +213,25 @@ AcpiHwValidateRegister ( return (AE_SUPPORT); } - /* Validate the BitWidth */ + /* Validate the AccessWidth */ - if ((Reg->BitWidth != 8) && - (Reg->BitWidth != 16) && - (Reg->BitWidth != 32) && - (Reg->BitWidth != MaxBitWidth)) + if (Reg->AccessWidth > 4) { ACPI_ERROR ((AE_INFO, - "Unsupported register bit width: 0x%X", Reg->BitWidth)); + "Unsupported register access width: 0x%X", Reg->AccessWidth)); return (AE_SUPPORT); } - /* Validate the BitOffset. Just a warning for now. */ + /* Validate the BitWidth, convert AccessWidth into number of bits */ - if (Reg->BitOffset != 0) + AccessWidth = AcpiHwGetAccessBitWidth (*Address, Reg, MaxBitWidth); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + if (MaxBitWidth < BitWidth) { ACPI_WARNING ((AE_INFO, - "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + "Requested bit width 0x%X is smaller than register bit width 0x%X", + MaxBitWidth, BitWidth)); + return (AE_SUPPORT); } return (AE_OK); @@ -158,10 +252,7 @@ AcpiHwValidateRegister ( * 64-bit values is not needed. * * LIMITATIONS: - * BitWidth must be exactly 8, 16, or 32. * SpaceID must be SystemMemory or SystemIO. - * BitOffset and AccessWidth are currently ignored, as there has - * not been a need to implement these. * ******************************************************************************/ @@ -171,7 +262,12 @@ AcpiHwRead ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; UINT64 Value64; + UINT32 Value32; + UINT8 Index; ACPI_STATUS Status; @@ -186,30 +282,58 @@ AcpiHwRead ( return (Status); } - /* Initialize entire 32-bit return value to zero */ - + /* + * Initialize entire 32-bit return value to zero, convert AccessWidth + * into number of bits based + */ *Value = 0; + AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32); + BitWidth = Reg->BitOffset + Reg->BitWidth; + BitOffset = Reg->BitOffset; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, &Value64, Reg->BitWidth); + if (BitOffset >= AccessWidth) + { + Value32 = 0; + BitOffset -= AccessWidth; + } + else + { + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value64, AccessWidth); + Value32 = (UINT32) Value64; + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value32, AccessWidth); + } + } - *Value = (UINT32) Value64; - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + /* + * Use offset style bit writes because "Index * AccessWidth" is + * ensured to be less than 32-bits by AcpiHwValidateRegister(). + */ + ACPI_SET_BITS (Value, Index * AccessWidth, + ACPI_MASK_BITS_ABOVE_32 (AccessWidth), Value32); + + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); @@ -237,6 +361,12 @@ AcpiHwWrite ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; + UINT64 Value64; + UINT32 Value32; + UINT8 Index; ACPI_STATUS Status; @@ -251,24 +381,58 @@ AcpiHwWrite ( return (Status); } + /* Convert AccessWidth into number of bits based */ + + AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32); + BitWidth = Reg->BitOffset + Reg->BitWidth; + BitOffset = Reg->BitOffset; + /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, (UINT64) Value, Reg->BitWidth); - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + /* + * Use offset style bit reads because "Index * AccessWidth" is + * ensured to be less than 32-bits by AcpiHwValidateRegister(). + */ + Value32 = ACPI_GET_BITS (&Value, Index * AccessWidth, + ACPI_MASK_BITS_ABOVE_32 (AccessWidth)); + + if (BitOffset >= AccessWidth) + { + BitOffset -= AccessWidth; + } + else + { + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Value64 = (UINT64) Value32; + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + Value64, AccessWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + Value32, AccessWidth); + } + } + + /* + * Index * AccessWidth is ensured to be less than 32-bits by + * AcpiHwValidateRegister(). + */ + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c b/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c index 13cf255137f..2431d9a8d42 100644 --- a/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c @@ -159,6 +159,16 @@ AcpiHwLegacySleep ( ACPI_FLUSH_CPU_CACHE (); + Status = AcpiOsEnterSleep (SleepState, Pm1aControl, Pm1bControl); + if (Status == AE_CTRL_TERMINATE) + { + return_ACPI_STATUS (AE_OK); + } + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Write #2: Write both SLP_TYP + SLP_EN */ Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); diff --git a/reactos/drivers/bus/acpi/acpica/include/acclib.h b/reactos/drivers/bus/acpi/acpica/include/acclib.h index 0b104b6126e..ab1c3d7676b 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acclib.h +++ b/reactos/drivers/bus/acpi/acpica/include/acclib.h @@ -103,6 +103,16 @@ strchr ( const char *String, int ch); +char * +strpbrk ( + const char *String, + const char *Delimiters); + +char * +strtok ( + char *String, + const char *Delimiters); + char * strcpy ( char *DstString, @@ -164,6 +174,12 @@ memcpy ( const void *Src, ACPI_SIZE Count); +void * +memmove ( + void *Dest, + const void *Src, + ACPI_SIZE Count); + void * memset ( void *Dest, @@ -226,6 +242,13 @@ sprintf ( */ extern int errno; +#ifndef EOF +#define EOF (-1) +#endif + +#define putchar(c) fputc(stdout, c) +#define getchar(c) fgetc(stdin) + int vprintf ( const char *Format, @@ -280,6 +303,21 @@ fseek ( long ftell ( FILE *File); + +int +fgetc ( + FILE *File); + +int +fputc ( + FILE *File, + char c); + +char * +fgets ( + char *s, + ACPI_SIZE Size, + FILE *File); #endif #endif /* _ACCLIB_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acconfig.h b/reactos/drivers/bus/acpi/acpica/include/acconfig.h index fb9727138ec..d6324911e8a 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acconfig.h +++ b/reactos/drivers/bus/acpi/acpica/include/acconfig.h @@ -148,7 +148,7 @@ /* Maximum number of While() loops before abort */ -#define ACPI_MAX_LOOP_COUNT 0xFFFF +#define ACPI_MAX_LOOP_COUNT 0x000FFFFF /****************************************************************************** diff --git a/reactos/drivers/bus/acpi/acpica/include/acdebug.h b/reactos/drivers/bus/acpi/acpica/include/acdebug.h index 8f3f47175b1..56e01269fd3 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acdebug.h +++ b/reactos/drivers/bus/acpi/acpica/include/acdebug.h @@ -233,8 +233,8 @@ AcpiDbDisassembleAml ( ACPI_PARSE_OBJECT *Op); void -AcpiDbBatchExecute ( - char *CountArg); +AcpiDbEvaluatePredefinedNames ( + void); /* @@ -421,8 +421,7 @@ AcpiDbExecuteThread ( ACPI_STATUS AcpiDbUserCommands ( - char Prompt, - ACPI_PARSE_OBJECT *Op); + void); char * AcpiDbGetNextToken ( diff --git a/reactos/drivers/bus/acpi/acpica/include/acdisasm.h b/reactos/drivers/bus/acpi/acpica/include/acdisasm.h index d60be8fd0b4..bbf727962c2 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acdisasm.h +++ b/reactos/drivers/bus/acpi/acpica/include/acdisasm.h @@ -280,8 +280,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt[]; @@ -425,14 +425,11 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoXenv[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2]; -extern ACPI_DMTABLE_INFO *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1]; - - /* * dmtable and ahtable */ extern const ACPI_DMTABLE_DATA AcpiDmTableData[]; -extern const AH_TABLE AcpiSupportedTables[]; +extern const AH_TABLE Gbl_AcpiSupportedTables[]; UINT8 AcpiDmGenerateChecksum ( @@ -654,6 +651,10 @@ AcpiDmDisassembleOneOp ( ACPI_OP_WALK_INFO *Info, ACPI_PARSE_OBJECT *Op); +BOOLEAN +AcpiDmIsTempName ( + ACPI_PARSE_OBJECT *Op); + UINT32 AcpiDmListType ( ACPI_PARSE_OBJECT *Op); diff --git a/reactos/drivers/bus/acpi/acpica/include/acevents.h b/reactos/drivers/bus/acpi/acpica/include/acevents.h index a14dbe57c1b..a2ea52042e4 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acevents.h +++ b/reactos/drivers/bus/acpi/acpica/include/acevents.h @@ -115,6 +115,11 @@ ACPI_STATUS AcpiEvEnableGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo); +ACPI_STATUS +AcpiEvMaskGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN IsMasked); + ACPI_STATUS AcpiEvAddGpeReference ( ACPI_GPE_EVENT_INFO *GpeEventInfo); @@ -331,8 +336,7 @@ AcpiEvDefaultRegionSetup ( ACPI_STATUS AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked); + ACPI_OPERAND_OBJECT *RegionObj); /* diff --git a/reactos/drivers/bus/acpi/acpica/include/acexcep.h b/reactos/drivers/bus/acpi/acpica/include/acexcep.h index 0f9a6aa5691..2fe81dccce3 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acexcep.h +++ b/reactos/drivers/bus/acpi/acpica/include/acexcep.h @@ -217,11 +217,10 @@ typedef struct acpi_exception_info #define AE_CTRL_TRANSFER EXCEP_CTL (0x0008) #define AE_CTRL_BREAK EXCEP_CTL (0x0009) #define AE_CTRL_CONTINUE EXCEP_CTL (0x000A) -#define AE_CTRL_SKIP EXCEP_CTL (0x000B) -#define AE_CTRL_PARSE_CONTINUE EXCEP_CTL (0x000C) -#define AE_CTRL_PARSE_PENDING EXCEP_CTL (0x000D) +#define AE_CTRL_PARSE_CONTINUE EXCEP_CTL (0x000B) +#define AE_CTRL_PARSE_PENDING EXCEP_CTL (0x000C) -#define AE_CODE_CTRL_MAX 0x000D +#define AE_CODE_CTRL_MAX 0x000C /* Exception strings for AcpiFormatException */ @@ -344,7 +343,6 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Ctrl[] = EXCEP_TXT ("AE_CTRL_TRANSFER", "Transfer control to called method"), EXCEP_TXT ("AE_CTRL_BREAK", "A Break has been executed"), EXCEP_TXT ("AE_CTRL_CONTINUE", "A Continue has been executed"), - EXCEP_TXT ("AE_CTRL_SKIP", "Not currently used"), EXCEP_TXT ("AE_CTRL_PARSE_CONTINUE", "Used to skip over bad opcodes"), EXCEP_TXT ("AE_CTRL_PARSE_PENDING", "Used to implement AML While loops") }; diff --git a/reactos/drivers/bus/acpi/acpica/include/acglobal.h b/reactos/drivers/bus/acpi/acpica/include/acglobal.h index fc7a7a213fd..60a2ffddfbf 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acglobal.h +++ b/reactos/drivers/bus/acpi/acpica/include/acglobal.h @@ -245,10 +245,6 @@ ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); ACPI_GLOBAL (ACPI_THREAD_STATE *, AcpiGbl_CurrentWalkList); -/* Maximum number of While() loop iterations before forced abort */ - -ACPI_GLOBAL (UINT16, AcpiGbl_MaxLoopIterations); - /* Control method single step flag */ ACPI_GLOBAL (UINT8, AcpiGbl_CmSingleStep); @@ -322,6 +318,7 @@ ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_CstyleDisassembly, TRUE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ForceAmlDisassembly, FALSE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Verbose, TRUE); ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DmEmitExternalOpcodes, FALSE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DoDisassemblerOptimizations, TRUE); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Disasm); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DmOpt_Listing); @@ -334,7 +331,6 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); #ifdef ACPI_DEBUGGER ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); -ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE); ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); @@ -353,7 +349,6 @@ ACPI_GLOBAL (ACPI_OBJECT_TYPE, AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARG /* These buffers should all be the same size */ -ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]); @@ -368,9 +363,6 @@ ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc); ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes); ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects); -ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandReady); -ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandComplete); - #endif /* ACPI_DEBUGGER */ #if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) diff --git a/reactos/drivers/bus/acpi/acpica/include/aclocal.h b/reactos/drivers/bus/acpi/acpica/include/aclocal.h index e7a0d37d144..734cae17a3b 100644 --- a/reactos/drivers/bus/acpi/acpica/include/aclocal.h +++ b/reactos/drivers/bus/acpi/acpica/include/aclocal.h @@ -550,11 +550,12 @@ typedef union acpi_gpe_dispatch_info */ typedef struct acpi_gpe_event_info { - union acpi_gpe_dispatch_info Dispatch; /* Either Method, Handler, or NotifyList */ - struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ - UINT8 Flags; /* Misc info about this GPE */ - UINT8 GpeNumber; /* This GPE */ - UINT8 RuntimeCount; /* References to a run GPE */ + union acpi_gpe_dispatch_info Dispatch; /* Either Method, Handler, or NotifyList */ + struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ + UINT8 Flags; /* Misc info about this GPE */ + UINT8 GpeNumber; /* This GPE */ + UINT8 RuntimeCount; /* References to a run GPE */ + BOOLEAN DisableForDispatch; /* Masked during dispatching */ } ACPI_GPE_EVENT_INFO; @@ -567,6 +568,7 @@ typedef struct acpi_gpe_register_info UINT16 BaseGpeNumber; /* Base GPE number for this register */ UINT8 EnableForWake; /* GPEs to keep enabled when sleeping */ UINT8 EnableForRun; /* GPEs to keep enabled when running */ + UINT8 MaskForRun; /* GPEs to keep masked when running */ UINT8 EnableMask; /* Current mask of enabled GPEs */ } ACPI_GPE_REGISTER_INFO; @@ -915,13 +917,13 @@ typedef union acpi_parse_value ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ UINT8 ArgListLength; /* Number of elements in the arg list */\ ACPI_DISASM_ONLY_MEMBERS (\ - UINT8 DisasmFlags; /* Used during AML disassembly */\ + UINT16 DisasmFlags; /* Used during AML disassembly */\ UINT8 DisasmOpcode; /* Subtype used for disassembly */\ char *OperatorSymbol;/* Used for C-style operator name strings */\ char AmlOpName[16]) /* Op name (debug only) */ -/* Flags for DisasmFlags field above */ +/* Internal opcodes for DisasmOpcode field above */ #define ACPI_DASM_BUFFER 0x00 /* Buffer is a simple data buffer */ #define ACPI_DASM_RESOURCE 0x01 /* Buffer is a Resource Descriptor */ @@ -934,7 +936,10 @@ typedef union acpi_parse_value #define ACPI_DASM_LNOT_PREFIX 0x08 /* Start of a LNotEqual (etc.) pair of opcodes */ #define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a LNotEqual (etc.) pair of opcodes */ #define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */ -#define ACPI_DASM_IGNORE 0x0B /* Not used at this time */ +#define ACPI_DASM_IGNORE_SINGLE 0x0B /* Ignore the opcode but not it's children */ +#define ACPI_DASM_SWITCH_PREDICATE 0x0C /* Object is a predicate for a Switch or Case block */ +#define ACPI_DASM_CASE 0x0D /* If/Else is a Case in a Switch/Case block */ +#define ACPI_DASM_DEFAULT 0x0E /* Else is a Default in a Switch/Case block */ /* * Generic operation (for example: If, While, Store) @@ -1035,14 +1040,15 @@ typedef struct acpi_parse_state /* Parse object DisasmFlags */ -#define ACPI_PARSEOP_IGNORE 0x01 -#define ACPI_PARSEOP_PARAMETER_LIST 0x02 -#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 -#define ACPI_PARSEOP_PREDEFINED_CHECKED 0x08 -#define ACPI_PARSEOP_CLOSING_PAREN 0x10 -#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT 0x20 -#define ACPI_PARSEOP_ASSIGNMENT 0x40 -#define ACPI_PARSEOP_ELSEIF 0x80 +#define ACPI_PARSEOP_IGNORE 0x0001 +#define ACPI_PARSEOP_PARAMETER_LIST 0x0002 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x0004 +#define ACPI_PARSEOP_PREDEFINED_CHECKED 0x0008 +#define ACPI_PARSEOP_CLOSING_PAREN 0x0010 +#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT 0x0020 +#define ACPI_PARSEOP_ASSIGNMENT 0x0040 +#define ACPI_PARSEOP_ELSEIF 0x0080 +#define ACPI_PARSEOP_LEGACY_ASL_ONLY 0x0100 /***************************************************************************** diff --git a/reactos/drivers/bus/acpi/acpica/include/acmacros.h b/reactos/drivers/bus/acpi/acpica/include/acmacros.h index 21256cbba7b..5a5e79318a7 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acmacros.h +++ b/reactos/drivers/bus/acpi/acpica/include/acmacros.h @@ -47,7 +47,7 @@ /* * Extract data using a pointer. Any more than a byte and we - * get into potential aligment issues -- see the STORE macros below. + * get into potential alignment issues -- see the STORE macros below. * Use with care. */ #define ACPI_CAST8(ptr) ACPI_CAST_PTR (UINT8, (ptr)) @@ -64,7 +64,7 @@ #define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (UINT64) (val)) /* - * printf() format helper. This macros is a workaround for the difficulties + * printf() format helper. This macro is a workaround for the difficulties * with emitting 64-bit integers and 64-bit pointers with the same code * for both 32-bit and 64-bit hosts. */ @@ -264,14 +264,93 @@ #define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) +/* Generic bit manipulation */ + +#ifndef ACPI_USE_NATIVE_BIT_FINDER + +#define __ACPI_FIND_LAST_BIT_2(a, r) ((((UINT8) (a)) & 0x02) ? (r)+1 : (r)) +#define __ACPI_FIND_LAST_BIT_4(a, r) ((((UINT8) (a)) & 0x0C) ? \ + __ACPI_FIND_LAST_BIT_2 ((a)>>2, (r)+2) : \ + __ACPI_FIND_LAST_BIT_2 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_8(a, r) ((((UINT8) (a)) & 0xF0) ? \ + __ACPI_FIND_LAST_BIT_4 ((a)>>4, (r)+4) : \ + __ACPI_FIND_LAST_BIT_4 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_16(a, r) ((((UINT16) (a)) & 0xFF00) ? \ + __ACPI_FIND_LAST_BIT_8 ((a)>>8, (r)+8) : \ + __ACPI_FIND_LAST_BIT_8 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_32(a, r) ((((UINT32) (a)) & 0xFFFF0000) ? \ + __ACPI_FIND_LAST_BIT_16 ((a)>>16, (r)+16) : \ + __ACPI_FIND_LAST_BIT_16 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_64(a, r) ((((UINT64) (a)) & 0xFFFFFFFF00000000) ? \ + __ACPI_FIND_LAST_BIT_32 ((a)>>32, (r)+32) : \ + __ACPI_FIND_LAST_BIT_32 ((a), (r))) + +#define ACPI_FIND_LAST_BIT_8(a) ((a) ? __ACPI_FIND_LAST_BIT_8 (a, 1) : 0) +#define ACPI_FIND_LAST_BIT_16(a) ((a) ? __ACPI_FIND_LAST_BIT_16 (a, 1) : 0) +#define ACPI_FIND_LAST_BIT_32(a) ((a) ? __ACPI_FIND_LAST_BIT_32 (a, 1) : 0) +#define ACPI_FIND_LAST_BIT_64(a) ((a) ? __ACPI_FIND_LAST_BIT_64 (a, 1) : 0) + +#define __ACPI_FIND_FIRST_BIT_2(a, r) ((((UINT8) (a)) & 0x01) ? (r) : (r)+1) +#define __ACPI_FIND_FIRST_BIT_4(a, r) ((((UINT8) (a)) & 0x03) ? \ + __ACPI_FIND_FIRST_BIT_2 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_2 ((a)>>2, (r)+2)) +#define __ACPI_FIND_FIRST_BIT_8(a, r) ((((UINT8) (a)) & 0x0F) ? \ + __ACPI_FIND_FIRST_BIT_4 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_4 ((a)>>4, (r)+4)) +#define __ACPI_FIND_FIRST_BIT_16(a, r) ((((UINT16) (a)) & 0x00FF) ? \ + __ACPI_FIND_FIRST_BIT_8 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_8 ((a)>>8, (r)+8)) +#define __ACPI_FIND_FIRST_BIT_32(a, r) ((((UINT32) (a)) & 0x0000FFFF) ? \ + __ACPI_FIND_FIRST_BIT_16 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_16 ((a)>>16, (r)+16)) +#define __ACPI_FIND_FIRST_BIT_64(a, r) ((((UINT64) (a)) & 0x00000000FFFFFFFF) ? \ + __ACPI_FIND_FIRST_BIT_32 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_32 ((a)>>32, (r)+32)) + +#define ACPI_FIND_FIRST_BIT_8(a) ((a) ? __ACPI_FIND_FIRST_BIT_8 (a, 1) : 0) +#define ACPI_FIND_FIRST_BIT_16(a) ((a) ? __ACPI_FIND_FIRST_BIT_16 (a, 1) : 0) +#define ACPI_FIND_FIRST_BIT_32(a) ((a) ? __ACPI_FIND_FIRST_BIT_32 (a, 1) : 0) +#define ACPI_FIND_FIRST_BIT_64(a) ((a) ? __ACPI_FIND_FIRST_BIT_64 (a, 1) : 0) + +#endif /* ACPI_USE_NATIVE_BIT_FINDER */ + +/* Generic (power-of-two) rounding */ + +#define ACPI_ROUND_UP_POWER_OF_TWO_8(a) ((UINT8) \ + (((UINT16) 1) << ACPI_FIND_LAST_BIT_8 ((a) - 1))) +#define ACPI_ROUND_DOWN_POWER_OF_TWO_8(a) ((UINT8) \ + (((UINT16) 1) << (ACPI_FIND_LAST_BIT_8 ((a)) - 1))) +#define ACPI_ROUND_UP_POWER_OF_TWO_16(a) ((UINT16) \ + (((UINT32) 1) << ACPI_FIND_LAST_BIT_16 ((a) - 1))) +#define ACPI_ROUND_DOWN_POWER_OF_TWO_16(a) ((UINT16) \ + (((UINT32) 1) << (ACPI_FIND_LAST_BIT_16 ((a)) - 1))) +#define ACPI_ROUND_UP_POWER_OF_TWO_32(a) ((UINT32) \ + (((UINT64) 1) << ACPI_FIND_LAST_BIT_32 ((a) - 1))) +#define ACPI_ROUND_DOWN_POWER_OF_TWO_32(a) ((UINT32) \ + (((UINT64) 1) << (ACPI_FIND_LAST_BIT_32 ((a)) - 1))) +#define ACPI_IS_ALIGNED(a, s) (((a) & ((s) - 1)) == 0) +#define ACPI_IS_POWER_OF_TWO(a) ACPI_IS_ALIGNED(a, a) + /* * Bitmask creation * Bit positions start at zero. * MASK_BITS_ABOVE creates a mask starting AT the position and above * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + * MASK_BITS_ABOVE/BELOW accepts a bit offset to create a mask + * MASK_BITS_ABOVE/BELOW_32/64 accepts a bit width to create a mask + * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler + * differences with the shift operator */ #define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((UINT32) (position)))) #define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((UINT32) (position))) +#define ACPI_MASK_BITS_ABOVE_32(width) ((UINT32) ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_32(width) ((UINT32) ACPI_MASK_BITS_BELOW(width)) +#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + ACPI_UINT64_MAX : \ + ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + (UINT64) 0 : \ + ACPI_MASK_BITS_BELOW(width)) /* Bitfields within ACPI registers */ @@ -376,7 +455,7 @@ */ #ifndef ACPI_NO_ERROR_MESSAGES /* - * Error reporting. Callers module and line number are inserted by AE_INFO, + * Error reporting. The callers module and line number are inserted by AE_INFO, * the plist contains a set of parens to allow variable-length lists. * These macros are used for both the debug and non-debug versions of the code. */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acnamesp.h b/reactos/drivers/bus/acpi/acpica/include/acnamesp.h index 11ee70d044e..09b319cc87c 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acnamesp.h +++ b/reactos/drivers/bus/acpi/acpica/include/acnamesp.h @@ -143,6 +143,11 @@ AcpiNsParseTable ( UINT32 TableIndex, ACPI_NAMESPACE_NODE *StartNode); +ACPI_STATUS +AcpiNsExecuteTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + ACPI_STATUS AcpiNsOneCompleteParse ( UINT32 PassNumber, @@ -379,6 +384,11 @@ char * AcpiNsNameOfCurrentScope ( ACPI_WALK_STATE *WalkState); +ACPI_STATUS +AcpiNsHandleToName ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer); + ACPI_STATUS AcpiNsHandleToPathname ( ACPI_HANDLE TargetHandle, @@ -390,6 +400,13 @@ AcpiNsPatternMatch ( ACPI_NAMESPACE_NODE *ObjNode, char *SearchFor); +ACPI_STATUS +AcpiNsGetNodeUnlocked ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *ExternalPathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **OutNode); + ACPI_STATUS AcpiNsGetNode ( ACPI_NAMESPACE_NODE *PrefixNode, diff --git a/reactos/drivers/bus/acpi/acpica/include/acopcode.h b/reactos/drivers/bus/acpi/acpica/include/acopcode.h index a278d4a154a..e5c35255ca5 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acopcode.h +++ b/reactos/drivers/bus/acpi/acpica/include/acopcode.h @@ -93,7 +93,7 @@ #define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) #define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_NAME_OR_REF,ARGP_TARGET) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SIMPLENAME, ARGP_TARGET) #define ARGP_CONNECTFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_CONTINUE_OP ARG_NONE #define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) @@ -106,7 +106,7 @@ #define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) #define ARGP_DEBUG_OP ARG_NONE #define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) #define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) #define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) @@ -153,14 +153,14 @@ #define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) #define ARGP_NOOP_OP ARG_NONE #define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_OBJECT_TYPE_OP ARGP_LIST1 (ARGP_NAME_OR_REF) +#define ARGP_OBJECT_TYPE_OP ARGP_LIST1 (ARGP_SIMPLENAME) #define ARGP_ONE_OP ARG_NONE #define ARGP_ONES_OP ARG_NONE #define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) #define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) #define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) #define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) -#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_NAME_OR_REF) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SIMPLENAME) #define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) #define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) @@ -251,7 +251,7 @@ #define ARGI_FIELD_OP ARGI_INVALID_OPCODE #define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_IF_OP ARGI_INVALID_OPCODE #define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) #define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE @@ -315,12 +315,12 @@ #define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE #define ARGI_TIMER_OP ARG_NONE -#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_TARGETREF) +#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) #define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) diff --git a/reactos/drivers/bus/acpi/acpica/include/acparser.h b/reactos/drivers/bus/acpi/acpica/include/acparser.h index dd2782199d0..4137981024f 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acparser.h +++ b/reactos/drivers/bus/acpi/acpica/include/acparser.h @@ -83,6 +83,10 @@ ACPI_STATUS AcpiPsExecuteMethod ( ACPI_EVALUATE_INFO *Info); +ACPI_STATUS +AcpiPsExecuteTable ( + ACPI_EVALUATE_INFO *Info); + /* * psargs - Parse AML opcode arguments diff --git a/reactos/drivers/bus/acpi/acpica/include/acpi.h b/reactos/drivers/bus/acpi/acpica/include/acpi.h index aae60df2422..664cd82c2bb 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acpi.h +++ b/reactos/drivers/bus/acpi/acpica/include/acpi.h @@ -46,7 +46,7 @@ #ifdef __REACTOS__ /* - * Header inclusion HACK (see modifications to actypes.h too). + * Header inclusion HACK. */ #include #undef ACPI_BIOS_ERROR // ACPI_BIOS_ERROR is redefined in acoutput.h diff --git a/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h b/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h index 788e06644d1..9c5775f0239 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h +++ b/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h @@ -456,6 +456,14 @@ AcpiOsSignal ( void *Info); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsEnterSleep +ACPI_STATUS +AcpiOsEnterSleep ( + UINT8 SleepState, + UINT32 RegaValue, + UINT32 RegbValue); +#endif + /* * Debug print routines @@ -482,7 +490,7 @@ AcpiOsRedirectOutput ( /* - * Debug input + * Debug IO */ #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine ACPI_STATUS @@ -492,6 +500,30 @@ AcpiOsGetLine ( UINT32 *BytesRead); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger +ACPI_STATUS +AcpiOsInitializeDebugger ( + void); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger +void +AcpiOsTerminateDebugger ( + void); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitCommandReady +ACPI_STATUS +AcpiOsWaitCommandReady ( + void); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsNotifyCommandComplete +ACPI_STATUS +AcpiOsNotifyCommandComplete ( + void); +#endif + #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint void AcpiOsTracePoint ( diff --git a/reactos/drivers/bus/acpi/acpica/include/acpixf.h b/reactos/drivers/bus/acpi/acpica/include/acpixf.h index 33f000fee2f..ce470205411 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acpixf.h +++ b/reactos/drivers/bus/acpi/acpica/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160729 +#define ACPI_CA_VERSION 0x20161222 #include "acconfig.h" #include "actypes.h" @@ -196,6 +196,13 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DoNotUseXsdt, FALSE); */ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_GroupModuleLevelCode, FALSE); +/* + * Optionally support module level code by parsing the entire table as + * a TermList. Default is FALSE, do not execute entire table until some + * lock order issues are fixed. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_ParseTableAsTermList, FALSE); + /* * Optionally use 32-bit FADT addresses if and when there is a conflict * (address mismatch) between the 32-bit and 64-bit versions of the @@ -253,6 +260,13 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_OsiData, 0); */ ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ReducedHardware, FALSE); +/* + * Maximum number of While() loop iterations before forced method abort. + * This mechanism is intended to prevent infinite loops during interpreter + * execution within a host kernel. + */ +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_MaxLoopIterations, ACPI_MAX_LOOP_COUNT); + /* * This mechanism is used to trace a specified AML method. The method is * traced each time it is executed. @@ -278,6 +292,15 @@ ACPI_INIT_GLOBAL (UINT32, AcpiDbgLayer, ACPI_COMPONENT_DEFAULT); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisplayDebugTimer, FALSE); +/* + * Debugger command handshake globals. Host OSes need to access these + * variables to implement their own command handshake mechanism. + */ +#ifdef ACPI_DEBUGGER +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE); +ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]); +#endif + /* * Other miscellaneous globals */ @@ -568,6 +591,11 @@ AcpiGetTable ( UINT32 Instance, ACPI_TABLE_HEADER **OutTable)) +ACPI_EXTERNAL_RETURN_VOID ( +void +AcpiPutTable ( + ACPI_TABLE_HEADER *Table)) + ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetTableByIndex ( @@ -907,6 +935,13 @@ AcpiFinishGpe ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber)) +ACPI_HW_DEPENDENT_RETURN_STATUS ( +ACPI_STATUS +AcpiMaskGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + BOOLEAN IsMasked)) + ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS AcpiMarkGpeForWake ( @@ -1240,6 +1275,10 @@ void AcpiTerminateDebugger ( void); +void +AcpiRunDebugger ( + char *BatchBuffer); + void AcpiSetDebuggerThreadId ( ACPI_THREAD_ID ThreadId); diff --git a/reactos/drivers/bus/acpi/acpica/include/actables.h b/reactos/drivers/bus/acpi/acpica/include/actables.h index 6abb14cc3ff..3269728a7fd 100644 --- a/reactos/drivers/bus/acpi/acpica/include/actables.h +++ b/reactos/drivers/bus/acpi/acpica/include/actables.h @@ -178,6 +178,22 @@ void AcpiTbUninstallTable ( ACPI_TABLE_DESC *TableDesc); +ACPI_STATUS +AcpiTbLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode); + +ACPI_STATUS +AcpiTbInstallAndLoadTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + BOOLEAN Override, + UINT32 *TableIndex); + +ACPI_STATUS +AcpiTbUnloadTable ( + UINT32 TableIndex); + void AcpiTbTerminate ( void); @@ -237,15 +253,18 @@ AcpiTbInstallTableWithOverride ( UINT32 *TableIndex); ACPI_STATUS -AcpiTbInstallFixedTable ( - ACPI_PHYSICAL_ADDRESS Address, - char *Signature, - UINT32 *TableIndex); - -ACPI_STATUS ACPI_INIT_FUNCTION AcpiTbParseRootTable ( ACPI_PHYSICAL_ADDRESS RsdpAddress); +ACPI_STATUS +AcpiTbGetTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **OutTable); + +void +AcpiTbPutTable ( + ACPI_TABLE_DESC *TableDesc); + /* * tbxfload diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl.h b/reactos/drivers/bus/acpi/acpica/include/actbl.h index b5c76c9c1b0..93e1a51fb0f 100644 --- a/reactos/drivers/bus/acpi/acpica/include/actbl.h +++ b/reactos/drivers/bus/acpi/acpica/include/actbl.h @@ -256,72 +256,62 @@ typedef struct acpi_table_facs typedef struct acpi_table_fadt { - ACPI_TABLE_HEADER Header; /* [V1] Common ACPI table header */ - UINT32 Facs; /* [V1] 32-bit physical address of FACS */ - UINT32 Dsdt; /* [V1] 32-bit physical address of DSDT */ - UINT8 Model; /* [V1] System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ - UINT8 PreferredProfile; /* [V1] Conveys preferred power management profile to OSPM. */ - UINT16 SciInterrupt; /* [V1] System vector of SCI interrupt */ - UINT32 SmiCommand; /* [V1] 32-bit Port address of SMI command port */ - UINT8 AcpiEnable; /* [V1] Value to write to SMI_CMD to enable ACPI */ - UINT8 AcpiDisable; /* [V1] Value to write to SMI_CMD to disable ACPI */ - UINT8 S4BiosRequest; /* [V1] Value to write to SMI_CMD to enter S4BIOS state */ - UINT8 PstateControl; /* [V1] Processor performance state control*/ - UINT32 Pm1aEventBlock; /* [V1] 32-bit port address of Power Mgt 1a Event Reg Blk */ - UINT32 Pm1bEventBlock; /* [V1] 32-bit port address of Power Mgt 1b Event Reg Blk */ - UINT32 Pm1aControlBlock; /* [V1] 32-bit port address of Power Mgt 1a Control Reg Blk */ - UINT32 Pm1bControlBlock; /* [V1] 32-bit port address of Power Mgt 1b Control Reg Blk */ - UINT32 Pm2ControlBlock; /* [V1] 32-bit port address of Power Mgt 2 Control Reg Blk */ - UINT32 PmTimerBlock; /* [V1] 32-bit port address of Power Mgt Timer Ctrl Reg Blk */ - UINT32 Gpe0Block; /* [V1] 32-bit port address of General Purpose Event 0 Reg Blk */ - UINT32 Gpe1Block; /* [V1] 32-bit port address of General Purpose Event 1 Reg Blk */ - UINT8 Pm1EventLength; /* [V1] Byte Length of ports at Pm1xEventBlock */ - UINT8 Pm1ControlLength; /* [V1] Byte Length of ports at Pm1xControlBlock */ - UINT8 Pm2ControlLength; /* [V1] Byte Length of ports at Pm2ControlBlock */ - UINT8 PmTimerLength; /* [V1] Byte Length of ports at PmTimerBlock */ - UINT8 Gpe0BlockLength; /* [V1] Byte Length of ports at Gpe0Block */ - UINT8 Gpe1BlockLength; /* [V1] Byte Length of ports at Gpe1Block */ - UINT8 Gpe1Base; /* [V1] Offset in GPE number space where GPE1 events start */ - UINT8 CstControl; /* [V1] Support for the _CST object and C-States change notification */ - UINT16 C2Latency; /* [V1] Worst case HW latency to enter/exit C2 state */ - UINT16 C3Latency; /* [V1] Worst case HW latency to enter/exit C3 state */ - UINT16 FlushSize; /* [V1] Processor memory cache line width, in bytes */ - UINT16 FlushStride; /* [V1] Number of flush strides that need to be read */ - UINT8 DutyOffset; /* [V1] Processor duty cycle index in processor P_CNT reg */ - UINT8 DutyWidth; /* [V1] Processor duty cycle value bit width in P_CNT register */ - UINT8 DayAlarm; /* [V1] Index to day-of-month alarm in RTC CMOS RAM */ - UINT8 MonthAlarm; /* [V1] Index to month-of-year alarm in RTC CMOS RAM */ - UINT8 Century; /* [V1] Index to century in RTC CMOS RAM */ - UINT16 BootFlags; /* [V3] IA-PC Boot Architecture Flags (see below for individual flags) */ - UINT8 Reserved; /* [V1] Reserved, must be zero */ - UINT32 Flags; /* [V1] Miscellaneous flag bits (see below for individual flags) */ - /* End of Version 1 FADT fields (ACPI 1.0) */ - - ACPI_GENERIC_ADDRESS ResetRegister; /* [V3] 64-bit address of the Reset register */ - UINT8 ResetValue; /* [V3] Value to write to the ResetRegister port to reset the system */ - UINT16 ArmBootFlags; /* [V5] ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ - UINT8 MinorRevision; /* [V5] FADT Minor Revision (ACPI 5.1) */ - UINT64 XFacs; /* [V3] 64-bit physical address of FACS */ - UINT64 XDsdt; /* [V3] 64-bit physical address of DSDT */ - ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* [V3] 64-bit Extended Power Mgt 1a Event Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* [V3] 64-bit Extended Power Mgt 1b Event Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* [V3] 64-bit Extended Power Mgt 1a Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* [V3] 64-bit Extended Power Mgt 1b Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* [V3] 64-bit Extended Power Mgt 2 Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPmTimerBlock; /* [V3] 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe0Block; /* [V3] 64-bit Extended General Purpose Event 0 Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe1Block; /* [V3] 64-bit Extended General Purpose Event 1 Reg Blk address */ - /* End of Version 3 FADT fields (ACPI 2.0) */ - - ACPI_GENERIC_ADDRESS SleepControl; /* [V4] 64-bit Sleep Control register (ACPI 5.0) */ - /* End of Version 4 FADT fields (ACPI 3.0 and ACPI 4.0) (Field was originally reserved in ACPI 3.0) */ - - ACPI_GENERIC_ADDRESS SleepStatus; /* [V5] 64-bit Sleep Status register (ACPI 5.0) */ - /* End of Version 5 FADT fields (ACPI 5.0) */ - - UINT64 HypervisorId; /* [V6] Hypervisor Vendor ID (ACPI 6.0) */ - /* End of Version 6 FADT fields (ACPI 6.0) */ - + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to SMI_CMD to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to SMI_CMD to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI_CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C-States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT16 ArmBootFlags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ + UINT8 MinorRevision; /* FADT Minor Revision (ACPI 5.1) */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + ACPI_GENERIC_ADDRESS SleepControl; /* 64-bit Sleep Control register (ACPI 5.0) */ + ACPI_GENERIC_ADDRESS SleepStatus; /* 64-bit Sleep Status register (ACPI 5.0) */ + UINT64 HypervisorId; /* Hypervisor Vendor ID (ACPI 6.0) */ } ACPI_TABLE_FADT; @@ -337,8 +327,8 @@ typedef struct acpi_table_fadt /* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ -#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5] PSCI 0.2+ is implemented */ -#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5] HVC must be used instead of SMC as the PSCI conduit */ +#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ /* Masks for FADT flags */ @@ -415,6 +405,7 @@ typedef struct acpi_table_desc ACPI_NAME_UNION Signature; ACPI_OWNER_ID OwnerId; UINT8 Flags; + UINT16 ValidationCount; } ACPI_TABLE_DESC; @@ -445,34 +436,20 @@ typedef struct acpi_table_desc * match the expected length. In other words, the length of the * FADT is the bottom line as to what the version really is. * - * NOTE: There is no officialy released V2 of the FADT. This - * version was used only for prototyping and testing during the - * 32-bit to 64-bit transition. V3 was the first official 64-bit - * version of the FADT. - * - * Update this list of defines when a new version of the FADT is - * added to the ACPI specification. Note that the FADT version is - * only incremented when new fields are appended to the existing - * version. Therefore, the FADT version is competely independent - * from the version of the ACPI specification where it is - * defined. - * - * For reference, the various FADT lengths are as follows: - * FADT V1 size: 0x074 ACPI 1.0 - * FADT V3 size: 0x0F4 ACPI 2.0 - * FADT V4 size: 0x100 ACPI 3.0 and ACPI 4.0 - * FADT V5 size: 0x10C ACPI 5.0 - * FADT V6 size: 0x114 ACPI 6.0 + * For reference, the values below are as follows: + * FADT V1 size: 0x074 + * FADT V2 size: 0x084 + * FADT V3 size: 0x0F4 + * FADT V4 size: 0x0F4 + * FADT V5 size: 0x10C + * FADT V6 size: 0x114 */ -#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) /* ACPI 1.0 */ -#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) /* ACPI 2.0 */ -#define ACPI_FADT_V4_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepStatus)) /* ACPI 3.0 and ACPI 4.0 */ -#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) /* ACPI 5.0 */ -#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) /* ACPI 6.0 */ - -/* Update these when new FADT versions are added */ +#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1) +#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) +#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) +#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) -#define ACPI_FADT_MAX_VERSION 6 #define ACPI_FADT_CONFORMANCE "ACPI 6.1 (FADT version 6)" #endif /* __ACTBL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actypes.h b/reactos/drivers/bus/acpi/acpica/include/actypes.h index 3861f12d5ba..0d2ab4cc8ad 100644 --- a/reactos/drivers/bus/acpi/acpica/include/actypes.h +++ b/reactos/drivers/bus/acpi/acpica/include/actypes.h @@ -745,16 +745,17 @@ typedef UINT32 ACPI_EVENT_TYPE; * The encoding of ACPI_EVENT_STATUS is illustrated below. * Note that a set bit (1) indicates the property is TRUE * (e.g. if bit 0 is set then the event is enabled). - * +-------------+-+-+-+-+-+ - * | Bits 31:5 |4|3|2|1|0| - * +-------------+-+-+-+-+-+ - * | | | | | | - * | | | | | +- Enabled? - * | | | | +--- Enabled for wake? - * | | | +----- Status bit set? - * | | +------- Enable bit set? - * | +--------- Has a handler? - * +--------------- + * +-------------+-+-+-+-+-+-+ + * | Bits 31:6 |5|4|3|2|1|0| + * +-------------+-+-+-+-+-+-+ + * | | | | | | | + * | | | | | | +- Enabled? + * | | | | | +--- Enabled for wake? + * | | | | +----- Status bit set? + * | | | +------- Enable bit set? + * | | +--------- Has a handler? + * | +----------- Masked? + * +----------------- */ typedef UINT32 ACPI_EVENT_STATUS; @@ -764,6 +765,7 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_EVENT_FLAG_STATUS_SET (ACPI_EVENT_STATUS) 0x04 #define ACPI_EVENT_FLAG_ENABLE_SET (ACPI_EVENT_STATUS) 0x08 #define ACPI_EVENT_FLAG_HAS_HANDLER (ACPI_EVENT_STATUS) 0x10 +#define ACPI_EVENT_FLAG_MASKED (ACPI_EVENT_STATUS) 0x20 #define ACPI_EVENT_FLAG_SET ACPI_EVENT_FLAG_STATUS_SET /* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */ @@ -774,14 +776,15 @@ typedef UINT32 ACPI_EVENT_STATUS; /* * GPE info flags - Per GPE - * +-------+-+-+---+ - * | 7:5 |4|3|2:0| - * +-------+-+-+---+ - * | | | | - * | | | +-- Type of dispatch:to method, handler, notify, or none - * | | +----- Interrupt type: edge or level triggered - * | +------- Is a Wake GPE - * +------------ + * +---+-+-+-+---+ + * |7:6|5|4|3|2:0| + * +---+-+-+-+---+ + * | | | | | + * | | | | +-- Type of dispatch:to method, handler, notify, or none + * | | | +----- Interrupt type: edge or level triggered + * | | +------- Is a Wake GPE + * | +--------- Is GPE masked by the software GPE masking machanism + * +------------ */ #define ACPI_GPE_DISPATCH_NONE (UINT8) 0x00 #define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x01 @@ -1079,13 +1082,6 @@ typedef struct acpi_statistics } ACPI_STATISTICS; -/* Table Event Types */ - -#define ACPI_TABLE_EVENT_LOAD 0x0 -#define ACPI_TABLE_EVENT_UNLOAD 0x1 -#define ACPI_NUM_TABLE_EVENTS 2 - - /* * Types specific to the OS service interfaces */ @@ -1158,9 +1154,14 @@ ACPI_STATUS (*ACPI_TABLE_HANDLER) ( void *Table, void *Context); -#define ACPI_TABLE_LOAD 0x0 -#define ACPI_TABLE_UNLOAD 0x1 -#define ACPI_NUM_TABLE_EVENTS 2 + +/* Table Event Types */ + +#define ACPI_TABLE_EVENT_LOAD 0x0 +#define ACPI_TABLE_EVENT_UNLOAD 0x1 +#define ACPI_TABLE_EVENT_INSTALL 0x2 +#define ACPI_TABLE_EVENT_UNINSTALL 0x3 +#define ACPI_NUM_TABLE_EVENTS 4 /* Address Spaces (For Operation Regions) */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acutils.h b/reactos/drivers/bus/acpi/acpica/include/acutils.h index f83996a4126..ac135ebb8b1 100644 --- a/reactos/drivers/bus/acpi/acpica/include/acutils.h +++ b/reactos/drivers/bus/acpi/acpica/include/acutils.h @@ -224,14 +224,16 @@ AcpiUtStricmp ( ACPI_STATUS AcpiUtStrtoul64 ( char *String, - UINT32 Base, - UINT32 MaxIntegerByteWidth, + UINT32 Flags, UINT64 *RetInteger); -/* Values for MaxIntegerByteWidth above */ - -#define ACPI_MAX32_BYTE_WIDTH 4 -#define ACPI_MAX64_BYTE_WIDTH 8 +/* + * Values for Flags above + * Note: LIMIT values correspond to AcpiGbl_IntegerByteWidth values (4/8) + */ +#define ACPI_STRTOUL_32BIT 0x04 /* 4 bytes */ +#define ACPI_STRTOUL_64BIT 0x08 /* 8 bytes */ +#define ACPI_STRTOUL_BASE16 0x10 /* Default: Base10/16 */ /* @@ -281,11 +283,20 @@ const char * AcpiUtGetEventName ( UINT32 EventId); +const char * +AcpiUtGetArgumentTypeName ( + UINT32 ArgType); + char AcpiUtHexToAsciiChar ( UINT64 Integer, UINT32 Position); +ACPI_STATUS +AcpiUtAsciiToHexByte ( + char *TwoAsciiChars, + UINT8 *ReturnByte); + UINT8 AcpiUtAsciiCharToHex ( int HexChar); diff --git a/reactos/drivers/bus/acpi/acpica/include/amlcode.h b/reactos/drivers/bus/acpi/acpica/include/amlcode.h index a432c2b7de7..640029b4428 100644 --- a/reactos/drivers/bus/acpi/acpica/include/amlcode.h +++ b/reactos/drivers/bus/acpi/acpica/include/amlcode.h @@ -243,6 +243,7 @@ #define ARGP_QWORDDATA 0x11 #define ARGP_SIMPLENAME 0x12 /* NameString | LocalTerm | ArgTerm */ #define ARGP_NAME_OR_REF 0x13 /* For ObjectType only */ +#define ARGP_MAX 0x13 /* * Resolved argument types for the AML Interpreter @@ -279,9 +280,24 @@ #define ARGI_DEVICE_REF 0x0D #define ARGI_REFERENCE 0x0E #define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ -#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ -#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ -#define ARGI_STORE_TARGET 0x12 /* Target for store is TARGETREF + package objects */ +#define ARGI_SIMPLE_TARGET 0x10 /* Name, Local, Arg -- no implicit conversion */ +#define ARGI_STORE_TARGET 0x11 /* Target for store is TARGETREF + package objects */ +/* + * #define ARGI_FIXED_TARGET 0x10 Target, no implicit conversion + * + * Removed 10/2016. ARGI_FIXED_TARGET was used for these operators: + * FromBCD + * ToBCD + * ToDecimalString + * ToHexString + * ToInteger + * ToBuffer + * The purpose of this type was to disable "implicit result conversion", + * but this was incorrect per the ACPI spec and other ACPI implementations. + * These operators now have the target operand defined as a normal + * ARGI_TARGETREF. + */ + /* Multiple/complex types */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h b/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h index 56c4b0aaa19..69f1e55c9a4 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h @@ -246,12 +246,16 @@ struct _ACPI_EFI_FILE_IO_INTERFACE; struct _ACPI_EFI_FILE_HANDLE; struct _ACPI_EFI_BOOT_SERVICES; struct _ACPI_EFI_SYSTEM_TABLE; +struct _ACPI_EFI_PCI_IO; extern struct _ACPI_EFI_SYSTEM_TABLE *ST; extern struct _ACPI_EFI_BOOT_SERVICES *BS; -#define FILE struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE -#define stdout ST->ConOut -#define stderr ST->ConOut +typedef union acpi_efi_file ACPI_EFI_FILE; +#define FILE ACPI_EFI_FILE + +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; #endif /* __ACEFI_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acefiex.h b/reactos/drivers/bus/acpi/acpica/include/platform/acefiex.h index 8f98a6266de..c16c1afbbb8 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/acefiex.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acefiex.h @@ -95,6 +95,20 @@ typedef struct { UINT8 Data4[8]; } ACPI_EFI_GUID; +typedef struct { + UINT16 Year; /* 1998 - 20XX */ + UINT8 Month; /* 1 - 12 */ + UINT8 Day; /* 1 - 31 */ + UINT8 Hour; /* 0 - 23 */ + UINT8 Minute; /* 0 - 59 */ + UINT8 Second; /* 0 - 59 */ + UINT8 Pad1; + UINT32 Nanosecond; /* 0 - 999,999,999 */ + INT16 TimeZone; /* -1440 to 1440 or 2047 */ + UINT8 Daylight; + UINT8 Pad2; +} ACPI_EFI_TIME; + typedef struct _ACPI_EFI_DEVICE_PATH { UINT8 Type; UINT8 SubType; @@ -375,6 +389,22 @@ ACPI_EFI_STATUS struct _ACPI_EFI_FILE_HANDLE *File, UINT64 *Position); +#define ACPI_EFI_FILE_INFO_ID \ + { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } + +typedef struct { + UINT64 Size; + UINT64 FileSize; + UINT64 PhysicalSize; + ACPI_EFI_TIME CreateTime; + ACPI_EFI_TIME LastAccessTime; + ACPI_EFI_TIME ModificationTime; + UINT64 Attribute; + CHAR16 FileName[1]; +} ACPI_EFI_FILE_INFO; + +#define SIZE_OF_ACPI_EFI_FILE_INFO ACPI_OFFSET(ACPI_EFI_FILE_INFO, FileName) + typedef ACPI_EFI_STATUS (ACPI_EFI_API *ACPI_EFI_FILE_GET_INFO) ( @@ -457,6 +487,15 @@ ACPI_EFI_STATUS ACPI_EFI_HANDLE ImageHandle); +typedef +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_SET_WATCHDOG_TIMER) ( + UINTN Timeout, + UINT64 WatchdogCode, + UINTN DataSize, + CHAR16 *WatchdogData); + + #define EFI_IMAGE_INFORMATION_REVISION 0x1000 typedef struct { UINT32 Revision; @@ -744,13 +783,12 @@ typedef struct _ACPI_EFI_BOOT_SERVICES { ACPI_EFI_EXIT_BOOT_SERVICES ExitBootServices; ACPI_EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; ACPI_EFI_STALL Stall; - ACPI_EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #else ACPI_EFI_UNKNOWN_INTERFACE ExitBootServices; ACPI_EFI_UNKNOWN_INTERFACE GetNextMonotonicCount; ACPI_EFI_UNKNOWN_INTERFACE Stall; - ACPI_EFI_UNKNOWN_INTERFACE SetWatchdogTimer; #endif + ACPI_EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; #if 0 ACPI_EFI_CONNECT_CONTROLLER ConnectController; @@ -831,6 +869,80 @@ typedef struct _ACPI_EFI_SYSTEM_TABLE { } ACPI_EFI_SYSTEM_TABLE; +/* + * EFI PCI I/O Protocol + */ +#define ACPI_EFI_PCI_IO_PROTOCOL \ + { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a} } + +typedef enum { + AcpiEfiPciIoWidthUint8 = 0, + AcpiEfiPciIoWidthUint16, + AcpiEfiPciIoWidthUint32, + AcpiEfiPciIoWidthUint64, + AcpiEfiPciIoWidthFifoUint8, + AcpiEfiPciIoWidthFifoUint16, + AcpiEfiPciIoWidthFifoUint32, + AcpiEfiPciIoWidthFifoUint64, + AcpiEfiPciIoWidthFillUint8, + AcpiEfiPciIoWidthFillUint16, + AcpiEfiPciIoWidthFillUint32, + AcpiEfiPciIoWidthFillUint64, + AcpiEfiPciIoWidthMaximum +} ACPI_EFI_PCI_IO_PROTOCOL_WIDTH; + +typedef +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_PCI_IO_PROTOCOL_CONFIG)( + struct _ACPI_EFI_PCI_IO *This, + ACPI_EFI_PCI_IO_PROTOCOL_WIDTH Width, + UINT32 Offset, + UINTN Count, + VOID *Buffer); + +typedef struct { + ACPI_EFI_PCI_IO_PROTOCOL_CONFIG Read; + ACPI_EFI_PCI_IO_PROTOCOL_CONFIG Write; +} ACPI_EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; + +typedef +ACPI_EFI_STATUS +(ACPI_EFI_API *ACPI_EFI_PCI_IO_PROTOCOL_GET_LOCATION)( + struct _ACPI_EFI_PCI_IO *This, + UINTN *SegmentNumber, + UINTN *BusNumber, + UINTN *DeviceNumber, + UINTN *FunctionNumber); + +typedef struct _ACPI_EFI_PCI_IO { + ACPI_EFI_UNKNOWN_INTERFACE PollMem; + ACPI_EFI_UNKNOWN_INTERFACE PollIo; + ACPI_EFI_UNKNOWN_INTERFACE Mem; + ACPI_EFI_UNKNOWN_INTERFACE Io; + ACPI_EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; + ACPI_EFI_UNKNOWN_INTERFACE CopyMem; + ACPI_EFI_UNKNOWN_INTERFACE Map; + ACPI_EFI_UNKNOWN_INTERFACE Unmap; + ACPI_EFI_UNKNOWN_INTERFACE AllocateBuffer; + ACPI_EFI_UNKNOWN_INTERFACE FreeBuffer; + ACPI_EFI_UNKNOWN_INTERFACE Flush; + ACPI_EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation; + ACPI_EFI_UNKNOWN_INTERFACE Attributes; + ACPI_EFI_UNKNOWN_INTERFACE GetBarAttributes; + ACPI_EFI_UNKNOWN_INTERFACE SetBarAttributes; + UINT64 RomSize; + VOID *RomImage; +} ACPI_EFI_PCI_IO; + +/* FILE abstraction */ + +union acpi_efi_file { + struct _ACPI_EFI_FILE_HANDLE File; + struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; + struct _ACPI_SIMPLE_INPUT_INTERFACE ConIn; +}; + + /* GNU EFI definitions */ #if defined(_GNU_EFI) @@ -864,5 +976,6 @@ extern ACPI_EFI_GUID AcpiGbl_LoadedImageProtocol; extern ACPI_EFI_GUID AcpiGbl_TextInProtocol; extern ACPI_EFI_GUID AcpiGbl_TextOutProtocol; extern ACPI_EFI_GUID AcpiGbl_FileSystemProtocol; +extern ACPI_EFI_GUID AcpiGbl_GenericFileInfo; #endif /* __ACEFIEX_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h b/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h index 72ee6826f3f..c9125704e8f 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h @@ -76,7 +76,8 @@ (defined ACPI_NAMES_APP) || \ (defined ACPI_SRC_APP) || \ (defined ACPI_XTRACT_APP) || \ - (defined ACPI_EXAMPLE_APP) + (defined ACPI_EXAMPLE_APP) || \ + (defined ACPI_EFI_HELLO) #define ACPI_APPLICATION #define ACPI_SINGLE_THREADED #define USE_NATIVE_ALLOCATE_ZEROED @@ -365,7 +366,7 @@ #include #include #include -#ifdef ACPI_APPLICATION +#if defined (ACPI_APPLICATION) || defined(ACPI_LIBRARY) #include #include #include diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h b/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h index 048f76a598a..c19a8e45f84 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h @@ -153,6 +153,8 @@ */ #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger /* * OSL interfaces used by utilities @@ -193,7 +195,8 @@ #define ACPI_CAST_PTHREAD_T(Pthread) ((ACPI_THREAD_ID) (Pthread)) #if defined(__ia64__) || defined(__x86_64__) ||\ - defined(__aarch64__) || defined(__PPC64__) + defined(__aarch64__) || defined(__PPC64__) ||\ + defined(__s390x__) #define ACPI_MACHINE_WIDTH 64 #define COMPILER_DEPENDENT_INT64 long #define COMPILER_DEPENDENT_UINT64 unsigned long diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/aclinuxex.h b/reactos/drivers/bus/acpi/acpica/include/platform/aclinuxex.h index f1f9c9a21a2..2e2cc6aa874 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/aclinuxex.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/aclinuxex.h @@ -144,6 +144,20 @@ AcpiOsReadable ( return TRUE; } +static inline ACPI_STATUS +AcpiOsInitializeDebugger ( + void) +{ + return AE_OK; +} + +static inline void +AcpiOsTerminateDebugger ( + void) +{ + return; +} + /* * OSL interfaces added by Linux diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acmacosx.h b/reactos/drivers/bus/acpi/acpica/include/platform/acmacosx.h index 5d2ba41e825..a16262a816a 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/acmacosx.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acmacosx.h @@ -47,7 +47,6 @@ #include "aclinux.h" #ifdef __APPLE__ -#define sem_destroy sem_close #define ACPI_USE_ALTERNATE_TIMEOUT #endif /* __APPLE__ */ diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsconvert.c b/reactos/drivers/bus/acpi/acpica/namespace/nsconvert.c index 2fa182eddcf..7ce98a5244c 100644 --- a/reactos/drivers/bus/acpi/acpica/namespace/nsconvert.c +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsconvert.c @@ -84,7 +84,7 @@ AcpiNsConvertToInteger ( /* String-to-Integer conversion */ Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - ACPI_ANY_BASE, AcpiGbl_IntegerByteWidth, &Value); + AcpiGbl_IntegerByteWidth, &Value); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsload.c b/reactos/drivers/bus/acpi/acpica/namespace/nsload.c index 9c899e78461..d7dbf8955fa 100644 --- a/reactos/drivers/bus/acpi/acpica/namespace/nsload.c +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsload.c @@ -46,6 +46,7 @@ #include "acnamesp.h" #include "acdispat.h" #include "actables.h" +#include "acinterp.h" #define _COMPONENT ACPI_NAMESPACE @@ -89,21 +90,6 @@ AcpiNsLoadTable ( ACPI_FUNCTION_TRACE (NsLoadTable); - /* - * Parse the table and load the namespace with all named - * objects found within. Control methods are NOT parsed - * at this time. In fact, the control methods cannot be - * parsed until the entire namespace is loaded, because - * if a control method makes a forward reference (call) - * to another control method, we can't continue parsing - * because we don't know how many arguments to parse next! - */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* If table already loaded into namespace, just return */ if (AcpiTbIsTableLoaded (TableIndex)) @@ -121,6 +107,15 @@ AcpiNsLoadTable ( goto Unlock; } + /* + * Parse the table and load the namespace with all named + * objects found within. Control methods are NOT parsed + * at this time. In fact, the control methods cannot be + * parsed until the entire namespace is loaded, because + * if a control method makes a forward reference (call) + * to another control method, we can't continue parsing + * because we don't know how many arguments to parse next! + */ Status = AcpiNsParseTable (TableIndex, Node); if (ACPI_SUCCESS (Status)) { @@ -137,7 +132,6 @@ AcpiNsLoadTable ( * exist. This target of Scope must already exist in the * namespace, as per the ACPI specification. */ - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); AcpiNsDeleteNamespaceByOwner ( AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); @@ -146,8 +140,6 @@ AcpiNsLoadTable ( } Unlock: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -162,7 +154,9 @@ Unlock: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Begin Table Object Initialization\n")); + AcpiExEnterInterpreter (); Status = AcpiDsInitializeObjects (TableIndex, Node); + AcpiExExitInterpreter (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); @@ -180,7 +174,7 @@ Unlock: * other ACPI implementations. Optionally, the execution can be deferred * until later, see AcpiInitializeObjects. */ - if (!AcpiGbl_GroupModuleLevelCode) + if (!AcpiGbl_ParseTableAsTermList && !AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); } diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c b/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c index 95f8c8db970..8af12f19727 100644 --- a/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c @@ -108,6 +108,58 @@ AcpiNsGetPathnameLength ( } +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToName + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * Buffer - Where the name is returned + * + * RETURN: Status, Buffer is filled with name if status is AE_OK + * + * DESCRIPTION: Build and return a full namespace name + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToName ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + const char *NodeName; + + + ACPI_FUNCTION_TRACE_PTR (NsHandleToName, TargetHandle); + + + Node = AcpiNsValidateHandle (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + NodeName = AcpiUtGetNodeName (Node); + ACPI_MOVE_NAME (Buffer->Pointer, NodeName); + ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%4.4s\n", (char *) Buffer->Pointer)); + return_ACPI_STATUS (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiNsHandleToPathname diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c b/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c index 1ff33362ed1..95f6da6ba58 100644 --- a/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c @@ -47,12 +47,116 @@ #include "acparser.h" #include "acdispat.h" #include "actables.h" +#include "acinterp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsparse") +/******************************************************************************* + * + * FUNCTION: NsExecuteTable + * + * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse + * StartNode - Where to enter the table into the namespace + * + * RETURN: Status + * + * DESCRIPTION: Load ACPI/AML table by executing the entire table as a + * TermList. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsExecuteTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + ACPI_EVALUATE_INFO *Info = NULL; + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_OPERAND_OBJECT *MethodObj = NULL; + + + ACPI_FUNCTION_TRACE (NsExecuteTable); + + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } + + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create, initialize, and link a new temporary method object */ + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Create table code block: %p\n", MethodObj)); + + MethodObj->Method.AmlStart = AmlStart; + MethodObj->Method.AmlLength = AmlLength; + MethodObj->Method.OwnerId = OwnerId; + MethodObj->Method.InfoFlags |= ACPI_METHOD_MODULE_LEVEL; + + Info->PassNumber = ACPI_IMODE_EXECUTE; + Info->Node = StartNode; + Info->ObjDesc = MethodObj; + Info->NodeFlags = Info->Node->Flags; + Info->FullPathname = AcpiNsGetNormalizedPathname (Info->Node, TRUE); + if (!Info->FullPathname) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiPsExecuteTable (Info); + +Cleanup: + if (Info) + { + ACPI_FREE (Info->FullPathname); + Info->FullPathname = NULL; + } + ACPI_FREE (Info); + AcpiUtRemoveReference (MethodObj); + return_ACPI_STATUS (Status); +} + + /******************************************************************************* * * FUNCTION: NsOneCompleteParse @@ -156,7 +260,9 @@ AcpiNsOneCompleteParse ( ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber)); + AcpiExEnterInterpreter (); Status = AcpiPsParseAml (WalkState); + AcpiExExitInterpreter (); Cleanup: AcpiPsDeleteParseTree (ParseRoot); @@ -188,40 +294,53 @@ AcpiNsParseTable ( ACPI_FUNCTION_TRACE (NsParseTable); - /* - * AML Parse, pass 1 - * - * In this pass, we load most of the namespace. Control methods - * are not parsed until later. A parse tree is not created. Instead, - * each Parser Op subtree is deleted when it is finished. This saves - * a great deal of memory, and allows a small cache of parse objects - * to service the entire parse. The second pass of the parse then - * performs another complete parse of the AML. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); - - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, - TableIndex, StartNode); - if (ACPI_FAILURE (Status)) + if (AcpiGbl_ParseTableAsTermList) { - return_ACPI_STATUS (Status); - } + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start load pass\n")); - /* - * AML Parse, pass 2 - * - * In this pass, we resolve forward references and other things - * that could not be completed during the first pass. - * Another complete parse of the AML is performed, but the - * overhead of this is compensated for by the fact that the - * parse objects are all cached. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); - Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, - TableIndex, StartNode); - if (ACPI_FAILURE (Status)) + Status = AcpiNsExecuteTable (TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else { - return_ACPI_STATUS (Status); + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. + * Instead, each Parser Op subtree is deleted when it is finished. + * This saves a great deal of memory, and allows a small cache of + * parse objects to service the entire parse. The second pass of + * the parse then performs another complete parse of the AML. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); + + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } return_ACPI_STATUS (Status); diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c b/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c index 72f9105ef5a..2dafae47194 100644 --- a/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c @@ -771,7 +771,7 @@ AcpiNsOpensScope ( /******************************************************************************* * - * FUNCTION: AcpiNsGetNode + * FUNCTION: AcpiNsGetNodeUnlocked * * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The * \ (backslash) and ^ (carat) prefixes, and the @@ -787,12 +787,12 @@ AcpiNsOpensScope ( * DESCRIPTION: Look up a name relative to a given scope and return the * corresponding Node. NOTE: Scope can be null. * - * MUTEX: Locks namespace + * MUTEX: Doesn't locks namespace * ******************************************************************************/ ACPI_STATUS -AcpiNsGetNode ( +AcpiNsGetNodeUnlocked ( ACPI_NAMESPACE_NODE *PrefixNode, const char *Pathname, UINT32 Flags, @@ -803,7 +803,7 @@ AcpiNsGetNode ( char *InternalPath; - ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); + ACPI_FUNCTION_TRACE_PTR (NsGetNodeUnlocked, ACPI_CAST_PTR (char, Pathname)); /* Simplest case is a null pathname */ @@ -835,14 +835,6 @@ AcpiNsGetNode ( return_ACPI_STATUS (Status); } - /* Must lock namespace during lookup */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - /* Setup lookup scope (search starting point) */ ScopeInfo.Scope.Node = PrefixNode; @@ -858,9 +850,55 @@ AcpiNsGetNode ( Pathname, AcpiFormatException (Status))); } - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - -Cleanup: ACPI_FREE (InternalPath); return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNode + * + * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The + * \ (backslash) and ^ (carat) prefixes, and the + * . (period) to separate segments are supported. + * PrefixNode - Root of subtree to be searched, or NS_ALL for the + * root of the name space. If Name is fully + * qualified (first INT8 is '\'), the passed value + * of Scope will not be accessed. + * Flags - Used to indicate whether to perform upsearch or + * not. + * ReturnNode - Where the Node is returned + * + * DESCRIPTION: Look up a name relative to a given scope and return the + * corresponding Node. NOTE: Scope can be null. + * + * MUTEX: Locks namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Pathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiNsGetNodeUnlocked (PrefixNode, Pathname, + Flags, ReturnNode); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c index cfd6937f497..1621ba985da 100644 --- a/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c @@ -176,8 +176,6 @@ AcpiGetName ( ACPI_BUFFER *Buffer) { ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - const char *NodeName; /* Parameter validation */ @@ -193,16 +191,6 @@ AcpiGetName ( return (Status); } - if (NameType == ACPI_FULL_PATHNAME || - NameType == ACPI_FULL_PATHNAME_NO_TRAILING) - { - /* Get the full pathname (From the namespace root) */ - - Status = AcpiNsHandleToPathname (Handle, Buffer, - NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); - return (Status); - } - /* * Wants the single segment ACPI name. * Validate handle and convert to a namespace Node @@ -213,30 +201,20 @@ AcpiGetName ( return (Status); } - Node = AcpiNsValidateHandle (Handle); - if (!Node) + if (NameType == ACPI_FULL_PATHNAME || + NameType == ACPI_FULL_PATHNAME_NO_TRAILING) { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Validate/Allocate/Clear caller buffer */ + /* Get the full pathname (From the namespace root) */ - Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; + Status = AcpiNsHandleToPathname (Handle, Buffer, + NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); } + else + { + /* Get the single name */ - /* Just copy the ACPI name from the Node and zero terminate it */ - - NodeName = AcpiUtGetNodeName (Node); - ACPI_MOVE_NAME (Buffer->Pointer, NodeName); - ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; - Status = AE_OK; - - -UnlockAndExit: + Status = AcpiNsHandleToName (Handle, Buffer); + } (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); diff --git a/reactos/drivers/bus/acpi/acpica/parser/psargs.c b/reactos/drivers/bus/acpi/acpica/parser/psargs.c index a4745c3adc1..67d8aef26e2 100644 --- a/reactos/drivers/bus/acpi/acpica/parser/psargs.c +++ b/reactos/drivers/bus/acpi/acpica/parser/psargs.c @@ -298,23 +298,26 @@ AcpiPsGetNextNamepath ( PossibleMethodCall && (Node->Type == ACPI_TYPE_METHOD)) { - if (WalkState->Opcode == AML_UNLOAD_OP) + if ((GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_SUPERNAME) || + (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_TARGET)) { /* - * AcpiPsGetNextNamestring has increased the AML pointer, - * so we need to restore the saved AML pointer for method call. + * AcpiPsGetNextNamestring has increased the AML pointer past + * the method invocation namestring, so we need to restore the + * saved AML pointer back to the original method invocation + * namestring. */ WalkState->ParserState.Aml = Start; WalkState->ArgCount = 1; AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); - return_ACPI_STATUS (AE_OK); } /* This name is actually a control method invocation */ MethodDesc = AcpiNsGetAttachedObject (Node); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); + "Control Method invocation %4.4s - %p Desc %p Path=%p\n", + Node->Name.Ascii, Node, MethodDesc, Path)); NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start); if (!NameOp) @@ -771,6 +774,10 @@ AcpiPsGetNextArg ( ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Expected argument type ARGP: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + switch (ArgType) { case ARGP_BYTEDATA: @@ -854,11 +861,13 @@ AcpiPsGetNextArg ( } break; - case ARGP_TARGET: - case ARGP_SUPERNAME: case ARGP_SIMPLENAME: case ARGP_NAME_OR_REF: + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** SimpleName/NameOrRef: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + Subop = AcpiPsPeekOpcode (ParserState); if (Subop == 0 || AcpiPsIsLeadingChar (Subop) || @@ -873,27 +882,46 @@ AcpiPsGetNextArg ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* To support SuperName arg of Unload */ + Status = AcpiPsGetNextNamepath (WalkState, ParserState, + Arg, ACPI_NOT_METHOD_CALL); + } + else + { + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + } + break; + + case ARGP_TARGET: + case ARGP_SUPERNAME: + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Target/Supername: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); - if (WalkState->Opcode == AML_UNLOAD_OP) + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + ACPI_IS_ROOT_PREFIX (Subop) || + ACPI_IS_PARENT_PREFIX (Subop)) + { + /* NULL target (zero). Convert to a NULL namepath */ + + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml); + if (!Arg) { - Status = AcpiPsGetNextNamepath (WalkState, ParserState, - Arg, ACPI_POSSIBLE_METHOD_CALL); - - /* - * If the SuperName argument is a method call, we have - * already restored the AML pointer, just free this Arg - */ - if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) - { - AcpiPsFreeOp (Arg); - Arg = NULL; - } + return_ACPI_STATUS (AE_NO_MEMORY); } - else + + Status = AcpiPsGetNextNamepath (WalkState, ParserState, + Arg, ACPI_POSSIBLE_METHOD_CALL); + + if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) { - Status = AcpiPsGetNextNamepath (WalkState, ParserState, - Arg, ACPI_NOT_METHOD_CALL); + AcpiPsFreeOp (Arg); + Arg = NULL; + WalkState->ArgCount = 1; } } else @@ -907,6 +935,11 @@ AcpiPsGetNextArg ( case ARGP_DATAOBJ: case ARGP_TERMARG: + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** TermArg/DataObj: %s (%2.2X)\n", + AcpiUtGetArgumentTypeName (ArgType), ArgType)); + /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; diff --git a/reactos/drivers/bus/acpi/acpica/parser/psloop.c b/reactos/drivers/bus/acpi/acpica/parser/psloop.c index e0839fd7d82..5056cd1de7f 100644 --- a/reactos/drivers/bus/acpi/acpica/parser/psloop.c +++ b/reactos/drivers/bus/acpi/acpica/parser/psloop.c @@ -104,6 +104,9 @@ AcpiPsGetArguments ( ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Get arguments for opcode [%s]\n", Op->Common.AmlOpName)); + switch (Op->Common.AmlOpcode) { case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ diff --git a/reactos/drivers/bus/acpi/acpica/parser/psobject.c b/reactos/drivers/bus/acpi/acpica/parser/psobject.c index 7edc39e2b7a..d027f6d9892 100644 --- a/reactos/drivers/bus/acpi/acpica/parser/psobject.c +++ b/reactos/drivers/bus/acpi/acpica/parser/psobject.c @@ -373,7 +373,13 @@ AcpiPsCreateOp ( Op->Common.Flags |= ACPI_PARSEOP_TARGET; } } - else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) + + /* + * Special case for both Increment() and Decrement(), where + * the lone argument is both a source and a target. + */ + else if ((ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) || + (ParentScope->Common.AmlOpcode == AML_DECREMENT_OP)) { Op->Common.Flags |= ACPI_PARSEOP_TARGET; } diff --git a/reactos/drivers/bus/acpi/acpica/parser/psparse.c b/reactos/drivers/bus/acpi/acpica/parser/psparse.c index 810d97e0e01..8f230320bab 100644 --- a/reactos/drivers/bus/acpi/acpica/parser/psparse.c +++ b/reactos/drivers/bus/acpi/acpica/parser/psparse.c @@ -555,8 +555,10 @@ AcpiPsParseAml ( { /* Either the method parse or actual execution failed */ + AcpiExExitInterpreter (); ACPI_ERROR_METHOD ("Method parse/execution failed", WalkState->MethodNode, NULL, Status); + AcpiExEnterInterpreter (); /* Check for possible multi-thread reentrancy problem */ @@ -589,7 +591,8 @@ AcpiPsParseAml ( * cleanup to do */ if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == - ACPI_PARSE_EXECUTE) || + ACPI_PARSE_EXECUTE && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) || (ACPI_FAILURE (Status))) { AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); diff --git a/reactos/drivers/bus/acpi/acpica/parser/pstree.c b/reactos/drivers/bus/acpi/acpica/parser/pstree.c index 729856982b6..a38eb435a28 100644 --- a/reactos/drivers/bus/acpi/acpica/parser/pstree.c +++ b/reactos/drivers/bus/acpi/acpica/parser/pstree.c @@ -142,12 +142,12 @@ AcpiPsAppendArg ( const ACPI_OPCODE_INFO *OpInfo; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE (PsAppendArg); if (!Op) { - return; + return_VOID; } /* Get the info structure for this opcode */ @@ -159,7 +159,7 @@ AcpiPsAppendArg ( ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X", Op->Common.AmlOpcode)); - return; + return_VOID; } /* Check if this opcode requires argument sub-objects */ @@ -168,7 +168,7 @@ AcpiPsAppendArg ( { /* Has no linked argument objects */ - return; + return_VOID; } /* Append the argument to the linked argument list */ @@ -200,6 +200,8 @@ AcpiPsAppendArg ( Op->Common.ArgListLength++; } + + return_VOID; } diff --git a/reactos/drivers/bus/acpi/acpica/parser/psxface.c b/reactos/drivers/bus/acpi/acpica/parser/psxface.c index a6fe31648ec..58c1ce82f11 100644 --- a/reactos/drivers/bus/acpi/acpica/parser/psxface.c +++ b/reactos/drivers/bus/acpi/acpica/parser/psxface.c @@ -273,6 +273,100 @@ Cleanup: } +/******************************************************************************* + * + * FUNCTION: AcpiPsExecuteTable + * + * PARAMETERS: Info - Method info block, contains: + * Node - Node to where the is entered into the + * namespace + * ObjDesc - Pseudo method object describing the AML + * code of the entire table + * PassNumber - Parse or execute pass + * + * RETURN: Status + * + * DESCRIPTION: Execute a table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsExecuteTable ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op = NULL; + ACPI_WALK_STATE *WalkState = NULL; + + + ACPI_FUNCTION_TRACE (PsExecuteTable); + + + /* Create and init a Root Node */ + + Op = AcpiPsCreateScopeOp (Info->ObjDesc->Method.AmlStart); + if (!Op) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState ( + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) + { + WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; + } + + /* Info->Node is the default location to load the table */ + + if (Info->Node && Info->Node != AcpiGbl_RootNode) + { + Status = AcpiDsScopeStackPush ( + Info->Node, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Parse the AML, WalkState will be deleted by ParseAml + */ + AcpiExEnterInterpreter (); + Status = AcpiPsParseAml (WalkState); + AcpiExExitInterpreter (); + WalkState = NULL; + +Cleanup: + if (WalkState) + { + AcpiDsDeleteWalkState (WalkState); + } + if (Op) + { + AcpiPsDeleteParseTree (Op); + } + return_ACPI_STATUS (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiPsUpdateParameterList diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbdata.c b/reactos/drivers/bus/acpi/acpica/tables/tbdata.c index 31fa25b92e7..95b5b2672cd 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbdata.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbdata.c @@ -45,6 +45,7 @@ #include "accommon.h" #include "acnamesp.h" #include "actables.h" +#include "acevents.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbdata") @@ -680,18 +681,13 @@ AcpiTbDeleteNamespaceByOwner ( * lock may block, and also since the execution of a namespace walk * must be allowed to use the interpreter. */ - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); - - AcpiNsDeleteNamespaceByOwner (OwnerId); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - + AcpiNsDeleteNamespaceByOwner (OwnerId); AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); - - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); return_ACPI_STATUS (Status); } @@ -867,3 +863,178 @@ AcpiTbSetTableLoadedFlag ( (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); } + + +/******************************************************************************* + * + * FUNCTION: AcpiTbLoadTable + * + * PARAMETERS: TableIndex - Table index + * ParentNode - Where table index is returned + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_TABLE_HEADER *Table; + ACPI_STATUS Status; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (TbLoadTable); + + + /* + * Note: Now table is "INSTALLED", it must be validated before + * using. + */ + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiNsLoadTable (TableIndex, ParentNode); + + /* Execute any module-level code that was found in the table */ + + if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } + + /* + * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is + * responsible for discovering any new wake GPEs by running _PRW methods + * that may have been loaded by this table. + */ + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_SUCCESS (Status)) + { + AcpiEvUpdateGpes (OwnerId); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, + AcpiGbl_TableHandlerContext); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallAndLoadTable + * + * PARAMETERS: Address - Physical address of the table + * Flags - Allocation flags of the table + * Override - Whether override should be performed + * TableIndex - Where table index is returned + * + * RETURN: Status + * + * DESCRIPTION: Install and load an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInstallAndLoadTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + BOOLEAN Override, + UINT32 *TableIndex) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbInstallAndLoadTable); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Install the table and load it into the namespace */ + + Status = AcpiTbInstallStandardTable (Address, Flags, TRUE, + Override, &i); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + Status = AcpiTbLoadTable (i, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + +UnlockAndExit: + *TableIndex = i; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbUnloadTable + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbUnloadTable ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE (TbUnloadTable); + + + /* Ensure the table is still loaded */ + + if (!AcpiTbIsTableLoaded (TableIndex)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, + AcpiGbl_TableHandlerContext); + } + } + + /* Delete the portion of the namespace owned by this table */ + + Status = AcpiTbDeleteNamespaceByOwner (TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + (void) AcpiTbReleaseOwnerId (TableIndex); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c b/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c index ba49633701d..1d327dc3113 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c @@ -341,6 +341,8 @@ AcpiTbParseFadt ( { UINT32 Length; ACPI_TABLE_HEADER *Table; + ACPI_TABLE_DESC *FadtDesc; + ACPI_STATUS Status; /* @@ -350,14 +352,13 @@ AcpiTbParseFadt ( * Get a local copy of the FADT and convert it to a common format * Map entire FADT, assumed to be smaller than one page. */ - Length = AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex].Length; - - Table = AcpiOsMapMemory ( - AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex].Address, Length); - if (!Table) + FadtDesc = &AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex]; + Status = AcpiTbGetTable (FadtDesc, &Table); + if (ACPI_FAILURE (Status)) { return; } + Length = FadtDesc->Length; /* * Validate the FADT checksum before we copy the table. Ignore @@ -371,12 +372,14 @@ AcpiTbParseFadt ( /* All done with the real FADT, unmap it */ - AcpiOsUnmapMemory (Table, Length); + AcpiTbPutTable (FadtDesc); /* Obtain the DSDT and FACS tables via their addresses within the FADT */ - AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, - ACPI_SIG_DSDT, &AcpiGbl_DsdtIndex); + AcpiTbInstallStandardTable ( + (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, + &AcpiGbl_DsdtIndex); /* If Hardware Reduced flag is set, there is no FACS */ @@ -384,13 +387,17 @@ AcpiTbParseFadt ( { if (AcpiGbl_FADT.Facs) { - AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs, - ACPI_SIG_FACS, &AcpiGbl_FacsIndex); + AcpiTbInstallStandardTable ( + (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, + &AcpiGbl_FacsIndex); } if (AcpiGbl_FADT.XFacs) { - AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, - ACPI_SIG_FACS, &AcpiGbl_XFacsIndex); + AcpiTbInstallStandardTable ( + (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, + &AcpiGbl_XFacsIndex); } } } @@ -516,19 +523,17 @@ AcpiTbConvertFadt ( /* - * For ACPI 1.0 FADTs (revision 1), ensure that reserved fields which + * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which * should be zero are indeed zero. This will workaround BIOSs that * inadvertently place values in these fields. * * The ACPI 1.0 reserved fields that will be zeroed are the bytes located * at offset 45, 55, 95, and the word located at offset 109, 110. * - * Note: The FADT revision value is unreliable because of BIOS errors. - * The table length is instead used as the final word on the version. - * - * Note: FADT revision 3 is the ACPI 2.0 version of the FADT. + * Note: The FADT revision value is unreliable. Only the length can be + * trusted. */ - if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V3_SIZE) + if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE) { AcpiGbl_FADT.PreferredProfile = 0; AcpiGbl_FADT.PstateControl = 0; @@ -593,65 +598,67 @@ AcpiTbConvertFadt ( * * Address32 zero, Address64 [don't care] - Use Address64 * + * No override: if AcpiGbl_Use32BitFadtAddresses is FALSE, and: * Address32 non-zero, Address64 zero - Copy/use Address32 * Address32 non-zero == Address64 non-zero - Use Address64 * Address32 non-zero != Address64 non-zero - Warning, use Address64 * * Override: if AcpiGbl_Use32BitFadtAddresses is TRUE, and: + * Address32 non-zero, Address64 zero - Copy/use Address32 + * Address32 non-zero == Address64 non-zero - Copy/use Address32 * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32 * * Note: SpaceId is always I/O for 32-bit legacy address fields */ if (Address32) { - if (!Address64->Address) - { - /* 64-bit address is zero, use 32-bit address */ - - AcpiTbInitGenericAddress (Address64, - ACPI_ADR_SPACE_SYSTEM_IO, - *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, - FadtInfoTable[i].Length), - (UINT64) Address32, Name, Flags); - } - else if (Address64->Address != (UINT64) Address32) + if (Address64->Address) { - /* Address mismatch */ - - ACPI_BIOS_WARNING ((AE_INFO, - "32/64X address mismatch in FADT/%s: " - "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", - Name, Address32, - ACPI_FORMAT_UINT64 (Address64->Address), - AcpiGbl_Use32BitFadtAddresses ? 32 : 64)); - - if (AcpiGbl_Use32BitFadtAddresses) + if (Address64->Address != (UINT64) Address32) { - /* 32-bit address override */ + /* Address mismatch */ + + ACPI_BIOS_WARNING ((AE_INFO, + "32/64X address mismatch in FADT/%s: " + "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", + Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address), + AcpiGbl_Use32BitFadtAddresses ? 32 : 64)); + } - AcpiTbInitGenericAddress (Address64, - ACPI_ADR_SPACE_SYSTEM_IO, - *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, - FadtInfoTable[i].Length), - (UINT64) Address32, Name, Flags); + /* + * 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 ((ACPI_MUL_8 (Length) <= ACPI_UINT8_MAX) && + (Address64->BitWidth != ACPI_MUL_8 (Length))) + { + ACPI_BIOS_WARNING ((AE_INFO, + "32/64X length mismatch in FADT/%s: %u/%u", + Name, ACPI_MUL_8 (Length), Address64->BitWidth)); } } - } - /* - * 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, - "32/64X length mismatch in FADT/%s: %u/%u", - Name, ACPI_MUL_8 (Length), Address64->BitWidth)); + /* + * Hardware register access code always uses the 64-bit fields. + * So if the 64-bit field is zero or is to be overridden, + * initialize it with the 32-bit fields. + * Note that when the 32-bit address favor is specified, the + * 64-bit fields are always re-initialized so that + * AccessSize/BitWidth/BitOffset fields can be correctly + * configured to the values to trigger a 32-bit compatible + * access mode in the hardware register access code. + */ + if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses) + { + AcpiTbInitGenericAddress (Address64, + ACPI_ADR_SPACE_SYSTEM_IO, Length, + (UINT64) Address32, Name, Flags); + } } if (FadtInfoTable[i].Flags & ACPI_FADT_REQUIRED) diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbfind.c b/reactos/drivers/bus/acpi/acpica/tables/tbfind.c index 32839a3cd32..563358cbbc9 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbfind.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbfind.c @@ -73,7 +73,7 @@ AcpiTbFindTable ( char *OemTableId, UINT32 *TableIndex) { - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; ACPI_TABLE_HEADER Header; UINT32 i; @@ -105,6 +105,7 @@ AcpiTbFindTable ( /* Search for the table */ + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if (memcmp (&(AcpiGbl_RootTableList.Tables[i].Signature), @@ -124,7 +125,7 @@ AcpiTbFindTable ( Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto UnlockAndExit; } if (!AcpiGbl_RootTableList.Tables[i].Pointer) @@ -148,9 +149,12 @@ AcpiTbFindTable ( ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", Header.Signature)); - return_ACPI_STATUS (AE_OK); + goto UnlockAndExit; } } + Status = AE_NOT_FOUND; - return_ACPI_STATUS (AE_NOT_FOUND); +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); } diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c b/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c index 78e8b4ec8bf..bb8f127cc71 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c @@ -167,74 +167,6 @@ AcpiTbInstallTableWithOverride ( } -/******************************************************************************* - * - * FUNCTION: AcpiTbInstallFixedTable - * - * PARAMETERS: Address - Physical address of DSDT or FACS - * Signature - Table signature, NULL if no need to - * match - * TableIndex - Where the table index is returned - * - * RETURN: Status - * - * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data - * structure. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbInstallFixedTable ( - ACPI_PHYSICAL_ADDRESS Address, - char *Signature, - UINT32 *TableIndex) -{ - ACPI_TABLE_DESC NewTableDesc; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (TbInstallFixedTable); - - - if (!Address) - { - ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", - Signature)); - return (AE_NO_MEMORY); - } - - /* Fill a table descriptor for validation */ - - Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, - ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not acquire table length at %8.8X%8.8X", - ACPI_FORMAT_UINT64 (Address))); - return_ACPI_STATUS (Status); - } - - /* Validate and verify a table before installation */ - - Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature); - if (ACPI_FAILURE (Status)) - { - goto ReleaseAndExit; - } - - /* Add the table to the global root table list */ - - AcpiTbInstallTableWithOverride (&NewTableDesc, TRUE, TableIndex); - -ReleaseAndExit: - - /* Release the temporary table descriptor */ - - AcpiTbReleaseTempTable (&NewTableDesc); - return_ACPI_STATUS (Status); -} - - /******************************************************************************* * * FUNCTION: AcpiTbInstallStandardTable @@ -248,8 +180,7 @@ ReleaseAndExit: * * RETURN: Status * - * DESCRIPTION: This function is called to install an ACPI table that is - * neither DSDT nor FACS (a "standard" table.) + * DESCRIPTION: This function is called to verify and install an ACPI table. * When this function is called by "Load" or "LoadTable" opcodes, * or by AcpiLoadTable() API, the "Reload" parameter is set. * After sucessfully returning from this function, table is @@ -390,6 +321,14 @@ AcpiTbInstallStandardTable ( AcpiTbInstallTableWithOverride (&NewTableDesc, Override, TableIndex); + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_INSTALL, + NewTableDesc.Pointer, AcpiGbl_TableHandlerContext); + } + ReleaseAndExit: /* Release the temporary table descriptor */ diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbutils.c b/reactos/drivers/bus/acpi/acpica/tables/tbutils.c index 85b9c3e4c56..6fc30a69fa3 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbutils.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbutils.c @@ -411,3 +411,99 @@ NextTable: AcpiOsUnmapMemory (Table, Length); return_ACPI_STATUS (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTable + * + * PARAMETERS: TableDesc - Table descriptor + * OutTable - Where the pointer to the table is returned + * + * RETURN: Status and pointer to the requested table + * + * DESCRIPTION: Increase a reference to a table descriptor and return the + * validated table pointer. + * If the table descriptor is an entry of the root table list, + * this API must be invoked with ACPI_MTX_TABLES acquired. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **OutTable) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiTbGetTable); + + + if (TableDesc->ValidationCount == 0) + { + /* Table need to be "VALIDATED" */ + + Status = AcpiTbValidateTable (TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + TableDesc->ValidationCount++; + if (TableDesc->ValidationCount == 0) + { + ACPI_ERROR ((AE_INFO, + "Table %p, Validation count is zero after increment\n", + TableDesc)); + TableDesc->ValidationCount--; + return_ACPI_STATUS (AE_LIMIT); + } + + *OutTable = TableDesc->Pointer; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbPutTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: None + * + * DESCRIPTION: Decrease a reference to a table descriptor and release the + * validated table pointer if no references. + * If the table descriptor is an entry of the root table list, + * this API must be invoked with ACPI_MTX_TABLES acquired. + * + ******************************************************************************/ + +void +AcpiTbPutTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + ACPI_FUNCTION_TRACE (AcpiTbPutTable); + + + if (TableDesc->ValidationCount == 0) + { + ACPI_WARNING ((AE_INFO, + "Table %p, Validation count is zero before decrement\n", + TableDesc)); + return_VOID; + } + TableDesc->ValidationCount--; + + if (TableDesc->ValidationCount == 0) + { + /* Table need to be "INVALIDATED" */ + + AcpiTbInvalidateTable (TableDesc); + } + + return_VOID; +} diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbxface.c b/reactos/drivers/bus/acpi/acpica/tables/tbxface.c index 4c8c065cf37..9346933cf52 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbxface.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbxface.c @@ -184,6 +184,7 @@ AcpiReallocateRootTable ( void) { ACPI_STATUS Status; + UINT32 i; ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); @@ -198,6 +199,22 @@ AcpiReallocateRootTable ( return_ACPI_STATUS (AE_SUPPORT); } + /* + * Ensure OS early boot logic, which is required by some hosts. If the + * table state is reported to be wrong, developers should fix the + * issue by invoking AcpiPutTable() for the reported table during the + * early stage. + */ + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) + { + if (AcpiGbl_RootTableList.Tables[i].Pointer) + { + ACPI_ERROR ((AE_INFO, + "Table [%4.4s] is not invalidated during early boot stage", + AcpiGbl_RootTableList.Tables[i].Signature.Ascii)); + } + } + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; Status = AcpiTbResizeRootTableList (); @@ -307,6 +324,11 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) * * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the * RSDT/XSDT. + * Note that an early stage AcpiGetTable() call must be paired + * with an early stage AcpiPutTable() call. otherwise the table + * pointer mapped by the early stage mapping implementation may be + * erroneously unmapped by the late stage unmapping implementation + * in an AcpiPutTable() invoked during the late stage. * ******************************************************************************/ @@ -318,7 +340,8 @@ AcpiGetTable ( { UINT32 i; UINT32 j; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_NOT_FOUND; + ACPI_TABLE_DESC *TableDesc; /* Parameter validation */ @@ -328,12 +351,22 @@ AcpiGetTable ( return (AE_BAD_PARAMETER); } + /* + * Note that the following line is required by some OSPMs, they only + * check if the returned table is NULL instead of the returned status + * to determined if this function is succeeded. + */ + *OutTable = NULL; + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + /* Walk the root table list */ for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { - if (!ACPI_COMPARE_NAME ( - &(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) + TableDesc = &AcpiGbl_RootTableList.Tables[i]; + + if (!ACPI_COMPARE_NAME (&TableDesc->Signature, Signature)) { continue; } @@ -343,19 +376,66 @@ AcpiGetTable ( continue; } - Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); - if (ACPI_SUCCESS (Status)) + Status = AcpiTbGetTable (TableDesc, OutTable); + break; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiPutTable + * + * PARAMETERS: Table - The pointer to the table + * + * RETURN: None + * + * DESCRIPTION: Release a table returned by AcpiGetTable() and its clones. + * Note that it is not safe if this function was invoked after an + * uninstallation happened to the original table descriptor. + * Currently there is no OSPMs' requirement to handle such + * situations. + * + ******************************************************************************/ + +void +AcpiPutTable ( + ACPI_TABLE_HEADER *Table) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + + + ACPI_FUNCTION_TRACE (AcpiPutTable); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Walk the root table list */ + + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) + { + TableDesc = &AcpiGbl_RootTableList.Tables[i]; + + if (TableDesc->Pointer != Table) { - *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; + continue; } - return (Status); + AcpiTbPutTable (TableDesc); + break; } - return (AE_NOT_FOUND); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_VOID; } -ACPI_EXPORT_SYMBOL (AcpiGetTable) +ACPI_EXPORT_SYMBOL (AcpiPutTable) /******************************************************************************* @@ -363,7 +443,7 @@ ACPI_EXPORT_SYMBOL (AcpiGetTable) * FUNCTION: AcpiGetTableByIndex * * PARAMETERS: TableIndex - Table index - * Table - Where the pointer to the table is returned + * OutTable - Where the pointer to the table is returned * * RETURN: Status and pointer to the requested table * @@ -375,7 +455,7 @@ ACPI_EXPORT_SYMBOL (AcpiGetTable) ACPI_STATUS AcpiGetTableByIndex ( UINT32 TableIndex, - ACPI_TABLE_HEADER **Table) + ACPI_TABLE_HEADER **OutTable) { ACPI_STATUS Status; @@ -385,37 +465,34 @@ AcpiGetTableByIndex ( /* Parameter validation */ - if (!Table) + if (!OutTable) { return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* + * Note that the following line is required by some OSPMs, they only + * check if the returned table is NULL instead of the returned status + * to determined if this function is succeeded. + */ + *OutTable = NULL; + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); /* Validate index */ if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_BAD_PARAMETER); + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; } - if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) - { - /* Table is not mapped, map it */ - - Status = AcpiTbValidateTable ( - &AcpiGbl_RootTableList.Tables[TableIndex]); - if (ACPI_FAILURE (Status)) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); - } - } + Status = AcpiTbGetTable ( + &AcpiGbl_RootTableList.Tables[TableIndex], OutTable); - *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; +UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbxfload.c b/reactos/drivers/bus/acpi/acpica/tables/tbxfload.c index 9fc26bdad1b..30c6534a569 100644 --- a/reactos/drivers/bus/acpi/acpica/tables/tbxfload.c +++ b/reactos/drivers/bus/acpi/acpica/tables/tbxfload.c @@ -111,7 +111,7 @@ AcpiLoadTables ( "While loading namespace from ACPI tables")); } - if (!AcpiGbl_GroupModuleLevelCode) + if (AcpiGbl_ParseTableAsTermList || !AcpiGbl_GroupModuleLevelCode) { /* * Initialize the objects that remain uninitialized. This @@ -207,11 +207,11 @@ AcpiTbLoadNamespace ( memcpy (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER)); - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - /* Load and parse tables */ + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); Status = AcpiNsLoadTable (AcpiGbl_DsdtIndex, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "[DSDT] table load failed")); @@ -224,7 +224,6 @@ AcpiTbLoadNamespace ( /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { Table = &AcpiGbl_RootTableList.Tables[i]; @@ -242,6 +241,7 @@ AcpiTbLoadNamespace ( (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); Status = AcpiNsLoadTable (i, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "(%4.4s:%8.8s) while loading table", @@ -257,14 +257,12 @@ AcpiTbLoadNamespace ( { TablesLoaded++; } - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); } if (!TablesFailed) { ACPI_INFO (( - "%u ACPI AML tables successfully acquired and loaded\n", + "%u ACPI AML tables successfully acquired and loaded", TablesLoaded)); } else @@ -278,6 +276,11 @@ AcpiTbLoadNamespace ( Status = AE_CTRL_TERMINATE; } +#ifdef ACPI_APPLICATION + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\n")); +#endif + + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); @@ -366,52 +369,11 @@ AcpiLoadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Must acquire the interpreter lock during this operation */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* Install the table and load it into the namespace */ ACPI_INFO (("Host-directed Dynamic ACPI Table Load:")); - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - - Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), - ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, TRUE, FALSE, - &TableIndex); - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* - * Note: Now table is "INSTALLED", it must be validated before - * using. - */ - Status = AcpiTbValidateTable ( - &AcpiGbl_RootTableList.Tables[TableIndex]); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - Status = AcpiNsLoadTable (TableIndex, AcpiGbl_RootNode); - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, - AcpiGbl_TableHandlerContext); - } - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiTbInstallAndLoadTable (ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, &TableIndex); return_ACPI_STATUS (Status); } @@ -466,9 +428,9 @@ AcpiUnloadParentTable ( return_ACPI_STATUS (AE_TYPE); } - /* Must acquire the interpreter lock during this operation */ + /* Must acquire the table lock during this operation */ - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -497,41 +459,13 @@ AcpiUnloadParentTable ( break; } - /* Ensure the table is actually loaded */ - - if (!AcpiTbIsTableLoaded (i)) - { - Status = AE_NOT_EXIST; - break; - } - - /* Invoke table handler if present */ - - if (AcpiGbl_TableHandler) - { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, - AcpiGbl_RootTableList.Tables[i].Pointer, - AcpiGbl_TableHandlerContext); - } - - /* - * Delete all namespace objects owned by this table. Note that - * these objects can appear anywhere in the namespace by virtue - * of the AML "Scope" operator. Thus, we need to track ownership - * by an ID, not simply a position within the hierarchy. - */ - Status = AcpiTbDeleteNamespaceByOwner (i); - if (ACPI_FAILURE (Status)) - { - break; - } - - Status = AcpiTbReleaseOwnerId (i); - AcpiTbSetTableLoadedFlag (i, FALSE); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + Status = AcpiTbUnloadTable (i); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); break; } - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utaddress.c b/reactos/drivers/bus/acpi/acpica/utilities/utaddress.c index 4b36391e248..2bf313fc74e 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utaddress.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utaddress.c @@ -82,7 +82,6 @@ AcpiUtAddAddressRange ( ACPI_NAMESPACE_NODE *RegionNode) { ACPI_ADDRESS_RANGE *RangeInfo; - ACPI_STATUS Status; ACPI_FUNCTION_TRACE (UtAddAddressRange); @@ -106,13 +105,6 @@ AcpiUtAddAddressRange ( RangeInfo->EndAddress = (Address + Length - 1); RangeInfo->RegionNode = RegionNode; - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (RangeInfo); - return_ACPI_STATUS (Status); - } - RangeInfo->Next = AcpiGbl_AddressRangeList[SpaceId]; AcpiGbl_AddressRangeList[SpaceId] = RangeInfo; @@ -122,7 +114,6 @@ AcpiUtAddAddressRange ( ACPI_FORMAT_UINT64 (Address), ACPI_FORMAT_UINT64 (RangeInfo->EndAddress))); - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_OK); } diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utclib.c b/reactos/drivers/bus/acpi/acpica/utilities/utclib.c index 8c188d00a4c..9b4c9c6f733 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utclib.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utclib.c @@ -127,6 +127,61 @@ memcmp ( } +/******************************************************************************* + * + * FUNCTION: memmove + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory with respect to the overlapping + * + ******************************************************************************/ + +void * +memmove ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + if (Old > New) + { + /* Copy from the beginning */ + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + } + else if (Old < New) + { + /* Copy from the end */ + + New = New + Count - 1; + Old = Old + Count - 1; + while (Count) + { + *New = *Old; + New--; + Old--; + Count--; + } + } + + return (Dest); +} + + /******************************************************************************* * * FUNCTION: memcpy @@ -229,6 +284,93 @@ strlen ( } +/******************************************************************************* + * + * FUNCTION: strpbrk + * + * PARAMETERS: String - Null terminated string + * Delimiters - Delimiters to match + * + * RETURN: The first occurance in the string of any of the bytes in the + * delimiters + * + * DESCRIPTION: Search a string for any of a set of the delimiters + * + ******************************************************************************/ + +char * +strpbrk ( + const char *String, + const char *Delimiters) +{ + const char *Delimiter; + + + for ( ; *String != '\0'; ++String) + { + for (Delimiter = Delimiters; *Delimiter != '\0'; Delimiter++) + { + if (*String == *Delimiter) + { + return (ACPI_CAST_PTR (char, String)); + } + } + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: strtok + * + * PARAMETERS: String - Null terminated string + * Delimiters - Delimiters to match + * + * RETURN: Pointer to the next token + * + * DESCRIPTION: Split string into tokens + * + ******************************************************************************/ + +char* +strtok ( + char *String, + const char *Delimiters) +{ + char *Begin = String; + static char *SavedPtr; + + + if (Begin == NULL) + { + if (SavedPtr == NULL) + { + return (NULL); + } + Begin = SavedPtr; + } + + SavedPtr = strpbrk (Begin, Delimiters); + while (SavedPtr == Begin) + { + *Begin++ = '\0'; + SavedPtr = strpbrk (Begin, Delimiters); + } + + if (SavedPtr) + { + *SavedPtr++ = '\0'; + return (Begin); + } + else + { + return (NULL); + } +} + + /******************************************************************************* * * FUNCTION: strcpy diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utdecode.c b/reactos/drivers/bus/acpi/acpica/utilities/utdecode.c index 5c8f2cec805..1a79286ccf3 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utdecode.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utdecode.c @@ -44,6 +44,7 @@ #include "acpi.h" #include "accommon.h" #include "acnamesp.h" +#include "amlcode.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdecode") @@ -268,7 +269,7 @@ AcpiUtGetObjectTypeName ( if (!ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); - return_PTR ("[NULL Object Descriptor]"); + return_STR ("[NULL Object Descriptor]"); } /* These descriptor types share a common area */ @@ -281,7 +282,7 @@ AcpiUtGetObjectTypeName ( ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), AcpiUtGetDescriptorName (ObjDesc), ObjDesc)); - return_PTR ("Invalid object"); + return_STR ("Invalid object"); } return_STR (AcpiUtGetTypeName (ObjDesc->Common.Type)); @@ -604,6 +605,59 @@ AcpiUtGetNotifyName ( return ("Hardware-Specific"); } + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetArgumentTypeName + * + * PARAMETERS: ArgType - an ARGP_* parser argument type + * + * RETURN: Decoded ARGP_* type + * + * DESCRIPTION: Decode an ARGP_* parser type, as defined in the amlcode.h file, + * and used in the acopcode.h file. For example, ARGP_TERMARG. + * Used for debug only. + * + ******************************************************************************/ + +static const char *AcpiGbl_ArgumentType[20] = +{ + /* 00 */ "Unknown ARGP", + /* 01 */ "ByteData", + /* 02 */ "ByteList", + /* 03 */ "CharList", + /* 04 */ "DataObject", + /* 05 */ "DataObjectList", + /* 06 */ "DWordData", + /* 07 */ "FieldList", + /* 08 */ "Name", + /* 09 */ "NameString", + /* 0A */ "ObjectList", + /* 0B */ "PackageLength", + /* 0C */ "SuperName", + /* 0D */ "Target", + /* 0E */ "TermArg", + /* 0F */ "TermList", + /* 10 */ "WordData", + /* 11 */ "QWordData", + /* 12 */ "SimpleName", + /* 13 */ "NameOrRef" +}; + +const char * +AcpiUtGetArgumentTypeName ( + UINT32 ArgType) +{ + + if (ArgType > ARGP_MAX) + { + return ("Unknown ARGP"); + } + + return (AcpiGbl_ArgumentType[ArgType]); +} + #endif diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c b/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c index 95a98f56818..d36eedfe69e 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c @@ -449,8 +449,9 @@ AcpiUtUpdateRefCount ( } ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Type %.2X Refs %.2X [Incremented]\n", - Object, Object->Common.Type, NewCount)); + "Obj %p Type %.2X [%s] Refs %.2X [Incremented]\n", + Object, Object->Common.Type, + AcpiUtGetObjectTypeName (Object), NewCount)); break; case REF_DECREMENT: diff --git a/reactos/drivers/bus/acpi/acpica/utilities/uthex.c b/reactos/drivers/bus/acpi/acpica/utilities/uthex.c index b93013b200f..94f6a7f9787 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/uthex.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/uthex.c @@ -80,11 +80,48 @@ AcpiUtHexToAsciiChar ( } +/******************************************************************************* + * + * FUNCTION: AcpiUtAsciiToHexByte + * + * PARAMETERS: TwoAsciiChars - Pointer to two ASCII characters + * ReturnByte - Where converted byte is returned + * + * RETURN: Status and converted hex byte + * + * DESCRIPTION: Perform ascii-to-hex translation, exactly two ASCII characters + * to a single converted byte value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAsciiToHexByte ( + char *TwoAsciiChars, + UINT8 *ReturnByte) +{ + + /* Both ASCII characters must be valid hex digits */ + + if (!isxdigit ((int) TwoAsciiChars[0]) || + !isxdigit ((int) TwoAsciiChars[1])) + { + return (AE_BAD_HEX_CONSTANT); + } + + *ReturnByte = + AcpiUtAsciiCharToHex (TwoAsciiChars[1]) | + (AcpiUtAsciiCharToHex (TwoAsciiChars[0]) << 4); + + return (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiUtAsciiCharToHex * - * PARAMETERS: HexChar - Hex character in Ascii + * PARAMETERS: HexChar - Hex character in Ascii. Must be: + * 0-9 or A-F or a-f * * RETURN: The binary value of the ascii/hex character * @@ -97,15 +134,21 @@ AcpiUtAsciiCharToHex ( int HexChar) { - if (HexChar <= 0x39) + /* Values 0-9 */ + + if (HexChar <= '9') { - return ((UINT8) (HexChar - 0x30)); + return ((UINT8) (HexChar - '0')); } - if (HexChar <= 0x46) + /* Upper case A-F */ + + if (HexChar <= 'F') { return ((UINT8) (HexChar - 0x37)); } + /* Lower case a-f */ + return ((UINT8) (HexChar - 0x57)); } diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c b/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c index 83b1cee0d79..563ef600ccd 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c @@ -129,19 +129,6 @@ AcpiUtMutexInitialize ( return_ACPI_STATUS (Status); } -#ifdef ACPI_DEBUGGER - - /* Debugger Support */ - - Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete); -#endif - return_ACPI_STATUS (Status); } @@ -187,12 +174,6 @@ AcpiUtMutexTerminate ( /* Delete the reader/writer lock */ AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); - -#ifdef ACPI_DEBUGGER - AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); - AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); -#endif - return_VOID; } diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utnonansi.c b/reactos/drivers/bus/acpi/acpica/utilities/utnonansi.c index 70fb33e64c0..4cddcf190b5 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utnonansi.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utnonansi.c @@ -48,10 +48,9 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utnonansi") - /* - * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit - * version of strtoul. + * Non-ANSI C library functions - strlwr, strupr, stricmp, and "safe" + * string functions. */ /******************************************************************************* @@ -238,430 +237,3 @@ AcpiUtSafeStrncat ( return (FALSE); } #endif - - -/******************************************************************************* - * - * FUNCTION: AcpiUtStrtoul64 - * - * PARAMETERS: String - Null terminated string - * Base - Radix of the string: 16 or 10 or - * ACPI_ANY_BASE - * MaxIntegerByteWidth - Maximum allowable integer,in bytes: - * 4 or 8 (32 or 64 bits) - * RetInteger - Where the converted integer is - * returned - * - * RETURN: Status and Converted value - * - * DESCRIPTION: Convert a string into an unsigned value. Performs either a - * 32-bit or 64-bit conversion, depending on the input integer - * size (often the current mode of the interpreter). - * - * NOTES: Negative numbers are not supported, as they are not supported - * by ACPI. - * - * AcpiGbl_IntegerByteWidth should be set to the proper width. - * For the core ACPICA code, this width depends on the DSDT - * version. For iASL, the default byte width is always 8 for the - * parser, but error checking is performed later to flag cases - * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. - * - * Does not support Octal strings, not needed at this time. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtStrtoul64 ( - char *String, - UINT32 Base, - UINT32 MaxIntegerByteWidth, - UINT64 *RetInteger) -{ - UINT32 ThisDigit = 0; - UINT64 ReturnValue = 0; - UINT64 Quotient; - UINT64 Dividend; - UINT8 ValidDigits = 0; - UINT8 SignOf0x = 0; - UINT8 Term = 0; - - - ACPI_FUNCTION_TRACE_STR (UtStrtoul64, String); - - - switch (Base) - { - case ACPI_ANY_BASE: - case 10: - case 16: - - break; - - default: - - /* Invalid Base */ - - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!String) - { - goto ErrorExit; - } - - /* Skip over any white space in the buffer */ - - while ((*String) && (isspace ((int) *String) || *String == '\t')) - { - String++; - } - - if (Base == ACPI_ANY_BASE) - { - /* - * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. - * We need to determine if it is decimal or hexadecimal. - */ - if ((*String == '0') && (tolower ((int) *(String + 1)) == 'x')) - { - SignOf0x = 1; - Base = 16; - - /* Skip over the leading '0x' */ - String += 2; - } - else - { - Base = 10; - } - } - - /* Any string left? Check that '0x' is not followed by white space. */ - - if (!(*String) || isspace ((int) *String) || *String == '\t') - { - if (Base == ACPI_ANY_BASE) - { - goto ErrorExit; - } - else - { - goto AllDone; - } - } - - /* - * Perform a 32-bit or 64-bit conversion, depending upon the input - * byte width - */ - Dividend = (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH) ? - ACPI_UINT32_MAX : ACPI_UINT64_MAX; - - /* Main loop: convert the string to a 32- or 64-bit integer */ - - while (*String) - { - if (isdigit ((int) *String)) - { - /* Convert ASCII 0-9 to Decimal value */ - - ThisDigit = ((UINT8) *String) - '0'; - } - else if (Base == 10) - { - /* Digit is out of range; possible in ToInteger case only */ - - Term = 1; - } - else - { - ThisDigit = (UINT8) toupper ((int) *String); - if (isxdigit ((int) ThisDigit)) - { - /* Convert ASCII Hex char to value */ - - ThisDigit = ThisDigit - 'A' + 10; - } - else - { - Term = 1; - } - } - - if (Term) - { - if (Base == ACPI_ANY_BASE) - { - goto ErrorExit; - } - else - { - break; - } - } - else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) - { - /* Skip zeros */ - String++; - continue; - } - - ValidDigits++; - - if (SignOf0x && ((ValidDigits > 16) || - ((ValidDigits > 8) && (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH)))) - { - /* - * This is ToInteger operation case. - * No restrictions for string-to-integer conversion, - * see ACPI spec. - */ - goto ErrorExit; - } - - /* Divide the digit into the correct position */ - - (void) AcpiUtShortDivide ( - (Dividend - (UINT64) ThisDigit), Base, &Quotient, NULL); - - if (ReturnValue > Quotient) - { - if (Base == ACPI_ANY_BASE) - { - goto ErrorExit; - } - else - { - break; - } - } - - ReturnValue *= Base; - ReturnValue += ThisDigit; - String++; - } - - /* All done, normal exit */ - -AllDone: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ReturnValue))); - - *RetInteger = ReturnValue; - return_ACPI_STATUS (AE_OK); - - -ErrorExit: - - /* Base was set/validated above (10 or 16) */ - - if (Base == 10) - { - return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); - } - else - { - return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); - } -} - - -#ifdef _OBSOLETE_FUNCTIONS -/* Removed: 01/2016 */ - -/******************************************************************************* - * - * FUNCTION: strtoul64 - * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte - * is returned - * Base - Radix of the string - * - * RETURN: Converted value - * - * DESCRIPTION: Convert a string into an unsigned value. - * - ******************************************************************************/ - -ACPI_STATUS -strtoul64 ( - char *String, - UINT32 Base, - UINT64 *RetInteger) -{ - UINT32 Index; - UINT32 Sign; - UINT64 ReturnValue = 0; - ACPI_STATUS Status = AE_OK; - - - *RetInteger = 0; - - switch (Base) - { - case 0: - case 8: - case 10: - case 16: - - break; - - default: - /* - * The specified Base parameter is not in the domain of - * this function: - */ - return (AE_BAD_PARAMETER); - } - - /* Skip over any white space in the buffer: */ - - while (isspace ((int) *String) || *String == '\t') - { - ++String; - } - - /* - * The buffer may contain an optional plus or minus sign. - * If it does, then skip over it but remember what is was: - */ - if (*String == '-') - { - Sign = ACPI_SIGN_NEGATIVE; - ++String; - } - else if (*String == '+') - { - ++String; - Sign = ACPI_SIGN_POSITIVE; - } - else - { - Sign = ACPI_SIGN_POSITIVE; - } - - /* - * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: - */ - if (Base == 0) - { - if (*String == '0') - { - if (tolower ((int) *(++String)) == 'x') - { - Base = 16; - ++String; - } - else - { - Base = 8; - } - } - else - { - Base = 10; - } - } - - /* - * For octal and hexadecimal bases, skip over the leading - * 0 or 0x, if they are present. - */ - if (Base == 8 && *String == '0') - { - String++; - } - - if (Base == 16 && - *String == '0' && - tolower ((int) *(++String)) == 'x') - { - String++; - } - - /* Main loop: convert the string to an unsigned long */ - - while (*String) - { - if (isdigit ((int) *String)) - { - Index = ((UINT8) *String) - '0'; - } - else - { - Index = (UINT8) toupper ((int) *String); - if (isupper ((int) Index)) - { - Index = Index - 'A' + 10; - } - else - { - goto ErrorExit; - } - } - - if (Index >= Base) - { - goto ErrorExit; - } - - /* Check to see if value is out of range: */ - - if (ReturnValue > ((ACPI_UINT64_MAX - (UINT64) Index) / - (UINT64) Base)) - { - goto ErrorExit; - } - else - { - ReturnValue *= Base; - ReturnValue += Index; - } - - ++String; - } - - - /* If a minus sign was present, then "the conversion is negated": */ - - if (Sign == ACPI_SIGN_NEGATIVE) - { - ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; - } - - *RetInteger = ReturnValue; - return (Status); - - -ErrorExit: - switch (Base) - { - case 8: - - Status = AE_BAD_OCTAL_CONSTANT; - break; - - case 10: - - Status = AE_BAD_DECIMAL_CONSTANT; - break; - - case 16: - - Status = AE_BAD_HEX_CONSTANT; - break; - - default: - - /* Base validated above */ - - break; - } - - return (Status); -} -#endif diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utosi.c b/reactos/drivers/bus/acpi/acpica/utilities/utosi.c index 674fe364d37..5193af52411 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utosi.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utosi.c @@ -442,11 +442,22 @@ AcpiUtGetInterface ( * PARAMETERS: WalkState - Current walk state * * RETURN: Status + * Integer: TRUE (0) if input string is matched + * FALSE (-1) if string is not matched * * DESCRIPTION: Implementation of the _OSI predefined control method. When * an invocation of _OSI is encountered in the system AML, * control is transferred to this function. * + * (August 2016) + * Note: _OSI is now defined to return "Ones" to indicate a match, for + * compatibility with other ACPI implementations. On a 32-bit DSDT, Ones + * is 0xFFFFFFFF. On a 64-bit DSDT, Ones is 0xFFFFFFFFFFFFFFFF + * (ACPI_UINT64_MAX). + * + * This function always returns ACPI_UINT64_MAX for TRUE, and later code + * will truncate this to 32 bits if necessary. + * ******************************************************************************/ ACPI_STATUS @@ -458,7 +469,7 @@ AcpiUtOsiImplementation ( ACPI_INTERFACE_INFO *InterfaceInfo; ACPI_INTERFACE_HANDLER InterfaceHandler; ACPI_STATUS Status; - UINT32 ReturnValue; + UINT64 ReturnValue; ACPI_FUNCTION_TRACE (UtOsiImplementation); @@ -507,7 +518,7 @@ AcpiUtOsiImplementation ( AcpiGbl_OsiData = InterfaceInfo->Value; } - ReturnValue = ACPI_UINT32_MAX; + ReturnValue = ACPI_UINT64_MAX; } AcpiOsReleaseMutex (AcpiGbl_OsiMutex); @@ -520,8 +531,11 @@ AcpiUtOsiImplementation ( InterfaceHandler = AcpiGbl_InterfaceHandler; if (InterfaceHandler) { - ReturnValue = InterfaceHandler ( - StringDesc->String.Pointer, ReturnValue); + if (InterfaceHandler ( + StringDesc->String.Pointer, (UINT32) ReturnValue)) + { + ReturnValue = ACPI_UINT64_MAX; + } } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c b/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c index 8efae429777..a3b0523fc8d 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c @@ -468,8 +468,10 @@ AcpiUtWalkAmlResources ( ACPI_FUNCTION_TRACE (UtWalkAmlResources); - /* The absolute minimum resource template is one EndTag descriptor */ - + /* + * The absolute minimum resource template is one EndTag descriptor. + * However, we will treat a lone EndTag as just a simple buffer. + */ if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) { return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); @@ -503,8 +505,8 @@ AcpiUtWalkAmlResources ( if (UserFunction) { - Status = UserFunction ( - Aml, Length, Offset, ResourceIndex, Context); + Status = UserFunction (Aml, Length, Offset, + ResourceIndex, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -531,6 +533,13 @@ AcpiUtWalkAmlResources ( *Context = Aml; } + /* Check if buffer is defined to be longer than the resource length */ + + if (AmlLength > (Offset + Length)) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + /* Normal exit */ return_ACPI_STATUS (AE_OK); diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utstrtoul64.c b/reactos/drivers/bus/acpi/acpica/utilities/utstrtoul64.c new file mode 100644 index 00000000000..f7558773681 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utstrtoul64.c @@ -0,0 +1,390 @@ +/******************************************************************************* + * + * Module Name: utstrtoul64 - string to 64-bit integer support + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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. + */ + +#include "acpi.h" +#include "accommon.h" + + +/******************************************************************************* + * + * The functions in this module satisfy the need for 64-bit string-to-integer + * conversions on both 32-bit and 64-bit platforms. + * + ******************************************************************************/ + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstrtoul64") + +/* Local prototypes */ + +static UINT64 +AcpiUtStrtoulBase10 ( + char *String, + UINT32 Flags); + +static UINT64 +AcpiUtStrtoulBase16 ( + char *String, + UINT32 Flags); + + +/******************************************************************************* + * + * String conversion rules as written in the ACPI specification. The error + * conditions and behavior are different depending on the type of conversion. + * + * + * Implicit data type conversion: string-to-integer + * -------------------------------------------------- + * + * Base is always 16. This is the ACPI_STRTOUL_BASE16 case. + * + * Example: + * Add ("BA98", Arg0, Local0) + * + * The integer is initialized to the value zero. + * The ASCII string is interpreted as a hexadecimal constant. + * + * 1) A "0x" prefix is not allowed. However, ACPICA allows this for + * compatibility with previous ACPICA. (NO ERROR) + * + * 2) Terminates when the size of an integer is reached (32 or 64 bits). + * (NO ERROR) + * + * 3) The first non-hex character terminates the conversion without error. + * (NO ERROR) + * + * 4) Conversion of a null (zero-length) string to an integer is not + * allowed. However, ACPICA allows this for compatibility with previous + * ACPICA. This conversion returns the value 0. (NO ERROR) + * + * + * Explicit data type conversion: ToInteger() with string operand + * --------------------------------------------------------------- + * + * Base is either 10 (default) or 16 (with 0x prefix) + * + * Examples: + * ToInteger ("1000") + * ToInteger ("0xABCD") + * + * 1) Can be (must be) either a decimal or hexadecimal numeric string. + * A hex value must be prefixed by "0x" or it is interpreted as a decimal. + * + * 2) The value must not exceed the maximum of an integer value. ACPI spec + * states the behavior is "unpredictable", so ACPICA matches the behavior + * of the implicit conversion case.(NO ERROR) + * + * 3) Behavior on the first non-hex character is not specified by the ACPI + * spec, so ACPICA matches the behavior of the implicit conversion case + * and terminates. (NO ERROR) + * + * 4) A null (zero-length) string is illegal. + * However, ACPICA allows this for compatibility with previous ACPICA. + * This conversion returns the value 0. (NO ERROR) + * + ******************************************************************************/ + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul64 + * + * PARAMETERS: String - Null terminated input string + * Flags - Conversion info, see below + * ReturnValue - Where the converted integer is + * returned + * + * RETURN: Status and Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. Performs either a + * 32-bit or 64-bit conversion, depending on the input integer + * size in Flags (often the current mode of the interpreter). + * + * Values for Flags: + * ACPI_STRTOUL_32BIT - Max integer value is 32 bits + * ACPI_STRTOUL_64BIT - Max integer value is 64 bits + * ACPI_STRTOUL_BASE16 - Input string is hexadecimal. Default + * is 10/16 based on string prefix (0x). + * + * NOTES: + * Negative numbers are not supported, as they are not supported by ACPI. + * + * Supports only base 16 or base 10 strings/values. Does not + * support Octal strings, as these are not supported by ACPI. + * + * Current users of this support: + * + * Interpreter - Implicit and explicit conversions, GPE method names + * Debugger - Command line input string conversion + * iASL - Main parser, conversion of constants to integers + * iASL - Data Table Compiler parser (constant math expressions) + * iASL - Preprocessor (constant math expressions) + * AcpiDump - Input table addresses + * AcpiExec - Testing of the AcpiUtStrtoul64 function + * + * Note concerning callers: + * AcpiGbl_IntegerByteWidth can be used to set the 32/64 limit. If used, + * this global should be set to the proper width. For the core ACPICA code, + * this width depends on the DSDT version. For iASL, the default byte + * width is always 8 for the parser, but error checking is performed later + * to flag cases where a 64-bit constant is defined in a 32-bit DSDT/SSDT. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Flags, + UINT64 *ReturnValue) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Base; + + + ACPI_FUNCTION_TRACE_STR (UtStrtoul64, String); + + + /* Parameter validation */ + + if (!String || !ReturnValue) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + *ReturnValue = 0; + + /* Check for zero-length string, returns 0 */ + + if (*String == 0) + { + return_ACPI_STATUS (AE_OK); + } + + /* Skip over any white space at start of string */ + + while (isspace ((int) *String)) + { + String++; + } + + /* End of string? return 0 */ + + if (*String == 0) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * 1) The "0x" prefix indicates base 16. Per the ACPI specification, + * the "0x" prefix is only allowed for implicit (non-strict) conversions. + * However, we always allow it for compatibility with older ACPICA. + */ + if ((*String == ACPI_ASCII_ZERO) && + (tolower ((int) *(String + 1)) == 'x')) + { + String += 2; /* Go past the 0x */ + if (*String == 0) + { + return_ACPI_STATUS (AE_OK); /* Return value 0 */ + } + + Base = 16; + } + + /* 2) Force to base 16 (implicit conversion case) */ + + else if (Flags & ACPI_STRTOUL_BASE16) + { + Base = 16; + } + + /* 3) Default fallback is to Base 10 */ + + else + { + Base = 10; + } + + /* Skip all leading zeros */ + + while (*String == ACPI_ASCII_ZERO) + { + String++; + if (*String == 0) + { + return_ACPI_STATUS (AE_OK); /* Return value 0 */ + } + } + + /* Perform the base 16 or 10 conversion */ + + if (Base == 16) + { + *ReturnValue = AcpiUtStrtoulBase16 (String, Flags); + } + else + { + *ReturnValue = AcpiUtStrtoulBase10 (String, Flags); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoulBase10 + * + * PARAMETERS: String - Null terminated input string + * Flags - Conversion info + * + * RETURN: 64-bit converted integer + * + * DESCRIPTION: Performs a base 10 conversion of the input string to an + * integer value, either 32 or 64 bits. + * Note: String must be valid and non-null. + * + ******************************************************************************/ + +static UINT64 +AcpiUtStrtoulBase10 ( + char *String, + UINT32 Flags) +{ + int AsciiDigit; + UINT64 NextValue; + UINT64 ReturnValue = 0; + + + /* Main loop: convert each ASCII byte in the input string */ + + while (*String) + { + AsciiDigit = *String; + if (!isdigit (AsciiDigit)) + { + /* Not ASCII 0-9, terminate */ + + goto Exit; + } + + /* Convert and insert (add) the decimal digit */ + + NextValue = + (ReturnValue * 10) + (AsciiDigit - ACPI_ASCII_ZERO); + + /* Check for overflow (32 or 64 bit) - return current converted value */ + + if (((Flags & ACPI_STRTOUL_32BIT) && (NextValue > ACPI_UINT32_MAX)) || + (NextValue < ReturnValue)) /* 64-bit overflow case */ + { + goto Exit; + } + + ReturnValue = NextValue; + String++; + } + +Exit: + return (ReturnValue); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoulBase16 + * + * PARAMETERS: String - Null terminated input string + * Flags - conversion info + * + * RETURN: 64-bit converted integer + * + * DESCRIPTION: Performs a base 16 conversion of the input string to an + * integer value, either 32 or 64 bits. + * Note: String must be valid and non-null. + * + ******************************************************************************/ + +static UINT64 +AcpiUtStrtoulBase16 ( + char *String, + UINT32 Flags) +{ + int AsciiDigit; + UINT32 ValidDigits = 1; + UINT64 ReturnValue = 0; + + + /* Main loop: convert each ASCII byte in the input string */ + + while (*String) + { + /* Check for overflow (32 or 64 bit) - return current converted value */ + + if ((ValidDigits > 16) || + ((ValidDigits > 8) && (Flags & ACPI_STRTOUL_32BIT))) + { + goto Exit; + } + + AsciiDigit = *String; + if (!isxdigit (AsciiDigit)) + { + /* Not Hex ASCII A-F, a-f, or 0-9, terminate */ + + goto Exit; + } + + /* Convert and insert the hex digit */ + + ReturnValue = + (ReturnValue << 4) | AcpiUtAsciiCharToHex (AsciiDigit); + + String++; + ValidDigits++; + } + +Exit: + return (ReturnValue); +} diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utxfinit.c b/reactos/drivers/bus/acpi/acpica/utilities/utxfinit.c index 7d775881586..6b79e08f72c 100644 --- a/reactos/drivers/bus/acpi/acpica/utilities/utxfinit.c +++ b/reactos/drivers/bus/acpi/acpica/utilities/utxfinit.c @@ -293,7 +293,7 @@ AcpiInitializeObjects ( * all of the tables have been loaded. It is a legacy option and is * not compatible with other ACPI implementations. See AcpiNsLoadTable. */ - if (AcpiGbl_GroupModuleLevelCode) + if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); diff --git a/reactos/drivers/bus/acpi/osl.c b/reactos/drivers/bus/acpi/osl.c index c95e011ab17..1c28c6f4212 100644 --- a/reactos/drivers/bus/acpi/osl.c +++ b/reactos/drivers/bus/acpi/osl.c @@ -928,6 +928,16 @@ AcpiOsSignal ( return (AE_OK); } +ACPI_STATUS +AcpiOsEnterSleep( + UINT8 SleepState, + UINT32 RegaValue, + UINT32 RegbValue) +{ + DPRINT1("Attempt to enter sleep. Aborting.\n"); + return AE_CTRL_TERMINATE; +} + ACPI_STATUS AcpiOsGetLine( char *Buffer, -- 2.17.1