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