From 5391902bdfae16dcc97f58a1c77a41c738f5f2f5 Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Wed, 14 Apr 2004 16:50:32 +0000 Subject: [PATCH 1/2] Only avoid disabling bus mastering on the sleep path. This should fix power off for some users. The patch has been submitted to Intel. Bug: http://bugme.osdl.org/show_bug.cgi?id=2109 --- sys/contrib/dev/acpica/hwsleep.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index 13224c72494c..488e765667ba 100644 --- a/sys/contrib/dev/acpica/hwsleep.c +++ b/sys/contrib/dev/acpica/hwsleep.c @@ -349,22 +349,22 @@ AcpiEnterSleepState ( SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A); SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + /* Clear wake status */ + + Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + if (SleepState != ACPI_STATE_S5) { - /* Clear wake status */ - - Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* Disable BM arbitration */ Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); From a5a81f7c89bfa1232e53c5594bfb6a005e4542ce Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Tue, 25 May 2004 02:34:44 +0000 Subject: [PATCH 2/2] Vendor import of Intel ACPI-CA 20040514. --- sys/contrib/dev/acpica/CHANGES.txt | 171 +++++++++ sys/contrib/dev/acpica/acconfig.h | 16 +- sys/contrib/dev/acpica/acdebug.h | 6 +- sys/contrib/dev/acpica/acdispat.h | 5 +- sys/contrib/dev/acpica/acefi.h | 4 +- sys/contrib/dev/acpica/acenv.h | 10 +- sys/contrib/dev/acpica/acevents.h | 53 ++- sys/contrib/dev/acpica/acexcep.h | 8 +- sys/contrib/dev/acpica/acfreebsd.h | 8 +- sys/contrib/dev/acpica/acglobal.h | 5 +- sys/contrib/dev/acpica/achware.h | 34 +- sys/contrib/dev/acpica/aclocal.h | 43 ++- sys/contrib/dev/acpica/acmacros.h | 4 +- sys/contrib/dev/acpica/acnamesp.h | 20 +- sys/contrib/dev/acpica/acobject.h | 15 +- sys/contrib/dev/acpica/acparser.h | 6 +- sys/contrib/dev/acpica/acpixf.h | 10 +- sys/contrib/dev/acpica/acstruct.h | 26 +- sys/contrib/dev/acpica/actbl.h | 33 +- sys/contrib/dev/acpica/actypes.h | 76 ++-- sys/contrib/dev/acpica/common/adisasm.c | 10 +- sys/contrib/dev/acpica/compiler/aslstubs.c | 9 +- sys/contrib/dev/acpica/dbcmds.c | 35 +- sys/contrib/dev/acpica/dbdisply.c | 144 +++++++- sys/contrib/dev/acpica/dbinput.c | 16 +- sys/contrib/dev/acpica/dmwalk.c | 4 +- sys/contrib/dev/acpica/dsmethod.c | 20 +- sys/contrib/dev/acpica/dsopcode.c | 6 +- sys/contrib/dev/acpica/dswstate.c | 23 +- sys/contrib/dev/acpica/evevent.c | 14 +- sys/contrib/dev/acpica/evgpe.c | 405 +++++++++++++++++++-- sys/contrib/dev/acpica/evgpeblk.c | 224 ++++++++---- sys/contrib/dev/acpica/evmisc.c | 12 +- sys/contrib/dev/acpica/evregion.c | 394 ++++++++++++++++++-- sys/contrib/dev/acpica/evxface.c | 178 +++++---- sys/contrib/dev/acpica/evxfevnt.c | 193 +++++----- sys/contrib/dev/acpica/evxfregn.c | 219 +---------- sys/contrib/dev/acpica/exconfig.c | 53 ++- sys/contrib/dev/acpica/exmutex.c | 53 +-- sys/contrib/dev/acpica/exoparg2.c | 40 +- sys/contrib/dev/acpica/exresolv.c | 10 +- sys/contrib/dev/acpica/exstore.c | 6 +- sys/contrib/dev/acpica/hwgpe.c | 391 ++++++-------------- sys/contrib/dev/acpica/hwregs.c | 33 +- sys/contrib/dev/acpica/hwsleep.c | 41 ++- sys/contrib/dev/acpica/nsaccess.c | 10 +- sys/contrib/dev/acpica/nsalloc.c | 6 +- sys/contrib/dev/acpica/nseval.c | 94 ++--- sys/contrib/dev/acpica/nsinit.c | 44 ++- sys/contrib/dev/acpica/nsparse.c | 7 +- sys/contrib/dev/acpica/nsxfeval.c | 56 +-- sys/contrib/dev/acpica/nsxfname.c | 6 +- sys/contrib/dev/acpica/psxface.c | 53 +-- sys/contrib/dev/acpica/rsutils.c | 9 +- sys/contrib/dev/acpica/rsxface.c | 5 +- sys/contrib/dev/acpica/uteval.c | 22 +- sys/contrib/dev/acpica/utglobal.c | 56 +-- sys/contrib/dev/acpica/utxface.c | 45 ++- 58 files changed, 2254 insertions(+), 1245 deletions(-) diff --git a/sys/contrib/dev/acpica/CHANGES.txt b/sys/contrib/dev/acpica/CHANGES.txt index 5eac16fe2c71..9e71afc30377 100644 --- a/sys/contrib/dev/acpica/CHANGES.txt +++ b/sys/contrib/dev/acpica/CHANGES.txt @@ -1,3 +1,174 @@ +---------------------------------------- +14 May 2004. Summary of changes for version 20040514: + +1) ACPI CA Core Subsystem: + +Fixed a problem where hardware GPE enable bits sometimes not set +properly during and after GPE method execution. Result of 04/27 +changes. + +Removed extra "clear all GPEs" when sleeping/waking. + +Removed AcpiHwEnableGpe and AcpiHwDisableGpe, replaced by the +single AcpiHwWriteGpeEnableReg. Changed a couple of calls to the +functions above to the new AcpiEv* calls as appropriate. + +ACPI_OS_NAME was removed from the OS-specific headers. The +default name is now "Microsoft Windows NT" for maximum +compatibility. However this can be changed by modifying the +acconfig.h file. + +Allow a single invocation of AcpiInstallNotifyHandler for a +handler that traps both types of notifies (System, Device). Use +ACPI_ALL_NOTIFY flag. + +Run _INI methods on ThermalZone objects. This is against the +ACPI specification, but there is apparently ASL code in the field +that has these _INI methods, and apparently "other" AML +interpreters execute them. + +Performed a full 16/32/64 bit lint that resulted in some small +changes. + +Added a sleep simulation command to the AML debugger to test +sleep code. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 162.9K Code, 67.0K Data, 229.9K Total + Current Release: + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 163.2K Code, 67.2K Data, 230.4K Total + +---------------------------------------- +27 April 2004. Summary of changes for version 20040427: + +1) ACPI CA Core Subsystem: + +Completed a major overhaul of the GPE handling within ACPI CA. +There are now three types of GPEs: wake-only, runtime-only, and +combination wake/run. The only GPEs allowed to be combination +wake/run are for button-style devices such as a control-method +power button, control-method sleep button, or a notebook lid +switch. GPEs that have an _Lxx or _Exx method and are not +referenced by any _PRW methods are marked for "runtime" and +hardware enabled. Any GPE that is referenced by a _PRW method is +marked for "wake" (and disabled at runtime). However, at sleep +time, only those GPEs that have been specifically enabled for +wake via the AcpiEnableGpe interface will actually be hardware +enabled. + +A new external interface has been added, AcpiSetGpeType(), that +is meant to be used by device drivers to force a GPE to a +particular type. It will be especially useful for the drivers +for the button devices mentioned above. + +Completed restructuring of the ACPI CA initialization sequence so +that default operation region handlers are installed before GPEs +are initialized and the _PRW methods are executed. This will +prevent errors when the _PRW methods attempt to access system +memory or I/O space. + +GPE enable/disable no longer reads the GPE enable register. We +now keep the enable info for runtime and wake separate and in the +GPE_EVENT_INFO. We thus no longer depend on the hardware to +maintain these bits. + +Always clear the wake status and fixed/GPE status bits before +sleep, even for state S5. + +Improved the AML debugger output for displaying the GPE blocks +and their current status. + +Added new strings for the _OSI method, of the form "Windows 2001 +SPx" where x = 0,1,2,3,4. + +Fixed a problem where the physical address was incorrectly +calculated when the Load() operator was used to directly load +from an Operation Region (vs. loading from a Field object.) Also +added check for minimum table length for this case. + +Fix for multiple mutex acquisition. Restore original thread +SyncLevel on mutex release. + +Added ACPI_VALID_SXDS flag to the AcpiGetObjectInfo interface for +consistency with the other fields returned. + +Shrunk the ACPI_GPE_EVENT_INFO structure by 40%. There is one +such structure for each GPE in the system, so the size of this +structure is important. + +CPU stack requirement reduction: Cleaned up the method execution +and object evaluation paths so that now a parameter structure is +passed, instead of copying the various method parameters over and +over again. + +In evregion.c: Correctly exit and reenter the interpreter region +if and only if dispatching an operation region request to a user- +installed handler. Do not exit/reenter when dispatching to a +default handler (e.g., default system memory or I/O handlers) + + +Notes for updating drivers for the new GPE support. The +following changes must be made to ACPI-related device drivers +that are attached to one or more GPEs: (This information will be +added to the ACPI CA Programmer Reference.) + +1) AcpiInstallGpeHandler no longer automatically enables the GPE, +you must explicitly call AcpiEnableGpe. +2) There is a new interface called AcpiSetGpeType. This should be +called before enabling the GPE. Also, this interface will +automatically disable the GPE if it is currently enabled. +3) AcpiEnableGpe no longer supports a GPE type flag. + +Specific drivers that must be changed: +1) EC driver: + AcpiInstallGpeHandler (NULL, GpeNum, ACPI_GPE_EDGE_TRIGGERED, +AeGpeHandler, NULL); + AcpiSetGpeType (NULL, GpeNum, ACPI_GPE_TYPE_RUNTIME); + AcpiEnableGpe (NULL, GpeNum, ACPI_NOT_ISR); + +2) Button Drivers (Power, Lid, Sleep): +Run _PRW method under parent device +If _PRW exists: /* This is a control-method button */ + Extract GPE number and possibly GpeDevice + AcpiSetGpeType (GpeDevice, GpeNum, ACPI_GPE_TYPE_WAKE_RUN); + AcpiEnableGpe (GpeDevice, GpeNum, ACPI_NOT_ISR); + +For all other devices that have _PRWs, we automatically set the +GPE type to ACPI_GPE_TYPE_WAKE, but the GPE is NOT automatically +(wake) enabled. This must be done on a selective basis, usually +requiring some kind of user app to allow the user to pick the +wake devices. + + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.0K Code, 11.4K Data, 88.4K Total + Debug Version: 161.0K Code, 66.3K Data, 227.3K Total + Current Release: + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 162.9K Code, 67.0K Data, 229.9K Total + + + ---------------------------------------- 02 April 2004. Summary of changes for version 20040402: diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h index 74895b5baf4d..f88098bed096 100644 --- a/sys/contrib/dev/acpica/acconfig.h +++ b/sys/contrib/dev/acpica/acconfig.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * $Revision: 152 $ + * $Revision: 156 $ * *****************************************************************************/ @@ -137,7 +137,17 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20040402 +#define ACPI_CA_VERSION 0x20040514 + +/* + * OS name, used for the _OS object. The _OS object is essentially obsolete, + * but there is a large base of ASL/AML code in existing machines that check + * for the string below. The use of this string usually guarantees that + * the ASL will execute down the most tested code path. Also, there is some + * code that will not execute the _OSI method unless _OS matches the string + * below. Therefore, change this string at your own risk. + */ +#define ACPI_OS_NAME "Microsoft Windows NT" /* Maximum objects in the various object caches */ @@ -260,7 +270,7 @@ /* Number of strings associated with the _OSI reserved method */ -#define ACPI_NUM_OSI_STRINGS 4 +#define ACPI_NUM_OSI_STRINGS 9 /****************************************************************************** diff --git a/sys/contrib/dev/acpica/acdebug.h b/sys/contrib/dev/acpica/acdebug.h index 45e3defc6d40..c27eebe562d0 100644 --- a/sys/contrib/dev/acpica/acdebug.h +++ b/sys/contrib/dev/acpica/acdebug.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * $Revision: 73 $ + * $Revision: 74 $ * *****************************************************************************/ @@ -239,6 +239,10 @@ void AcpiDbSetScope ( char *Name); +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg); + void AcpiDbFindReferences ( char *ObjectArg); diff --git a/sys/contrib/dev/acpica/acdispat.h b/sys/contrib/dev/acpica/acdispat.h index 63593540d1da..906cdb73a993 100644 --- a/sys/contrib/dev/acpica/acdispat.h +++ b/sys/contrib/dev/acpica/acdispat.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdispat.h - dispatcher (parser to interpreter interface) - * $Revision: 57 $ + * $Revision: 58 $ * *****************************************************************************/ @@ -510,8 +510,7 @@ AcpiDsInitAmlWalk ( ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc, + ACPI_PARAMETER_INFO *Info, UINT32 PassNumber); ACPI_STATUS diff --git a/sys/contrib/dev/acpica/acefi.h b/sys/contrib/dev/acpica/acefi.h index 55ef0c3feca2..15c3f421388e 100644 --- a/sys/contrib/dev/acpica/acefi.h +++ b/sys/contrib/dev/acpica/acefi.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acefi.h - OS specific defines, etc. - * $Revision: 14 $ + * $Revision: 15 $ * *****************************************************************************/ @@ -117,8 +117,6 @@ #ifndef __ACEFI_H__ #define __ACEFI_H__ -#define ACPI_OS_NAME "AED EFI" - #include #include #include diff --git a/sys/contrib/dev/acpica/acenv.h b/sys/contrib/dev/acpica/acenv.h index 373d7ac133bf..bc17268aedd5 100644 --- a/sys/contrib/dev/acpica/acenv.h +++ b/sys/contrib/dev/acpica/acenv.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acenv.h - Generation environment specific items - * $Revision: 106 $ + * $Revision: 107 $ * *****************************************************************************/ @@ -225,12 +225,8 @@ #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long - -/* Name of host operating system (returned by the _OS_ namespace object) */ - -#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" - -/* This macro is used to tag functions as "printf-like" because +/* + * This macro is used to tag functions as "printf-like" because * some compilers can catch printf format string problems. MSVC * doesn't, so this is proprocessed away. */ diff --git a/sys/contrib/dev/acpica/acevents.h b/sys/contrib/dev/acpica/acevents.h index f8bb079ba290..6c50306a5b41 100644 --- a/sys/contrib/dev/acpica/acevents.h +++ b/sys/contrib/dev/acpica/acevents.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acevents.h - Event subcomponent prototypes and defines - * $Revision: 93 $ + * $Revision: 95 $ * *****************************************************************************/ @@ -119,11 +119,11 @@ ACPI_STATUS -AcpiEvInitialize ( +AcpiEvInitializeEvents ( void); ACPI_STATUS -AcpiEvHandlerInitialize ( +AcpiEvInstallXruptHandlers ( void); @@ -190,6 +190,20 @@ BOOLEAN AcpiEvValidGpeEvent ( ACPI_GPE_EVENT_INFO *GpeEventInfo); +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware); + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + ACPI_GPE_EVENT_INFO * AcpiEvGetGpeEventInfo ( ACPI_HANDLE GpeDevice, @@ -212,6 +226,11 @@ ACPI_STATUS AcpiEvDeleteGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock); +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); + UINT32 AcpiEvGpeDispatch ( ACPI_GPE_EVENT_INFO *GpeEventInfo, @@ -221,12 +240,25 @@ UINT32 AcpiEvGpeDetect ( ACPI_GPE_XRUPT_INFO *GpeXruptList); +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + /* * Evregion - Address Space handling */ ACPI_STATUS -AcpiEvInitAddressSpaces ( +AcpiEvInstallRegionHandlers ( + void); + +ACPI_STATUS +AcpiEvInitializeOpRegions ( void); ACPI_STATUS @@ -255,6 +287,19 @@ AcpiEvDetachRegion ( ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked); +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + ACPI_STATUS AcpiEvExecuteRegMethod ( ACPI_OPERAND_OBJECT *RegionObj, diff --git a/sys/contrib/dev/acpica/acexcep.h b/sys/contrib/dev/acpica/acexcep.h index 3546bf3c1e98..fd5ae2908570 100644 --- a/sys/contrib/dev/acpica/acexcep.h +++ b/sys/contrib/dev/acpica/acexcep.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acexcep.h - Exception codes returned by the ACPI subsystem - * $Revision: 70 $ + * $Revision: 71 $ * *****************************************************************************/ @@ -168,8 +168,9 @@ #define AE_LOGICAL_ADDRESS (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) #define AE_ABORT_METHOD (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL) #define AE_SAME_HANDLER (ACPI_STATUS) (0x001D | AE_CODE_ENVIRONMENTAL) +#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001E | AE_CODE_ENVIRONMENTAL) -#define AE_CODE_ENV_MAX 0x001D +#define AE_CODE_ENV_MAX 0x001E /* * Programmer exceptions @@ -295,7 +296,8 @@ char const *AcpiGbl_ExceptionNames_Env[] = "AE_NO_GLOBAL_LOCK", "AE_LOGICAL_ADDRESS", "AE_ABORT_METHOD", - "AE_SAME_HANDLER" + "AE_SAME_HANDLER", + "AE_WAKE_ONLY_GPE" }; char const *AcpiGbl_ExceptionNames_Pgm[] = diff --git a/sys/contrib/dev/acpica/acfreebsd.h b/sys/contrib/dev/acpica/acfreebsd.h index 9edbe390dbd1..447d0f677f1a 100644 --- a/sys/contrib/dev/acpica/acfreebsd.h +++ b/sys/contrib/dev/acpica/acfreebsd.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acfreebsd.h - OS specific defines, etc. - * $Revision: 13 $ + * $Revision: 15 $ * *****************************************************************************/ @@ -117,12 +117,6 @@ #ifndef __ACFREEBSD_H__ #define __ACFREEBSD_H__ -/* - * Some systems' ASL may have problems because they look for names - * of Microsoft operating systems. To override this, set hw.acpi.os_name - * to the appropriate string. - */ -#define ACPI_OS_NAME "FreeBSD" /* FreeBSD uses GCC */ diff --git a/sys/contrib/dev/acpica/acglobal.h b/sys/contrib/dev/acpica/acglobal.h index 0bf6ce10ca34..b5935b2d1cce 100644 --- a/sys/contrib/dev/acpica/acglobal.h +++ b/sys/contrib/dev/acpica/acglobal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acglobal.h - Declarations for global variables - * $Revision: 152 $ + * $Revision: 154 $ * *****************************************************************************/ @@ -132,7 +132,7 @@ #define ACPI_INIT_GLOBAL(a,b) a #endif -/* +/* * Keep local copies of these FADT-based registers. NOTE: These globals * are first in this file for alignment reasons on 64-bit systems. */ @@ -265,6 +265,7 @@ ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; +ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; extern BOOLEAN AcpiGbl_Shutdown; extern UINT32 AcpiGbl_StartupFlags; diff --git a/sys/contrib/dev/acpica/achware.h b/sys/contrib/dev/acpica/achware.h index dd33a4b6a184..b9e0ecc0f971 100644 --- a/sys/contrib/dev/acpica/achware.h +++ b/sys/contrib/dev/acpica/achware.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: achware.h -- hardware specific interfaces - * $Revision: 69 $ + * $Revision: 72 $ * *****************************************************************************/ @@ -187,15 +187,7 @@ AcpiHwClearAcpiStatus ( /* GPE support */ ACPI_STATUS -AcpiHwEnableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - -void -AcpiHwEnableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - -ACPI_STATUS -AcpiHwDisableGpe ( +AcpiHwWriteGpeEnableReg ( ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_STATUS @@ -203,10 +195,6 @@ AcpiHwDisableGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock); -void -AcpiHwDisableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - ACPI_STATUS AcpiHwClearGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo); @@ -222,13 +210,27 @@ AcpiHwGetGpeStatus ( ACPI_EVENT_STATUS *EventStatus); ACPI_STATUS -AcpiHwPrepareGpesForSleep ( +AcpiHwDisableAllGpes ( void); ACPI_STATUS -AcpiHwRestoreGpesOnWake ( +AcpiHwEnableAllRuntimeGpes ( void); +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void); + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); + +ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); + /* ACPI Timer prototypes */ diff --git a/sys/contrib/dev/acpica/aclocal.h b/sys/contrib/dev/acpica/aclocal.h index 98bee4991393..09aee94cfafb 100644 --- a/sys/contrib/dev/acpica/aclocal.h +++ b/sys/contrib/dev/acpica/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 199 $ + * $Revision: 201 $ * *****************************************************************************/ @@ -264,8 +264,6 @@ typedef struct acpi_namespace_node UINT8 Type; /* Type associated with this name */ UINT16 OwnerId; ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ - - union acpi_operand_object *Object; /* Pointer to attached ACPI object (optional) */ struct acpi_namespace_node *Child; /* First child */ struct acpi_namespace_node *Peer; /* Next peer*/ @@ -287,10 +285,8 @@ typedef struct acpi_namespace_node #define ANOBJ_METHOD_LOCAL 0x10 #define ANOBJ_METHOD_NO_RETVAL 0x20 #define ANOBJ_METHOD_SOME_NO_RETVAL 0x40 - #define ANOBJ_IS_BIT_OFFSET 0x80 - /* * ACPI Table Descriptor. One per ACPI table */ @@ -392,16 +388,33 @@ typedef struct acpi_create_field_info * ****************************************************************************/ -/* Information about a GPE, one per each GPE in an array */ +/* Dispatch info for each GPE -- either a method or handler, cannot be both */ -typedef struct acpi_gpe_event_info +typedef struct acpi_handler_info +{ + ACPI_EVENT_HANDLER Address; /* Address of handler, if any */ + void *Context; /* Context to be passed to handler */ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level (saved) */ + +} ACPI_HANDLER_INFO; + +typedef union acpi_gpe_dispatch_info { ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ - ACPI_GPE_HANDLER Handler; /* Address of handler, if any */ - void *Context; /* Context to be passed to handler */ + struct acpi_handler_info *Handler; + +} ACPI_GPE_DISPATCH_INFO; + +/* + * Information about a GPE, one per each GPE in an array. + * NOTE: Important to keep this struct as small as possible. + */ +typedef struct acpi_gpe_event_info +{ + union acpi_gpe_dispatch_info Dispatch; /* Either Method or Handler */ struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ - UINT8 Flags; /* Level or Edge */ - UINT8 BitMask; /* This GPE within the register */ + UINT8 Flags; /* Misc info about this GPE */ + UINT8 RegisterBit; /* This GPE bit within the register */ } ACPI_GPE_EVENT_INFO; @@ -411,9 +424,8 @@ typedef struct acpi_gpe_register_info { ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ - UINT8 Status; /* Current value of status reg */ - UINT8 Enable; /* Current value of enable reg */ - UINT8 WakeEnable; /* Mask of bits to keep enabled when sleeping */ + UINT8 EnableForWake; /* GPEs to keep enabled when sleeping */ + UINT8 EnableForRun; /* GPEs to keep enabled when running */ UINT8 BaseGpeNumber; /* Base GPE number for this register */ } ACPI_GPE_REGISTER_INFO; @@ -424,6 +436,7 @@ typedef struct acpi_gpe_register_info */ typedef struct acpi_gpe_block_info { + ACPI_NAMESPACE_NODE *Node; struct acpi_gpe_block_info *Previous; struct acpi_gpe_block_info *Next; struct acpi_gpe_xrupt_info *XruptBlock; /* Backpointer to interrupt block */ @@ -598,7 +611,7 @@ typedef struct acpi_thread_state struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ UINT32 ThreadId; /* Running thread ID */ - UINT16 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ } ACPI_THREAD_STATE; diff --git a/sys/contrib/dev/acpica/acmacros.h b/sys/contrib/dev/acpica/acmacros.h index 3d4f66c8bbfd..9f577d6af589 100644 --- a/sys/contrib/dev/acpica/acmacros.h +++ b/sys/contrib/dev/acpica/acmacros.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acmacros.h - C macros for the entire subsystem. - * $Revision: 149 $ + * $Revision: 150 $ * *****************************************************************************/ @@ -170,7 +170,7 @@ * printf() format helpers */ -/* Split 64-bit integer into two 32-bit values. Use with %8,8X%8.8X */ +/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) diff --git a/sys/contrib/dev/acpica/acnamesp.h b/sys/contrib/dev/acpica/acnamesp.h index 1437aa334d13..290ebc15c9ab 100644 --- a/sys/contrib/dev/acpica/acnamesp.h +++ b/sys/contrib/dev/acpica/acnamesp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 135 $ + * $Revision: 136 $ * *****************************************************************************/ @@ -351,33 +351,25 @@ AcpiNsDumpObjects ( ACPI_STATUS AcpiNsEvaluateByHandle ( - ACPI_NAMESPACE_NODE *PrefixNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject); + ACPI_PARAMETER_INFO *Info); ACPI_STATUS AcpiNsEvaluateByName ( char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject); + ACPI_PARAMETER_INFO *Info); ACPI_STATUS AcpiNsEvaluateRelative ( - ACPI_NAMESPACE_NODE *PrefixNode, char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject); + ACPI_PARAMETER_INFO *Info); ACPI_STATUS AcpiNsExecuteControlMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc); + ACPI_PARAMETER_INFO *Info); ACPI_STATUS AcpiNsGetObjectValue ( - ACPI_NAMESPACE_NODE *ObjectNode, - ACPI_OPERAND_OBJECT **ReturnObjDesc); + ACPI_PARAMETER_INFO *Info); /* diff --git a/sys/contrib/dev/acpica/acobject.h b/sys/contrib/dev/acpica/acobject.h index dbdb9ef28c6f..f47920a878c9 100644 --- a/sys/contrib/dev/acpica/acobject.h +++ b/sys/contrib/dev/acpica/acobject.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * $Revision: 124 $ + * $Revision: 125 $ * *****************************************************************************/ @@ -284,13 +284,14 @@ typedef struct acpi_object_method typedef struct acpi_object_mutex { ACPI_OBJECT_COMMON_HEADER - UINT16 SyncLevel; - UINT16 AcquisitionDepth; - struct acpi_thread_state *OwnerThread; - void *Semaphore; + UINT8 SyncLevel; /* 0-15, specified in Mutex() call */ + UINT16 AcquisitionDepth; /* Allow multiple Acquires, same thread */ + struct acpi_thread_state *OwnerThread; /* Current owner of the mutex */ + void *Semaphore; /* Actual OS synchronization object */ union acpi_operand_object *Prev; /* Link for list of acquired mutexes */ union acpi_operand_object *Next; /* Link for list of acquired mutexes */ - ACPI_NAMESPACE_NODE *Node; /* containing object */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + UINT8 OriginalSyncLevel; /* Owner's original sync level (0-15) */ } ACPI_OBJECT_MUTEX; @@ -301,7 +302,7 @@ typedef struct acpi_object_region UINT8 SpaceId; union acpi_operand_object *Handler; /* Handler for region access */ - ACPI_NAMESPACE_NODE *Node; /* containing object */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ union acpi_operand_object *Next; UINT32 Length; ACPI_PHYSICAL_ADDRESS Address; diff --git a/sys/contrib/dev/acpica/acparser.h b/sys/contrib/dev/acpica/acparser.h index 96c23342008c..32a2ae6dbc70 100644 --- a/sys/contrib/dev/acpica/acparser.h +++ b/sys/contrib/dev/acpica/acparser.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * $Revision: 66 $ + * $Revision: 67 $ * *****************************************************************************/ @@ -146,9 +146,7 @@ AcpiPsxLoadTable ( ACPI_STATUS AcpiPsxExecute ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc); + ACPI_PARAMETER_INFO *Info); /****************************************************************************** diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h index d836f58b9e50..57fce7761f7b 100644 --- a/sys/contrib/dev/acpica/acpixf.h +++ b/sys/contrib/dev/acpica/acpixf.h @@ -368,7 +368,7 @@ AcpiInstallGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, - ACPI_GPE_HANDLER Handler, + ACPI_EVENT_HANDLER Address, void *Context); ACPI_STATUS @@ -384,7 +384,7 @@ ACPI_STATUS AcpiRemoveGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - ACPI_GPE_HANDLER Handler); + ACPI_EVENT_HANDLER Address); ACPI_STATUS AcpiEnableEvent ( @@ -405,6 +405,12 @@ AcpiGetEventStatus ( UINT32 Event, ACPI_EVENT_STATUS *EventStatus); +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type); + ACPI_STATUS AcpiEnableGpe ( ACPI_HANDLE GpeDevice, diff --git a/sys/contrib/dev/acpica/acstruct.h b/sys/contrib/dev/acpica/acstruct.h index 2b9e6c08847b..1852650a48f4 100644 --- a/sys/contrib/dev/acpica/acstruct.h +++ b/sys/contrib/dev/acpica/acstruct.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acstruct.h - Internal structs - * $Revision: 27 $ + * $Revision: 28 $ * *****************************************************************************/ @@ -142,13 +142,14 @@ typedef struct acpi_walk_state { UINT8 DataType; /* To differentiate various internal objs MUST BE FIRST!*/\ + UINT8 WalkType; ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 Reserved; /* For alignment */ UINT8 CurrentResult; /* */ UINT8 NextOpInfo; /* Info about NextOp */ UINT8 NumOperands; /* Stack pointer for Operands[] array */ UINT8 ReturnUsed; - UINT8 WalkType; UINT16 Opcode; /* Current AML opcode */ UINT8 ScopeDepth; UINT8 Reserved1; @@ -164,7 +165,8 @@ typedef struct acpi_walk_state struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ union acpi_operand_object **CallerReturnDesc; ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ - struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + struct acpi_gpe_event_info *GpeEventInfo; /* Info for GPE (_Lxx/_Exx methods only */ struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ @@ -279,4 +281,22 @@ typedef union acpi_aml_operands } ACPI_AML_OPERANDS; +/* Internal method parameter list */ + +typedef struct acpi_parameter_info +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT **Parameters; + ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 ParameterType; + UINT8 ReturnObjectType; + +} ACPI_PARAMETER_INFO; + +/* Types for ParameterType above */ + +#define ACPI_PARAM_ARGS 0 +#define ACPI_PARAM_GPE 1 + + #endif diff --git a/sys/contrib/dev/acpica/actbl.h b/sys/contrib/dev/acpica/actbl.h index b16e2f7719ab..2547800dcdc2 100644 --- a/sys/contrib/dev/acpica/actbl.h +++ b/sys/contrib/dev/acpica/actbl.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl.h - Table data structures defined in ACPI specification - * $Revision: 64 $ + * $Revision: 66 $ * *****************************************************************************/ @@ -375,20 +375,6 @@ typedef struct smart_battery_table } SMART_BATTERY_TABLE; -/* - * High performance timer - */ -typedef struct hpet_table -{ - ACPI_TABLE_HEADER_DEF - UINT32 HardwareId; - UINT32 BaseAddress [3]; - UINT8 HpetNumber; - UINT16 ClockTick; - UINT8 Attributes; - -} HPET_TABLE; - #pragma pack() @@ -433,4 +419,21 @@ typedef struct acpi_table_support #include "actbl2.h" /* Acpi 2.0 table definitions */ +#pragma pack(1) +/* + * High performance timer + */ +typedef struct hpet_table +{ + ACPI_TABLE_HEADER_DEF + UINT32 HardwareId; + ACPI_GENERIC_ADDRESS BaseAddress; + UINT8 HpetNumber; + UINT16 ClockTick; + UINT8 Attributes; + +} HPET_TABLE; + +#pragma pack() + #endif /* __ACTBL_H__ */ diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h index 8c3804f7f036..98abcc5955c6 100644 --- a/sys/contrib/dev/acpica/actypes.h +++ b/sys/contrib/dev/acpica/actypes.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 266 $ + * $Revision: 270 $ * *****************************************************************************/ @@ -636,34 +636,56 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_GPE_MAX 0xFF #define ACPI_NUM_GPE 256 +#define ACPI_GPE_ENABLE 0 +#define ACPI_GPE_DISABLE 1 + + /* * GPE info flags - Per GPE - * +---------+-+-+-+ - * |Bits 8:3 |2|1|0| - * +---------+-+-+-+ - * | | | | - * | | | +- Edge or Level Triggered - * | | +--- Type: Wake or Runtime - * | +----- Enabled for wake? - * +-------- + * +-+-+-+---+---+-+ + * |7|6|5|4:3|2:1|0| + * +-+-+-+---+---+-+ + * | | | | | | + * | | | | | +--- Interrupt type: Edge or Level Triggered + * | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime + * | | | +--- Type of dispatch -- to method, handler, or none + * | | +--- Enabled for runtime? + * | +--- Enabled for wake? + * +--- System state when GPE ocurred (running/waking) */ -#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 1 -#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 1 -#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0 +#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x01 +#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x01 +#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 -#define ACPI_GPE_TYPE_MASK (UINT8) 2 -#define ACPI_GPE_TYPE_WAKE (UINT8) 2 -#define ACPI_GPE_TYPE_RUNTIME (UINT8) 0 /* Default */ +#define ACPI_GPE_TYPE_MASK (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE_RUN (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE (UINT8) 0x02 +#define ACPI_GPE_TYPE_RUNTIME (UINT8) 0x04 /* Default */ -#define ACPI_GPE_ENABLE_MASK (UINT8) 4 -#define ACPI_GPE_ENABLED (UINT8) 4 -#define ACPI_GPE_DISABLED (UINT8) 0 /* Default */ +#define ACPI_GPE_DISPATCH_MASK (UINT8) 0x18 +#define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x08 +#define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x10 +#define ACPI_GPE_DISPATCH_NOT_USED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_RUN_ENABLE_MASK (UINT8) 0x20 +#define ACPI_GPE_RUN_ENABLED (UINT8) 0x20 +#define ACPI_GPE_RUN_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_WAKE_ENABLE_MASK (UINT8) 0x40 +#define ACPI_GPE_WAKE_ENABLED (UINT8) 0x40 +#define ACPI_GPE_WAKE_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ + +#define ACPI_GPE_SYSTEM_MASK (UINT8) 0x80 +#define ACPI_GPE_SYSTEM_RUNNING (UINT8) 0x80 +#define ACPI_GPE_SYSTEM_WAKING (UINT8) 0x00 /* * Flags for GPE and Lock interfaces */ -#define ACPI_EVENT_WAKE_ENABLE 0x2 -#define ACPI_EVENT_WAKE_DISABLE 0x2 +#define ACPI_EVENT_WAKE_ENABLE 0x2 /* AcpiGpeEnable */ +#define ACPI_EVENT_WAKE_DISABLE 0x2 /* AcpiGpeDisable */ #define ACPI_NOT_ISR 0x1 #define ACPI_ISR 0x0 @@ -671,9 +693,10 @@ typedef UINT32 ACPI_EVENT_STATUS; /* Notify types */ -#define ACPI_SYSTEM_NOTIFY 0 -#define ACPI_DEVICE_NOTIFY 1 -#define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 +#define ACPI_SYSTEM_NOTIFY 0x1 +#define ACPI_DEVICE_NOTIFY 0x2 +#define ACPI_ALL_NOTIFY 0x3 +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 #define ACPI_MAX_SYS_NOTIFY 0x7f @@ -873,10 +896,6 @@ typedef UINT32 (*ACPI_EVENT_HANDLER) ( void *Context); -typedef -void (*ACPI_GPE_HANDLER) ( - void *Context); - typedef void (*ACPI_NOTIFY_HANDLER) ( ACPI_HANDLE Device, @@ -967,6 +986,7 @@ typedef struct acpi_compatible_id_list #define ACPI_VALID_HID 0x0004 #define ACPI_VALID_UID 0x0008 #define ACPI_VALID_CID 0x0010 +#define ACPI_VALID_SXDS 0x0020 #define ACPI_COMMON_OBJ_INFO \ @@ -987,12 +1007,12 @@ typedef struct acpi_device_info { ACPI_COMMON_OBJ_INFO; - UINT8 HighestDstates[4]; /* _SxD values 0xFF indicates not valid */ UINT32 Valid; /* Indicates which fields below are valid */ UINT32 CurrentStatus; /* _STA value */ ACPI_INTEGER Address; /* _ADR value if any */ ACPI_DEVICE_ID HardwareId; /* _HID value if any */ ACPI_DEVICE_ID UniqueId; /* _UID value if any */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ ACPI_COMPATIBLE_ID_LIST CompatibilityId; /* List of _CIDs if any */ } ACPI_DEVICE_INFO; diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index a46d72ea4b39..f30410dbbf67 100644 --- a/sys/contrib/dev/acpica/common/adisasm.c +++ b/sys/contrib/dev/acpica/common/adisasm.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: adisasm - Application-level disassembler routines - * $Revision: 65 $ + * $Revision: 67 $ * *****************************************************************************/ @@ -548,9 +548,9 @@ AdAmlDisassemble ( } /* - * TBD: We want to cross reference the namespace here, in order to + * TBD: We want to cross reference the namespace here, in order to * generate External() statements. The problem is that the parse - * tree is in run-time (interpreter) format, not compiler format, + * tree is in run-time (interpreter) format, not compiler format, * so we cannot directly use the function below: * * Status = LkCrossReferenceNamespace (); @@ -709,7 +709,7 @@ AdDeferredParse ( } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, Aml, - AmlLength, NULL, NULL, 1); + AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -1026,7 +1026,7 @@ AdParseTable ( } Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParsedNamespaceRoot, - NULL, AmlStart, AmlLength, NULL, NULL, 1); + NULL, AmlStart, AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index cb1838560b64..c1724ae2fc25 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslstubs - Stubs used to link to Aml interpreter - * $Revision: 12 $ + * $Revision: 13 $ * *****************************************************************************/ @@ -211,6 +211,13 @@ AcpiEvInitializeRegion ( return (AE_OK); } +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + return (AE_OK); +} + ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE *WalkState, diff --git a/sys/contrib/dev/acpica/dbcmds.c b/sys/contrib/dev/acpica/dbcmds.c index 75bb091b2686..33c6e6b58947 100644 --- a/sys/contrib/dev/acpica/dbcmds.c +++ b/sys/contrib/dev/acpica/dbcmds.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * $Revision: 110 $ + * $Revision: 112 $ * ******************************************************************************/ @@ -157,6 +157,37 @@ static ARGUMENT_INFO AcpiDbObjectTypes [] = }; +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg) +{ + ACPI_STATUS Status; + UINT8 SleepState; + + + SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); + + AcpiOsPrintf ("**** Prepare to sleep ****\n"); + Status = AcpiEnterSleepStatePrep (SleepState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiOsPrintf ("**** Going to sleep ****\n"); + Status = AcpiEnterSleepState (SleepState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiOsPrintf ("**** returning from sleep ****\n"); + Status = AcpiLeaveSleepState (SleepState); + + return (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiDbWalkForReferences @@ -1298,7 +1329,7 @@ AcpiDbGenerateGpe ( return; } - AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); + (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbdisply.c b/sys/contrib/dev/acpica/dbdisply.c index 363bcfe81fa4..0dd6396d3ca6 100644 --- a/sys/contrib/dev/acpica/dbdisply.c +++ b/sys/contrib/dev/acpica/dbdisply.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbdisply - debug display commands - * $Revision: 101 $ + * $Revision: 105 $ * ******************************************************************************/ @@ -783,26 +783,150 @@ AcpiDbDisplayGpes (void) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; - UINT32 i = 0; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 GpeIndex; + UINT32 Block = 0; + UINT32 i; + UINT32 j; + char Buffer[80]; + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + RetBuf.Length = sizeof (Buffer); + RetBuf.Pointer = Buffer; + + Block = 0; + + /* Walk the GPE lists */ + GpeXruptInfo = AcpiGbl_GpeXruptListHead; while (GpeXruptInfo) { GpeBlock = GpeXruptInfo->GpeBlockListHead; while (GpeBlock) { - AcpiOsPrintf ("Block %d - %p\n", i, GpeBlock); - AcpiOsPrintf (" Registers: %d\n", GpeBlock->RegisterCount); - AcpiOsPrintf (" GPE range: %d to %d\n", GpeBlock->BlockBaseNumber, - GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8) -1); - AcpiOsPrintf (" RegisterInfo: %p\n", GpeBlock->RegisterInfo); - AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); - i++; + Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert name to pathname\n"); + } + AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n", + Block, GpeBlock, GpeBlock->Node, Buffer); + AcpiOsPrintf (" Registers: %u (%u GPEs) \n", + GpeBlock->RegisterCount, + ACPI_MUL_8 (GpeBlock->RegisterCount)); + AcpiOsPrintf (" GPE range: 0x%X to 0x%X\n", + GpeBlock->BlockBaseNumber, + GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8) -1); + AcpiOsPrintf (" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", + GpeBlock->RegisterInfo, + ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); + AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + + AcpiOsPrintf ( + " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", + i, GpeRegisterInfo->EnableForWake, + GpeRegisterInfo->EnableForRun, + ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; + GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; + + if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)) + { + /* This GPE is not used (no method or handler) */ + + continue; + } + + AcpiOsPrintf ( + " GPE %.3X: %p Bit %2.2X Flags %2.2X: ", + GpeBlock->BlockBaseNumber + GpeIndex, + GpeEventInfo, GpeEventInfo->RegisterBit, + GpeEventInfo->Flags); + + if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) + { + AcpiOsPrintf ("Level, "); + } + else + { + AcpiOsPrintf ("Edge, "); + } + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + AcpiOsPrintf ("WakeOnly: "); + break; + case ACPI_GPE_TYPE_RUNTIME: + AcpiOsPrintf (" RunOnly: "); + break; + case ACPI_GPE_TYPE_WAKE_RUN: + AcpiOsPrintf (" WakeRun: "); + break; + default: + AcpiOsPrintf (" NotUsed: "); + break; + } + + if (GpeEventInfo->Flags & ACPI_GPE_WAKE_ENABLED) + { + AcpiOsPrintf ("[Wake 1 "); + } + else + { + AcpiOsPrintf ("[Wake 0 "); + } + + if (GpeEventInfo->Flags & ACPI_GPE_RUN_ENABLED) + { + AcpiOsPrintf ("Run 1], "); + } + else + { + AcpiOsPrintf ("Run 0], "); + } + + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) + { + case ACPI_GPE_DISPATCH_NOT_USED: + AcpiOsPrintf ("NotUsed"); + break; + case ACPI_GPE_DISPATCH_HANDLER: + AcpiOsPrintf ("Handler"); + break; + case ACPI_GPE_DISPATCH_METHOD: + AcpiOsPrintf ("Method"); + break; + default: + AcpiOsPrintf ("UNKNOWN: %X", + GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK); + break; + } + + AcpiOsPrintf ("\n"); + } + } + Block++; GpeBlock = GpeBlock->Next; } - GpeXruptInfo = GpeXruptInfo->Next; } } diff --git a/sys/contrib/dev/acpica/dbinput.c b/sys/contrib/dev/acpica/dbinput.c index 003e18c7df56..33d54a3aedca 100644 --- a/sys/contrib/dev/acpica/dbinput.c +++ b/sys/contrib/dev/acpica/dbinput.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * $Revision: 98 $ + * $Revision: 100 $ * ******************************************************************************/ @@ -175,6 +175,7 @@ enum AcpiExDebuggerCommands CMD_RESOURCES, CMD_RESULTS, CMD_SET, + CMD_SLEEP, CMD_STATS, CMD_STOP, CMD_TABLES, @@ -233,6 +234,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"RESOURCES", 1}, {"RESULTS", 0}, {"SET", 3}, + {"SLEEP", 1}, {"STATS", 0}, {"STOP", 0}, {"TABLES", 0}, @@ -621,7 +623,7 @@ AcpiDbCommandDispatch ( break; case CMD_FIND: - AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); + Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); break; case CMD_GO: @@ -730,7 +732,7 @@ AcpiDbCommandDispatch ( break; case CMD_METHODS: - AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); + Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); break; case CMD_NAMESPACE: @@ -744,7 +746,7 @@ AcpiDbCommandDispatch ( case CMD_OBJECT: ACPI_STRUPR (AcpiGbl_DbArgs[1]); - AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); + Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; case CMD_OPEN: @@ -775,8 +777,12 @@ AcpiDbCommandDispatch ( AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); break; + case CMD_SLEEP: + Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); + break; + case CMD_STATS: - AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); + Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); break; case CMD_STOP: diff --git a/sys/contrib/dev/acpica/dmwalk.c b/sys/contrib/dev/acpica/dmwalk.c index f9de88e3345e..fa0c01caaedd 100644 --- a/sys/contrib/dev/acpica/dmwalk.c +++ b/sys/contrib/dev/acpica/dmwalk.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmwalk - AML disassembly tree walk - * $Revision: 12 $ + * $Revision: 13 $ * ******************************************************************************/ @@ -474,7 +474,7 @@ AcpiDmDescendingOp ( NextExternal = AcpiGbl_ExternalList->Next; ACPI_MEM_FREE (AcpiGbl_ExternalList->Path); ACPI_MEM_FREE (AcpiGbl_ExternalList); - AcpiGbl_ExternalList = NextExternal; + AcpiGbl_ExternalList = NextExternal; } AcpiOsPrintf ("\n"); } diff --git a/sys/contrib/dev/acpica/dsmethod.c b/sys/contrib/dev/acpica/dsmethod.c index f6e69df62e08..46c7e6694ead 100644 --- a/sys/contrib/dev/acpica/dsmethod.c +++ b/sys/contrib/dev/acpica/dsmethod.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * $Revision: 94 $ + * $Revision: 97 $ * *****************************************************************************/ @@ -225,8 +225,9 @@ AcpiDsParseMethod ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, Op, Node, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, NULL, 1); + Status = AcpiDsInitAmlWalk (WalkState, Op, Node, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -353,8 +354,9 @@ AcpiDsCallControlMethod ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *MethodNode; - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_WALK_STATE *NextWalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARAMETER_INFO Info; UINT32 i; @@ -400,7 +402,6 @@ AcpiDsCallControlMethod ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* Create and init a Root Node */ Op = AcpiPsCreateScopeOp (); @@ -412,7 +413,7 @@ AcpiDsCallControlMethod ( Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - NULL, NULL, 1); + NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (NextWalkState); @@ -442,9 +443,12 @@ AcpiDsCallControlMethod ( */ ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; + Info.Parameters = &ThisWalkState->Operands[0]; + Info.ParameterType = ACPI_PARAM_ARGS; + Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - &ThisWalkState->Operands[0], NULL, 3); + &Info, 3); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -479,7 +483,7 @@ AcpiDsCallControlMethod ( /* On error, we must delete the new walk state */ Cleanup: - if (NextWalkState->MethodDesc) + if (NextWalkState && (NextWalkState->MethodDesc)) { /* Decrement the thread count on the method parse tree */ diff --git a/sys/contrib/dev/acpica/dsopcode.c b/sys/contrib/dev/acpica/dsopcode.c index dd0f064bc92a..5ccabb64f2c9 100644 --- a/sys/contrib/dev/acpica/dsopcode.c +++ b/sys/contrib/dev/acpica/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 93 $ + * $Revision: 94 $ * *****************************************************************************/ @@ -181,7 +181,7 @@ AcpiDsExecuteArguments ( } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, NULL, 1); + AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -230,7 +230,7 @@ AcpiDsExecuteArguments ( /* Execute the opcode and arguments */ Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, NULL, 3); + AmlLength, NULL, 3); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); diff --git a/sys/contrib/dev/acpica/dswstate.c b/sys/contrib/dev/acpica/dswstate.c index ae4fea6d8c2c..ac60760d68ed 100644 --- a/sys/contrib/dev/acpica/dswstate.c +++ b/sys/contrib/dev/acpica/dswstate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 78 $ + * $Revision: 80 $ * *****************************************************************************/ @@ -1017,8 +1017,7 @@ AcpiDsInitAmlWalk ( ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc, + ACPI_PARAMETER_INFO *Info, UINT32 PassNumber) { ACPI_STATUS Status; @@ -1037,8 +1036,20 @@ AcpiDsInitAmlWalk ( /* The NextOp of the NextWalk will be the beginning of the method */ WalkState->NextOp = NULL; - WalkState->Params = Params; - WalkState->CallerReturnDesc = ReturnObjDesc; + + if (Info) + { + if (Info->ParameterType == ACPI_PARAM_GPE) + { + WalkState->GpeEventInfo = ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO, + Info->Parameters); + } + else + { + WalkState->Params = Info->Parameters; + WalkState->CallerReturnDesc = &Info->ReturnObject; + } + } Status = AcpiPsInitScope (&WalkState->ParserState, Op); if (ACPI_FAILURE (Status)) @@ -1063,7 +1074,7 @@ AcpiDsInitAmlWalk ( /* Init the method arguments */ - Status = AcpiDsMethodDataInitArgs (Params, ACPI_METHOD_NUM_ARGS, WalkState); + Status = AcpiDsMethodDataInitArgs (WalkState->Params, ACPI_METHOD_NUM_ARGS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/evevent.c b/sys/contrib/dev/acpica/evevent.c index ff7c98758577..48a148405b6a 100644 --- a/sys/contrib/dev/acpica/evevent.c +++ b/sys/contrib/dev/acpica/evevent.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evevent - Fixed Event handling and dispatch - * $Revision: 112 $ + * $Revision: 113 $ * *****************************************************************************/ @@ -123,7 +123,7 @@ /******************************************************************************* * - * FUNCTION: AcpiEvInitialize + * FUNCTION: AcpiEvInitializeEvents * * PARAMETERS: None * @@ -134,13 +134,13 @@ ******************************************************************************/ ACPI_STATUS -AcpiEvInitialize ( +AcpiEvInitializeEvents ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvInitialize"); + ACPI_FUNCTION_TRACE ("EvInitializeEvents"); /* Make sure we have ACPI tables */ @@ -180,7 +180,7 @@ AcpiEvInitialize ( /******************************************************************************* * - * FUNCTION: AcpiEvHandlerInitialize + * FUNCTION: AcpiEvInstallXruptHandlers * * PARAMETERS: None * @@ -191,13 +191,13 @@ AcpiEvInitialize ( ******************************************************************************/ ACPI_STATUS -AcpiEvHandlerInitialize ( +AcpiEvInstallXruptHandlers ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvHandlerInitialize"); + ACPI_FUNCTION_TRACE ("EvInstallXruptHandlers"); /* Install the SCI handler */ diff --git a/sys/contrib/dev/acpica/evgpe.c b/sys/contrib/dev/acpica/evgpe.c index 44d2665048d7..77ac5cda15d5 100644 --- a/sys/contrib/dev/acpica/evgpe.c +++ b/sys/contrib/dev/acpica/evgpe.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpe - General Purpose Event handling and dispatch - * $Revision: 35 $ + * $Revision: 40 $ * *****************************************************************************/ @@ -122,6 +122,258 @@ ACPI_MODULE_NAME ("evgpe") +/******************************************************************************* + * + * FUNCTION: AcpiEvSetGpeType + * + * PARAMETERS: GpeEventInfo - GPE to set + * Type - New type + * + * RETURN: Status + * + * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvSetGpeType"); + + + /* Validate type and update register enable masks */ + + switch (Type) + { + case ACPI_GPE_TYPE_WAKE: + case ACPI_GPE_TYPE_RUNTIME: + case ACPI_GPE_TYPE_WAKE_RUN: + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE if currently enabled */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Type was validated above */ + + GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ + GpeEventInfo->Flags |= Type; /* Insert type */ + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpeEnableMasks + * + * PARAMETERS: GpeEventInfo - GPE to update + * + * RETURN: Status + * + * DESCRIPTION: Updates GPE register enable masks based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT8 RegisterBit; + + + ACPI_FUNCTION_TRACE ("EvUpdateGpeEnableMasks"); + + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + RegisterBit = GpeEventInfo->RegisterBit; + + /* 1) Disable case. Simply clear all enable bits */ + + if (Type == ACPI_GPE_DISABLE) + { + GpeRegisterInfo->EnableForWake &= ~RegisterBit; + GpeRegisterInfo->EnableForRun &= ~RegisterBit; + return_ACPI_STATUS (AE_OK); + } + + /* 2) Enable case. Set the appropriate enable bits */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + GpeRegisterInfo->EnableForWake |= RegisterBit; + GpeRegisterInfo->EnableForRun &= ~RegisterBit; + break; + + case ACPI_GPE_TYPE_RUNTIME: + GpeRegisterInfo->EnableForWake &= ~RegisterBit; + GpeRegisterInfo->EnableForRun |= RegisterBit; + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + GpeRegisterInfo->EnableForWake |= RegisterBit; + GpeRegisterInfo->EnableForRun |= RegisterBit; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvEnableGpe + * + * PARAMETERS: GpeEventInfo - GPE to enable + * + * RETURN: Status + * + * DESCRIPTION: Enable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvEnableGpe"); + + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-enabled or HW enable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + GpeEventInfo->Flags |= ACPI_GPE_WAKE_ENABLED; + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + GpeEventInfo->Flags |= ACPI_GPE_WAKE_ENABLED; + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + GpeEventInfo->Flags |= ACPI_GPE_RUN_ENABLED; + + if (WriteToHardware) + { + /* Clear the GPE (of stale events), then enable it */ + + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable the requested runtime GPE */ + + Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + } + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDisableGpe + * + * PARAMETERS: GpeEventInfo - GPE to disable + * + * RETURN: Status + * + * DESCRIPTION: Disable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvDisableGpe"); + + + if (!(GpeEventInfo->Flags & ACPI_GPE_ENABLE_MASK)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-disabled or HW disable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + GpeEventInfo->Flags &= ~ACPI_GPE_WAKE_ENABLED; + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + GpeEventInfo->Flags &= ~ACPI_GPE_WAKE_ENABLED; + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + /* Disable the requested runtime GPE */ + + GpeEventInfo->Flags &= ~ACPI_GPE_RUN_ENABLED; + Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiEvGetGpeEventInfo @@ -218,11 +470,12 @@ AcpiEvGpeDetect ( UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; UINT8 EnabledStatusByte; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - UINT32 InValue; + UINT32 StatusReg; + UINT32 EnableReg; ACPI_STATUS Status; ACPI_GPE_BLOCK_INFO *GpeBlock; - UINT32 i; - UINT32 j; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; ACPI_FUNCTION_NAME ("EvGpeDetect"); @@ -253,9 +506,8 @@ AcpiEvGpeDetect ( /* Read the Status Register */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue, + Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &StatusReg, &GpeRegisterInfo->StatusAddress); - GpeRegisterInfo->Status = (UINT8) InValue; if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -263,9 +515,8 @@ AcpiEvGpeDetect ( /* Read the Enable Register */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue, + Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &EnableReg, &GpeRegisterInfo->EnableAddress); - GpeRegisterInfo->Enable = (UINT8) InValue; if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -273,15 +524,16 @@ AcpiEvGpeDetect ( ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, "GPE pair: Status %8.8X%8.8X = %02X, Enable %8.8X%8.8X = %02X\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)), - GpeRegisterInfo->Status, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address)), - GpeRegisterInfo->Enable)); + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( + GpeRegisterInfo->StatusAddress.Address)), + StatusReg, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( + GpeRegisterInfo->EnableAddress.Address)), + EnableReg)); /* First check if there is anything active at all in this register */ - EnabledStatusByte = (UINT8) (GpeRegisterInfo->Status & - GpeRegisterInfo->Enable); + EnabledStatusByte = (UINT8) (StatusReg & EnableReg); if (!EnabledStatusByte) { /* No active GPEs in this register, move on */ @@ -303,7 +555,7 @@ AcpiEvGpeDetect ( */ IntStatus |= AcpiEvGpeDispatch ( &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j], - j + GpeRegisterInfo->BaseGpeNumber); + (UINT32) j + GpeRegisterInfo->BaseGpeNumber); } } } @@ -342,6 +594,7 @@ AcpiEvAsynchExecuteGpeMethod ( UINT32 GpeNumber = 0; ACPI_STATUS Status; ACPI_GPE_EVENT_INFO LocalGpeEventInfo; + ACPI_PARAMETER_INFO Info; ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); @@ -361,6 +614,10 @@ AcpiEvAsynchExecuteGpeMethod ( return_VOID; } + /* Set the GPE flags for return to enabled state */ + + (void) AcpiEvEnableGpe (GpeEventInfo, FALSE); + /* * Take a snapshot of the GPE info for this level - we copy the * info to prevent a race condition with RemoveHandler/RemoveBlock. @@ -373,26 +630,36 @@ AcpiEvAsynchExecuteGpeMethod ( return_VOID; } - if (LocalGpeEventInfo.MethodNode) + /* + * Must check for control method type dispatch one more + * time to avoid race with EvGpeInstallHandler + */ + if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) { /* - * Invoke the GPE Method (_Lxx, _Exx): - * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.) + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx + * control method that corresponds to this GPE */ - Status = AcpiNsEvaluateByHandle (LocalGpeEventInfo.MethodNode, NULL, NULL); + Info.Node = LocalGpeEventInfo.Dispatch.MethodNode; + Info.Parameters = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT *, GpeEventInfo); + Info.ParameterType = ACPI_PARAM_GPE; + + Status = AcpiNsEvaluateByHandle (&Info); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("%s while evaluating method [%4.4s] for GPE[%2X]\n", + ACPI_REPORT_ERROR (( + "%s while evaluating method [%4.4s] for GPE[%2X]\n", AcpiFormatException (Status), - AcpiUtGetNodeName (LocalGpeEventInfo.MethodNode), GpeNumber)); + AcpiUtGetNodeName (LocalGpeEventInfo.Dispatch.MethodNode), + GpeNumber)); } } if ((LocalGpeEventInfo.Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) { /* - * GPE is level-triggered, we clear the GPE status bit after handling - * the event. + * GPE is level-triggered, we clear the GPE status bit after + * handling the event. */ Status = AcpiHwClearGpe (&LocalGpeEventInfo); if (ACPI_FAILURE (Status)) @@ -403,7 +670,7 @@ AcpiEvAsynchExecuteGpeMethod ( /* Enable this GPE */ - (void) AcpiHwEnableGpe (&LocalGpeEventInfo); + (void) AcpiHwWriteGpeEnableReg (&LocalGpeEventInfo); return_VOID; } @@ -450,6 +717,17 @@ AcpiEvGpeDispatch ( } } + /* Save current system state */ + + if (AcpiGbl_SystemAwakeAndRunning) + { + GpeEventInfo->Flags |= ACPI_GPE_SYSTEM_RUNNING; + } + else + { + GpeEventInfo->Flags &= ~ACPI_GPE_SYSTEM_RUNNING; + } + /* * Dispatch the GPE to either an installed handler, or the control * method associated with this GPE (_Lxx or _Exx). @@ -457,11 +735,14 @@ AcpiEvGpeDispatch ( * If there is neither a handler nor a method, we disable the level to * prevent further events from coming in here. */ - if (GpeEventInfo->Handler) + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) { + case ACPI_GPE_DISPATCH_HANDLER: + /* Invoke the installed handler (at interrupt level) */ - GpeEventInfo->Handler (GpeEventInfo->Context); + GpeEventInfo->Dispatch.Handler->Address ((void *) + GpeEventInfo->Dispatch.Handler->Context); /* It is now safe to clear level-triggered events. */ @@ -476,14 +757,15 @@ AcpiEvGpeDispatch ( return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } } - } - else if (GpeEventInfo->MethodNode) - { + break; + + case ACPI_GPE_DISPATCH_METHOD: + /* * Disable GPE, so it doesn't keep firing before the method has a * chance to run. */ - Status = AcpiHwDisableGpe (GpeEventInfo); + Status = AcpiEvDisableGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( @@ -504,9 +786,10 @@ AcpiEvGpeDispatch ( "AcpiEvGpeDispatch: Unable to queue handler for GPE[%2X], event is disabled\n", GpeNumber)); } - } - else - { + break; + + default: + /* No handler or method to run! */ ACPI_REPORT_ERROR (( @@ -517,7 +800,7 @@ AcpiEvGpeDispatch ( * Disable the GPE. The GPE will remain disabled until the ACPI * Core Subsystem is restarted, or a handler is installed. */ - Status = AcpiHwDisableGpe (GpeEventInfo); + Status = AcpiEvDisableGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( @@ -525,8 +808,62 @@ AcpiEvGpeDispatch ( GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } + break; } return_VALUE (ACPI_INTERRUPT_HANDLED); } + +#ifdef ACPI_GPE_NOTIFY_CHECK + +/******************************************************************************* + * NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED + * + * FUNCTION: AcpiEvCheckForWakeOnlyGpe + * + * PARAMETERS: GpeEventInfo - info for this GPE + * + * RETURN: Status + * + * DESCRIPTION: Determine if a a GPE is "wake-only". + * + * Called from Notify() code in interpreter when a "DeviceWake" + * Notify comes in. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvCheckForWakeOnlyGpe"); + + + if ((GpeEventInfo) && /* Only >0 for _Lxx/_Exx */ + ((GpeEventInfo->Flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ + { + /* This must be a wake-only GPE, disable it */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Set GPE to wake-only. Do not change wake disabled/enabled status */ + + AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); + + ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n", + GpeEventInfo)); + + /* This was a wake-only GPE */ + + return_ACPI_STATUS (AE_WAKE_ONLY_GPE); + } + + return_ACPI_STATUS (AE_OK); +} +#endif + + diff --git a/sys/contrib/dev/acpica/evgpeblk.c b/sys/contrib/dev/acpica/evgpeblk.c index c28f621b1055..b34cbe9cfb0a 100644 --- a/sys/contrib/dev/acpica/evgpeblk.c +++ b/sys/contrib/dev/acpica/evgpeblk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpeblk - GPE block creation and initialization. - * $Revision: 29 $ + * $Revision: 34 $ * *****************************************************************************/ @@ -126,7 +126,7 @@ * * FUNCTION: AcpiEvValidGpeEvent * - * PARAMETERS: GpeEventInfo - Info for this GPE + * PARAMETERS: GpeEventInfo - Info for this GPE * * RETURN: TRUE if the GpeEvent is valid * @@ -233,6 +233,56 @@ AcpiEvWalkGpeList ( } +/****************************************************************************** + * + * FUNCTION: AcpiEvDeleteGpeHandlers + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Delete all Handler objects found in the GPE data structs. + * Used only prior to termination. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + + + ACPI_FUNCTION_TRACE ("EvDeleteGpeHandlers"); + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j]; + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) + { + ACPI_MEM_FREE (GpeEventInfo->Dispatch.Handler); + GpeEventInfo->Dispatch.Handler = NULL; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; + } + } + } + + return_ACPI_STATUS (AE_OK); +} + + /******************************************************************************* * * FUNCTION: AcpiEvSaveMethodInfo @@ -267,12 +317,13 @@ AcpiEvSaveMethodInfo ( UINT32 GpeNumber; char Name[ACPI_NAME_SIZE + 1]; UINT8 Type; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvSaveMethodInfo"); - /* + /* * _Lxx and _Exx GPE method support * * 1) Extract the name from the object and convert to a string @@ -285,17 +336,17 @@ AcpiEvSaveMethodInfo ( * 2) Edge/Level determination is based on the 2nd character * of the method name * - * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE if a - * _PRW object is found that points to this GPE. + * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE + * if a _PRW object is found that points to this GPE. */ switch (Name[1]) { case 'L': - Type = ACPI_GPE_LEVEL_TRIGGERED | ACPI_GPE_TYPE_RUNTIME; + Type = ACPI_GPE_LEVEL_TRIGGERED; break; case 'E': - Type = ACPI_GPE_EDGE_TRIGGERED | ACPI_GPE_TYPE_RUNTIME; + Type = ACPI_GPE_EDGE_TRIGGERED; break; default: @@ -335,23 +386,30 @@ AcpiEvSaveMethodInfo ( /* * Now we can add this information to the GpeEventInfo block - * for use during dispatch of this GPE. + * for use during dispatch of this GPE. Default type is RUNTIME, although + * this may change when the _PRW methods are executed later. */ GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; - GpeEventInfo->Flags = Type; - GpeEventInfo->MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; + GpeEventInfo->Flags = (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD | + ACPI_GPE_TYPE_RUNTIME); + + GpeEventInfo->Dispatch.MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; + + /* Update enable mask, but don't enable the HW GPE as of yet */ + + Status = AcpiEvEnableGpe (GpeEventInfo, FALSE); ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Registered GPE method %s as GPE number 0x%.2X\n", Name, GpeNumber)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiEvGetGpeType + * FUNCTION: AcpiEvMatchPrwAndGpe * * PARAMETERS: Callback from WalkNamespace * @@ -364,7 +422,7 @@ AcpiEvSaveMethodInfo ( ******************************************************************************/ static ACPI_STATUS -AcpiEvGetGpeType ( +AcpiEvMatchPrwAndGpe ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Info, @@ -381,7 +439,7 @@ AcpiEvGetGpeType ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvGetGpeType"); + ACPI_FUNCTION_TRACE ("EvMatchPrwAndGpe"); /* Check for a _PRW method under this device */ @@ -458,10 +516,17 @@ AcpiEvGetGpeType ( (GpeNumber >= GpeBlock->BlockBaseNumber) && (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) { - /* Mark GPE for WAKE but DISABLED (even for wake) */ - GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; - GpeEventInfo->Flags |= ACPI_GPE_TYPE_WAKE; + + /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); + Status = AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); } Cleanup: @@ -857,7 +922,7 @@ AcpiEvCreateGpeInfoBlocks ( for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - ThisEvent->BitMask = AcpiGbl_DecodeTo8bit[j]; + ThisEvent->RegisterBit = AcpiGbl_DecodeTo8bit[j]; ThisEvent->RegisterInfo = ThisRegister; ThisEvent++; } @@ -936,6 +1001,7 @@ AcpiEvCreateGpeBlock ( ACPI_STATUS Status; ACPI_GPE_WALK_INFO GpeInfo; + ACPI_FUNCTION_TRACE ("EvCreateGpeBlock"); @@ -956,6 +1022,7 @@ AcpiEvCreateGpeBlock ( GpeBlock->RegisterCount = RegisterCount; GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; + GpeBlock->Node = GpeDevice; ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, sizeof (ACPI_GENERIC_ADDRESS)); @@ -977,6 +1044,61 @@ AcpiEvCreateGpeBlock ( return_ACPI_STATUS (Status); } + /* Find all GPE methods (_Lxx, _Exx) for this block */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, AcpiEvSaveMethodInfo, + GpeBlock, NULL); + + /* + * Runtime option: Should Wake GPEs be enabled at runtime? The default + * is No,they should only be enabled just as the machine goes to sleep. + */ + if (AcpiGbl_LeaveWakeGpesDisabled) + { + /* + * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. + * (Each GPE that has one or more _PRWs that reference it is by + * definition a WAKE GPE and will not be enabled while the machine + * is running.) + */ + GpeInfo.GpeBlock = GpeBlock; + GpeInfo.GpeDevice = GpeDevice; + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiEvMatchPrwAndGpe, + &GpeInfo, NULL); + } + + /* + * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, + * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must + * be enabled via the AcpiEnableGpe() external interface. + */ + WakeGpeCount = 0; + GpeEnabledCount = 0; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + for (j = 0; j < 8; j++) + { + /* Get the info block for this particular GPE */ + + GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j]; + + if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && + (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME)) + { + GpeEnabledCount++; + } + + if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE) + { + WakeGpeCount++; + } + } + } + /* Dump info about this GPE block */ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, @@ -989,68 +1111,13 @@ AcpiEvCreateGpeBlock ( ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)), InterruptLevel)); - /* Find all GPE methods (_Lxx, _Exx) for this block */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, AcpiEvSaveMethodInfo, - GpeBlock, NULL); + /* Enable all valid GPEs found above */ - /* - * Runtime option: Should Wake GPEs be enabled at runtime? The default is - * No,they should only be enabled just as the machine goes to sleep. - */ - if (AcpiGbl_LeaveWakeGpesDisabled) - { - /* - * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. (Each - * GPE that has one or more _PRWs that reference it is by definition a - * WAKE GPE and will not be enabled while the machine is running.) - */ - GpeInfo.GpeBlock = GpeBlock; - GpeInfo.GpeDevice = GpeDevice; + Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock); - Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiEvGetGpeType, - &GpeInfo, NULL); - } - - /* - * Enable all GPEs in this block that are 1) "runtime" GPEs, and 2) have - * a corresponding _Lxx or _Exx method. All other GPEs must be enabled via - * the AcpiEnableGpe() external interface. - */ - WakeGpeCount = 0; - GpeEnabledCount = 0; - - for (i = 0; i < GpeBlock->RegisterCount; i++) - { - for (j = 0; j < 8; j++) - { - /* Get the info block for this particular GPE */ - - GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j]; - if ((GpeEventInfo->MethodNode) && - ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == ACPI_GPE_TYPE_RUNTIME)) - { - /* Enable this GPE, it is 1) RUNTIME and 2) has an _Lxx or _Exx method */ - - Status = AcpiHwEnableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - GpeEnabledCount++; - } - - if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == ACPI_GPE_TYPE_WAKE) - { - WakeGpeCount++; - } - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Found %u Wake, Enabled %u Runtime GPEs in this block\n", + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Found %u Wake, Enabled %u Runtime GPEs in this block\n", WakeGpeCount, GpeEnabledCount)); /* Return the new block */ @@ -1194,7 +1261,8 @@ AcpiEvGpeInitialize ( { /* GPEs are not required by ACPI, this is OK */ - ACPI_REPORT_INFO (("There are no GPE blocks defined in the FADT\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "There are no GPE blocks defined in the FADT\n")); Status = AE_OK; goto Cleanup; } diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c index 932a6ad08343..8a39fbe4f1e8 100644 --- a/sys/contrib/dev/acpica/evmisc.c +++ b/sys/contrib/dev/acpica/evmisc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evmisc - Miscellaneous event manager support functions - * $Revision: 72 $ + * $Revision: 75 $ * *****************************************************************************/ @@ -210,7 +210,7 @@ AcpiEvQueueNotifyRequest ( if (NotifyValue <= 7) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", AcpiNotifyValueNames[NotifyValue])); } else @@ -280,8 +280,8 @@ AcpiEvQueueNotifyRequest ( /* There is no per-device notify handler for this device */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "No notify handler for [%4.4s] node %p\n", - AcpiUtGetNodeName (Node), Node)); + "No notify handler for Notify(%4.4s, %X) node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); } return (Status); @@ -662,6 +662,10 @@ AcpiEvTerminate (void) } } + /* Deallocate all handler objects installed within GPE info structs */ + + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers); + /* Return to original mode if necessary */ if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) diff --git a/sys/contrib/dev/acpica/evregion.c b/sys/contrib/dev/acpica/evregion.c index aefd35358526..55f57aa7aba2 100644 --- a/sys/contrib/dev/acpica/evregion.c +++ b/sys/contrib/dev/acpica/evregion.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * $Revision: 149 $ + * $Revision: 151 $ * *****************************************************************************/ @@ -136,7 +136,7 @@ static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = { /******************************************************************************* * - * FUNCTION: AcpiEvInitAddressSpaces + * FUNCTION: AcpiEvInstallRegionHandlers * * PARAMETERS: None * @@ -147,16 +147,22 @@ static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = { ******************************************************************************/ ACPI_STATUS -AcpiEvInitAddressSpaces ( +AcpiEvInstallRegionHandlers ( void) { ACPI_STATUS Status; ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("EvInitAddressSpaces"); + ACPI_FUNCTION_TRACE ("EvInstallRegionHandlers"); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* * All address spaces (PCI Config, EC, SMBus) are scope dependent * and registration must occur for a specific device. @@ -175,10 +181,9 @@ AcpiEvInitAddressSpaces ( * has already been installed (via AcpiInstallAddressSpaceHandler). * Similar for AE_SAME_HANDLER. */ - for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { - Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode, + Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, AcpiGbl_DefaultAddressSpaces[i], ACPI_DEFAULT_HANDLER, NULL, NULL); switch (Status) @@ -189,15 +194,65 @@ AcpiEvInitAddressSpaces ( /* These exceptions are all OK */ + Status = AE_OK; break; default: - return_ACPI_STATUS (Status); + goto UnlockAndExit; } } - return_ACPI_STATUS (AE_OK); +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeOpRegions + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG methods for all Operation Regions that have + * an installed default region handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void) +{ + ACPI_STATUS Status; + ACPI_NATIVE_UINT i; + + + ACPI_FUNCTION_TRACE ("EvInitializeOpRegions"); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Run the _REG methods for OpRegions in each default address space + */ + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + /* TBD: Make sure handler is the DEFAULT handler, otherwise + * _REG will have already been run. + */ + Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i]); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); } @@ -216,11 +271,12 @@ AcpiEvInitAddressSpaces ( ACPI_STATUS AcpiEvExecuteRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj, + ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function) { - ACPI_OPERAND_OBJECT *Params[3]; - ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_PARAMETER_INFO Info; + ACPI_OPERAND_OBJECT *Params[3]; + ACPI_OPERAND_OBJECT *RegionObj2; ACPI_STATUS Status; @@ -239,10 +295,11 @@ AcpiEvExecuteRegMethod ( } /* - * _REG method has two arguments - * Arg0: Integer: Operation region space ID + * The _REG method has two arguments: + * + * Arg0, Integer: Operation region space ID * Same value as RegionObj->Region.SpaceId - * Arg1: Integer: connection status + * Arg1, Integer: connection status * 1 for connecting the handler, * 0 for disconnecting the handler * Passed as a parameter @@ -266,10 +323,15 @@ AcpiEvExecuteRegMethod ( Params[1]->Integer.Value = Function; Params[2] = NULL; + Info.Node = RegionObj2->Extra.Method_REG; + Info.Parameters = Params; + Info.ParameterType = ACPI_PARAM_ARGS; + /* Execute the method, no return value */ - ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, RegionObj2->Extra.Method_REG, NULL)); - Status = AcpiNsEvaluateByHandle (RegionObj2->Extra.Method_REG, Params, NULL); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, Info.Node, NULL)); + Status = AcpiNsEvaluateByHandle (&Info); AcpiUtRemoveReference (Params[1]); @@ -417,7 +479,7 @@ AcpiEvAddressSpaceDispatch ( ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (RegionObj->Region.SpaceId))); - if (!(HandlerDesc->AddressSpace.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * For handlers other than the default (supplied) handlers, we must @@ -440,7 +502,7 @@ AcpiEvAddressSpaceDispatch ( AcpiFormatException (Status))); } - if (!(HandlerDesc->AddressSpace.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * We just returned from a non-default handler, we must re-enter the @@ -790,6 +852,288 @@ AcpiEvInstallHandler ( return (Status); } + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallSpaceHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE Type; + UINT16 Flags = 0; + + + ACPI_FUNCTION_TRACE ("EvInstallSpaceHandler"); + + + /* + * This registration is valid for only the types below + * and the root. This is where the default handlers + * get placed. + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + Handler = AcpiExSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ACPI_ADR_SPACE_SYSTEM_IO: + Handler = AcpiExSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_CONFIG: + Handler = AcpiExPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + case ACPI_ADR_SPACE_CMOS: + Handler = AcpiExCmosSpaceHandler; + Setup = AcpiEvCmosRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_BAR_TARGET: + Handler = AcpiExPciBarSpaceHandler; + Setup = AcpiEvPciBarRegionSetup; + break; + + case ACPI_ADR_SPACE_DATA_TABLE: + Handler = AcpiExDataTableSpaceHandler; + Setup = NULL; + break; + + default: + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* If the caller hasn't specified a setup routine, use the default */ + + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* + * The attached device object already exists. + * Make sure the handler is not already installed. + */ + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the handler list for this device */ + + while (HandlerObj) + { + /* Same SpaceId indicates a handler already installed */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.Handler == Handler) + { + /* + * It is (relatively) OK to attempt to install the SAME + * handler twice. This can easily happen with PCI_Config space. + */ + Status = AE_SAME_HANDLER; + goto UnlockAndExit; + } + else + { + /* A handler is already installed */ + + Status = AE_ALREADY_EXISTS; + } + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Creating object on Device %p while installing handler\n", Node)); + + /* ObjDesc does not exist, create one */ + + if (Node->Type == ACPI_TYPE_ANY) + { + Type = ACPI_TYPE_DEVICE; + } + else + { + Type = Node->Type; + } + + ObjDesc = AcpiUtCreateInternalObject (Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init new descriptor */ + + ObjDesc->Common.Type = (UINT8) Type; + + /* Attach the new object to the Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, + AcpiUtGetNodeName (Node), Node, ObjDesc)); + + /* + * Install the handler + * + * At this point there is no existing handler. + * Just allocate the object for the handler and link it + * into the list. + */ + HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init handler obj */ + + HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; + HandlerObj->AddressSpace.Hflags = Flags; + HandlerObj->AddressSpace.RegionList = NULL; + HandlerObj->AddressSpace.Node = Node; + HandlerObj->AddressSpace.Handler = Handler; + HandlerObj->AddressSpace.Context = Context; + HandlerObj->AddressSpace.Setup = Setup; + + /* Install at head of Device.AddressSpace list */ + + HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + + /* + * The Device object is the first reference on the HandlerObj. + * Each region that uses the handler adds a reference. + */ + ObjDesc->Device.Handler = HandlerObj; + + /* + * Walk the namespace finding all of the regions this + * handler will manage. + * + * Start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case, back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, + HandlerObj, NULL); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethods + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: Status + * + * DESCRIPTION: Run _REG methods for the Space ID; + * Note: assumes namespace is locked, or system init time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvExecuteRegMethods"); + + + /* + * Run all _REG methods for all Operation Regions for this + * space ID. This is a separate walk in order to handle any + * interdependencies between regions and _REG methods. (i.e. handlers + * must be installed for all regions of this Space ID before we + * can run any _REG methods) + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, + &SpaceId, NULL); + + return_ACPI_STATUS (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiEvRegRun @@ -807,20 +1151,13 @@ AcpiEvRegRun ( void *Context, void **ReturnValue) { - ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; + ACPI_ADR_SPACE_TYPE SpaceId; ACPI_STATUS Status; - HandlerObj = (ACPI_OPERAND_OBJECT *) Context; - - /* Parameter validation */ - - if (!HandlerObj) - { - return (AE_OK); - } + SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context); /* Convert and validate the device handle */ @@ -850,10 +1187,9 @@ AcpiEvRegRun ( return (AE_OK); } - /* Object is a Region */ - if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId) + if (ObjDesc->Region.SpaceId != SpaceId) { /* * This region is for a different address space diff --git a/sys/contrib/dev/acpica/evxface.c b/sys/contrib/dev/acpica/evxface.c index 9d5534f6b6cc..8dba99b45f36 100644 --- a/sys/contrib/dev/acpica/evxface.c +++ b/sys/contrib/dev/acpica/evxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * $Revision: 142 $ + * $Revision: 145 $ * *****************************************************************************/ @@ -272,6 +272,7 @@ AcpiRemoveFixedEventHandler ( * HandlerType - The type of handler: * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device * Handler - Address of the handler * Context - Value passed to the handler on each GPE * @@ -331,22 +332,23 @@ AcpiInstallNotifyHandler ( { /* Make sure the handler is not already installed */ - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - AcpiGbl_SystemNotify.Handler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && AcpiGbl_DeviceNotify.Handler)) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { AcpiGbl_SystemNotify.Node = Node; AcpiGbl_SystemNotify.Handler = Handler; AcpiGbl_SystemNotify.Context = Context; } - else /* ACPI_DEVICE_NOTIFY */ + + if (HandlerType & ACPI_DEVICE_NOTIFY) { AcpiGbl_DeviceNotify.Node = Node; AcpiGbl_DeviceNotify.Handler = Handler; @@ -378,9 +380,9 @@ AcpiInstallNotifyHandler ( { /* Object exists - make sure there's no handler */ - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && ObjDesc->CommonNotify.SystemNotify) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && + ((HandlerType & ACPI_DEVICE_NOTIFY) && ObjDesc->CommonNotify.DeviceNotify)) { Status = AE_ALREADY_EXISTS; @@ -405,7 +407,6 @@ AcpiInstallNotifyHandler ( /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); - if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -425,14 +426,22 @@ AcpiInstallNotifyHandler ( NotifyObj->Notify.Handler = Handler; NotifyObj->Notify.Context = Context; - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { ObjDesc->CommonNotify.SystemNotify = NotifyObj; } - else /* ACPI_DEVICE_NOTIFY */ + + if (HandlerType & ACPI_DEVICE_NOTIFY) { ObjDesc->CommonNotify.DeviceNotify = NotifyObj; } + + if (HandlerType == ACPI_ALL_NOTIFY) + { + /* Extra ref if installed in both */ + + AcpiUtAddReference (NotifyObj); + } } @@ -450,6 +459,7 @@ AcpiInstallNotifyHandler ( * HandlerType - The type of handler: * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device * Handler - Address of the handler * RETURN: Status * @@ -503,22 +513,23 @@ AcpiRemoveNotifyHandler ( { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - !AcpiGbl_SystemNotify.Handler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + !AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && !AcpiGbl_DeviceNotify.Handler)) { Status = AE_NOT_EXIST; goto UnlockAndExit; } - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { AcpiGbl_SystemNotify.Node = NULL; AcpiGbl_SystemNotify.Handler = NULL; AcpiGbl_SystemNotify.Context = NULL; } - else + + if (HandlerType & ACPI_DEVICE_NOTIFY) { AcpiGbl_DeviceNotify.Node = NULL; AcpiGbl_DeviceNotify.Handler = NULL; @@ -550,34 +561,37 @@ AcpiRemoveNotifyHandler ( /* Object exists - make sure there's an existing handler */ - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { NotifyObj = ObjDesc->CommonNotify.SystemNotify; + if ((!NotifyObj) || + (NotifyObj->Notify.Handler != Handler)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.SystemNotify = NULL; + AcpiUtRemoveReference (NotifyObj); } - else + + if (HandlerType & ACPI_DEVICE_NOTIFY) { NotifyObj = ObjDesc->CommonNotify.DeviceNotify; - } + if ((!NotifyObj) || + (NotifyObj->Notify.Handler != Handler)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } - if ((!NotifyObj) || - (NotifyObj->Notify.Handler != Handler)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } + /* Remove the handler */ - /* Remove the handler */ - - if (HandlerType == ACPI_SYSTEM_NOTIFY) - { - ObjDesc->CommonNotify.SystemNotify = NULL; - } - else - { ObjDesc->CommonNotify.DeviceNotify = NULL; + AcpiUtRemoveReference (NotifyObj); } - - AcpiUtRemoveReference (NotifyObj); } @@ -595,7 +609,7 @@ AcpiRemoveNotifyHandler ( * GpeBlock - GPE block (NULL == FADT GPEs) * Type - Whether this GPE should be treated as an * edge- or level-triggered interrupt. - * Handler - Address of the handler + * Address - Address of the handler * Context - Value passed to the handler on each GPE * * RETURN: Status @@ -609,11 +623,12 @@ AcpiInstallGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, - ACPI_GPE_HANDLER Handler, + ACPI_EVENT_HANDLER Address, void *Context) { - ACPI_STATUS Status; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler"); @@ -621,7 +636,7 @@ AcpiInstallGpeHandler ( /* Parameter validation */ - if (!Handler) + if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -643,30 +658,45 @@ AcpiInstallGpeHandler ( /* Make sure that there isn't a handler there already */ - if (GpeEventInfo->Handler) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } + /* Allocate and init handler object */ + + Handler = ACPI_MEM_CALLOCATE (sizeof (ACPI_HANDLER_INFO)); + if (!Handler) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Handler->Address = Address; + Handler->Context = Context; + Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; + + /* Disable the GPE before installing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + /* Install the handler */ AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); - GpeEventInfo->Handler = Handler; - GpeEventInfo->Context = Context; - GpeEventInfo->Flags = (UINT8) Type; + GpeEventInfo->Dispatch.Handler = Handler; + + /* Setup up dispatch flags to indicate handler (vs. method) */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); + AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); - /* Clear the GPE (of stale events), the enable it */ - - Status = AcpiHwClearGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - Status = AcpiHwEnableGpe (GpeEventInfo); - UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); @@ -680,7 +710,7 @@ AcpiInstallGpeHandler ( * * PARAMETERS: GpeNumber - The event to remove a handler * GpeBlock - GPE block (NULL == FADT GPEs) - * Handler - Address of the handler + * Address - Address of the handler * * RETURN: Status * @@ -692,10 +722,11 @@ ACPI_STATUS AcpiRemoveGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - ACPI_GPE_HANDLER Handler) + ACPI_EVENT_HANDLER Address) { - ACPI_STATUS Status; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler"); @@ -703,7 +734,7 @@ AcpiRemoveGpeHandler ( /* Parameter validation */ - if (!Handler) + if (!Address) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -723,30 +754,49 @@ AcpiRemoveGpeHandler ( goto UnlockAndExit; } - /* Disable the GPE before removing the handler */ + /* Make sure that a handler is indeed installed */ - Status = AcpiHwDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) { + Status = AE_NOT_EXIST; goto UnlockAndExit; } /* Make sure that the installed handler is the same */ - if (GpeEventInfo->Handler != Handler) + if (GpeEventInfo->Dispatch.Handler->Address != Address) { - (void) AcpiHwEnableGpe (GpeEventInfo); Status = AE_BAD_PARAMETER; goto UnlockAndExit; } + /* Disable the GPE before removing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + /* Remove the handler */ AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); - GpeEventInfo->Handler = NULL; - GpeEventInfo->Context = NULL; + Handler = GpeEventInfo->Dispatch.Handler; + + /* Restore Method node (if any), set dispatch flags */ + + GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ + if (Handler->MethodNode) + { + GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD; + } AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + /* Now we can free the handler object */ + + ACPI_MEM_FREE (Handler); + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); diff --git a/sys/contrib/dev/acpica/evxfevnt.c b/sys/contrib/dev/acpica/evxfevnt.c index 45d2c4973677..c78189b50ba2 100644 --- a/sys/contrib/dev/acpica/evxfevnt.c +++ b/sys/contrib/dev/acpica/evxfevnt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * $Revision: 75 $ + * $Revision: 79 $ * *****************************************************************************/ @@ -289,6 +289,56 @@ AcpiEnableEvent ( } +/******************************************************************************* + * + * FUNCTION: AcpiSetGpeType + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Type - New GPE type + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE ("AcpiSetGpeType"); + + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type) + { + return_ACPI_STATUS (AE_OK); + } + + /* Set the new type (will disable GPE if currently enabled) */ + + Status = AcpiEvSetGpeType (GpeEventInfo, Type); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiEnableGpe @@ -337,33 +387,68 @@ AcpiEnableGpe ( goto UnlockAndExit; } - /* Check for Wake vs Runtime GPE */ + /* Perform the enable */ - if (Flags & ACPI_EVENT_WAKE_ENABLE) + Status = AcpiEvEnableGpe (GpeEventInfo, TRUE); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) { - /* Ensure the requested wake GPE is disabled */ - - Status = AcpiHwDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - /* Defer Enable of Wake GPE until sleep time */ - - AcpiHwEnableGpeForWakeup (GpeEventInfo); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); } - else - { - /* Enable the requested runtime GPE */ + return_ACPI_STATUS (Status); +} - Status = AcpiHwEnableGpe (GpeEventInfo); + +/******************************************************************************* + * + * FUNCTION: AcpiDisableGpe + * + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Just disable, or also wake disable? + * Called from ISR or not + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + + + ACPI_FUNCTION_TRACE ("AcpiDisableGpe"); + + + /* Use semaphore lock if not executing at interrupt level */ + + if (Flags & ACPI_NOT_ISR) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { - goto UnlockAndExit; + return_ACPI_STATUS (Status); } } + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiEvDisableGpe (GpeEventInfo); UnlockAndExit: if (Flags & ACPI_NOT_ISR) @@ -435,76 +520,6 @@ AcpiDisableEvent ( } -/******************************************************************************* - * - * FUNCTION: AcpiDisableGpe - * - * PARAMETERS: GpeDevice - Parent GPE Device - * GpeNumber - GPE level within the GPE block - * Flags - Just enable, or also wake enable? - * Called from ISR or not - * - * RETURN: Status - * - * DESCRIPTION: Disable an ACPI event (general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDisableGpe ( - ACPI_HANDLE GpeDevice, - UINT32 GpeNumber, - UINT32 Flags) -{ - ACPI_STATUS Status = AE_OK; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - - - ACPI_FUNCTION_TRACE ("AcpiDisableGpe"); - - - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Ensure that we have a valid GPE number */ - - GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); - if (!GpeEventInfo) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* - * Only disable the requested GPE number for wake if specified. - * Otherwise, turn it totally off - */ - if (Flags & ACPI_EVENT_WAKE_DISABLE) - { - AcpiHwDisableGpeForWakeup (GpeEventInfo); - } - else - { - Status = AcpiHwDisableGpe (GpeEventInfo); - } - -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } - return_ACPI_STATUS (Status); -} - - /******************************************************************************* * * FUNCTION: AcpiClearEvent diff --git a/sys/contrib/dev/acpica/evxfregn.c b/sys/contrib/dev/acpica/evxfregn.c index 2023550deeee..1e93eb1f9518 100644 --- a/sys/contrib/dev/acpica/evxfregn.c +++ b/sys/contrib/dev/acpica/evxfregn.c @@ -2,7 +2,7 @@ * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. - * $Revision: 61 $ + * $Revision: 63 $ * *****************************************************************************/ @@ -120,7 +120,6 @@ #include "acpi.h" #include "acnamesp.h" #include "acevents.h" -#include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfregn") @@ -150,12 +149,8 @@ AcpiInstallAddressSpaceHandler ( ACPI_ADR_SPACE_SETUP Setup, void *Context) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *HandlerObj; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_OBJECT_TYPE Type; - UINT16 Flags = 0; ACPI_FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); @@ -183,217 +178,17 @@ AcpiInstallAddressSpaceHandler ( goto UnlockAndExit; } - /* - * This registration is valid for only the types below - * and the root. This is where the default handlers - * get placed. - */ - if ((Node->Type != ACPI_TYPE_DEVICE) && - (Node->Type != ACPI_TYPE_PROCESSOR) && - (Node->Type != ACPI_TYPE_THERMAL) && - (Node != AcpiGbl_RootNode)) + /* Install the handler for all Regions for this Space ID */ + + Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); + if (ACPI_FAILURE (Status)) { - Status = AE_BAD_PARAMETER; goto UnlockAndExit; } - if (Handler == ACPI_DEFAULT_HANDLER) - { - Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; + /* Run all _REG methods for this address space */ - switch (SpaceId) - { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - Handler = AcpiExSystemMemorySpaceHandler; - Setup = AcpiEvSystemMemoryRegionSetup; - break; - - case ACPI_ADR_SPACE_SYSTEM_IO: - Handler = AcpiExSystemIoSpaceHandler; - Setup = AcpiEvIoSpaceRegionSetup; - break; - - case ACPI_ADR_SPACE_PCI_CONFIG: - Handler = AcpiExPciConfigSpaceHandler; - Setup = AcpiEvPciConfigRegionSetup; - break; - - case ACPI_ADR_SPACE_CMOS: - Handler = AcpiExCmosSpaceHandler; - Setup = AcpiEvCmosRegionSetup; - break; - - case ACPI_ADR_SPACE_PCI_BAR_TARGET: - Handler = AcpiExPciBarSpaceHandler; - Setup = AcpiEvPciBarRegionSetup; - break; - - case ACPI_ADR_SPACE_DATA_TABLE: - Handler = AcpiExDataTableSpaceHandler; - Setup = NULL; - break; - - default: - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - } - - /* If the caller hasn't specified a setup routine, use the default */ - - if (!Setup) - { - Setup = AcpiEvDefaultRegionSetup; - } - - /* Check for an existing internal object */ - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (ObjDesc) - { - /* - * The attached device object already exists. - * Make sure the handler is not already installed. - */ - HandlerObj = ObjDesc->Device.Handler; - - /* Walk the handler list for this device */ - - while (HandlerObj) - { - /* Same SpaceId indicates a handler already installed */ - - if(HandlerObj->AddressSpace.SpaceId == SpaceId) - { - if (HandlerObj->AddressSpace.Handler == Handler) - { - /* - * It is (relatively) OK to attempt to install the SAME - * handler twice. This can easily happen with PCI_Config space. - */ - Status = AE_SAME_HANDLER; - goto UnlockAndExit; - } - else - { - /* A handler is already installed */ - - Status = AE_ALREADY_EXISTS; - } - goto UnlockAndExit; - } - - /* Walk the linked list of handlers */ - - HandlerObj = HandlerObj->AddressSpace.Next; - } - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Creating object on Device %p while installing handler\n", Node)); - - /* ObjDesc does not exist, create one */ - - if (Node->Type == ACPI_TYPE_ANY) - { - Type = ACPI_TYPE_DEVICE; - } - else - { - Type = Node->Type; - } - - ObjDesc = AcpiUtCreateInternalObject (Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Init new descriptor */ - - ObjDesc->Common.Type = (UINT8) Type; - - /* Attach the new object to the Node */ - - Status = AcpiNsAttachObject (Node, ObjDesc, Type); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", - AcpiUtGetRegionName (SpaceId), SpaceId, - AcpiUtGetNodeName (Node), Node, ObjDesc)); - - /* - * Install the handler - * - * At this point there is no existing handler. - * Just allocate the object for the handler and link it - * into the list. - */ - HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); - if (!HandlerObj) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Init handler obj */ - - HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; - HandlerObj->AddressSpace.Hflags = Flags; - HandlerObj->AddressSpace.RegionList = NULL; - HandlerObj->AddressSpace.Node = Node; - HandlerObj->AddressSpace.Handler = Handler; - HandlerObj->AddressSpace.Context = Context; - HandlerObj->AddressSpace.Setup = Setup; - - /* Install at head of Device.AddressSpace list */ - - HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; - - /* - * The Device object is the first reference on the HandlerObj. - * Each region that uses the handler adds a reference. - */ - ObjDesc->Device.Handler = HandlerObj; - - /* - * Walk the namespace finding all of the regions this - * handler will manage. - * - * Start at the device and search the branch toward - * the leaf nodes until either the leaf is encountered or - * a device is detected that has an address handler of the - * same type. - * - * In either case, back up and search down the remainder - * of the branch - */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, - HandlerObj, NULL); - - /* - * Now we can run the _REG methods for all Regions for this - * space ID. This is a separate walk in order to handle any - * interdependencies between regions and _REG methods. (i.e. handlers - * must be installed for all regions of this Space ID before we - * can run any _REG methods. - */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, - HandlerObj, NULL); + Status = AcpiEvExecuteRegMethods (Node, SpaceId); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c index 99c93fcc0a4e..e3ed1087431c 100644 --- a/sys/contrib/dev/acpica/exconfig.c +++ b/sys/contrib/dev/acpica/exconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 75 $ + * $Revision: 77 $ * *****************************************************************************/ @@ -123,6 +123,7 @@ #include "acnamesp.h" #include "acevents.h" #include "actables.h" +#include "acdispat.h" #define _COMPONENT ACPI_EXECUTER @@ -375,7 +376,7 @@ AcpiExLoadOp ( ACPI_OPERAND_OBJECT *DdbHandle; ACPI_OPERAND_OBJECT *BufferDesc = NULL; ACPI_TABLE_HEADER *TablePtr = NULL; - UINT8 *TableDataPtr; + ACPI_PHYSICAL_ADDRESS Address; ACPI_TABLE_HEADER TableHeader; UINT32 i; @@ -391,13 +392,30 @@ AcpiExLoadOp ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); - /* Get the table header */ + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Get the base physical address of the region */ + + Address = ObjDesc->Region.Address; + + /* Get the table length from the table header */ TableHeader.Length = 0; - for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) + for (i = 0; i < 8; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, + (ACPI_PHYSICAL_ADDRESS) i + Address, 8, ((UINT8 *) &TableHeader) + i); if (ACPI_FAILURE (Status)) { @@ -405,6 +423,13 @@ AcpiExLoadOp ( } } + /* Sanity check the table length */ + + if (TableHeader.Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } + /* Allocate a buffer for the entire table */ TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length); @@ -413,18 +438,13 @@ AcpiExLoadOp ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* Copy the header to the buffer */ - - ACPI_MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); - TableDataPtr = ACPI_PTR_ADD (UINT8, TablePtr, sizeof (ACPI_TABLE_HEADER)); - - /* Get the table from the op region */ + /* Get the entire table from the op region */ for (i = 0; i < TableHeader.Length; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, - ((UINT8 *) TableDataPtr + i)); + (ACPI_PHYSICAL_ADDRESS) i + Address, 8, + ((UINT8 *) TablePtr + i)); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -452,6 +472,13 @@ AcpiExLoadOp ( } TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer); + + /* Sanity check the table length */ + + if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } break; diff --git a/sys/contrib/dev/acpica/exmutex.c b/sys/contrib/dev/acpica/exmutex.c index 3c1f4dd03963..7f019af35854 100644 --- a/sys/contrib/dev/acpica/exmutex.c +++ b/sys/contrib/dev/acpica/exmutex.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * $Revision: 21 $ + * $Revision: 24 $ * *****************************************************************************/ @@ -128,7 +128,7 @@ * * FUNCTION: AcpiExUnlinkMutex * - * PARAMETERS: *ObjDesc - The mutex to be unlinked + * PARAMETERS: ObjDesc - The mutex to be unlinked * * RETURN: Status * @@ -148,6 +148,8 @@ AcpiExUnlinkMutex ( return; } + /* Doubly linked list */ + if (ObjDesc->Mutex.Next) { (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; @@ -168,8 +170,8 @@ AcpiExUnlinkMutex ( * * FUNCTION: AcpiExLinkMutex * - * PARAMETERS: *ObjDesc - The mutex to be linked - * *ListHead - head of the "AcquiredMutex" list + * PARAMETERS: ObjDesc - The mutex to be linked + * ListHead - head of the "AcquiredMutex" list * * RETURN: Status * @@ -209,8 +211,8 @@ AcpiExLinkMutex ( * * FUNCTION: AcpiExAcquireMutex * - * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor - * *ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -255,9 +257,8 @@ AcpiExAcquireMutex ( return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* - * Support for multiple acquires by the owning thread - */ + /* Support for multiple acquires by the owning thread */ + if (ObjDesc->Mutex.OwnerThread) { /* Special case for Global Lock, allow all threads */ @@ -284,10 +285,11 @@ AcpiExAcquireMutex ( return_ACPI_STATUS (Status); } - /* Have the mutex, update mutex and walk info */ + /* Have the mutex: update mutex and walk info and save the SyncLevel */ - ObjDesc->Mutex.OwnerThread = WalkState->Thread; - ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; @@ -303,7 +305,7 @@ AcpiExAcquireMutex ( * * FUNCTION: AcpiExReleaseMutex * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -345,13 +347,12 @@ AcpiExReleaseMutex ( return_ACPI_STATUS (AE_AML_INTERNAL); } - /* + /* * The Mutex is owned, but this thread must be the owner. * Special case for Global Lock, any thread can release */ if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore)) - { ACPI_REPORT_ERROR (( "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", @@ -372,9 +373,8 @@ AcpiExReleaseMutex ( return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* - * Match multiple Acquires with multiple Releases - */ + /* Match multiple Acquires with multiple Releases */ + ObjDesc->Mutex.AcquisitionDepth--; if (ObjDesc->Mutex.AcquisitionDepth != 0) { @@ -391,10 +391,10 @@ AcpiExReleaseMutex ( Status = AcpiExSystemReleaseMutex (ObjDesc); - /* Update the mutex and walk state */ + /* Update the mutex and walk state, restore SyncLevel before acquire */ ObjDesc->Mutex.OwnerThread = NULL; - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; return_ACPI_STATUS (Status); } @@ -404,7 +404,7 @@ AcpiExReleaseMutex ( * * FUNCTION: AcpiExReleaseAllMutexes * - * PARAMETERS: *MutexList - Head of the mutex list + * PARAMETERS: MutexList - Head of the mutex list * * RETURN: Status * @@ -424,9 +424,8 @@ AcpiExReleaseAllMutexes ( ACPI_FUNCTION_ENTRY (); - /* - * Traverse the list of owned mutexes, releasing each one. - */ + /* Traverse the list of owned mutexes, releasing each one */ + while (Next) { This = Next; @@ -446,7 +445,11 @@ AcpiExReleaseAllMutexes ( /* Mark mutex unowned */ - This->Mutex.OwnerThread = NULL; + This->Mutex.OwnerThread = NULL; + + /* Update Thread SyncLevel (Last mutex is the important one) */ + + Thread->CurrentSyncLevel = This->Mutex.OriginalSyncLevel; } } diff --git a/sys/contrib/dev/acpica/exoparg2.c b/sys/contrib/dev/acpica/exoparg2.c index a39320e0fdc0..5ab65d47db29 100644 --- a/sys/contrib/dev/acpica/exoparg2.c +++ b/sys/contrib/dev/acpica/exoparg2.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * $Revision: 119 $ + * $Revision: 121 $ * *****************************************************************************/ @@ -172,6 +172,7 @@ AcpiExOpcode_2A_0T_0R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_NAMESPACE_NODE *Node; + UINT32 Value; ACPI_STATUS Status = AE_OK; @@ -189,17 +190,49 @@ AcpiExOpcode_2A_0T_0R ( Node = (ACPI_NAMESPACE_NODE *) Operand[0]; + /* Second value is the notify value */ + + Value = (UINT32) Operand[1]->Integer.Value; + /* Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type [%s]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unexpected notify object type [%s]\n", AcpiUtGetTypeName (Node->Type))); Status = AE_AML_OPERAND_TYPE; break; } +#ifdef ACPI_GPE_NOTIFY_CHECK + /* + * GPE method wake/notify check. Here, we want to ensure that we + * don't receive any "DeviceWake" Notifies from a GPE _Lxx or _Exx + * GPE method during system runtime. If we do, the GPE is marked + * as "wake-only" and disabled. + * + * 1) Is the Notify() value == DeviceWake? + * 2) Is this a GPE deferred method? (An _Lxx or _Exx method) + * 3) Did the original GPE happen at system runtime? + * (versus during wake) + * + * If all three cases are true, this is a wake-only GPE that should + * be disabled at runtime. + */ + if (Value == 2) /* DeviceWake */ + { + Status = AcpiEvCheckForWakeOnlyGpe (WalkState->GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ + + return_ACPI_STATUS (AE_OK) + } + } +#endif + /* * Dispatch the notify to the appropriate handler * NOTE: the request is queued for execution after this method @@ -207,8 +240,7 @@ AcpiExOpcode_2A_0T_0R ( * from this thread -- because handlers may in turn run other * control methods. */ - Status = AcpiEvQueueNotifyRequest (Node, - (UINT32) Operand[1]->Integer.Value); + Status = AcpiEvQueueNotifyRequest (Node, Value); break; diff --git a/sys/contrib/dev/acpica/exresolv.c b/sys/contrib/dev/acpica/exresolv.c index 3da3d426fd10..bc6860e4266f 100644 --- a/sys/contrib/dev/acpica/exresolv.c +++ b/sys/contrib/dev/acpica/exresolv.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresolv - AML Interpreter object resolution - * $Revision: 123 $ + * $Revision: 124 $ * *****************************************************************************/ @@ -269,15 +269,15 @@ AcpiExResolveObjectToValue ( return_ACPI_STATUS (Status); } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", + StackDesc->Reference.Offset, ObjDesc)); + /* * Now we can delete the original Reference Object and - * replace it with the resolve value + * replace it with the resolved value */ AcpiUtRemoveReference (StackDesc); *StackPtr = ObjDesc; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %d] ValueObj is %p\n", - StackDesc->Reference.Offset, ObjDesc)); break; diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index 48c594c30598..82f4fd06521a 100644 --- a/sys/contrib/dev/acpica/exstore.c +++ b/sys/contrib/dev/acpica/exstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * $Revision: 181 $ + * $Revision: 182 $ * *****************************************************************************/ @@ -279,14 +279,14 @@ AcpiExStore ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X", (UINT32) SourceDesc->Buffer.Length)); - ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, + ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); break; case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n", SourceDesc->String.Length, SourceDesc->String.Pointer)); break; diff --git a/sys/contrib/dev/acpica/hwgpe.c b/sys/contrib/dev/acpica/hwgpe.c index db2b43bdd4e1..626836d5463b 100644 --- a/sys/contrib/dev/acpica/hwgpe.c +++ b/sys/contrib/dev/acpica/hwgpe.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwgpe - Low level GPE enable/disable/clear functions - * $Revision: 57 $ + * $Revision: 62 $ * *****************************************************************************/ @@ -124,183 +124,46 @@ /****************************************************************************** * - * FUNCTION: AcpiHwEnableGpe + * FUNCTION: AcpiHwWriteGpeEnableReg * * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled * * RETURN: Status * - * DESCRIPTION: Enable a single GPE. + * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must + * already be cleared or set in the parent register + * EnableForRun mask. * ******************************************************************************/ ACPI_STATUS -AcpiHwEnableGpe ( +AcpiHwWriteGpeEnableReg ( ACPI_GPE_EVENT_INFO *GpeEventInfo) { - UINT32 InByte; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); - /* - * Read the current value of the register, set the appropriate bit - * to enable the GPE, and write out the new register. - */ - Status = AcpiHwLowLevelRead (8, &InByte, - &GpeEventInfo->RegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) { - return (Status); + return (AE_NOT_EXIST); } - /* Write with the new GPE bit enabled */ + /* Write the entire GPE (runtime) enable register */ - Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask), - &GpeEventInfo->RegisterInfo->EnableAddress); + Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->EnableForRun, + &GpeRegisterInfo->EnableAddress); return (Status); } -/****************************************************************************** - * - * FUNCTION: AcpiHwEnableGpeForWakeup - * - * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled - * - * RETURN: None - * - * DESCRIPTION: Keep track of which GPEs the OS has requested not be - * disabled when going to sleep. - * - ******************************************************************************/ - -void -AcpiHwEnableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - - - ACPI_FUNCTION_ENTRY (); - - - /* Get the info block for the entire GPE register */ - - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) - { - return; - } - - /* - * Set the bit so we will not enable this GPE when sleeping (and disable - * it upon wake) - */ - GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask; - GpeEventInfo->Flags |= (ACPI_GPE_TYPE_WAKE | ACPI_GPE_ENABLED); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiHwDisableGpe - * - * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled - * - * RETURN: Status - * - * DESCRIPTION: Disable a single GPE. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiHwDisableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - UINT32 InByte; - ACPI_STATUS Status; - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - - - ACPI_FUNCTION_ENTRY (); - - - /* Get the info block for the entire GPE register */ - - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) - { - return (AE_BAD_PARAMETER); - } - - /* - * Read the current value of the register, clear the appropriate bit, - * and write out the new register value to disable the GPE. - */ - Status = AcpiHwLowLevelRead (8, &InByte, - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Write the byte with this GPE bit cleared */ - - Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)), - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Make sure this GPE is disabled for wake, also */ - - AcpiHwDisableGpeForWakeup (GpeEventInfo); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiHwDisableGpeForWakeup - * - * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled - * - * RETURN: None - * - * DESCRIPTION: Keep track of which GPEs the OS has requested not be - * disabled when going to sleep. - * - ******************************************************************************/ - -void -AcpiHwDisableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - - - ACPI_FUNCTION_ENTRY (); - - - /* Get the info block for the entire GPE register */ - - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) - { - return; - } - - /* Clear the bit so we will disable this when sleeping */ - - GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask); -} - - /****************************************************************************** * * FUNCTION: AcpiHwClearGpe @@ -327,7 +190,7 @@ AcpiHwClearGpe ( * Write a one to the appropriate bit in the status register to * clear this GPE. */ - Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask, + Status = AcpiHwLowLevelWrite (8, GpeEventInfo->RegisterBit, &GpeEventInfo->RegisterInfo->StatusAddress); return (Status); @@ -353,7 +216,7 @@ AcpiHwGetGpeStatus ( ACPI_EVENT_STATUS *EventStatus) { UINT32 InByte; - UINT8 BitMask; + UINT8 RegisterBit; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; ACPI_EVENT_STATUS LocalEventStatus = 0; @@ -373,29 +236,23 @@ AcpiHwGetGpeStatus ( /* Get the register bitmask for this GPE */ - BitMask = GpeEventInfo->BitMask; + RegisterBit = GpeEventInfo->RegisterBit; - /* GPE Enabled? */ + /* GPE currently enabled? (enabled for runtime?) */ - Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - if (BitMask & InByte) + if (RegisterBit & GpeRegisterInfo->EnableForRun) { LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; } - /* GPE Enabled for wake? */ + /* GPE enabled for wake? */ - if (BitMask & GpeRegisterInfo->WakeEnable) + if (RegisterBit & GpeRegisterInfo->EnableForWake) { LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; } - /* GPE active (set)? */ + /* GPE currently active (status bit == 1)? */ Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress); if (ACPI_FAILURE (Status)) @@ -403,7 +260,7 @@ AcpiHwGetGpeStatus ( goto UnlockAndExit; } - if (BitMask & InByte) + if (RegisterBit & InByte) { LocalEventStatus |= ACPI_EVENT_FLAG_SET; } @@ -500,67 +357,46 @@ AcpiHwClearGpeBlock ( /****************************************************************************** * - * FUNCTION: AcpiHwPrepareGpeBlockForSleep + * FUNCTION: AcpiHwEnableRuntimeGpeBlock * * PARAMETERS: GpeXruptInfo - GPE Interrupt info * GpeBlock - Gpe Block info * * RETURN: Status * - * DESCRIPTION: Disable all runtime GPEs and enable all wakeup GPEs -- within - * a single GPE block + * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes + * combination wake/run GPEs.) * ******************************************************************************/ -static ACPI_STATUS -AcpiHwPrepareGpeBlockForSleep ( +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock) { UINT32 i; - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - UINT32 InValue; ACPI_STATUS Status; - /* Get the register info for the entire GPE block */ - - GpeRegisterInfo = GpeBlock->RegisterInfo; + /* NOTE: assumes that all GPEs are currently disabled */ /* Examine each GPE Register within the block */ for (i = 0; i < GpeBlock->RegisterCount; i++) { - /* - * Read the enabled/disabled status of all GPEs. We - * will be using it to restore all the GPEs later. - * - * NOTE: Wake GPEs are are ALL disabled at this time, so when we wake - * and restore this register, they will be automatically disabled. - */ - Status = AcpiHwLowLevelRead (8, &InValue, - &GpeRegisterInfo->EnableAddress); + if (!GpeBlock->RegisterInfo[i].EnableForRun) + { + continue; + } + + /* Enable all "runtime" GPEs in this register */ + + Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForRun, + &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); } - - GpeRegisterInfo->Enable = (UINT8) InValue; - - /* - * 1) Disable all runtime GPEs - * 2) Enable all wakeup GPEs - */ - Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable, - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Point to next GPE register */ - - GpeRegisterInfo++; } return (AE_OK); @@ -569,96 +405,44 @@ AcpiHwPrepareGpeBlockForSleep ( /****************************************************************************** * - * FUNCTION: AcpiHwPrepareGpesForSleep - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Disable all runtime GPEs, enable all wake GPEs. - * Called with interrupts disabled. The interrupt handler also - * modifies GpeRegisterInfo->Enable, so it should not be - * given the chance to run until after the runtime GPEs are - * re-enabled. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiHwPrepareGpesForSleep ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_ENTRY (); - - - Status = AcpiEvWalkGpeList (AcpiHwPrepareGpeBlockForSleep); - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiHwRestoreGpeBlockOnWake + * FUNCTION: AcpiHwEnableWakeupGpeBlock * * PARAMETERS: GpeXruptInfo - GPE Interrupt info * GpeBlock - Gpe Block info * * RETURN: Status * - * DESCRIPTION: Enable all runtime GPEs and disable all wake GPEs -- in one - * GPE block + * DESCRIPTION: Enable all "wake" GPEs within a GPE block. (Includes + * combination wake/run GPEs.) * ******************************************************************************/ -static ACPI_STATUS -AcpiHwRestoreGpeBlockOnWake ( +ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock) { UINT32 i; - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; - /* This callback processes one entire GPE block */ - - /* Get the register info for the entire GPE block */ - - GpeRegisterInfo = GpeBlock->RegisterInfo; - - /* Examine each GPE register within the block */ + /* Examine each GPE Register within the block */ for (i = 0; i < GpeBlock->RegisterCount; i++) { - /* Clear the entire status register */ + if (!GpeBlock->RegisterInfo[i].EnableForWake) + { + continue; + } - Status = AcpiHwLowLevelWrite (8, 0xFF, - &GpeBlock->RegisterInfo[i].StatusAddress); + /* Enable all "wake" GPEs in this register */ + + Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForWake, + &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); } - - /* - * Restore the GPE Enable register, which will do the following: - * - * 1) Disable all wakeup GPEs - * 2) Enable all runtime GPEs - * - * (On sleep, we saved the enabled status of all GPEs) - */ - Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable, - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Point to next GPE register */ - - GpeRegisterInfo++; } return (AE_OK); @@ -667,27 +451,82 @@ AcpiHwRestoreGpeBlockOnWake ( /****************************************************************************** * - * FUNCTION: AcpiHwRestoreGpesOnWake + * FUNCTION: AcpiHwDisableAllGpes * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Enable all runtime GPEs and disable all wake GPEs -- in all - * GPE blocks + * DESCRIPTION: Disable and clear all GPEs * ******************************************************************************/ ACPI_STATUS -AcpiHwRestoreGpesOnWake ( +AcpiHwDisableAllGpes ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE ("HwDisableAllGpes"); - Status = AcpiEvWalkGpeList (AcpiHwRestoreGpeBlockOnWake); - return (Status); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); + return_ACPI_STATUS (Status); } + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all GPEs of the given type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes"); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllWakeupGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all GPEs of the given type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes"); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock); + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/hwregs.c b/sys/contrib/dev/acpica/hwregs.c index 240b6a7ba1dd..0595010ca192 100644 --- a/sys/contrib/dev/acpica/hwregs.c +++ b/sys/contrib/dev/acpica/hwregs.c @@ -3,7 +3,7 @@ * * Module Name: hwregs - Read/write access functions for the various ACPI * control and status registers. - * $Revision: 154 $ + * $Revision: 156 $ * ******************************************************************************/ @@ -215,7 +215,7 @@ AcpiGetSleepTypeData ( UINT8 *SleepTypeB) { ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARAMETER_INFO Info; ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData"); @@ -233,8 +233,9 @@ AcpiGetSleepTypeData ( /* * Evaluate the namespace object containing the values for this state */ + Info.Parameters = NULL; Status = AcpiNsEvaluateByName ((char *) AcpiGbl_SleepStateNames[SleepState], - NULL, &ObjDesc); + &Info); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n", @@ -245,7 +246,7 @@ AcpiGetSleepTypeData ( /* Must have a return object */ - if (!ObjDesc) + if (!Info.ReturnObject) { ACPI_REPORT_ERROR (("Missing Sleep State object\n")); Status = AE_NOT_EXIST; @@ -253,7 +254,7 @@ AcpiGetSleepTypeData ( /* It must be of type Package */ - else if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_PACKAGE) + else if (ACPI_GET_OBJECT_TYPE (Info.ReturnObject) != ACPI_TYPE_PACKAGE) { ACPI_REPORT_ERROR (("Sleep State object not a Package\n")); Status = AE_AML_OPERAND_TYPE; @@ -261,7 +262,7 @@ AcpiGetSleepTypeData ( /* The package must have at least two elements */ - else if (ObjDesc->Package.Count < 2) + else if (Info.ReturnObject->Package.Count < 2) { ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n")); Status = AE_AML_NO_OPERAND; @@ -269,12 +270,12 @@ AcpiGetSleepTypeData ( /* The first two elements must both be of type Integer */ - else if ((ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER)) + else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) != ACPI_TYPE_INTEGER) || + (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) != ACPI_TYPE_INTEGER)) { ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n", - AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[0]), - AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[1]))); + AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[1]))); Status = AE_AML_OPERAND_TYPE; } else @@ -282,17 +283,19 @@ AcpiGetSleepTypeData ( /* * Valid _Sx_ package size, type, and value */ - *SleepTypeA = (UINT8) (ObjDesc->Package.Elements[0])->Integer.Value; - *SleepTypeB = (UINT8) (ObjDesc->Package.Elements[1])->Integer.Value; + *SleepTypeA = (UINT8) (Info.ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) (Info.ReturnObject->Package.Elements[1])->Integer.Value; } if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating SleepState [%s], bad Sleep object %p type %s\n", - AcpiGbl_SleepStateNames[SleepState], ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "While evaluating SleepState [%s], bad Sleep object %p type %s\n", + AcpiGbl_SleepStateNames[SleepState], Info.ReturnObject, + AcpiUtGetObjectTypeName (Info.ReturnObject))); } - AcpiUtRemoveReference (ObjDesc); + AcpiUtRemoveReference (Info.ReturnObject); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index 488e765667ba..c8ade38349f4 100644 --- a/sys/contrib/dev/acpica/hwsleep.c +++ b/sys/contrib/dev/acpica/hwsleep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * $Revision: 66 $ + * $Revision: 69 $ * *****************************************************************************/ @@ -357,6 +357,8 @@ AcpiEnterSleepState ( return_ACPI_STATUS (Status); } + /* Clear all fixed and general purpose status bits */ + Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { @@ -375,10 +377,17 @@ AcpiEnterSleepState ( } /* - * 1) Disable all runtime GPEs + * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwPrepareGpesForSleep (); + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -520,10 +529,17 @@ AcpiEnterSleepStateS4bios ( } /* - * 1) Disable all runtime GPEs + * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwPrepareGpesForSleep (); + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -647,10 +663,17 @@ AcpiLeaveSleepState ( /* * Restore the GPEs: - * 1) Disable all wakeup GPEs + * 1) Disable/Clear all GPEs * 2) Enable all runtime GPEs */ - Status = AcpiHwRestoreGpesOnWake (); + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = TRUE; + + Status = AcpiHwEnableAllRuntimeGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -658,9 +681,9 @@ AcpiLeaveSleepState ( /* Enable power button */ - AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); - AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); /* Enable BM arbitration */ diff --git a/sys/contrib/dev/acpica/nsaccess.c b/sys/contrib/dev/acpica/nsaccess.c index d602e5bc3399..5abee9ecfe3a 100644 --- a/sys/contrib/dev/acpica/nsaccess.c +++ b/sys/contrib/dev/acpica/nsaccess.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * $Revision: 180 $ + * $Revision: 182 $ * ******************************************************************************/ @@ -190,7 +190,7 @@ AcpiNsRootInitialize (void) } Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode); if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ @@ -210,7 +210,7 @@ AcpiNsRootInitialize (void) Status = AcpiOsPredefinedOverride (InitVal, &Val); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not override predefined %s\n", InitVal->Name)); } @@ -239,7 +239,7 @@ AcpiNsRootInitialize (void) switch (InitVal->Type) { case ACPI_TYPE_METHOD: - ObjDesc->Method.ParamCount = (UINT8) ACPI_STRTOUL + ObjDesc->Method.ParamCount = (UINT8) ACPI_STRTOUL (Val, NULL, 10); ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; @@ -277,7 +277,7 @@ AcpiNsRootInitialize (void) case ACPI_TYPE_MUTEX: ObjDesc->Mutex.Node = NewNode; - ObjDesc->Mutex.SyncLevel = (UINT16) ACPI_STRTOUL + ObjDesc->Mutex.SyncLevel = (UINT8) ACPI_STRTOUL (Val, NULL, 10); if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) diff --git a/sys/contrib/dev/acpica/nsalloc.c b/sys/contrib/dev/acpica/nsalloc.c index 065403c927c4..5ab596ad689e 100644 --- a/sys/contrib/dev/acpica/nsalloc.c +++ b/sys/contrib/dev/acpica/nsalloc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities - * $Revision: 85 $ + * $Revision: 87 $ * ******************************************************************************/ @@ -355,7 +355,7 @@ AcpiNsInstallNode ( { #ifdef ACPI_ALPHABETIC_NAMESPACE /* - * Walk the list whilst searching for the the correct + * Walk the list whilst searching for the correct * alphabetic placement. */ PreviousChildNode = NULL; @@ -428,7 +428,7 @@ AcpiNsInstallNode ( Node->OwnerId = OwnerId; Node->Type = (UINT8) Type; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c index 688f92b60cfb..93cf067d9c4f 100644 --- a/sys/contrib/dev/acpica/nseval.c +++ b/sys/contrib/dev/acpica/nseval.c @@ -2,7 +2,7 @@ * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * $Revision: 125 $ + * $Revision: 127 $ * ******************************************************************************/ @@ -152,13 +152,10 @@ ACPI_STATUS AcpiNsEvaluateRelative ( - ACPI_NAMESPACE_NODE *Handle, char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *PrefixNode; ACPI_NAMESPACE_NODE *Node = NULL; ACPI_GENERIC_STATE *ScopeInfo; char *InternalPath = NULL; @@ -170,7 +167,7 @@ AcpiNsEvaluateRelative ( /* * Must have a valid object handle */ - if (!Handle) + if (!Info || !Info->Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -197,8 +194,8 @@ AcpiNsEvaluateRelative ( goto Cleanup; } - PrefixNode = AcpiNsMapHandleToNode (Handle); - if (!PrefixNode) + Info->Node = AcpiNsMapHandleToNode (Info->Node); + if (!Info->Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AE_BAD_PARAMETER; @@ -207,7 +204,7 @@ AcpiNsEvaluateRelative ( /* Lookup the name in the namespace */ - ScopeInfo->Scope.Node = PrefixNode; + ScopeInfo->Scope.Node = Info->Node; Status = AcpiNsLookup (ScopeInfo, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &Node); @@ -228,7 +225,8 @@ AcpiNsEvaluateRelative ( ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Pathname, Node, AcpiNsGetAttachedObject (Node))); - Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + Info->Node = Node; + Status = AcpiNsEvaluateByHandle (Info); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", Pathname)); @@ -247,6 +245,7 @@ AcpiNsEvaluateRelative ( * FUNCTION: AcpiNsEvaluateByName * * PARAMETERS: Pathname - Fully qualified pathname to the object + * Info - Contains: * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. * Params - List of parameters to pass to the method, @@ -265,11 +264,9 @@ AcpiNsEvaluateRelative ( ACPI_STATUS AcpiNsEvaluateByName ( char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; char *InternalPath = NULL; @@ -294,7 +291,7 @@ AcpiNsEvaluateByName ( Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, - &Node); + &Info->Node); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -310,9 +307,9 @@ AcpiNsEvaluateByName ( * to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - Pathname, Node, AcpiNsGetAttachedObject (Node))); + Pathname, Info->Node, AcpiNsGetAttachedObject (Info->Node))); - Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + Status = AcpiNsEvaluateByHandle (Info); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", Pathname)); @@ -339,6 +336,7 @@ AcpiNsEvaluateByName ( * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. + * ParamType - Type of Parameter list * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. * @@ -352,13 +350,9 @@ AcpiNsEvaluateByName ( ACPI_STATUS AcpiNsEvaluateByHandle ( - ACPI_NAMESPACE_NODE *Handle, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) + ACPI_PARAMETER_INFO *Info) { - ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *LocalReturnObject; ACPI_FUNCTION_TRACE ("NsEvaluateByHandle"); @@ -373,17 +367,14 @@ AcpiNsEvaluateByHandle ( /* Parameter Validation */ - if (!Handle) + if (!Info) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (ReturnObject) - { - /* Initialize the return value to an invalid object */ + /* Initialize the return value to an invalid object */ - *ReturnObject = NULL; - } + Info->ReturnObject = NULL; /* Get the prefix handle and Node */ @@ -393,8 +384,8 @@ AcpiNsEvaluateByHandle ( return_ACPI_STATUS (Status); } - Node = AcpiNsMapHandleToNode (Handle); - if (!Node) + Info->Node = AcpiNsMapHandleToNode (Info->Node); + if (!Info->Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -405,9 +396,9 @@ AcpiNsEvaluateByHandle ( * so that proper scoping context will be established * before execution. */ - if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { - Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + Info->Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->Node->Object); } /* @@ -419,13 +410,12 @@ AcpiNsEvaluateByHandle ( * In both cases, the namespace is unlocked by the * AcpiNs* procedure */ - if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) + if (AcpiNsGetType (Info->Node) == ACPI_TYPE_METHOD) { /* * Case 1) We have an actual control method to execute */ - Status = AcpiNsExecuteControlMethod (Node, Params, - &LocalReturnObject); + Status = AcpiNsExecuteControlMethod (Info); } else { @@ -433,7 +423,7 @@ AcpiNsEvaluateByHandle ( * Case 2) Object is NOT a method, just return its * current value */ - Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); + Status = AcpiNsGetObjectValue (Info); } /* @@ -442,21 +432,6 @@ AcpiNsEvaluateByHandle ( */ if (Status == AE_CTRL_RETURN_VALUE) { - /* - * If the Method returned a value and the caller - * provided a place to store a returned value, Copy - * the returned value to the object descriptor provided - * by the caller. - */ - if (ReturnObject) - { - /* - * Valid return object, copy the pointer to - * the returned object - */ - *ReturnObject = LocalReturnObject; - } - /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ Status = AE_OK; @@ -491,9 +466,7 @@ AcpiNsEvaluateByHandle ( ACPI_STATUS AcpiNsExecuteControlMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; @@ -504,7 +477,7 @@ AcpiNsExecuteControlMethod ( /* Verify that there is a method associated with this object */ - ObjDesc = AcpiNsGetAttachedObject (MethodNode); + ObjDesc = AcpiNsGetAttachedObject (Info->Node); if (!ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); @@ -513,7 +486,7 @@ AcpiNsExecuteControlMethod ( return_ACPI_STATUS (AE_NULL_OBJECT); } - ACPI_DUMP_PATHNAME (MethodNode, "Execute Method:", + ACPI_DUMP_PATHNAME (Info->Node, "Execute Method:", ACPI_LV_INFO, _COMPONENT); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", @@ -542,7 +515,7 @@ AcpiNsExecuteControlMethod ( return_ACPI_STATUS (Status); } - Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc); + Status = AcpiPsxExecute (Info); AcpiExExitInterpreter (); return_ACPI_STATUS (Status); @@ -566,11 +539,10 @@ AcpiNsExecuteControlMethod ( ACPI_STATUS AcpiNsGetObjectValue ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OPERAND_OBJECT **ReturnObjDesc) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status = AE_OK; - ACPI_NAMESPACE_NODE *ResolvedNode = Node; + ACPI_NAMESPACE_NODE *ResolvedNode = Info->Node; ACPI_FUNCTION_TRACE ("NsGetObjectValue"); @@ -619,9 +591,9 @@ AcpiNsGetObjectValue ( if (ACPI_SUCCESS (Status)) { Status = AE_CTRL_RETURN_VALUE; - *ReturnObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode); + Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", - *ReturnObjDesc, AcpiUtGetObjectTypeName (*ReturnObjDesc))); + Info->ReturnObject, AcpiUtGetObjectTypeName (Info->ReturnObject))); } } diff --git a/sys/contrib/dev/acpica/nsinit.c b/sys/contrib/dev/acpica/nsinit.c index a4a0ac85321d..c370af874f77 100644 --- a/sys/contrib/dev/acpica/nsinit.c +++ b/sys/contrib/dev/acpica/nsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * $Revision: 58 $ + * $Revision: 60 $ * *****************************************************************************/ @@ -226,7 +226,7 @@ AcpiNsInitializeDevices ( return_ACPI_STATUS (Status); } - /* Walk namespace for all objects of type Device or Processor */ + /* Walk namespace for all objects */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, TRUE, AcpiNsInitOneDevice, &Info, NULL); @@ -422,26 +422,30 @@ AcpiNsInitOneDevice ( void *Context, void **ReturnValue) { - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - UINT32 Flags; ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; + ACPI_PARAMETER_INFO Pinfo; + UINT32 Flags; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("NsInitOneDevice"); - Node = AcpiNsMapHandleToNode (ObjHandle); - if (!Node) + Pinfo.Parameters = NULL; + Pinfo.ParameterType = ACPI_PARAM_ARGS; + + Pinfo.Node = AcpiNsMapHandleToNode (ObjHandle); + if (!Pinfo.Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* - * We will run _STA/_INI on Devices and Processors only + * We will run _STA/_INI on Devices, Processors and ThermalZones only */ - if ((Node->Type != ACPI_TYPE_DEVICE) && - (Node->Type != ACPI_TYPE_PROCESSOR)) + if ((Pinfo.Node->Type != ACPI_TYPE_DEVICE) && + (Pinfo.Node->Type != ACPI_TYPE_PROCESSOR) && + (Pinfo.Node->Type != ACPI_TYPE_THERMAL)) { return_ACPI_STATUS (AE_OK); } @@ -456,19 +460,19 @@ AcpiNsInitOneDevice ( /* * Run _STA to determine if we can run _INI on the device. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Node, "_STA")); - Status = AcpiUtExecute_STA (Node, &Flags); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Pinfo.Node, "_STA")); + Status = AcpiUtExecute_STA (Pinfo.Node, &Flags); if (ACPI_FAILURE (Status)) { - if (Node->Type == ACPI_TYPE_DEVICE) + if (Pinfo.Node->Type == ACPI_TYPE_DEVICE) { /* Ignore error and move on to next device */ return_ACPI_STATUS (AE_OK); } - /* _STA is not required for Processor objects */ + /* _STA is not required for Processor or ThermalZone objects */ } else { @@ -485,8 +489,8 @@ AcpiNsInitOneDevice ( /* * The device is present. Run _INI. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, ObjHandle, "_INI")); - Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Pinfo.Node, "_INI")); + Status = AcpiNsEvaluateRelative ("_INI", &Pinfo); if (ACPI_FAILURE (Status)) { /* No _INI (AE_NOT_FOUND) means device requires no initialization */ @@ -495,14 +499,14 @@ AcpiNsInitOneDevice ( { /* Ignore error and move on to next device */ - #ifdef ACPI_DEBUG_OUTPUT - char *ScopeName = AcpiNsGetExternalPathname (ObjHandle); +#ifdef ACPI_DEBUG_OUTPUT + char *ScopeName = AcpiNsGetExternalPathname (Pinfo.Node); ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", ScopeName, AcpiFormatException (Status))); ACPI_MEM_FREE (ScopeName); - #endif +#endif } Status = AE_OK; @@ -518,7 +522,7 @@ AcpiNsInitOneDevice ( { /* External initialization handler is present, call it */ - Status = AcpiGbl_InitHandler (ObjHandle, ACPI_INIT_DEVICE_INI); + Status = AcpiGbl_InitHandler (Pinfo.Node, ACPI_INIT_DEVICE_INI); } diff --git a/sys/contrib/dev/acpica/nsparse.c b/sys/contrib/dev/acpica/nsparse.c index 824fe63f8b29..4a103cbed2d2 100644 --- a/sys/contrib/dev/acpica/nsparse.c +++ b/sys/contrib/dev/acpica/nsparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsparse - namespace interface to AML parser - * $Revision: 5 $ + * $Revision: 6 $ * *****************************************************************************/ @@ -170,8 +170,9 @@ AcpiNsOneCompleteParse ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, TableDesc->AmlStart, - TableDesc->AmlLength, NULL, NULL, PassNumber); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + TableDesc->AmlStart, TableDesc->AmlLength, + NULL, PassNumber); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); diff --git a/sys/contrib/dev/acpica/nsxfeval.c b/sys/contrib/dev/acpica/nsxfeval.c index 4184bffd0b70..81cc111538c6 100644 --- a/sys/contrib/dev/acpica/nsxfeval.c +++ b/sys/contrib/dev/acpica/nsxfeval.c @@ -2,7 +2,7 @@ * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces - * $Revision: 12 $ + * $Revision: 14 $ * ******************************************************************************/ @@ -256,8 +256,7 @@ AcpiEvaluateObject ( { ACPI_STATUS Status; ACPI_STATUS Status2; - ACPI_OPERAND_OBJECT **InternalParams = NULL; - ACPI_OPERAND_OBJECT *InternalReturnObj = NULL; + ACPI_PARAMETER_INFO Info; ACPI_SIZE BufferSpaceNeeded; UINT32 i; @@ -265,6 +264,11 @@ AcpiEvaluateObject ( ACPI_FUNCTION_TRACE ("AcpiEvaluateObject"); + Info.Node = Handle; + Info.Parameters = NULL; + Info.ReturnObject = NULL; + Info.ParameterType = ACPI_PARAM_ARGS; + /* * If there are parameters to be passed to the object * (which must be a control method), the external objects @@ -276,9 +280,10 @@ AcpiEvaluateObject ( * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ - InternalParams = ACPI_MEM_CALLOCATE (((ACPI_SIZE) ExternalParams->Count + 1) * - sizeof (void *)); - if (!InternalParams) + Info.Parameters = ACPI_MEM_CALLOCATE ( + ((ACPI_SIZE) ExternalParams->Count + 1) * + sizeof (void *)); + if (!Info.Parameters) { return_ACPI_STATUS (AE_NO_MEMORY); } @@ -290,16 +295,17 @@ AcpiEvaluateObject ( for (i = 0; i < ExternalParams->Count; i++) { Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i], - &InternalParams[i]); + &Info.Parameters[i]); if (ACPI_FAILURE (Status)) { - AcpiUtDeleteInternalObjectList (InternalParams); + AcpiUtDeleteInternalObjectList (Info.Parameters); return_ACPI_STATUS (Status); } } - InternalParams[ExternalParams->Count] = NULL; + Info.Parameters[ExternalParams->Count] = NULL; } + /* * Three major cases: * 1) Fully qualified pathname @@ -312,8 +318,7 @@ AcpiEvaluateObject ( /* * The path is fully qualified, just evaluate by name */ - Status = AcpiNsEvaluateByName (Pathname, InternalParams, - &InternalReturnObj); + Status = AcpiNsEvaluateByName (Pathname, &Info); } else if (!Handle) { @@ -348,16 +353,14 @@ AcpiEvaluateObject ( * The null pathname case means the handle is for * the actual object to be evaluated */ - Status = AcpiNsEvaluateByHandle (Handle, InternalParams, - &InternalReturnObj); + Status = AcpiNsEvaluateByHandle (&Info); } else { /* * Both a Handle and a relative Pathname */ - Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams, - &InternalReturnObj); + Status = AcpiNsEvaluateRelative (Pathname, &Info); } } @@ -368,13 +371,13 @@ AcpiEvaluateObject ( */ if (ReturnBuffer) { - if (!InternalReturnObj) + if (!Info.ReturnObject) { ReturnBuffer->Length = 0; } else { - if (ACPI_GET_DESCRIPTOR_TYPE (InternalReturnObj) == ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (Info.ReturnObject) == ACPI_DESC_TYPE_NAMED) { /* * If we received a NS Node as a return object, this means that @@ -385,7 +388,7 @@ AcpiEvaluateObject ( * support for various types at a later date if necessary. */ Status = AE_TYPE; - InternalReturnObj = NULL; /* No need to delete a NS Node */ + Info.ReturnObject = NULL; /* No need to delete a NS Node */ ReturnBuffer->Length = 0; } @@ -395,7 +398,7 @@ AcpiEvaluateObject ( * Find out how large a buffer is needed * to contain the returned object */ - Status = AcpiUtGetObjectSize (InternalReturnObj, + Status = AcpiUtGetObjectSize (Info.ReturnObject, &BufferSpaceNeeded); if (ACPI_SUCCESS (Status)) { @@ -409,14 +412,15 @@ AcpiEvaluateObject ( */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Needed buffer size %X, %s\n", - (UINT32) BufferSpaceNeeded, AcpiFormatException (Status))); + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); } else { /* * We have enough space for the object, build it */ - Status = AcpiUtCopyIobjectToEobject (InternalReturnObj, + Status = AcpiUtCopyIobjectToEobject (Info.ReturnObject, ReturnBuffer); } } @@ -424,9 +428,9 @@ AcpiEvaluateObject ( } } - if (InternalReturnObj) + if (Info.ReturnObject) { - /* + /* * Delete the internal return object. NOTE: Interpreter * must be locked to avoid race condition. */ @@ -437,7 +441,7 @@ AcpiEvaluateObject ( * Delete the internal return object. (Or at least * decrement the reference count by one) */ - AcpiUtRemoveReference (InternalReturnObj); + AcpiUtRemoveReference (Info.ReturnObject); AcpiExExitInterpreter (); } } @@ -445,11 +449,11 @@ AcpiEvaluateObject ( /* * Free the input parameter list (if we created one), */ - if (InternalParams) + if (Info.Parameters) { /* Free the allocated parameter block */ - AcpiUtDeleteInternalObjectList (InternalParams); + AcpiUtDeleteInternalObjectList (Info.Parameters); } return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/nsxfname.c b/sys/contrib/dev/acpica/nsxfname.c index 8b0d7a4dac3f..e7da5f2eda81 100644 --- a/sys/contrib/dev/acpica/nsxfname.c +++ b/sys/contrib/dev/acpica/nsxfname.c @@ -2,7 +2,7 @@ * * Module Name: nsxfname - Public interfaces to the ACPI subsystem * ACPI Namespace oriented interfaces - * $Revision: 100 $ + * $Revision: 101 $ * *****************************************************************************/ @@ -374,7 +374,7 @@ AcpiGetObjectInfo ( { /* * Get extra info for ACPI Devices objects only: - * Run the Device _HID, _UID, _CID, _STA, and _ADR methods. + * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info.Valid bitfield is used @@ -429,7 +429,7 @@ AcpiGetObjectInfo ( Status = AcpiUtExecute_Sxds (Node, Info.HighestDstates); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_STA; + Info.Valid |= ACPI_VALID_SXDS; } Status = AE_OK; diff --git a/sys/contrib/dev/acpica/psxface.c b/sys/contrib/dev/acpica/psxface.c index 4a153a8f0dab..026f0ca77c87 100644 --- a/sys/contrib/dev/acpica/psxface.c +++ b/sys/contrib/dev/acpica/psxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psxface - Parser external interfaces - * $Revision: 71 $ + * $Revision: 75 $ * *****************************************************************************/ @@ -131,7 +131,7 @@ * * FUNCTION: AcpiPsxExecute * - * PARAMETERS: MethodNode - A method object containing both the AML + * PARAMETERS: Info->Node - A method object containing both the AML * address and length. * **Params - List of parameters to pass to method, * terminated by NULL. Params itself may be @@ -147,9 +147,7 @@ ACPI_STATUS AcpiPsxExecute ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; @@ -163,12 +161,12 @@ AcpiPsxExecute ( /* Validate the Node and get the attached object */ - if (!MethodNode) + if (!Info || !Info->Node) { return_ACPI_STATUS (AE_NULL_ENTRY); } - ObjDesc = AcpiNsGetAttachedObject (MethodNode); + ObjDesc = AcpiNsGetAttachedObject (Info->Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NULL_OBJECT); @@ -176,21 +174,22 @@ AcpiPsxExecute ( /* Init for new method, wait on concurrency semaphore */ - Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, NULL); + Status = AcpiDsBeginMethodExecution (Info->Node, ObjDesc, NULL); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - if (Params) + if ((Info->ParameterType == ACPI_PARAM_ARGS) && + (Info->Parameters)) { /* * The caller "owns" the parameters, so give each one an extra * reference */ - for (i = 0; Params[i]; i++) + for (i = 0; Info->Parameters[i]; i++) { - AcpiUtAddReference (Params[i]); + AcpiUtAddReference (Info->Parameters[i]); } } @@ -200,7 +199,7 @@ AcpiPsxExecute ( */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Begin Method Parse **** Entry=%p obj=%p\n", - MethodNode, ObjDesc)); + Info->Node, ObjDesc)); /* Create and init a Root Node */ @@ -228,8 +227,9 @@ AcpiPsxExecute ( goto Cleanup2; } - Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, NULL, 1); + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { goto Cleanup3; @@ -242,7 +242,6 @@ AcpiPsxExecute ( if (ACPI_FAILURE (Status)) { goto Cleanup1; /* Walk state is already deleted */ - } /* @@ -250,7 +249,7 @@ AcpiPsxExecute ( */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Begin Method Execution **** Entry=%p obj=%p\n", - MethodNode, ObjDesc)); + Info->Node, ObjDesc)); /* Create and init a Root Node */ @@ -263,8 +262,8 @@ AcpiPsxExecute ( /* Init new op with the method name and pointer back to the NS node */ - AcpiPsSetName (Op, MethodNode->Name.Integer); - Op->Common.Node = MethodNode; + AcpiPsSetName (Op, Info->Node->Name.Integer); + Op->Common.Node = Info->Node; /* Create and initialize a new walk state */ @@ -275,8 +274,9 @@ AcpiPsxExecute ( goto Cleanup2; } - Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, Params, ReturnObjDesc, 3); + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, Info, 3); if (ACPI_FAILURE (Status)) { goto Cleanup3; @@ -296,15 +296,16 @@ AcpiPsxExecute ( AcpiPsDeleteParseTree (Op); Cleanup1: - if (Params) + if ((Info->ParameterType == ACPI_PARAM_ARGS) && + (Info->Parameters)) { /* Take away the extra reference that we gave the parameters above */ - for (i = 0; Params[i]; i++) + for (i = 0; Info->Parameters[i]; i++) { /* Ignore errors, just do them all */ - (void) AcpiUtUpdateObjectReference (Params[i], REF_DECREMENT); + (void) AcpiUtUpdateObjectReference (Info->Parameters[i], REF_DECREMENT); } } @@ -317,11 +318,11 @@ AcpiPsxExecute ( * If the method has returned an object, signal this to the caller with * a control exception code */ - if (*ReturnObjDesc) + if (Info->ReturnObject) { ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", - *ReturnObjDesc)); - ACPI_DUMP_STACK_ENTRY (*ReturnObjDesc); + Info->ReturnObject)); + ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); Status = AE_CTRL_RETURN_VALUE; } diff --git a/sys/contrib/dev/acpica/rsutils.c b/sys/contrib/dev/acpica/rsutils.c index 42cd2c845ebd..4a438e61e0e7 100644 --- a/sys/contrib/dev/acpica/rsutils.c +++ b/sys/contrib/dev/acpica/rsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsutils - Utilities for the resource manager - * $Revision: 38 $ + * $Revision: 39 $ * ******************************************************************************/ @@ -367,6 +367,7 @@ AcpiRsSetSrsMethodData ( ACPI_HANDLE Handle, ACPI_BUFFER *InBuffer) { + ACPI_PARAMETER_INFO Info; ACPI_OPERAND_OBJECT *Params[2]; ACPI_STATUS Status; ACPI_BUFFER Buffer; @@ -409,10 +410,14 @@ AcpiRsSetSrsMethodData ( Params[0]->Common.Flags = AOPOBJ_DATA_VALID; Params[1] = NULL; + Info.Node = Handle; + Info.Parameters = Params; + Info.ParameterType = ACPI_PARAM_ARGS; + /* * Execute the method, no return value */ - Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL); + Status = AcpiNsEvaluateRelative ("_SRS", &Info); /* * Clean up and return the status from AcpiNsEvaluateRelative diff --git a/sys/contrib/dev/acpica/rsxface.c b/sys/contrib/dev/acpica/rsxface.c index b63d49a70914..cf55799c805d 100644 --- a/sys/contrib/dev/acpica/rsxface.c +++ b/sys/contrib/dev/acpica/rsxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsxface - Public interfaces to the resource manager - * $Revision: 29 $ + * $Revision: 30 $ * ******************************************************************************/ @@ -342,7 +342,8 @@ AcpiWalkResources ( /* Setup pointers */ Resource = (ACPI_RESOURCE *) Buffer.Pointer; - BufferEnd = (ACPI_RESOURCE *) ((UINT8 *) Buffer.Pointer + Buffer.Length); + BufferEnd = ACPI_CAST_PTR (ACPI_RESOURCE, + ((UINT8 *) Buffer.Pointer + Buffer.Length)); /* Walk the resource list */ diff --git a/sys/contrib/dev/acpica/uteval.c b/sys/contrib/dev/acpica/uteval.c index 635d711c820a..d977076bee1f 100644 --- a/sys/contrib/dev/acpica/uteval.c +++ b/sys/contrib/dev/acpica/uteval.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: uteval - Object evaluation - * $Revision: 52 $ + * $Revision: 54 $ * *****************************************************************************/ @@ -170,7 +170,7 @@ AcpiUtOsiImplementation ( for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { - if (!ACPI_STRCMP (StringDesc->String.Pointer, + if (!ACPI_STRCMP (StringDesc->String.Pointer, (char *) AcpiGbl_ValidOsiStrings[i])) { /* This string is supported */ @@ -211,7 +211,7 @@ AcpiUtEvaluateObject ( UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc) { - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARAMETER_INFO Info; ACPI_STATUS Status; UINT32 ReturnBtype; @@ -219,9 +219,13 @@ AcpiUtEvaluateObject ( ACPI_FUNCTION_TRACE ("UtEvaluateObject"); + Info.Node = PrefixNode; + Info.Parameters = NULL; + Info.ParameterType = ACPI_PARAM_ARGS; + /* Evaluate the object/method */ - Status = AcpiNsEvaluateRelative (PrefixNode, Path, NULL, &ObjDesc); + Status = AcpiNsEvaluateRelative (Path, &Info); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -240,7 +244,7 @@ AcpiUtEvaluateObject ( /* Did we get a return object? */ - if (!ObjDesc) + if (!Info.ReturnObject) { if (ExpectedReturnBtypes) { @@ -255,7 +259,7 @@ AcpiUtEvaluateObject ( /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ACPI_GET_OBJECT_TYPE (Info.ReturnObject)) { case ACPI_TYPE_INTEGER: ReturnBtype = ACPI_BTYPE_INTEGER; @@ -287,17 +291,17 @@ AcpiUtEvaluateObject ( ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Type returned from %s was incorrect: %X\n", - Path, ACPI_GET_OBJECT_TYPE (ObjDesc))); + Path, ACPI_GET_OBJECT_TYPE (Info.ReturnObject))); /* On error exit, we must delete the return object */ - AcpiUtRemoveReference (ObjDesc); + AcpiUtRemoveReference (Info.ReturnObject); return_ACPI_STATUS (AE_TYPE); } /* Object type is OK, return it */ - *ReturnDesc = ObjDesc; + *ReturnDesc = Info.ReturnObject; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/utglobal.c b/sys/contrib/dev/acpica/utglobal.c index 0db55dee0c7c..0825d2159b5d 100644 --- a/sys/contrib/dev/acpica/utglobal.c +++ b/sys/contrib/dev/acpica/utglobal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utglobal - Global variables for the ACPI subsystem - * $Revision: 198 $ + * $Revision: 201 $ * *****************************************************************************/ @@ -251,27 +251,40 @@ BOOLEAN AcpiGbl_Shutdown = TRUE; const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; -const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = { - "\\_S0_", - "\\_S1_", - "\\_S2_", - "\\_S3_", - "\\_S4_", - "\\_S5_"}; +const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = +{ + "\\_S0_", + "\\_S1_", + "\\_S2_", + "\\_S3_", + "\\_S4_", + "\\_S5_" +}; -const char *AcpiGbl_HighestDstateNames[4] = { - "_S1D", - "_S2D", - "_S3D", - "_S4D"}; +const char *AcpiGbl_HighestDstateNames[4] = +{ + "_S1D", + "_S2D", + "_S3D", + "_S4D" +}; -/* Strings supported by the _OSI predefined (internal) method */ - -const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = { - "Linux", - "Windows 2000", - "Windows 2001", - "Windows 2001.1"}; +/* + * Strings supported by the _OSI predefined (internal) method. + * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. + */ +const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = +{ + "Linux", + "Windows 2000", + "Windows 2001", + "Windows 2001.1", + "Windows 2001 SP0", + "Windows 2001 SP1", + "Windows 2001 SP2", + "Windows 2001 SP3", + "Windows 2001 SP4" +}; /****************************************************************************** @@ -294,7 +307,7 @@ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_SB_", ACPI_TYPE_DEVICE, NULL}, {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_TZ_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_TZ_", ACPI_TYPE_THERMAL, NULL}, {"_REV", ACPI_TYPE_INTEGER, "2"}, {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, {"_GL_", ACPI_TYPE_MUTEX, "0"}, @@ -968,6 +981,7 @@ AcpiUtInitGlobals ( /* Hardware oriented */ AcpiGbl_EventsInitialized = FALSE; + AcpiGbl_SystemAwakeAndRunning = TRUE; /* Namespace */ diff --git a/sys/contrib/dev/acpica/utxface.c b/sys/contrib/dev/acpica/utxface.c index 9eae1c1c9c9c..d327e2d962f6 100644 --- a/sys/contrib/dev/acpica/utxface.c +++ b/sys/contrib/dev/acpica/utxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utxface - External interfaces for "global" ACPI functions - * $Revision: 105 $ + * $Revision: 106 $ * *****************************************************************************/ @@ -237,9 +237,8 @@ AcpiEnableSubsystem ( } } - /* - * Enable ACPI mode - */ + /* Enable ACPI mode */ + if (!(Flags & ACPI_NO_ACPI_ENABLE)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); @@ -255,7 +254,23 @@ AcpiEnableSubsystem ( } /* - * Initialize ACPI Event handling + * Install the default OpRegion handlers. These are installed unless + * other handlers have already been installed via the + * InstallAddressSpaceHandler interface. + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize ACPI Event handling (Fixed and General Purpose) * * NOTE: We must have the hardware AND events initialized before we can execute * ANY control methods SAFELY. Any control method can require ACPI hardware @@ -265,20 +280,20 @@ AcpiEnableSubsystem ( { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); - Status = AcpiEvInitialize (); + Status = AcpiEvInitializeEvents (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } - /* Install the SCI handler, Global Lock handler, and GPE handlers */ + /* Install the SCI handler and Global Lock handler */ if (!(Flags & ACPI_NO_HANDLER_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL/GPE handlers\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); - Status = AcpiEvHandlerInitialize (); + Status = AcpiEvInstallXruptHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -312,19 +327,17 @@ AcpiInitializeObjects ( /* - * Install the default OpRegion handlers. These are installed unless - * other handlers have already been installed via the - * InstallAddressSpaceHandler interface. + * Run all _REG methods * - * NOTE: This will cause _REG methods to be run. Any objects accessed + * NOTE: Any objects accessed * by the _REG methods will be automatically initialized, even if they * contain executable AML (see call to AcpiNsInitializeObjects below). */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Executing _REG OpRegion methods\n")); - Status = AcpiEvInitAddressSpaces (); + Status = AcpiEvInitializeOpRegions (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -338,7 +351,7 @@ AcpiInitializeObjects ( */ if (!(Flags & ACPI_NO_OBJECT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Objects\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n")); Status = AcpiNsInitializeObjects (); if (ACPI_FAILURE (Status))