xref: /freebsd/sys/contrib/edk2/Include/Protocol/WatchdogTimer.h (revision f439973d6726c3be929c8fb3b1545b8b1744abc3)
1*f439973dSWarner Losh /** @file
2*f439973dSWarner Losh   Watchdog Timer Architectural Protocol as defined in PI Specification VOLUME 2 DXE
3*f439973dSWarner Losh 
4*f439973dSWarner Losh   Used to provide system watchdog timer services
5*f439973dSWarner Losh 
6*f439973dSWarner Losh   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7*f439973dSWarner Losh   SPDX-License-Identifier: BSD-2-Clause-Patent
8*f439973dSWarner Losh **/
9*f439973dSWarner Losh 
10*f439973dSWarner Losh #ifndef __ARCH_PROTOCOL_WATCHDOG_TIMER_H__
11*f439973dSWarner Losh #define __ARCH_PROTOCOL_WATCHDOG_TIMER_H__
12*f439973dSWarner Losh 
13*f439973dSWarner Losh ///
14*f439973dSWarner Losh /// Global ID for the Watchdog Timer Architectural Protocol
15*f439973dSWarner Losh ///
16*f439973dSWarner Losh #define EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID \
17*f439973dSWarner Losh   { 0x665E3FF5, 0x46CC, 0x11d4, {0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } }
18*f439973dSWarner Losh 
19*f439973dSWarner Losh ///
20*f439973dSWarner Losh /// Declare forward reference for the Timer Architectural Protocol
21*f439973dSWarner Losh ///
22*f439973dSWarner Losh typedef struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL EFI_WATCHDOG_TIMER_ARCH_PROTOCOL;
23*f439973dSWarner Losh 
24*f439973dSWarner Losh /**
25*f439973dSWarner Losh   A function of this type is called when the watchdog timer fires if a
26*f439973dSWarner Losh   handler has been registered.
27*f439973dSWarner Losh 
28*f439973dSWarner Losh   @param  Time             The time in 100 ns units that has passed since the watchdog
29*f439973dSWarner Losh                            timer was armed. For the notify function to be called, this
30*f439973dSWarner Losh                            must be greater than TimerPeriod.
31*f439973dSWarner Losh 
32*f439973dSWarner Losh   @return None.
33*f439973dSWarner Losh 
34*f439973dSWarner Losh **/
35*f439973dSWarner Losh typedef
36*f439973dSWarner Losh VOID
37*f439973dSWarner Losh (EFIAPI *EFI_WATCHDOG_TIMER_NOTIFY)(
38*f439973dSWarner Losh   IN UINT64  Time
39*f439973dSWarner Losh   );
40*f439973dSWarner Losh 
41*f439973dSWarner Losh /**
42*f439973dSWarner Losh   This function registers a handler that is to be invoked when the watchdog
43*f439973dSWarner Losh   timer fires.  By default, the EFI_WATCHDOG_TIMER protocol will call the
44*f439973dSWarner Losh   Runtime Service ResetSystem() when the watchdog timer fires.  If a
45*f439973dSWarner Losh   NotifyFunction is registered, then the NotifyFunction will be called before
46*f439973dSWarner Losh   the Runtime Service ResetSystem() is called.  If NotifyFunction is NULL, then
47*f439973dSWarner Losh   the watchdog handler is unregistered.  If a watchdog handler is registered,
48*f439973dSWarner Losh   then EFI_SUCCESS is returned.  If an attempt is made to register a handler
49*f439973dSWarner Losh   when a handler is already registered, then EFI_ALREADY_STARTED is returned.
50*f439973dSWarner Losh   If an attempt is made to uninstall a handler when a handler is not installed,
51*f439973dSWarner Losh   then return EFI_INVALID_PARAMETER.
52*f439973dSWarner Losh 
53*f439973dSWarner Losh   @param  This             The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
54*f439973dSWarner Losh   @param  NotifyFunction   The function to call when the watchdog timer fires. If this
55*f439973dSWarner Losh                            is NULL, then the handler will be unregistered.
56*f439973dSWarner Losh 
57*f439973dSWarner Losh   @retval EFI_SUCCESS           The watchdog timer handler was registered or
58*f439973dSWarner Losh                                 unregistered.
59*f439973dSWarner Losh   @retval EFI_ALREADY_STARTED   NotifyFunction is not NULL, and a handler is already
60*f439973dSWarner Losh                                 registered.
61*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a handler was not
62*f439973dSWarner Losh                                 previously registered.
63*f439973dSWarner Losh 
64*f439973dSWarner Losh **/
65*f439973dSWarner Losh typedef
66*f439973dSWarner Losh EFI_STATUS
67*f439973dSWarner Losh (EFIAPI *EFI_WATCHDOG_TIMER_REGISTER_HANDLER)(
68*f439973dSWarner Losh   IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,
69*f439973dSWarner Losh   IN EFI_WATCHDOG_TIMER_NOTIFY         NotifyFunction
70*f439973dSWarner Losh   );
71*f439973dSWarner Losh 
72*f439973dSWarner Losh /**
73*f439973dSWarner Losh   This function sets the amount of time to wait before firing the watchdog
74*f439973dSWarner Losh   timer to TimerPeriod 100 nS units.  If TimerPeriod is 0, then the watchdog
75*f439973dSWarner Losh   timer is disabled.
76*f439973dSWarner Losh 
77*f439973dSWarner Losh   @param  This             The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
78*f439973dSWarner Losh   @param  TimerPeriod      The amount of time in 100 nS units to wait before the watchdog
79*f439973dSWarner Losh                            timer is fired. If TimerPeriod is zero, then the watchdog
80*f439973dSWarner Losh                            timer is disabled.
81*f439973dSWarner Losh 
82*f439973dSWarner Losh   @retval EFI_SUCCESS           The watchdog timer has been programmed to fire in Time
83*f439973dSWarner Losh                                 100 nS units.
84*f439973dSWarner Losh   @retval EFI_DEVICE_ERROR      A watchdog timer could not be programmed due to a device
85*f439973dSWarner Losh                                 error.
86*f439973dSWarner Losh 
87*f439973dSWarner Losh **/
88*f439973dSWarner Losh typedef
89*f439973dSWarner Losh EFI_STATUS
90*f439973dSWarner Losh (EFIAPI *EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD)(
91*f439973dSWarner Losh   IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,
92*f439973dSWarner Losh   IN UINT64                            TimerPeriod
93*f439973dSWarner Losh   );
94*f439973dSWarner Losh 
95*f439973dSWarner Losh /**
96*f439973dSWarner Losh   This function retrieves the amount of time the system will wait before firing
97*f439973dSWarner Losh   the watchdog timer.  This period is returned in TimerPeriod, and EFI_SUCCESS
98*f439973dSWarner Losh   is returned.  If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned.
99*f439973dSWarner Losh 
100*f439973dSWarner Losh   @param  This             The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
101*f439973dSWarner Losh   @param  TimerPeriod      A pointer to the amount of time in 100 nS units that the system
102*f439973dSWarner Losh                            will wait before the watchdog timer is fired. If TimerPeriod of
103*f439973dSWarner Losh                            zero is returned, then the watchdog timer is disabled.
104*f439973dSWarner Losh 
105*f439973dSWarner Losh   @retval EFI_SUCCESS           The amount of time that the system will wait before
106*f439973dSWarner Losh                                 firing the watchdog timer was returned in TimerPeriod.
107*f439973dSWarner Losh   @retval EFI_INVALID_PARAMETER TimerPeriod is NULL.
108*f439973dSWarner Losh 
109*f439973dSWarner Losh **/
110*f439973dSWarner Losh typedef
111*f439973dSWarner Losh EFI_STATUS
112*f439973dSWarner Losh (EFIAPI *EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD)(
113*f439973dSWarner Losh   IN  EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,
114*f439973dSWarner Losh   OUT UINT64                            *TimerPeriod
115*f439973dSWarner Losh   );
116*f439973dSWarner Losh 
117*f439973dSWarner Losh ///
118*f439973dSWarner Losh /// This protocol provides the services required to implement the Boot Service
119*f439973dSWarner Losh /// SetWatchdogTimer().  It provides a service to set the amount of time to wait
120*f439973dSWarner Losh /// before firing the watchdog timer, and it also provides a service to register
121*f439973dSWarner Losh /// a handler that is invoked when the watchdog timer fires.  This protocol can
122*f439973dSWarner Losh /// implement the watchdog timer by using the event and timer Boot Services, or
123*f439973dSWarner Losh /// it can make use of custom hardware.  When the watchdog timer fires, control
124*f439973dSWarner Losh /// will be passed to a handler if one has been registered.  If no handler has
125*f439973dSWarner Losh /// been registered, or the registered handler returns, then the system will be
126*f439973dSWarner Losh /// reset by calling the Runtime Service ResetSystem().
127*f439973dSWarner Losh ///
128*f439973dSWarner Losh struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL {
129*f439973dSWarner Losh   EFI_WATCHDOG_TIMER_REGISTER_HANDLER    RegisterHandler;
130*f439973dSWarner Losh   EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD    SetTimerPeriod;
131*f439973dSWarner Losh   EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD    GetTimerPeriod;
132*f439973dSWarner Losh };
133*f439973dSWarner Losh 
134*f439973dSWarner Losh extern EFI_GUID  gEfiWatchdogTimerArchProtocolGuid;
135*f439973dSWarner Losh 
136*f439973dSWarner Losh #endif
137