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