]>
Commit | Line | Data |
---|---|---|
a47463f2 | 1 | /** @file\r |
2 | CPU DXE Module.\r | |
3 | \r | |
e41aad15 | 4 | Copyright (c) 2008 - 2013, 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 |
661cab5d | 32 | #include <Library/UefiCpuLib.h>\r |
e41aad15 JF |
33 | #include <Library/UefiLib.h>\r |
34 | #include <Library/CpuExceptionHandlerLib.h>\r | |
533263ee | 35 | #include <Library/TimerLib.h>\r |
32394027 | 36 | #include <Guid/IdleLoopEvent.h>\r |
e41aad15 | 37 | #include <Guid/VectorHandoffTable.h>\r |
a47463f2 | 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 | 62 | EFI_STATUS\r |
63 | EFIAPI\r | |
64 | CpuFlushCpuDataCache (\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 | 80 | EFI_STATUS\r |
81 | EFIAPI\r | |
82 | CpuEnableInterrupt (\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 | 95 | EFI_STATUS\r |
96 | EFIAPI\r | |
97 | CpuDisableInterrupt (\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 | 111 | EFI_STATUS\r |
112 | EFIAPI\r | |
113 | CpuGetInterruptState (\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 | 130 | EFI_STATUS\r |
131 | EFIAPI\r | |
132 | CpuInit (\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 | 157 | EFI_STATUS\r |
158 | EFIAPI\r | |
159 | CpuRegisterInterruptHandler (\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 | 188 | EFI_STATUS\r |
189 | EFIAPI\r | |
190 | CpuGetTimerValue (\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 | 213 | EFI_STATUS\r |
214 | EFIAPI\r | |
215 | CpuSetMemoryAttributes (\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 | Initialize Global Descriptor Table.\r | |
224 | \r | |
225 | **/\r | |
a47463f2 | 226 | VOID\r |
227 | InitGlobalDescriptorTable (\r | |
228 | VOID\r | |
229 | );\r | |
230 | \r | |
430fbbe0 | 231 | /**\r |
232 | Sets the code selector (CS).\r | |
233 | \r | |
234 | @param Selector Value of code selector.\r | |
235 | \r | |
236 | **/\r | |
a47463f2 | 237 | VOID\r |
238 | EFIAPI\r | |
239 | SetCodeSelector (\r | |
240 | UINT16 Selector\r | |
241 | );\r | |
242 | \r | |
430fbbe0 | 243 | /**\r |
244 | Sets the data selector (DS).\r | |
245 | \r | |
246 | @param Selector Value of data selector.\r | |
247 | \r | |
248 | **/\r | |
a47463f2 | 249 | VOID\r |
250 | EFIAPI\r | |
251 | SetDataSelectors (\r | |
252 | UINT16 Selector\r | |
253 | );\r | |
254 | \r | |
a47463f2 | 255 | #endif\r |
256 | \r |