2 CPU Architectural Protocol as defined in DXE CIS
4 This code abstracts the DXE core from processor implementation details.
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
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.
17 @par Revision Reference:
22 #ifndef __ARCH_PROTOCOL_CPU_H__
23 #define __ARCH_PROTOCOL_CPU_H__
25 #include <Protocol/DebugSupport.h>
27 #define EFI_CPU_ARCH_PROTOCOL_GUID \
28 { 0x26baccb1, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
30 typedef struct _EFI_CPU_ARCH_PROTOCOL EFI_CPU_ARCH_PROTOCOL
;
33 EfiCpuFlushTypeWriteBackInvalidate
,
34 EfiCpuFlushTypeWriteBack
,
35 EfiCpuFlushTypeInvalidate
,
45 EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs.
47 @param InterruptType Defines the type of interrupt or exception that
48 occurred on the processor.This parameter is processor architecture specific.
49 @param SystemContext A pointer to the processor context when
50 the interrupt occurred on the processor.
57 (EFIAPI
*EFI_CPU_INTERRUPT_HANDLER
) (
58 IN CONST EFI_EXCEPTION_TYPE InterruptType
,
59 IN CONST EFI_SYSTEM_CONTEXT SystemContext
63 This function flushes the range of addresses from Start to Start+Length
64 from the processor's data cache. If Start is not aligned to a cache line
65 boundary, then the bytes before Start to the preceding cache line boundary
66 are also flushed. If Start+Length is not aligned to a cache line boundary,
67 then the bytes past Start+Length to the end of the next cache line boundary
68 are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be
69 supported. If the data cache is fully coherent with all DMA operations, then
70 this function can just return EFI_SUCCESS. If the processor does not support
71 flushing a range of the data cache, then the entire data cache can be flushed.
73 @param This The EFI_CPU_ARCH_PROTOCOL instance.
74 @param Start The beginning physical address to flush from the processor's data
76 @param Length The number of bytes to flush from the processor's data cache. This
77 function may flush more bytes than Length specifies depending upon
78 the granularity of the flush operation that the processor supports.
79 @param FlushType Specifies the type of flush operation to perform.
81 @retval EFI_SUCCESS The address range from Start to Start+Length was flushed from
82 the processor's data cache.
83 @retval EFI_UNSUPPORTEDT The processor does not support the cache flush type specified
85 @retval EFI_DEVICE_ERROR The address range from Start to Start+Length could not be flushed
86 from the processor's data cache.
91 (EFIAPI
*EFI_CPU_FLUSH_DATA_CACHE
) (
92 IN EFI_CPU_ARCH_PROTOCOL
*This
,
93 IN EFI_PHYSICAL_ADDRESS Start
,
95 IN EFI_CPU_FLUSH_TYPE FlushType
100 This function enables interrupt processing by the processor.
102 @param This The EFI_CPU_ARCH_PROTOCOL instance.
104 @retval EFI_SUCCESS Interrupts are enabled on the processor.
105 @retval EFI_DEVICE_ERROR Interrupts could not be enabled on the processor.
110 (EFIAPI
*EFI_CPU_ENABLE_INTERRUPT
) (
111 IN EFI_CPU_ARCH_PROTOCOL
*This
116 This function disables interrupt processing by the processor.
118 @param This The EFI_CPU_ARCH_PROTOCOL instance.
120 @retval EFI_SUCCESS Interrupts are disabled on the processor.
121 @retval EFI_DEVICE_ERROR Interrupts could not be disabled on the processor.
126 (EFIAPI
*EFI_CPU_DISABLE_INTERRUPT
) (
127 IN EFI_CPU_ARCH_PROTOCOL
*This
132 This function retrieves the processor's current interrupt state a returns it in
133 State. If interrupts are currently enabled, then TRUE is returned. If interrupts
134 are currently disabled, then FALSE is returned.
136 @param This The EFI_CPU_ARCH_PROTOCOL instance.
137 @param State A pointer to the processor's current interrupt state. Set to TRUE if
138 interrupts are enabled and FALSE if interrupts are disabled.
140 @retval EFI_SUCCESS The processor's current interrupt state was returned in State.
141 @retval EFI_INVALID_PARAMETER State is NULL.
146 (EFIAPI
*EFI_CPU_GET_INTERRUPT_STATE
) (
147 IN EFI_CPU_ARCH_PROTOCOL
*This
,
153 This function generates an INIT on the processor. If this function succeeds, then the
154 processor will be reset, and control will not be returned to the caller. If InitType is
155 not supported by this processor, or the processor cannot programmatically generate an
156 INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error
157 occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned.
159 @param This The EFI_CPU_ARCH_PROTOCOL instance.
160 @param InitType The type of processor INIT to perform.
162 @retval EFI_SUCCESS The processor INIT was performed. This return code should never be seen.
163 @retval EFI_UNSUPPORTED The processor INIT operation specified by InitType is not supported
165 @retval EFI_DEVICE_ERROR The processor INIT failed.
170 (EFIAPI
*EFI_CPU_INIT
) (
171 IN EFI_CPU_ARCH_PROTOCOL
*This
,
172 IN EFI_CPU_INIT_TYPE InitType
177 This function registers and enables the handler specified by InterruptHandler for a processor
178 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
179 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
180 The installed handler is called once for each processor interrupt or exception.
182 @param This The EFI_CPU_ARCH_PROTOCOL instance.
183 @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts
184 are enabled and FALSE if interrupts are disabled.
185 @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
186 when a processor interrupt occurs. If this parameter is NULL, then the handler
189 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
190 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
191 previously installed.
192 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
193 previously installed.
194 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
199 (EFIAPI
*EFI_CPU_REGISTER_INTERRUPT_HANDLER
) (
200 IN EFI_CPU_ARCH_PROTOCOL
*This
,
201 IN EFI_EXCEPTION_TYPE InterruptType
,
202 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
207 This function reads the processor timer specified by TimerIndex and returns it in TimerValue.
209 @param This The EFI_CPU_ARCH_PROTOCOL instance.
210 @param TimerIndex Specifies which processor timer is to be returned in TimerValue. This parameter
211 must be between 0 and NumberOfTimers-1.
212 @param TimerValue Pointer to the returned timer value.
213 @param TimerPeriod A pointer to the amount of time that passes in femtoseconds for each increment
216 @retval EFI_SUCCESS The processor timer value specified by TimerIndex was returned in TimerValue.
217 @retval EFI_DEVICE_ERROR An error occurred attempting to read one of the processor's timers.
218 @retval EFI_INVALID_PARAMETER TimerValue is NULL or TimerIndex is not valid.
219 @retval EFI_UNSUPPORTED The processor does not have any readable timers.
224 (EFIAPI
*EFI_CPU_GET_TIMER_VALUE
) (
225 IN EFI_CPU_ARCH_PROTOCOL
*This
,
226 IN UINT32 TimerIndex
,
227 OUT UINT64
*TimerValue
,
228 OUT UINT64
*TimerPeriod OPTIONAL
233 This function modifies the attributes for the memory region specified by BaseAddress and
234 Length from their current attributes to the attributes specified by Attributes.
236 @param This The EFI_CPU_ARCH_PROTOCOL instance.
237 @param BaseAddress The physical address that is the start address of a memory region.
238 @param Length The size in bytes of the memory region.
239 @param Attributes The bit mask of attributes to set for the memory region.
241 @retval EFI_SUCCESS The attributes were set for the memory region.
242 @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by
243 BaseAddress and Length cannot be modified.
244 @retval EFI_INVALID_PARAMETER Length is zero.
245 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of
246 the memory resource range.
247 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory
248 resource range specified by BaseAddress and Length.
249 The bit mask of attributes is not support for the memory resource
250 range specified by BaseAddress and Length.
255 (EFIAPI
*EFI_CPU_SET_MEMORY_ATTRIBUTES
) (
256 IN EFI_CPU_ARCH_PROTOCOL
*This
,
257 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
264 @par Protocol Description:
265 The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE
266 Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt
267 vectors and exception vectors, reading internal processor timers, resetting the processor, and
268 determining the processor frequency.
270 @param FlushDataCache
271 Flushes a range of the processor's data cache. If the processor does
272 not contain a data cache, or the data cache is fully coherent, then this
273 function can just return EFI_SUCCESS. If the processor does not support
274 flushing a range of addresses from the data cache, then the entire data
275 cache must be flushed.
277 @param EnableInterrupt
278 Enables interrupt processing by the processor.
280 @param DisableInterrupt
281 Disables interrupt processing by the processor.
283 @param GetInterruptState
284 Retrieves the processor's current interrupt state.
287 Generates an INIT on the processor. If a processor cannot programmatically
288 generate an INIT without help from external hardware, then this function
289 returns EFI_UNSUPPORTED.
291 @param RegisterInterruptHandler
292 Associates an interrupt service routine with one of the processor's interrupt
293 vectors. This function is typically used by the EFI_TIMER_ARCH_PROTOCOL to
294 hook the timer interrupt in a system. It can also be used by the debugger to
295 hook exception vectors.
298 Returns the value of one of the processor's internal timers.
300 @param SetMemoryAttributes
301 Attempts to set the attributes of a memory region.
303 @param NumberOfTimers
304 The number of timers that are available in a processor. The value in this
305 field is a constant that must not be modified after the CPU Architectural
306 Protocol is installed. All consumers must treat this as a read-only field.
308 @param DmaBufferAlignment
309 The size, in bytes, of the alignment required for DMA buffer allocations.
310 This is typically the size of the largest data cache line in the platform.
311 The value in this field is a constant that must not be modified after the
312 CPU Architectural Protocol is installed. All consumers must treat this as
316 struct _EFI_CPU_ARCH_PROTOCOL
{
317 EFI_CPU_FLUSH_DATA_CACHE FlushDataCache
;
318 EFI_CPU_ENABLE_INTERRUPT EnableInterrupt
;
319 EFI_CPU_DISABLE_INTERRUPT DisableInterrupt
;
320 EFI_CPU_GET_INTERRUPT_STATE GetInterruptState
;
322 EFI_CPU_REGISTER_INTERRUPT_HANDLER RegisterInterruptHandler
;
323 EFI_CPU_GET_TIMER_VALUE GetTimerValue
;
324 EFI_CPU_SET_MEMORY_ATTRIBUTES SetMemoryAttributes
;
325 UINT32 NumberOfTimers
;
326 UINT32 DmaBufferAlignment
;
329 extern EFI_GUID gEfiCpuArchProtocolGuid
;