TianoCore EDK2 master
Loading...
Searching...
No Matches
GenericWatchdogDxe.c File Reference

Go to the source code of this file.

Macros

#define TIME_UNITS_PER_SECOND   10000000
 
#define MAX_UINT48   0xFFFFFFFFFFFFULL
 

Functions

STATIC UINT64 GetMaxWatchdogOffsetRegisterValue (VOID)
 
STATIC VOID WatchdogWriteOffsetRegister (UINT64 Value)
 
STATIC VOID WatchdogWriteCompareRegister (UINT64 Value)
 
STATIC VOID WatchdogEnable (VOID)
 
STATIC VOID WatchdogDisable (VOID)
 
STATIC VOID EFIAPI WatchdogExitBootServicesEvent (IN EFI_EVENT Event, IN VOID *Context)
 
STATIC VOID EFIAPI WatchdogInterruptHandler (IN HARDWARE_INTERRUPT_SOURCE Source, IN EFI_SYSTEM_CONTEXT SystemContext)
 
STATIC EFI_STATUS EFIAPI WatchdogRegisterHandler (IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction)
 
STATIC EFI_STATUS EFIAPI WatchdogSetTimerPeriod (IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, IN UINT64 TimerPeriod)
 
STATIC EFI_STATUS EFIAPI WatchdogGetTimerPeriod (IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, OUT UINT64 *TimerPeriod)
 
EFI_STATUS EFIAPI GenericWatchdogEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC UINT64 mTimerPeriod = 0
 
STATIC BOOLEAN mExitedBootServices = FALSE
 
STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOLmInterruptProtocol
 
STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify
 
STATIC EFI_EVENT mEfiExitBootServicesEvent
 
STATIC EFI_WATCHDOG_TIMER_ARCH_PROTOCOL mWatchdogTimer
 

Detailed Description

Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
Copyright (c) 2013-2018, ARM Limited. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file GenericWatchdogDxe.c.

Macro Definition Documentation

◆ MAX_UINT48

#define MAX_UINT48   0xFFFFFFFFFFFFULL

Definition at line 39 of file GenericWatchdogDxe.c.

◆ TIME_UNITS_PER_SECOND

#define TIME_UNITS_PER_SECOND   10000000

Definition at line 29 of file GenericWatchdogDxe.c.

Function Documentation

◆ GenericWatchdogEntry()

EFI_STATUS EFIAPI GenericWatchdogEntry ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Definition at line 355 of file GenericWatchdogDxe.c.

◆ GetMaxWatchdogOffsetRegisterValue()

STATIC UINT64 GetMaxWatchdogOffsetRegisterValue ( VOID  )

This function returns the maximum watchdog offset register value.

Return values
MAX_UINT32The watchdog offset register holds a 32-bit value.
MAX_UINT48The watchdog offset register holds a 48-bit value.

Definition at line 53 of file GenericWatchdogDxe.c.

◆ WatchdogDisable()

STATIC VOID WatchdogDisable ( VOID  )

Definition at line 106 of file GenericWatchdogDxe.c.

◆ WatchdogEnable()

STATIC VOID WatchdogEnable ( VOID  )

Definition at line 97 of file GenericWatchdogDxe.c.

◆ WatchdogExitBootServicesEvent()

STATIC VOID EFIAPI WatchdogExitBootServicesEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

On exiting boot services we must make sure the Watchdog Timer is stopped.

Definition at line 119 of file GenericWatchdogDxe.c.

◆ WatchdogGetTimerPeriod()

STATIC EFI_STATUS EFIAPI WatchdogGetTimerPeriod ( IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL This,
OUT UINT64 *  TimerPeriod 
)

This function retrieves the period of timer interrupts in 100ns units, returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is returned, then the timer is currently disabled.

Parameters
ThisThe EFI_TIMER_ARCH_PROTOCOL instance.
TimerPeriodA pointer to the timer period to retrieve in 100ns units. If 0 is returned, then the timer is currently disabled.
Return values
EFI_SUCCESSThe timer period was returned in TimerPeriod.
EFI_INVALID_PARAMETERTimerPeriod is NULL.

Definition at line 301 of file GenericWatchdogDxe.c.

◆ WatchdogInterruptHandler()

STATIC VOID EFIAPI WatchdogInterruptHandler ( IN HARDWARE_INTERRUPT_SOURCE  Source,
IN EFI_SYSTEM_CONTEXT  SystemContext 
)

Definition at line 135 of file GenericWatchdogDxe.c.

◆ WatchdogRegisterHandler()

STATIC EFI_STATUS EFIAPI WatchdogRegisterHandler ( IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL This,
IN EFI_WATCHDOG_TIMER_NOTIFY  NotifyFunction 
)

This function registers the handler NotifyFunction so it is called every time the watchdog timer expires. It also passes the amount of time since the last handler call to the NotifyFunction. If NotifyFunction is not NULL and a handler is not already registered, then the new handler is registered and EFI_SUCCESS is returned. If NotifyFunction is NULL, and a handler is already registered, then that handler is unregistered. If an attempt is made to register a handler when a handler is already registered, then EFI_ALREADY_STARTED is returned. If an attempt is made to unregister a handler when a handler is not registered, then EFI_INVALID_PARAMETER is returned.

Parameters
ThisThe EFI_TIMER_ARCH_PROTOCOL instance.
NotifyFunctionThe function to call when a timer interrupt fires. This function executes at TPL_HIGH_LEVEL. The DXE Core will register a handler for the timer interrupt, so it can know how much time has passed. This information is used to signal timer based events. NULL will unregister the handler.
Return values
EFI_UNSUPPORTEDThe code does not support NotifyFunction.

Definition at line 194 of file GenericWatchdogDxe.c.

◆ WatchdogSetTimerPeriod()

STATIC EFI_STATUS EFIAPI WatchdogSetTimerPeriod ( IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL This,
IN UINT64  TimerPeriod 
)

This function sets the amount of time to wait before firing the watchdog timer to TimerPeriod 100ns units. If TimerPeriod is 0, then the watchdog timer is disabled.

Parameters
ThisThe EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
TimerPeriodThe amount of time in 100ns units to wait before the watchdog timer is fired. If TimerPeriod is zero, then the watchdog timer is disabled.
Return values
EFI_SUCCESSThe watchdog timer has been programmed to fire in TimerPeriod 100ns units.
EFI_DEVICE_ERRORBoot Services has been exited but TimerPeriod is not zero.

Definition at line 230 of file GenericWatchdogDxe.c.

◆ WatchdogWriteCompareRegister()

STATIC VOID WatchdogWriteCompareRegister ( UINT64  Value)

Definition at line 87 of file GenericWatchdogDxe.c.

◆ WatchdogWriteOffsetRegister()

STATIC VOID WatchdogWriteOffsetRegister ( UINT64  Value)

Definition at line 75 of file GenericWatchdogDxe.c.

Variable Documentation

◆ mEfiExitBootServicesEvent

STATIC EFI_EVENT mEfiExitBootServicesEvent

Definition at line 43 of file GenericWatchdogDxe.c.

◆ mExitedBootServices

STATIC BOOLEAN mExitedBootServices = FALSE

Definition at line 37 of file GenericWatchdogDxe.c.

◆ mInterruptProtocol

Definition at line 41 of file GenericWatchdogDxe.c.

◆ mTimerPeriod

STATIC UINT64 mTimerPeriod = 0

Definition at line 34 of file GenericWatchdogDxe.c.

◆ mWatchdogNotify

Definition at line 42 of file GenericWatchdogDxe.c.

◆ mWatchdogTimer

Initial value:
= {
}
STATIC EFI_STATUS EFIAPI WatchdogRegisterHandler(IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction)
STATIC EFI_STATUS EFIAPI WatchdogGetTimerPeriod(IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, OUT UINT64 *TimerPeriod)
STATIC EFI_STATUS EFIAPI WatchdogSetTimerPeriod(IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, IN UINT64 TimerPeriod)

Interface structure for the Watchdog Architectural Protocol.

Protocol Description:
This protocol provides a service to set the amount of time to wait before firing the watchdog timer, and it also provides a service to register a handler that is invoked when the watchdog timer fires.
When the watchdog timer fires, control will be passed to a handler
if one has been registered. If no handler has been registered, or the registered handler returns, then the system will be reset by calling the Runtime Service ResetSystem().
Parameters
RegisterHandlerRegisters a handler that will be called each time the watchdogtimer interrupt fires. TimerPeriod defines the minimum time between timer interrupts, so TimerPeriod will also be the minimum time between calls to the registered handler. NOTE: If the watchdog resets the system in hardware, then this function will not have any chance of executing.
SetTimerPeriodSets the period of the timer interrupt in 100ns units. This function is optional, and may return EFI_UNSUPPORTED. If this function is supported, then the timer period will be rounded up to the nearest supported timer period.
GetTimerPeriodRetrieves the period of the timer interrupt in 100ns units.

Definition at line 347 of file GenericWatchdogDxe.c.