2 CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol.
4 Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Protocol/Cpu.h>
21 #include <Protocol/MpService.h>
23 #include <Ppi/SecPlatformInformation.h>
24 #include <Ppi/SecPlatformInformation2.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/DxeServicesTableLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/CpuLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/DebugLib.h>
34 #include <Library/MtrrLib.h>
35 #include <Library/LocalApicLib.h>
36 #include <Library/UefiCpuLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/CpuExceptionHandlerLib.h>
39 #include <Library/HobLib.h>
40 #include <Library/ReportStatusCodeLib.h>
41 #include <Library/MpInitLib.h>
43 #include <Guid/IdleLoopEvent.h>
44 #include <Guid/VectorHandoffTable.h>
46 #define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \
55 Flush CPU data cache. If the instruction cache is fully coherent
56 with all DMA operations then function can just return EFI_SUCCESS.
58 @param This Protocol instance structure
59 @param Start Physical address to start flushing from.
60 @param Length Number of bytes to flush. Round up to chipset
62 @param FlushType Specifies the type of flush operation to perform.
64 @retval EFI_SUCCESS If cache was flushed
65 @retval EFI_UNSUPPORTED If flush type is not supported.
66 @retval EFI_DEVICE_ERROR If requested range could not be flushed.
71 CpuFlushCpuDataCache (
72 IN EFI_CPU_ARCH_PROTOCOL
*This
,
73 IN EFI_PHYSICAL_ADDRESS Start
,
75 IN EFI_CPU_FLUSH_TYPE FlushType
79 Enables CPU interrupts.
81 @param This Protocol instance structure
83 @retval EFI_SUCCESS If interrupts were enabled in the CPU
84 @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU.
90 IN EFI_CPU_ARCH_PROTOCOL
*This
94 Disables CPU interrupts.
96 @param This Protocol instance structure
98 @retval EFI_SUCCESS If interrupts were disabled in the CPU.
99 @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU.
104 CpuDisableInterrupt (
105 IN EFI_CPU_ARCH_PROTOCOL
*This
109 Return the state of interrupts.
111 @param This Protocol instance structure
112 @param State Pointer to the CPU's current interrupt state
114 @retval EFI_SUCCESS If interrupts were disabled in the CPU.
115 @retval EFI_INVALID_PARAMETER State is NULL.
120 CpuGetInterruptState (
121 IN EFI_CPU_ARCH_PROTOCOL
*This
,
126 Generates an INIT to the CPU.
128 @param This Protocol instance structure
129 @param InitType Type of CPU INIT to perform
131 @retval EFI_SUCCESS If CPU INIT occurred. This value should never be
133 @retval EFI_DEVICE_ERROR If CPU INIT failed.
134 @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported.
140 IN EFI_CPU_ARCH_PROTOCOL
*This
,
141 IN EFI_CPU_INIT_TYPE InitType
145 Registers a function to be called from the CPU interrupt handler.
147 @param This Protocol instance structure
148 @param InterruptType Defines which interrupt to hook. IA-32
149 valid range is 0x00 through 0xFF
150 @param InterruptHandler A pointer to a function of type
151 EFI_CPU_INTERRUPT_HANDLER that is called
152 when a processor interrupt occurs. A null
153 pointer is an error condition.
155 @retval EFI_SUCCESS If handler installed or uninstalled.
156 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler
157 for InterruptType was previously installed.
158 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for
159 InterruptType was not previously installed.
160 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType
166 CpuRegisterInterruptHandler (
167 IN EFI_CPU_ARCH_PROTOCOL
*This
,
168 IN EFI_EXCEPTION_TYPE InterruptType
,
169 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
173 Returns a timer value from one of the CPU's internal timers. There is no
174 inherent time interval between ticks but is a function of the CPU frequency.
176 @param This - Protocol instance structure.
177 @param TimerIndex - Specifies which CPU timer is requested.
178 @param TimerValue - Pointer to the returned timer value.
179 @param TimerPeriod - A pointer to the amount of time that passes
180 in femtoseconds (10-15) for each increment
181 of TimerValue. If TimerValue does not
182 increment at a predictable rate, then 0 is
183 returned. The amount of time that has
184 passed between two calls to GetTimerValue()
185 can be calculated with the formula
186 (TimerValue2 - TimerValue1) * TimerPeriod.
187 This parameter is optional and may be NULL.
189 @retval EFI_SUCCESS - If the CPU timer count was returned.
190 @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers.
191 @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer.
192 @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL.
198 IN EFI_CPU_ARCH_PROTOCOL
*This
,
199 IN UINT32 TimerIndex
,
200 OUT UINT64
*TimerValue
,
201 OUT UINT64
*TimerPeriod OPTIONAL
205 Set memory cacheability attributes for given range of memeory.
207 @param This Protocol instance structure
208 @param BaseAddress Specifies the start address of the
210 @param Length Specifies the length of the memory range
211 @param Attributes The memory cacheability for the memory range
213 @retval EFI_SUCCESS If the cacheability of that memory range is
215 @retval EFI_UNSUPPORTED If the desired operation cannot be done
216 @retval EFI_INVALID_PARAMETER The input parameter is not correct,
222 CpuSetMemoryAttributes (
223 IN EFI_CPU_ARCH_PROTOCOL
*This
,
224 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
230 Initialize Global Descriptor Table.
234 InitGlobalDescriptorTable (
239 Sets the code selector (CS).
241 @param Selector Value of code selector.
251 Sets the data selector (DS).
253 @param Selector Value of data selector.