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