]>
Commit | Line | Data |
---|---|---|
d1f95000 | 1 | /** @file\r |
4ca9b6c4 | 2 | CPU Architectural Protocol as defined in PI spec Volume 2 DXE\r |
d1f95000 | 3 | \r |
4 | This code abstracts the DXE core from processor implementation details.\r | |
5 | \r | |
4ca9b6c4 | 6 | Copyright (c) 2006 - 2008, Intel Corporation \r |
d1f95000 | 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 | |
d1f95000 | 15 | **/\r |
16 | \r | |
17 | #ifndef __ARCH_PROTOCOL_CPU_H__\r | |
18 | #define __ARCH_PROTOCOL_CPU_H__\r | |
19 | \r | |
20 | #include <Protocol/DebugSupport.h>\r | |
21 | \r | |
22 | #define EFI_CPU_ARCH_PROTOCOL_GUID \\r | |
23 | { 0x26baccb1, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }\r | |
24 | \r | |
25 | typedef struct _EFI_CPU_ARCH_PROTOCOL EFI_CPU_ARCH_PROTOCOL;\r | |
26 | \r | |
27 | typedef enum {\r | |
28 | EfiCpuFlushTypeWriteBackInvalidate,\r | |
29 | EfiCpuFlushTypeWriteBack,\r | |
30 | EfiCpuFlushTypeInvalidate,\r | |
31 | EfiCpuMaxFlushType\r | |
32 | } EFI_CPU_FLUSH_TYPE;\r | |
33 | \r | |
34 | typedef enum {\r | |
35 | EfiCpuInit,\r | |
36 | EfiCpuMaxInitType\r | |
37 | } EFI_CPU_INIT_TYPE;\r | |
38 | \r | |
39 | /**\r | |
40 | EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs.\r | |
41 | \r | |
42 | @param InterruptType Defines the type of interrupt or exception that\r | |
43 | occurred on the processor.This parameter is processor architecture specific.\r | |
44 | @param SystemContext A pointer to the processor context when\r | |
45 | the interrupt occurred on the processor.\r | |
46 | \r | |
47 | @return None\r | |
48 | \r | |
49 | **/\r | |
50 | typedef\r | |
51 | VOID\r | |
8b13229b | 52 | (EFIAPI *EFI_CPU_INTERRUPT_HANDLER)(\r |
d1f95000 | 53 | IN CONST EFI_EXCEPTION_TYPE InterruptType,\r |
54 | IN CONST EFI_SYSTEM_CONTEXT SystemContext\r | |
55 | );\r | |
56 | \r | |
57 | /**\r | |
58 | This function flushes the range of addresses from Start to Start+Length \r | |
59 | from the processor's data cache. If Start is not aligned to a cache line \r | |
60 | boundary, then the bytes before Start to the preceding cache line boundary \r | |
61 | are also flushed. If Start+Length is not aligned to a cache line boundary, \r | |
62 | then the bytes past Start+Length to the end of the next cache line boundary \r | |
63 | are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be \r | |
64 | supported. If the data cache is fully coherent with all DMA operations, then \r | |
65 | this function can just return EFI_SUCCESS. If the processor does not support \r | |
66 | flushing a range of the data cache, then the entire data cache can be flushed.\r | |
67 | \r | |
68 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
69 | @param Start The beginning physical address to flush from the processor's data\r | |
70 | cache.\r | |
71 | @param Length The number of bytes to flush from the processor's data cache. This\r | |
72 | function may flush more bytes than Length specifies depending upon\r | |
73 | the granularity of the flush operation that the processor supports.\r | |
74 | @param FlushType Specifies the type of flush operation to perform.\r | |
75 | \r | |
76 | @retval EFI_SUCCESS The address range from Start to Start+Length was flushed from\r | |
77 | the processor's data cache.\r | |
78 | @retval EFI_UNSUPPORTEDT The processor does not support the cache flush type specified\r | |
79 | by FlushType.\r | |
80 | @retval EFI_DEVICE_ERROR The address range from Start to Start+Length could not be flushed\r | |
81 | from the processor's data cache.\r | |
82 | \r | |
83 | **/\r | |
84 | typedef\r | |
85 | EFI_STATUS\r | |
8b13229b | 86 | (EFIAPI *EFI_CPU_FLUSH_DATA_CACHE)(\r |
d1f95000 | 87 | IN EFI_CPU_ARCH_PROTOCOL *This,\r |
88 | IN EFI_PHYSICAL_ADDRESS Start,\r | |
89 | IN UINT64 Length,\r | |
90 | IN EFI_CPU_FLUSH_TYPE FlushType\r | |
91 | );\r | |
92 | \r | |
93 | \r | |
94 | /**\r | |
95 | This function enables interrupt processing by the processor. \r | |
96 | \r | |
97 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
98 | \r | |
99 | @retval EFI_SUCCESS Interrupts are enabled on the processor.\r | |
100 | @retval EFI_DEVICE_ERROR Interrupts could not be enabled on the processor.\r | |
101 | \r | |
102 | **/\r | |
103 | typedef\r | |
104 | EFI_STATUS\r | |
8b13229b | 105 | (EFIAPI *EFI_CPU_ENABLE_INTERRUPT)(\r |
d1f95000 | 106 | IN EFI_CPU_ARCH_PROTOCOL *This\r |
107 | );\r | |
108 | \r | |
109 | \r | |
110 | /**\r | |
111 | This function disables interrupt processing by the processor.\r | |
112 | \r | |
113 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
114 | \r | |
115 | @retval EFI_SUCCESS Interrupts are disabled on the processor.\r | |
116 | @retval EFI_DEVICE_ERROR Interrupts could not be disabled on the processor.\r | |
117 | \r | |
118 | **/\r | |
119 | typedef\r | |
120 | EFI_STATUS\r | |
8b13229b | 121 | (EFIAPI *EFI_CPU_DISABLE_INTERRUPT)(\r |
d1f95000 | 122 | IN EFI_CPU_ARCH_PROTOCOL *This\r |
123 | );\r | |
124 | \r | |
125 | \r | |
126 | /**\r | |
127 | This function retrieves the processor's current interrupt state a returns it in \r | |
128 | State. If interrupts are currently enabled, then TRUE is returned. If interrupts \r | |
129 | are currently disabled, then FALSE is returned.\r | |
130 | \r | |
131 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
132 | @param State A pointer to the processor's current interrupt state. Set to TRUE if\r | |
133 | interrupts are enabled and FALSE if interrupts are disabled.\r | |
134 | \r | |
135 | @retval EFI_SUCCESS The processor's current interrupt state was returned in State.\r | |
136 | @retval EFI_INVALID_PARAMETER State is NULL.\r | |
137 | \r | |
138 | **/\r | |
139 | typedef\r | |
140 | EFI_STATUS\r | |
8b13229b | 141 | (EFIAPI *EFI_CPU_GET_INTERRUPT_STATE)(\r |
d1f95000 | 142 | IN EFI_CPU_ARCH_PROTOCOL *This,\r |
143 | OUT BOOLEAN *State\r | |
144 | );\r | |
145 | \r | |
146 | \r | |
147 | /**\r | |
148 | This function generates an INIT on the processor. If this function succeeds, then the\r | |
149 | processor will be reset, and control will not be returned to the caller. If InitType is \r | |
150 | not supported by this processor, or the processor cannot programmatically generate an \r | |
151 | INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error \r | |
152 | occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned.\r | |
153 | \r | |
154 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
155 | @param InitType The type of processor INIT to perform.\r | |
156 | \r | |
157 | @retval EFI_SUCCESS The processor INIT was performed. This return code should never be seen.\r | |
158 | @retval EFI_UNSUPPORTED The processor INIT operation specified by InitType is not supported\r | |
159 | by this processor.\r | |
160 | @retval EFI_DEVICE_ERROR The processor INIT failed.\r | |
161 | \r | |
162 | **/\r | |
163 | typedef\r | |
164 | EFI_STATUS\r | |
8b13229b | 165 | (EFIAPI *EFI_CPU_INIT)(\r |
d1f95000 | 166 | IN EFI_CPU_ARCH_PROTOCOL *This,\r |
167 | IN EFI_CPU_INIT_TYPE InitType\r | |
168 | );\r | |
169 | \r | |
170 | \r | |
171 | /**\r | |
172 | This function registers and enables the handler specified by InterruptHandler for a processor \r | |
173 | interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the \r | |
174 | handler for the processor interrupt or exception type specified by InterruptType is uninstalled. \r | |
175 | The installed handler is called once for each processor interrupt or exception.\r | |
176 | \r | |
177 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
178 | @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts\r | |
179 | are enabled and FALSE if interrupts are disabled.\r | |
180 | @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r | |
181 | when a processor interrupt occurs. If this parameter is NULL, then the handler\r | |
182 | will be uninstalled.\r | |
183 | \r | |
184 | @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r | |
185 | @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r | |
186 | previously installed.\r | |
187 | @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r | |
188 | previously installed.\r | |
189 | @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.\r | |
190 | \r | |
191 | **/\r | |
192 | typedef\r | |
193 | EFI_STATUS\r | |
8b13229b | 194 | (EFIAPI *EFI_CPU_REGISTER_INTERRUPT_HANDLER)(\r |
d1f95000 | 195 | IN EFI_CPU_ARCH_PROTOCOL *This,\r |
196 | IN EFI_EXCEPTION_TYPE InterruptType,\r | |
197 | IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r | |
198 | );\r | |
199 | \r | |
200 | \r | |
201 | /**\r | |
202 | This function reads the processor timer specified by TimerIndex and returns it in TimerValue.\r | |
203 | \r | |
204 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
205 | @param TimerIndex Specifies which processor timer is to be returned in TimerValue. This parameter\r | |
206 | must be between 0 and NumberOfTimers-1.\r | |
207 | @param TimerValue Pointer to the returned timer value.\r | |
208 | @param TimerPeriod A pointer to the amount of time that passes in femtoseconds for each increment\r | |
209 | of TimerValue.\r | |
210 | \r | |
211 | @retval EFI_SUCCESS The processor timer value specified by TimerIndex was returned in TimerValue.\r | |
212 | @retval EFI_DEVICE_ERROR An error occurred attempting to read one of the processor's timers.\r | |
213 | @retval EFI_INVALID_PARAMETER TimerValue is NULL or TimerIndex is not valid.\r | |
214 | @retval EFI_UNSUPPORTED The processor does not have any readable timers.\r | |
215 | \r | |
216 | **/\r | |
217 | typedef\r | |
218 | EFI_STATUS\r | |
8b13229b | 219 | (EFIAPI *EFI_CPU_GET_TIMER_VALUE)(\r |
d1f95000 | 220 | IN EFI_CPU_ARCH_PROTOCOL *This,\r |
221 | IN UINT32 TimerIndex,\r | |
222 | OUT UINT64 *TimerValue,\r | |
223 | OUT UINT64 *TimerPeriod OPTIONAL\r | |
224 | );\r | |
225 | \r | |
226 | \r | |
227 | /**\r | |
228 | This function modifies the attributes for the memory region specified by BaseAddress and\r | |
229 | Length from their current attributes to the attributes specified by Attributes.\r | |
230 | \r | |
231 | @param This The EFI_CPU_ARCH_PROTOCOL instance.\r | |
232 | @param BaseAddress The physical address that is the start address of a memory region.\r | |
233 | @param Length The size in bytes of the memory region.\r | |
234 | @param Attributes The bit mask of attributes to set for the memory region.\r | |
235 | \r | |
236 | @retval EFI_SUCCESS The attributes were set for the memory region.\r | |
237 | @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r | |
238 | BaseAddress and Length cannot be modified.\r | |
239 | @retval EFI_INVALID_PARAMETER Length is zero.\r | |
240 | @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r | |
241 | the memory resource range.\r | |
242 | @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r | |
243 | resource range specified by BaseAddress and Length.\r | |
244 | The bit mask of attributes is not support for the memory resource\r | |
245 | range specified by BaseAddress and Length.\r | |
246 | \r | |
247 | **/\r | |
248 | typedef\r | |
249 | EFI_STATUS\r | |
8b13229b | 250 | (EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES)(\r |
d1f95000 | 251 | IN EFI_CPU_ARCH_PROTOCOL *This,\r |
252 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
253 | IN UINT64 Length,\r | |
254 | IN UINT64 Attributes\r | |
255 | );\r | |
256 | \r | |
257 | \r | |
258 | /**\r | |
259 | @par Protocol Description:\r | |
260 | The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE\r | |
261 | Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt\r | |
262 | vectors and exception vectors, reading internal processor timers, resetting the processor, and\r | |
263 | determining the processor frequency.\r | |
264 | \r | |
265 | @param FlushDataCache\r | |
266 | Flushes a range of the processor's data cache. If the processor does \r | |
267 | not contain a data cache, or the data cache is fully coherent, then this \r | |
268 | function can just return EFI_SUCCESS. If the processor does not support \r | |
269 | flushing a range of addresses from the data cache, then the entire data \r | |
270 | cache must be flushed. \r | |
271 | \r | |
272 | @param EnableInterrupt \r | |
273 | Enables interrupt processing by the processor.\r | |
274 | \r | |
275 | @param DisableInterrupt \r | |
276 | Disables interrupt processing by the processor.\r | |
277 | \r | |
278 | @param GetInterruptState \r | |
279 | Retrieves the processor's current interrupt state.\r | |
280 | \r | |
281 | @param Init\r | |
282 | Generates an INIT on the processor. If a processor cannot programmatically \r | |
283 | generate an INIT without help from external hardware, then this function \r | |
284 | returns EFI_UNSUPPORTED.\r | |
285 | \r | |
286 | @param RegisterInterruptHandler\r | |
287 | Associates an interrupt service routine with one of the processor's interrupt \r | |
288 | vectors. This function is typically used by the EFI_TIMER_ARCH_PROTOCOL to \r | |
289 | hook the timer interrupt in a system. It can also be used by the debugger to \r | |
290 | hook exception vectors.\r | |
291 | \r | |
292 | @param GetTimerValue \r | |
293 | Returns the value of one of the processor's internal timers.\r | |
294 | \r | |
295 | @param SetMemoryAttributes \r | |
296 | Attempts to set the attributes of a memory region.\r | |
297 | \r | |
298 | @param NumberOfTimers\r | |
299 | The number of timers that are available in a processor. The value in this \r | |
300 | field is a constant that must not be modified after the CPU Architectural \r | |
301 | Protocol is installed. All consumers must treat this as a read-only field.\r | |
302 | \r | |
303 | @param DmaBufferAlignment\r | |
304 | The size, in bytes, of the alignment required for DMA buffer allocations. \r | |
305 | This is typically the size of the largest data cache line in the platform. \r | |
306 | The value in this field is a constant that must not be modified after the \r | |
307 | CPU Architectural Protocol is installed. All consumers must treat this as \r | |
308 | a read-only field.\r | |
309 | \r | |
310 | **/\r | |
311 | struct _EFI_CPU_ARCH_PROTOCOL {\r | |
312 | EFI_CPU_FLUSH_DATA_CACHE FlushDataCache;\r | |
313 | EFI_CPU_ENABLE_INTERRUPT EnableInterrupt;\r | |
314 | EFI_CPU_DISABLE_INTERRUPT DisableInterrupt;\r | |
315 | EFI_CPU_GET_INTERRUPT_STATE GetInterruptState;\r | |
316 | EFI_CPU_INIT Init;\r | |
317 | EFI_CPU_REGISTER_INTERRUPT_HANDLER RegisterInterruptHandler;\r | |
318 | EFI_CPU_GET_TIMER_VALUE GetTimerValue;\r | |
319 | EFI_CPU_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;\r | |
320 | UINT32 NumberOfTimers;\r | |
321 | UINT32 DmaBufferAlignment;\r | |
322 | };\r | |
323 | \r | |
324 | extern EFI_GUID gEfiCpuArchProtocolGuid;\r | |
325 | \r | |
326 | #endif\r |