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 - 2008, Intel Corporation. All rights reserved.<BR>
7   This program and the accompanying materials
8   are licensed and made available under the terms and conditions of the BSD License
9   which accompanies this distribution.  The full text of the license may be found at
10   http://opensource.org/licenses/bsd-license.php
11 
12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 **/
15 
16 #ifndef __ARCH_PROTOCOL_WATCHDOG_TIMER_H__
17 #define __ARCH_PROTOCOL_WATCHDOG_TIMER_H__
18 
19 ///
20 /// Global ID for the Watchdog Timer Architectural Protocol
21 ///
22 #define EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID \
23   { 0x665E3FF5, 0x46CC, 0x11d4, {0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } }
24 
25 ///
26 /// Declare forward reference for the Timer Architectural Protocol
27 ///
28 typedef struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  EFI_WATCHDOG_TIMER_ARCH_PROTOCOL;
29 
30 /**
31   A function of this type is called when the watchdog timer fires if a
32   handler has been registered.
33 
34   @param  Time             The time in 100 ns units that has passed since the watchdog
35                            timer was armed. For the notify function to be called, this
36                            must be greater than TimerPeriod.
37 
38   @return None.
39 
40 **/
41 typedef
42 VOID
43 (EFIAPI *EFI_WATCHDOG_TIMER_NOTIFY)(
44   IN UINT64  Time
45   );
46 
47 /**
48   This function registers a handler that is to be invoked when the watchdog
49   timer fires.  By default, the EFI_WATCHDOG_TIMER protocol will call the
50   Runtime Service ResetSystem() when the watchdog timer fires.  If a
51   NotifyFunction is registered, then the NotifyFunction will be called before
52   the Runtime Service ResetSystem() is called.  If NotifyFunction is NULL, then
53   the watchdog handler is unregistered.  If a watchdog handler is registered,
54   then EFI_SUCCESS is returned.  If an attempt is made to register a handler
55   when a handler is already registered, then EFI_ALREADY_STARTED is returned.
56   If an attempt is made to uninstall a handler when a handler is not installed,
57   then return EFI_INVALID_PARAMETER.
58 
59   @param  This             The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
60   @param  NotifyFunction   The function to call when the watchdog timer fires. If this
61                            is NULL, then the handler will be unregistered.
62 
63   @retval EFI_SUCCESS           The watchdog timer handler was registered or
64                                 unregistered.
65   @retval EFI_ALREADY_STARTED   NotifyFunction is not NULL, and a handler is already
66                                 registered.
67   @retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a handler was not
68                                 previously registered.
69 
70 **/
71 typedef
72 EFI_STATUS
73 (EFIAPI *EFI_WATCHDOG_TIMER_REGISTER_HANDLER)(
74   IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,
75   IN EFI_WATCHDOG_TIMER_NOTIFY         NotifyFunction
76   );
77 
78 /**
79   This function sets the amount of time to wait before firing the watchdog
80   timer to TimerPeriod 100 nS units.  If TimerPeriod is 0, then the watchdog
81   timer is disabled.
82 
83   @param  This             The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
84   @param  TimerPeriod      The amount of time in 100 nS units to wait before the watchdog
85                            timer is fired. If TimerPeriod is zero, then the watchdog
86                            timer is disabled.
87 
88   @retval EFI_SUCCESS           The watchdog timer has been programmed to fire in Time
89                                 100 nS units.
90   @retval EFI_DEVICE_ERROR      A watchdog timer could not be programmed due to a device
91                                 error.
92 
93 **/
94 typedef
95 EFI_STATUS
96 (EFIAPI *EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD)(
97   IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,
98   IN UINT64                            TimerPeriod
99   );
100 
101 /**
102   This function retrieves the amount of time the system will wait before firing
103   the watchdog timer.  This period is returned in TimerPeriod, and EFI_SUCCESS
104   is returned.  If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned.
105 
106   @param  This             The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
107   @param  TimerPeriod      A pointer to the amount of time in 100 nS units that the system
108                            will wait before the watchdog timer is fired. If TimerPeriod of
109                            zero is returned, then the watchdog timer is disabled.
110 
111   @retval EFI_SUCCESS           The amount of time that the system will wait before
112                                 firing the watchdog timer was returned in TimerPeriod.
113   @retval EFI_INVALID_PARAMETER TimerPeriod is NULL.
114 
115 **/
116 typedef
117 EFI_STATUS
118 (EFIAPI *EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD)(
119   IN  EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,
120   OUT UINT64                            *TimerPeriod
121   );
122 
123 
124 ///
125 /// This protocol provides the services required to implement the Boot Service
126 /// SetWatchdogTimer().  It provides a service to set the amount of time to wait
127 /// before firing the watchdog timer, and it also provides a service to register
128 /// a handler that is invoked when the watchdog timer fires.  This protocol can
129 /// implement the watchdog timer by using the event and timer Boot Services, or
130 /// it can make use of custom hardware.  When the watchdog timer fires, control
131 /// will be passed to a handler if one has been registered.  If no handler has
132 /// been registered, or the registered handler returns, then the system will be
133 /// reset by calling the Runtime Service ResetSystem().
134 ///
135 struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL {
136   EFI_WATCHDOG_TIMER_REGISTER_HANDLER  RegisterHandler;
137   EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD  SetTimerPeriod;
138   EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD  GetTimerPeriod;
139 };
140 
141 extern EFI_GUID gEfiWatchdogTimerArchProtocolGuid;
142 
143 #endif
144 
145