summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
index fdcda2be1b..5bff073bc5 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 (