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