summaryrefslogtreecommitdiff
path: root/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c')
-rw-r--r--ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c102
1 files changed, 61 insertions, 41 deletions
diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
index f79cc91..66c6c37 100644
--- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
+++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
@@ -25,18 +25,18 @@
/* The number of 100ns periods (the unit of time passed to these functions)
in a second */
-#define TIME_UNITS_PER_SECOND 10000000
+#define TIME_UNITS_PER_SECOND 10000000
// Tick frequency of the generic timer basis of the generic watchdog.
-STATIC UINTN mTimerFrequencyHz = 0;
+STATIC UINTN mTimerFrequencyHz = 0;
/* In cases where the compare register was set manually, information about
how long the watchdog was asked to wait cannot be retrieved from hardware.
It is therefore stored here. 0 means the timer is not running. */
-STATIC UINT64 mNumTimerTicks = 0;
+STATIC UINT64 mNumTimerTicks = 0;
-STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;
-STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify;
+STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;
+STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify;
STATIC
VOID
@@ -97,12 +97,12 @@ STATIC
VOID
EFIAPI
WatchdogInterruptHandler (
- IN HARDWARE_INTERRUPT_SOURCE Source,
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN HARDWARE_INTERRUPT_SOURCE Source,
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- STATIC CONST CHAR16 ResetString[]= L"The generic watchdog timer ran out.";
- UINT64 TimerPeriod;
+ STATIC CONST CHAR16 ResetString[] = L"The generic watchdog timer ran out.";
+ UINT64 TimerPeriod;
WatchdogDisable ();
@@ -119,8 +119,12 @@ WatchdogInterruptHandler (
mWatchdogNotify (TimerPeriod + 1);
}
- gRT->ResetSystem (EfiResetCold, EFI_TIMEOUT, StrSize (ResetString),
- (CHAR16 *)ResetString);
+ gRT->ResetSystem (
+ EfiResetCold,
+ EFI_TIMEOUT,
+ StrSize (ResetString),
+ (CHAR16 *)ResetString
+ );
// If we got here then the reset didn't work
ASSERT (FALSE);
@@ -154,15 +158,15 @@ STATIC
EFI_STATUS
EFIAPI
WatchdogRegisterHandler (
- IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
- IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
+ IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
)
{
- if (mWatchdogNotify == NULL && NotifyFunction == NULL) {
+ if ((mWatchdogNotify == NULL) && (NotifyFunction == NULL)) {
return EFI_INVALID_PARAMETER;
}
- if (mWatchdogNotify != NULL && NotifyFunction != NULL) {
+ if ((mWatchdogNotify != NULL) && (NotifyFunction != NULL)) {
return EFI_ALREADY_STARTED;
}
@@ -188,11 +192,11 @@ STATIC
EFI_STATUS
EFIAPI
WatchdogSetTimerPeriod (
- IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
- IN UINT64 TimerPeriod // In 100ns units
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
+ IN UINT64 TimerPeriod // In 100ns units
)
{
- UINTN SystemCount;
+ UINTN SystemCount;
// if TimerPeriod is 0, this is a request to stop the watchdog.
if (TimerPeriod == 0) {
@@ -244,8 +248,8 @@ STATIC
EFI_STATUS
EFIAPI
WatchdogGetTimerPeriod (
- IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
- OUT UINT64 *TimerPeriod
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
+ OUT UINT64 *TimerPeriod
)
{
if (TimerPeriod == NULL) {
@@ -289,26 +293,29 @@ WatchdogGetTimerPeriod (
Retrieves the period of the timer interrupt in 100ns units.
**/
-STATIC EFI_WATCHDOG_TIMER_ARCH_PROTOCOL mWatchdogTimer = {
+STATIC EFI_WATCHDOG_TIMER_ARCH_PROTOCOL mWatchdogTimer = {
WatchdogRegisterHandler,
WatchdogSetTimerPeriod,
WatchdogGetTimerPeriod
};
-STATIC EFI_EVENT mEfiExitBootServicesEvent;
+STATIC EFI_EVENT mEfiExitBootServicesEvent;
EFI_STATUS
EFIAPI
GenericWatchdogEntry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
-
- Status = gBS->LocateProtocol (&gHardwareInterrupt2ProtocolGuid, NULL,
- (VOID **)&mInterruptProtocol);
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Status = gBS->LocateProtocol (
+ &gHardwareInterrupt2ProtocolGuid,
+ NULL,
+ (VOID **)&mInterruptProtocol
+ );
ASSERT_EFI_ERROR (Status);
/* Make sure the Watchdog Timer Architectural Protocol has not been installed
@@ -320,33 +327,44 @@ GenericWatchdogEntry (
ASSERT (mTimerFrequencyHz != 0);
// Install interrupt handler
- Status = mInterruptProtocol->RegisterInterruptSource (mInterruptProtocol,
+ Status = mInterruptProtocol->RegisterInterruptSource (
+ mInterruptProtocol,
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
- WatchdogInterruptHandler);
+ WatchdogInterruptHandler
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- Status = mInterruptProtocol->SetTriggerType (mInterruptProtocol,
+ Status = mInterruptProtocol->SetTriggerType (
+ mInterruptProtocol,
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
- EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING);
+ EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING
+ );
if (EFI_ERROR (Status)) {
goto UnregisterHandler;
}
// Install the Timer Architectural Protocol onto a new handle
Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
- &gEfiWatchdogTimerArchProtocolGuid, &mWatchdogTimer,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiWatchdogTimerArchProtocolGuid,
+ &mWatchdogTimer,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto UnregisterHandler;
}
// Register for an ExitBootServicesEvent
- Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY,
- WatchdogExitBootServicesEvent, NULL,
- &mEfiExitBootServicesEvent);
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_NOTIFY,
+ WatchdogExitBootServicesEvent,
+ NULL,
+ &mEfiExitBootServicesEvent
+ );
ASSERT_EFI_ERROR (Status);
mNumTimerTicks = 0;
@@ -356,8 +374,10 @@ GenericWatchdogEntry (
UnregisterHandler:
// Unregister the handler
- mInterruptProtocol->RegisterInterruptSource (mInterruptProtocol,
+ mInterruptProtocol->RegisterInterruptSource (
+ mInterruptProtocol,
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
- NULL);
+ NULL
+ );
return Status;
}