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