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