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