]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/CpuDxe/CpuDxe.h
OvmfPkg/QemuVideoDxe/VbeShim: handle PAM1 register on Q35 correctly
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuDxe.h
CommitLineData
a47463f2 1/** @file\r
7fadaacd 2 CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol.\r
a47463f2 3\r
7537f8c0 4 Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
01a1c0fc 5 This program and the accompanying materials\r
a47463f2 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
430fbbe0 15#ifndef _CPU_DXE_H_\r
16#define _CPU_DXE_H_\r
a47463f2 17\r
18#include <PiDxe.h>\r
19\r
20#include <Protocol/Cpu.h>\r
7fadaacd 21#include <Protocol/MpService.h>\r
b1bd0d74 22#include <Register/Msr.h>\r
7fadaacd
JF
23\r
24#include <Ppi/SecPlatformInformation.h>\r
25#include <Ppi/SecPlatformInformation2.h>\r
a47463f2 26\r
27#include <Library/UefiDriverEntryPoint.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/DxeServicesTableLib.h>\r
30#include <Library/BaseLib.h>\r
31#include <Library/CpuLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
34#include <Library/DebugLib.h>\r
35#include <Library/MtrrLib.h>\r
d4605c23 36#include <Library/LocalApicLib.h>\r
661cab5d 37#include <Library/UefiCpuLib.h>\r
e41aad15
JF
38#include <Library/UefiLib.h>\r
39#include <Library/CpuExceptionHandlerLib.h>\r
7fadaacd
JF
40#include <Library/HobLib.h>\r
41#include <Library/ReportStatusCodeLib.h>\r
42#include <Library/MpInitLib.h>\r
7537f8c0 43#include <Library/TimerLib.h>\r
7fadaacd 44\r
32394027 45#include <Guid/IdleLoopEvent.h>\r
e41aad15 46#include <Guid/VectorHandoffTable.h>\r
a47463f2 47\r
48#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \\r
49 EFI_MEMORY_WC | \\r
50 EFI_MEMORY_WT | \\r
51 EFI_MEMORY_WB | \\r
52 EFI_MEMORY_UCE \\r
53 )\r
54\r
55\r
430fbbe0 56/**\r
57 Flush CPU data cache. If the instruction cache is fully coherent\r
58 with all DMA operations then function can just return EFI_SUCCESS.\r
59\r
60 @param This Protocol instance structure\r
61 @param Start Physical address to start flushing from.\r
62 @param Length Number of bytes to flush. Round up to chipset\r
63 granularity.\r
64 @param FlushType Specifies the type of flush operation to perform.\r
65\r
66 @retval EFI_SUCCESS If cache was flushed\r
67 @retval EFI_UNSUPPORTED If flush type is not supported.\r
68 @retval EFI_DEVICE_ERROR If requested range could not be flushed.\r
69\r
70**/\r
a47463f2 71EFI_STATUS\r
72EFIAPI\r
73CpuFlushCpuDataCache (\r
74 IN EFI_CPU_ARCH_PROTOCOL *This,\r
75 IN EFI_PHYSICAL_ADDRESS Start,\r
76 IN UINT64 Length,\r
77 IN EFI_CPU_FLUSH_TYPE FlushType\r
78 );\r
79\r
430fbbe0 80/**\r
81 Enables CPU interrupts.\r
82\r
83 @param This Protocol instance structure\r
84\r
85 @retval EFI_SUCCESS If interrupts were enabled in the CPU\r
86 @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU.\r
87\r
88**/\r
a47463f2 89EFI_STATUS\r
90EFIAPI\r
91CpuEnableInterrupt (\r
92 IN EFI_CPU_ARCH_PROTOCOL *This\r
93 );\r
94\r
430fbbe0 95/**\r
96 Disables CPU interrupts.\r
97\r
98 @param This Protocol instance structure\r
99\r
100 @retval EFI_SUCCESS If interrupts were disabled in the CPU.\r
101 @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU.\r
102\r
103**/\r
a47463f2 104EFI_STATUS\r
105EFIAPI\r
106CpuDisableInterrupt (\r
107 IN EFI_CPU_ARCH_PROTOCOL *This\r
108 );\r
109\r
430fbbe0 110/**\r
111 Return the state of interrupts.\r
112\r
113 @param This Protocol instance structure\r
114 @param State Pointer to the CPU's current interrupt state\r
115\r
116 @retval EFI_SUCCESS If interrupts were disabled in the CPU.\r
117 @retval EFI_INVALID_PARAMETER State is NULL.\r
118\r
119**/\r
a47463f2 120EFI_STATUS\r
121EFIAPI\r
122CpuGetInterruptState (\r
123 IN EFI_CPU_ARCH_PROTOCOL *This,\r
124 OUT BOOLEAN *State\r
125 );\r
126\r
430fbbe0 127/**\r
128 Generates an INIT to the CPU.\r
129\r
130 @param This Protocol instance structure\r
131 @param InitType Type of CPU INIT to perform\r
132\r
133 @retval EFI_SUCCESS If CPU INIT occurred. This value should never be\r
134 seen.\r
135 @retval EFI_DEVICE_ERROR If CPU INIT failed.\r
136 @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported.\r
137\r
138**/\r
a47463f2 139EFI_STATUS\r
140EFIAPI\r
141CpuInit (\r
142 IN EFI_CPU_ARCH_PROTOCOL *This,\r
143 IN EFI_CPU_INIT_TYPE InitType\r
144 );\r
145\r
430fbbe0 146/**\r
147 Registers a function to be called from the CPU interrupt handler.\r
148\r
149 @param This Protocol instance structure\r
150 @param InterruptType Defines which interrupt to hook. IA-32\r
151 valid range is 0x00 through 0xFF\r
152 @param InterruptHandler A pointer to a function of type\r
153 EFI_CPU_INTERRUPT_HANDLER that is called\r
154 when a processor interrupt occurs. A null\r
155 pointer is an error condition.\r
156\r
157 @retval EFI_SUCCESS If handler installed or uninstalled.\r
158 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler\r
159 for InterruptType was previously installed.\r
160 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for\r
161 InterruptType was not previously installed.\r
162 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType\r
163 is not supported.\r
164\r
165**/\r
a47463f2 166EFI_STATUS\r
167EFIAPI\r
168CpuRegisterInterruptHandler (\r
169 IN EFI_CPU_ARCH_PROTOCOL *This,\r
170 IN EFI_EXCEPTION_TYPE InterruptType,\r
171 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r
172 );\r
173\r
430fbbe0 174/**\r
175 Returns a timer value from one of the CPU's internal timers. There is no\r
176 inherent time interval between ticks but is a function of the CPU frequency.\r
177\r
178 @param This - Protocol instance structure.\r
179 @param TimerIndex - Specifies which CPU timer is requested.\r
180 @param TimerValue - Pointer to the returned timer value.\r
181 @param TimerPeriod - A pointer to the amount of time that passes\r
182 in femtoseconds (10-15) for each increment\r
183 of TimerValue. If TimerValue does not\r
184 increment at a predictable rate, then 0 is\r
185 returned. The amount of time that has\r
186 passed between two calls to GetTimerValue()\r
187 can be calculated with the formula\r
188 (TimerValue2 - TimerValue1) * TimerPeriod.\r
189 This parameter is optional and may be NULL.\r
190\r
191 @retval EFI_SUCCESS - If the CPU timer count was returned.\r
192 @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers.\r
193 @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer.\r
194 @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL.\r
195\r
196**/\r
a47463f2 197EFI_STATUS\r
198EFIAPI\r
199CpuGetTimerValue (\r
200 IN EFI_CPU_ARCH_PROTOCOL *This,\r
201 IN UINT32 TimerIndex,\r
202 OUT UINT64 *TimerValue,\r
203 OUT UINT64 *TimerPeriod OPTIONAL\r
204 );\r
205\r
430fbbe0 206/**\r
207 Set memory cacheability attributes for given range of memeory.\r
208\r
209 @param This Protocol instance structure\r
210 @param BaseAddress Specifies the start address of the\r
211 memory range\r
212 @param Length Specifies the length of the memory range\r
213 @param Attributes The memory cacheability for the memory range\r
214\r
215 @retval EFI_SUCCESS If the cacheability of that memory range is\r
216 set successfully\r
217 @retval EFI_UNSUPPORTED If the desired operation cannot be done\r
218 @retval EFI_INVALID_PARAMETER The input parameter is not correct,\r
219 such as Length = 0\r
220\r
221**/\r
a47463f2 222EFI_STATUS\r
223EFIAPI\r
224CpuSetMemoryAttributes (\r
225 IN EFI_CPU_ARCH_PROTOCOL *This,\r
226 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
227 IN UINT64 Length,\r
228 IN UINT64 Attributes\r
229 );\r
230\r
430fbbe0 231/**\r
232 Initialize Global Descriptor Table.\r
233\r
234**/\r
a47463f2 235VOID\r
236InitGlobalDescriptorTable (\r
237 VOID\r
238 );\r
239\r
430fbbe0 240/**\r
241 Sets the code selector (CS).\r
242\r
243 @param Selector Value of code selector.\r
244\r
245**/\r
a47463f2 246VOID\r
247EFIAPI\r
248SetCodeSelector (\r
249 UINT16 Selector\r
250 );\r
251\r
430fbbe0 252/**\r
253 Sets the data selector (DS).\r
254\r
255 @param Selector Value of data selector.\r
256\r
257**/\r
a47463f2 258VOID\r
259EFIAPI\r
260SetDataSelectors (\r
261 UINT16 Selector\r
262 );\r
263\r
a47463f2 264#endif\r
265\r