]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2004, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Timer.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Timer Architectural Protocol as defined in the DXE CIS\r | |
19 | \r | |
20 | This code is used to provide the timer tick for the DXE core.\r | |
21 | \r | |
22 | --*/\r | |
23 | \r | |
24 | #ifndef _ARCH_PROTOCOL_TIMER_H_\r | |
25 | #define _ARCH_PROTOCOL_TIMER_H_\r | |
26 | \r | |
27 | //\r | |
28 | // Global ID for the Timer Architectural Protocol\r | |
29 | //\r | |
30 | #define EFI_TIMER_ARCH_PROTOCOL_GUID \\r | |
31 | { 0x26baccb3, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }\r | |
32 | \r | |
33 | //\r | |
34 | // Declare forward reference for the Timer Architectural Protocol\r | |
35 | //\r | |
36 | EFI_FORWARD_DECLARATION (EFI_TIMER_ARCH_PROTOCOL);\r | |
37 | \r | |
38 | typedef\r | |
39 | VOID\r | |
40 | (EFIAPI *EFI_TIMER_NOTIFY) (\r | |
41 | IN UINT64 Time\r | |
42 | );\r | |
43 | /*++\r | |
44 | \r | |
45 | Routine Description:\r | |
46 | \r | |
47 | This function of this type is called when a timer interrupt fires. This \r | |
48 | function executes at TPL_HIGH_LEVEL. The DXE Core will register a funtion\r | |
49 | of tyis type to be called for the timer interrupt, so it can know how much \r | |
50 | time has passed. This information is used to signal timer based events. \r | |
51 | \r | |
52 | Arguments:\r | |
53 | \r | |
54 | Time - Time since the last timer interrupt in 100 ns units. This will \r | |
55 | typically be TimerPeriod, but if a timer interrupt is missed, and the \r | |
56 | EFI_TIMER_ARCH_PROTOCOL driver can detect missed interrupts, then Time \r | |
57 | will contain the actual amount of time since the last interrupt.\r | |
58 | \r | |
59 | Returns: \r | |
60 | \r | |
61 | None.\r | |
62 | \r | |
63 | --*/\r | |
64 | \r | |
65 | typedef \r | |
66 | EFI_STATUS\r | |
67 | (EFIAPI *EFI_TIMER_REGISTER_HANDLER) (\r | |
68 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r | |
69 | IN EFI_TIMER_NOTIFY NotifyFunction\r | |
70 | );\r | |
71 | /*++\r | |
72 | \r | |
73 | Routine Description:\r | |
74 | \r | |
75 | This function registers the handler NotifyFunction so it is called every time \r | |
76 | the timer interrupt fires. It also passes the amount of time since the last \r | |
77 | handler call to the NotifyFunction. If NotifyFunction is NULL, then the \r | |
78 | handler is unregistered. If the handler is registered, then EFI_SUCCESS is \r | |
79 | returned. If the CPU does not support registering a timer interrupt handler, \r | |
80 | then EFI_UNSUPPORTED is returned. If an attempt is made to register a handler \r | |
81 | when a handler is already registered, then EFI_ALREADY_STARTED is returned. \r | |
82 | If an attempt is made to unregister a handler when a handler is not registered, \r | |
83 | then EFI_INVALID_PARAMETER is returned. If an error occurs attempting to \r | |
84 | register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR \r | |
85 | is returned.\r | |
86 | \r | |
87 | Arguments:\r | |
88 | \r | |
89 | This - The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
90 | \r | |
91 | NotifyFunction - The function to call when a timer interrupt fires. This \r | |
92 | function executes at TPL_HIGH_LEVEL. The DXE Core will \r | |
93 | register a handler for the timer interrupt, so it can know \r | |
94 | how much time has passed. This information is used to \r | |
95 | signal timer based events. NULL will unregister the handler.\r | |
96 | \r | |
97 | Returns: \r | |
98 | \r | |
99 | EFI_SUCCESS - The timer handler was registered.\r | |
100 | \r | |
101 | EFI_UNSUPPORTED - The platform does not support timer interrupts.\r | |
102 | \r | |
103 | EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already \r | |
104 | registered.\r | |
105 | \r | |
106 | EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not \r | |
107 | previously registered.\r | |
108 | \r | |
109 | EFI_DEVICE_ERROR - The timer handler could not be registered.\r | |
110 | \r | |
111 | --*/\r | |
112 | \r | |
113 | typedef \r | |
114 | EFI_STATUS\r | |
115 | (EFIAPI *EFI_TIMER_SET_TIMER_PERIOD) (\r | |
116 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r | |
117 | IN UINT64 TimerPeriod\r | |
118 | );\r | |
119 | /*++\r | |
120 | \r | |
121 | Routine Description:\r | |
122 | \r | |
123 | This function adjusts the period of timer interrupts to the value specified \r | |
124 | by TimerPeriod. If the timer period is updated, then the selected timer \r | |
125 | period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If \r | |
126 | the timer hardware is not programmable, then EFI_UNSUPPORTED is returned. \r | |
127 | If an error occurs while attempting to update the timer period, then the \r | |
128 | timer hardware will be put back in its state prior to this call, and \r | |
129 | EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt \r | |
130 | is disabled. This is not the same as disabling the CPU's interrupts. \r | |
131 | Instead, it must either turn off the timer hardware, or it must adjust the \r | |
132 | interrupt controller so that a CPU interrupt is not generated when the timer \r | |
133 | interrupt fires. \r | |
134 | \r | |
135 | Arguments:\r | |
136 | \r | |
137 | This - The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
138 | \r | |
139 | TimerPeriod - The rate to program the timer interrupt in 100 nS units. If \r | |
140 | the timer hardware is not programmable, then EFI_UNSUPPORTED is \r | |
141 | returned. If the timer is programmable, then the timer period \r | |
142 | will be rounded up to the nearest timer period that is supported \r | |
143 | by the timer hardware. If TimerPeriod is set to 0, then the \r | |
144 | timer interrupts will be disabled.\r | |
145 | \r | |
146 | Returns: \r | |
147 | \r | |
148 | EFI_SUCCESS - The timer period was changed.\r | |
149 | \r | |
150 | EFI_UNSUPPORTED - The platform cannot change the period of the timer interrupt.\r | |
151 | \r | |
152 | EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.\r | |
153 | \r | |
154 | --*/\r | |
155 | \r | |
156 | typedef \r | |
157 | EFI_STATUS\r | |
158 | (EFIAPI *EFI_TIMER_GET_TIMER_PERIOD) (\r | |
159 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r | |
160 | OUT UINT64 *TimerPeriod\r | |
161 | );\r | |
162 | /*++\r | |
163 | \r | |
164 | Routine Description:\r | |
165 | \r | |
166 | This function retrieves the period of timer interrupts in 100 ns units, \r | |
167 | returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod \r | |
168 | is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is \r | |
169 | returned, then the timer is currently disabled.\r | |
170 | \r | |
171 | Arguments:\r | |
172 | \r | |
173 | This - The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
174 | \r | |
175 | TimerPeriod - A pointer to the timer period to retrieve in 100 ns units. If \r | |
176 | 0 is returned, then the timer is currently disabled.\r | |
177 | \r | |
178 | Returns: \r | |
179 | \r | |
180 | EFI_SUCCESS - The timer period was returned in TimerPeriod.\r | |
181 | \r | |
182 | EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r | |
183 | \r | |
184 | --*/\r | |
185 | \r | |
186 | typedef \r | |
187 | EFI_STATUS\r | |
188 | (EFIAPI *EFI_TIMER_GENERATE_SOFT_INTERRUPT) (\r | |
189 | IN EFI_TIMER_ARCH_PROTOCOL *This\r | |
190 | );\r | |
191 | /*++\r | |
192 | \r | |
193 | Routine Description:\r | |
194 | \r | |
195 | This function generates a soft timer interrupt. If the platform does not support soft \r | |
196 | timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned. \r | |
197 | If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() \r | |
198 | service, then a soft timer interrupt will be generated. If the timer interrupt is \r | |
199 | enabled when this service is called, then the registered handler will be invoked. The \r | |
200 | registered handler should not be able to distinguish a hardware-generated timer \r | |
201 | interrupt from a software-generated timer interrupt.\r | |
202 | \r | |
203 | Arguments:\r | |
204 | \r | |
205 | This - The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
206 | \r | |
207 | Returns: \r | |
208 | \r | |
209 | EFI_SUCCESS - The soft timer interrupt was generated.\r | |
210 | \r | |
211 | EFI_UNSUPPORTEDT - The platform does not support the generation of soft timer interrupts.\r | |
212 | \r | |
213 | --*/\r | |
214 | \r | |
215 | //\r | |
216 | // Interface stucture for the Timer Architectural Protocol\r | |
217 | //\r | |
218 | typedef struct _EFI_TIMER_ARCH_PROTOCOL {\r | |
219 | EFI_TIMER_REGISTER_HANDLER RegisterHandler;\r | |
220 | EFI_TIMER_SET_TIMER_PERIOD SetTimerPeriod;\r | |
221 | EFI_TIMER_GET_TIMER_PERIOD GetTimerPeriod;\r | |
222 | EFI_TIMER_GENERATE_SOFT_INTERRUPT GenerateSoftInterrupt;\r | |
223 | } EFI_TIMER_ARCH_PROTOCOL;\r | |
224 | \r | |
225 | /*++\r | |
226 | \r | |
227 | Protocol Description:\r | |
228 | This protocol provides the services to initialize a periodic timer \r | |
229 | interrupt, and to register a handler that is called each time the timer\r | |
230 | interrupt fires. It may also provide a service to adjust the rate of the\r | |
231 | periodic timer interrupt. When a timer interrupt occurs, the handler is \r | |
232 | passed the amount of time that has passed since the previous timer \r | |
233 | interrupt.\r | |
234 | \r | |
235 | Parameters:\r | |
236 | \r | |
237 | RegisterHandler - Registers a handler that will be called each time the \r | |
238 | timer interrupt fires. TimerPeriod defines the minimum \r | |
239 | time between timer interrupts, so TimerPeriod will also \r | |
240 | be the minimum time between calls to the registered \r | |
241 | handler.\r | |
242 | \r | |
243 | SetTimerPeriod - Sets the period of the timer interrupt in 100 nS units. \r | |
244 | This function is optional, and may return EFI_UNSUPPORTED. \r | |
245 | If this function is supported, then the timer period will \r | |
246 | be rounded up to the nearest supported timer period.\r | |
247 | \r | |
248 | GetTimerPeriod - Retrieves the period of the timer interrupt in 100 nS units.\r | |
249 | \r | |
250 | GenerateSoftInterrupt - \r | |
251 | Generates a soft timer interrupt that simulates the firing of \r | |
252 | the timer interrupt. This service can be used to invoke the \r | |
253 | registered handler if the timer interrupt has been masked for \r | |
254 | a period of time.\r | |
255 | \r | |
256 | --*/\r | |
257 | \r | |
258 | extern EFI_GUID gEfiTimerArchProtocolGuid;\r | |
259 | \r | |
260 | #endif\r |