summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d3b0593)
Even though UEFI does not appear to use it, let's implement the
complete PI watchdog protocol, including handler registration,
which will be invoked before the ResetSystem() runtime service
when the watchdog timer expires.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
STATIC UINT64 mNumTimerTicks = 0;\r
\r
STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;\r
STATIC UINT64 mNumTimerTicks = 0;\r
\r
STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;\r
+STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify;\r
)\r
{\r
STATIC CONST CHAR16 ResetString[]= L"The generic watchdog timer ran out.";\r
)\r
{\r
STATIC CONST CHAR16 ResetString[]= L"The generic watchdog timer ran out.";\r
\r
WatchdogDisable ();\r
\r
mInterruptProtocol->EndOfInterrupt (mInterruptProtocol, Source);\r
\r
\r
WatchdogDisable ();\r
\r
mInterruptProtocol->EndOfInterrupt (mInterruptProtocol, Source);\r
\r
- gRT->ResetSystem (\r
- EfiResetCold,\r
- EFI_TIMEOUT,\r
- StrSize (ResetString),\r
- (VOID *) &ResetString\r
- );\r
+ //\r
+ // The notify function should be called with the elapsed number of ticks\r
+ // since the watchdog was armed, which should exceed the timer period.\r
+ // We don't actually know the elapsed number of ticks, so let's return\r
+ // the timer period plus 1.\r
+ //\r
+ if (mWatchdogNotify != NULL) {\r
+ TimerPeriod = ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * mNumTimerTicks);\r
+ mWatchdogNotify (TimerPeriod + 1);\r
+ }\r
+\r
+ gRT->ResetSystem (EfiResetCold, EFI_TIMEOUT, StrSize (ResetString),\r
+ (CHAR16 *)ResetString);\r
\r
// If we got here then the reset didn't work\r
ASSERT (FALSE);\r
\r
// If we got here then the reset didn't work\r
ASSERT (FALSE);\r
IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction\r
)\r
{\r
IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction\r
)\r
{\r
- // ERROR: This function is not supported.\r
- // The watchdog will reset the board\r
- return EFI_UNSUPPORTED;\r
+ if (mWatchdogNotify == NULL && NotifyFunction == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (mWatchdogNotify != NULL && NotifyFunction != NULL) {\r
+ return EFI_ALREADY_STARTED;\r
+ }\r
+\r
+ mWatchdogNotify = NotifyFunction;\r
+ return EFI_SUCCESS;\r