]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol.\r | |
3 | \r | |
4 | Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
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 | |
15 | #ifndef _CPU_DXE_H_\r | |
16 | #define _CPU_DXE_H_\r | |
17 | \r | |
18 | #include <PiDxe.h>\r | |
19 | \r | |
20 | #include <Protocol/Cpu.h>\r | |
21 | #include <Protocol/MpService.h>\r | |
22 | \r | |
23 | #include <Ppi/SecPlatformInformation.h>\r | |
24 | #include <Ppi/SecPlatformInformation2.h>\r | |
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 | |
35 | #include <Library/LocalApicLib.h>\r | |
36 | #include <Library/UefiCpuLib.h>\r | |
37 | #include <Library/UefiLib.h>\r | |
38 | #include <Library/CpuExceptionHandlerLib.h>\r | |
39 | #include <Library/HobLib.h>\r | |
40 | #include <Library/ReportStatusCodeLib.h>\r | |
41 | #include <Library/MpInitLib.h>\r | |
42 | \r | |
43 | #include <Guid/IdleLoopEvent.h>\r | |
44 | #include <Guid/VectorHandoffTable.h>\r | |
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 | |
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 | |
69 | EFI_STATUS\r | |
70 | EFIAPI\r | |
71 | CpuFlushCpuDataCache (\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 | |
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 | |
87 | EFI_STATUS\r | |
88 | EFIAPI\r | |
89 | CpuEnableInterrupt (\r | |
90 | IN EFI_CPU_ARCH_PROTOCOL *This\r | |
91 | );\r | |
92 | \r | |
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 | |
102 | EFI_STATUS\r | |
103 | EFIAPI\r | |
104 | CpuDisableInterrupt (\r | |
105 | IN EFI_CPU_ARCH_PROTOCOL *This\r | |
106 | );\r | |
107 | \r | |
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 | |
118 | EFI_STATUS\r | |
119 | EFIAPI\r | |
120 | CpuGetInterruptState (\r | |
121 | IN EFI_CPU_ARCH_PROTOCOL *This,\r | |
122 | OUT BOOLEAN *State\r | |
123 | );\r | |
124 | \r | |
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 | |
137 | EFI_STATUS\r | |
138 | EFIAPI\r | |
139 | CpuInit (\r | |
140 | IN EFI_CPU_ARCH_PROTOCOL *This,\r | |
141 | IN EFI_CPU_INIT_TYPE InitType\r | |
142 | );\r | |
143 | \r | |
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 | |
164 | EFI_STATUS\r | |
165 | EFIAPI\r | |
166 | CpuRegisterInterruptHandler (\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 | |
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 | |
195 | EFI_STATUS\r | |
196 | EFIAPI\r | |
197 | CpuGetTimerValue (\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 | |
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 | |
220 | EFI_STATUS\r | |
221 | EFIAPI\r | |
222 | CpuSetMemoryAttributes (\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 | |
229 | /**\r | |
230 | Initialize Global Descriptor Table.\r | |
231 | \r | |
232 | **/\r | |
233 | VOID\r | |
234 | InitGlobalDescriptorTable (\r | |
235 | VOID\r | |
236 | );\r | |
237 | \r | |
238 | /**\r | |
239 | Sets the code selector (CS).\r | |
240 | \r | |
241 | @param Selector Value of code selector.\r | |
242 | \r | |
243 | **/\r | |
244 | VOID\r | |
245 | EFIAPI\r | |
246 | SetCodeSelector (\r | |
247 | UINT16 Selector\r | |
248 | );\r | |
249 | \r | |
250 | /**\r | |
251 | Sets the data selector (DS).\r | |
252 | \r | |
253 | @param Selector Value of data selector.\r | |
254 | \r | |
255 | **/\r | |
256 | VOID\r | |
257 | EFIAPI\r | |
258 | SetDataSelectors (\r | |
259 | UINT16 Selector\r | |
260 | );\r | |
261 | \r | |
262 | #endif\r | |
263 | \r |