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>
This commit is contained in:
Rebecca Cran 2024-01-29 11:25:13 -07:00 committed by mergify[bot]
parent 9ac93da5b5
commit 909a9a5ae4
1 changed files with 17 additions and 4 deletions

View File

@ -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.
@ -119,6 +123,7 @@ WatchdogExitBootServicesEvent (
{
WatchdogDisable ();
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 (