diff options
author | Rebecca Cran <rebecca@os.amperecomputing.com> | 2024-01-29 11:25:13 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-01-30 15:01:17 +0000 |
commit | 909a9a5ae4b8236c1ca7cad7f214c752a579bd67 (patch) | |
tree | 31133f6c7f400bc7e1dd3eccde758a702f44b7ce | |
parent | 9ac93da5b55bab8eed81016dbf33509b9d98f370 (diff) | |
download | edk2-909a9a5ae4b8236c1ca7cad7f214c752a579bd67.zip edk2-909a9a5ae4b8236c1ca7cad7f214c752a579bd67.tar.gz edk2-909a9a5ae4b8236c1ca7cad7f214c752a579bd67.tar.bz2 |
ArmPkg: Disable watchdog interaction after exiting boot services
Update GenericWatchdogDxe to disable watchdog interaction after exiting
boot services. Also, move the mEfiExitBootServicesEvent event to the top
of the file with the other static variables.
Signed-off-by: Rebecca Cran <rebecca@os.amperecomputing.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
-rw-r--r-- | ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index fdcda2b..5bff073 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c @@ -33,10 +33,14 @@ It is therefore stored here. 0 means the timer is not running. */
STATIC UINT64 mTimerPeriod = 0;
+/* disables watchdog interaction after Exit Boot Services */
+STATIC BOOLEAN mExitedBootServices = FALSE;
+
#define MAX_UINT48 0xFFFFFFFFFFFFULL
STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;
STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify;
+STATIC EFI_EVENT mEfiExitBootServicesEvent;
/**
This function returns the maximum watchdog offset register value.
@@ -118,7 +122,8 @@ WatchdogExitBootServicesEvent ( )
{
WatchdogDisable ();
- mTimerPeriod = 0;
+ mTimerPeriod = 0;
+ mExitedBootServices = TRUE;
}
/* This function is called when the watchdog's first signal (WS0) goes high.
@@ -215,6 +220,8 @@ WatchdogRegisterHandler ( @retval EFI_SUCCESS The watchdog timer has been programmed to fire
in TimerPeriod 100ns units.
+ @retval EFI_DEVICE_ERROR Boot Services has been exited but TimerPeriod
+ is not zero.
**/
STATIC
@@ -230,7 +237,15 @@ WatchdogSetTimerPeriod ( UINT64 TimerFrequencyHz;
UINT64 NumTimerTicks;
- // if TimerPeriod is 0, this is a request to stop the watchdog.
+ // If we've exited Boot Services but TimerPeriod isn't zero, this
+ // indicates that the caller is doing something wrong.
+ if (mExitedBootServices && (TimerPeriod != 0)) {
+ mTimerPeriod = 0;
+ WatchdogDisable ();
+ return EFI_DEVICE_ERROR;
+ }
+
+ // If TimerPeriod is 0 this is a request to stop the watchdog.
if (TimerPeriod == 0) {
mTimerPeriod = 0;
WatchdogDisable ();
@@ -335,8 +350,6 @@ STATIC EFI_WATCHDOG_TIMER_ARCH_PROTOCOL mWatchdogTimer = { WatchdogGetTimerPeriod
};
-STATIC EFI_EVENT mEfiExitBootServicesEvent;
-
EFI_STATUS
EFIAPI
GenericWatchdogEntry (
|