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