]>
Commit | Line | Data |
---|---|---|
d1f95000 | 1 | /** @file\r |
4ca9b6c4 | 2 | Timer Architectural Protocol as defined in PI Specification VOLUME 2 DXE\r |
d1f95000 | 3 | \r |
4 | This code is used to provide the timer tick for the DXE core.\r | |
5 | \r | |
9095d37b LG |
6 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
7 | 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 | |
d1f95000 | 11 | \r |
9095d37b LG |
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 | |
d1f95000 | 14 | \r |
d1f95000 | 15 | **/\r |
16 | \r | |
17 | #ifndef __ARCH_PROTOCOL_TIMER_H__\r | |
18 | #define __ARCH_PROTOCOL_TIMER_H__\r | |
19 | \r | |
99e8ed21 | 20 | ///\r |
21 | /// Global ID for the Timer Architectural Protocol\r | |
22 | ///\r | |
d1f95000 | 23 | #define EFI_TIMER_ARCH_PROTOCOL_GUID \\r |
24 | { 0x26baccb3, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }\r | |
25 | \r | |
99e8ed21 | 26 | ///\r |
27 | /// Declare forward reference for the Timer Architectural Protocol\r | |
28 | ///\r | |
d1f95000 | 29 | typedef struct _EFI_TIMER_ARCH_PROTOCOL EFI_TIMER_ARCH_PROTOCOL;\r |
30 | \r | |
31 | /**\r | |
9095d37b | 32 | This function of this type is called when a timer interrupt fires. This\r |
00b7cc0f | 33 | function executes at TPL_HIGH_LEVEL. The DXE Core will register a function\r |
9095d37b LG |
34 | of this type to be called for the timer interrupt, so it can know how much\r |
35 | time has passed. This information is used to signal timer based events.\r | |
d1f95000 | 36 | \r |
4ca9b6c4 LG |
37 | @param Time Time since the last timer interrupt in 100 ns units. This will\r |
38 | typically be TimerPeriod, but if a timer interrupt is missed, and the\r | |
39 | EFI_TIMER_ARCH_PROTOCOL driver can detect missed interrupts, then Time\r | |
40 | will contain the actual amount of time since the last interrupt.\r | |
d1f95000 | 41 | \r |
42 | None.\r | |
43 | \r | |
44 | **/\r | |
45 | typedef\r | |
46 | VOID\r | |
8b13229b | 47 | (EFIAPI *EFI_TIMER_NOTIFY)(\r |
d1f95000 | 48 | IN UINT64 Time\r |
49 | );\r | |
50 | \r | |
51 | /**\r | |
9095d37b LG |
52 | This function registers the handler NotifyFunction so it is called every time\r |
53 | the timer interrupt fires. It also passes the amount of time since the last\r | |
54 | handler call to the NotifyFunction. If NotifyFunction is NULL, then the\r | |
55 | handler is unregistered. If the handler is registered, then EFI_SUCCESS is\r | |
56 | returned. If the CPU does not support registering a timer interrupt handler,\r | |
57 | then EFI_UNSUPPORTED is returned. If an attempt is made to register a handler\r | |
58 | when a handler is already registered, then EFI_ALREADY_STARTED is returned.\r | |
59 | If an attempt is made to unregister a handler when a handler is not registered,\r | |
60 | then EFI_INVALID_PARAMETER is returned. If an error occurs attempting to\r | |
61 | register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR\r | |
d1f95000 | 62 | is returned.\r |
63 | \r | |
64 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
65 | @param NotifyFunction The function to call when a timer interrupt fires. This\r | |
66 | function executes at TPL_HIGH_LEVEL. The DXE Core will\r | |
67 | register a handler for the timer interrupt, so it can know\r | |
68 | how much time has passed. This information is used to\r | |
69 | signal timer based events. NULL will unregister the handler.\r | |
70 | \r | |
71 | @retval EFI_SUCCESS The timer handler was registered.\r | |
72 | @retval EFI_UNSUPPORTED The platform does not support timer interrupts.\r | |
73 | @retval EFI_ALREADY_STARTED NotifyFunction is not NULL, and a handler is already\r | |
74 | registered.\r | |
75 | @retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a handler was not\r | |
76 | previously registered.\r | |
77 | @retval EFI_DEVICE_ERROR The timer handler could not be registered.\r | |
78 | \r | |
79 | **/\r | |
9095d37b | 80 | typedef\r |
d1f95000 | 81 | EFI_STATUS\r |
8b13229b | 82 | (EFIAPI *EFI_TIMER_REGISTER_HANDLER)(\r |
d1f95000 | 83 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r |
84 | IN EFI_TIMER_NOTIFY NotifyFunction\r | |
85 | );\r | |
86 | \r | |
87 | /**\r | |
9095d37b LG |
88 | This function adjusts the period of timer interrupts to the value specified\r |
89 | by TimerPeriod. If the timer period is updated, then the selected timer\r | |
90 | period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If\r | |
91 | the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r | |
92 | If an error occurs while attempting to update the timer period, then the\r | |
93 | timer hardware will be put back in its state prior to this call, and\r | |
94 | EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt\r | |
95 | is disabled. This is not the same as disabling the CPU's interrupts.\r | |
96 | Instead, it must either turn off the timer hardware, or it must adjust the\r | |
97 | interrupt controller so that a CPU interrupt is not generated when the timer\r | |
98 | interrupt fires.\r | |
d1f95000 | 99 | \r |
100 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
101 | @param TimerPeriod The rate to program the timer interrupt in 100 nS units. If\r | |
102 | the timer hardware is not programmable, then EFI_UNSUPPORTED is\r | |
103 | returned. If the timer is programmable, then the timer period\r | |
104 | will be rounded up to the nearest timer period that is supported\r | |
105 | by the timer hardware. If TimerPeriod is set to 0, then the\r | |
106 | timer interrupts will be disabled.\r | |
107 | \r | |
108 | @retval EFI_SUCCESS The timer period was changed.\r | |
109 | @retval EFI_UNSUPPORTED The platform cannot change the period of the timer interrupt.\r | |
110 | @retval EFI_DEVICE_ERROR The timer period could not be changed due to a device error.\r | |
111 | \r | |
112 | **/\r | |
9095d37b | 113 | typedef\r |
d1f95000 | 114 | EFI_STATUS\r |
8b13229b | 115 | (EFIAPI *EFI_TIMER_SET_TIMER_PERIOD)(\r |
d1f95000 | 116 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r |
117 | IN UINT64 TimerPeriod\r | |
118 | );\r | |
119 | \r | |
120 | /**\r | |
9095d37b LG |
121 | This function retrieves the period of timer interrupts in 100 ns units,\r |
122 | returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod\r | |
123 | is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is\r | |
d1f95000 | 124 | returned, then the timer is currently disabled.\r |
125 | \r | |
126 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
127 | @param TimerPeriod A pointer to the timer period to retrieve in 100 ns units. If\r | |
128 | 0 is returned, then the timer is currently disabled.\r | |
129 | \r | |
130 | @retval EFI_SUCCESS The timer period was returned in TimerPeriod.\r | |
131 | @retval EFI_INVALID_PARAMETER TimerPeriod is NULL.\r | |
132 | \r | |
133 | **/\r | |
9095d37b | 134 | typedef\r |
d1f95000 | 135 | EFI_STATUS\r |
8b13229b | 136 | (EFIAPI *EFI_TIMER_GET_TIMER_PERIOD)(\r |
d1f95000 | 137 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r |
138 | OUT UINT64 *TimerPeriod\r | |
139 | );\r | |
140 | \r | |
141 | /**\r | |
9095d37b LG |
142 | This function generates a soft timer interrupt. If the platform does not support soft\r |
143 | timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r | |
144 | If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r | |
145 | service, then a soft timer interrupt will be generated. If the timer interrupt is\r | |
146 | enabled when this service is called, then the registered handler will be invoked. The\r | |
147 | registered handler should not be able to distinguish a hardware-generated timer\r | |
d1f95000 | 148 | interrupt from a software-generated timer interrupt.\r |
149 | \r | |
4ca9b6c4 | 150 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r |
d1f95000 | 151 | \r |
152 | @retval EFI_SUCCESS The soft timer interrupt was generated.\r | |
b88df761 | 153 | @retval EFI_UNSUPPORTED The platform does not support the generation of soft timer interrupts.\r |
d1f95000 | 154 | \r |
155 | **/\r | |
9095d37b | 156 | typedef\r |
d1f95000 | 157 | EFI_STATUS\r |
8b13229b | 158 | (EFIAPI *EFI_TIMER_GENERATE_SOFT_INTERRUPT)(\r |
d1f95000 | 159 | IN EFI_TIMER_ARCH_PROTOCOL *This\r |
160 | );\r | |
161 | \r | |
162 | \r | |
44717a39 | 163 | ///\r |
9095d37b | 164 | /// This protocol provides the services to initialize a periodic timer\r |
44717a39 | 165 | /// interrupt, and to register a handler that is called each time the timer\r |
166 | /// interrupt fires. It may also provide a service to adjust the rate of the\r | |
9095d37b LG |
167 | /// periodic timer interrupt. When a timer interrupt occurs, the handler is\r |
168 | /// passed the amount of time that has passed since the previous timer\r | |
44717a39 | 169 | /// interrupt.\r |
170 | ///\r | |
d1f95000 | 171 | struct _EFI_TIMER_ARCH_PROTOCOL {\r |
172 | EFI_TIMER_REGISTER_HANDLER RegisterHandler;\r | |
173 | EFI_TIMER_SET_TIMER_PERIOD SetTimerPeriod;\r | |
174 | EFI_TIMER_GET_TIMER_PERIOD GetTimerPeriod;\r | |
175 | EFI_TIMER_GENERATE_SOFT_INTERRUPT GenerateSoftInterrupt;\r | |
176 | };\r | |
177 | \r | |
178 | extern EFI_GUID gEfiTimerArchProtocolGuid;\r | |
179 | \r | |
180 | #endif\r |