]>
Commit | Line | Data |
---|---|---|
1 | /**@file\r | |
2 | X64 specific debug support macros, typedefs and prototypes.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation \r | |
5 | All rights reserved. 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 _PLDEBUG_SUPPORT_H\r | |
16 | #define _PLDEBUG_SUPPORT_H\r | |
17 | \r | |
18 | //\r | |
19 | // The package level header files this module uses\r | |
20 | //\r | |
21 | #include <PiDxe.h>\r | |
22 | //\r | |
23 | // The protocols, PPI and GUID defintions for this module\r | |
24 | //\r | |
25 | #include <Protocol/DebugSupport.h>\r | |
26 | #include <Protocol/LoadedImage.h>\r | |
27 | //\r | |
28 | // The Library classes this module consumes\r | |
29 | //\r | |
30 | #include <Library/DebugLib.h>\r | |
31 | #include <Library/UefiDriverEntryPoint.h>\r | |
32 | #include <Library/BaseMemoryLib.h>\r | |
33 | #include <Library/MemoryAllocationLib.h>\r | |
34 | #include <Library/UefiBootServicesTableLib.h>\r | |
35 | #include <Library/BaseLib.h>\r | |
36 | \r | |
37 | #include <Library/PcdLib.h>\r | |
38 | #define NUM_IDT_ENTRIES 0x78\r | |
39 | #define SYSTEM_TIMER_VECTOR 0x68\r | |
40 | #define VECTOR_ENTRY_PAGES 1\r | |
41 | #define CopyDescriptor(Dest, Src) CopyMem ((Dest), (Src), sizeof (DESCRIPTOR))\r | |
42 | #define ZeroDescriptor(Dest) CopyDescriptor ((Dest), &NullDesc)\r | |
43 | #define ReadIdt(Vector, Dest) CopyDescriptor ((Dest), &((GetIdtr ())[(Vector)]))\r | |
44 | #define WriteIdt(Vector, Src) CopyDescriptor (&((GetIdtr ())[(Vector)]), (Src))\r | |
45 | #define CompareDescriptor(Desc1, Desc2) CompareMem ((Desc1), (Desc2), sizeof (DESCRIPTOR))\r | |
46 | #define EFI_ISA IsaX64\r | |
47 | #define FF_FXSR (1 << 24)\r | |
48 | \r | |
49 | typedef struct {\r | |
50 | UINT64 Low;\r | |
51 | UINT64 High;\r | |
52 | } DESCRIPTOR;\r | |
53 | \r | |
54 | typedef\r | |
55 | VOID\r | |
56 | (*DEBUG_PROC) (\r | |
57 | VOID\r | |
58 | )\r | |
59 | ;\r | |
60 | \r | |
61 | typedef struct {\r | |
62 | DESCRIPTOR OrigDesc;\r | |
63 | DEBUG_PROC OrigVector;\r | |
64 | DESCRIPTOR NewDesc;\r | |
65 | DEBUG_PROC StubEntry;\r | |
66 | VOID (*RegisteredCallback) ();\r | |
67 | } IDT_ENTRY;\r | |
68 | \r | |
69 | extern EFI_SYSTEM_CONTEXT SystemContext;\r | |
70 | extern UINT8 InterruptEntryStub[];\r | |
71 | extern UINT32 StubSize;\r | |
72 | extern VOID (*OrigVector) (VOID);\r | |
73 | \r | |
74 | VOID\r | |
75 | CommonIdtEntry (\r | |
76 | VOID\r | |
77 | )\r | |
78 | /*++\r | |
79 | \r | |
80 | Routine Description:\r | |
81 | \r | |
82 | Generic IDT entry\r | |
83 | \r | |
84 | Arguments:\r | |
85 | \r | |
86 | None\r | |
87 | \r | |
88 | Returns:\r | |
89 | \r | |
90 | None\r | |
91 | \r | |
92 | --*/\r | |
93 | ;\r | |
94 | \r | |
95 | \r | |
96 | BOOLEAN\r | |
97 | FxStorSupport (\r | |
98 | VOID\r | |
99 | )\r | |
100 | /*++\r | |
101 | \r | |
102 | Routine Description:\r | |
103 | \r | |
104 | Check whether FXSTOR is supported\r | |
105 | \r | |
106 | Arguments:\r | |
107 | \r | |
108 | None\r | |
109 | \r | |
110 | Returns:\r | |
111 | \r | |
112 | TRUE - supported\r | |
113 | FALSE - not supported\r | |
114 | \r | |
115 | --*/\r | |
116 | ;\r | |
117 | \r | |
118 | DESCRIPTOR *\r | |
119 | GetIdtr (\r | |
120 | VOID\r | |
121 | )\r | |
122 | /*++\r | |
123 | \r | |
124 | Routine Description:\r | |
125 | \r | |
126 | Return the physical address of IDTR\r | |
127 | \r | |
128 | Arguments:\r | |
129 | \r | |
130 | None\r | |
131 | \r | |
132 | Returns:\r | |
133 | \r | |
134 | The physical address of IDTR\r | |
135 | \r | |
136 | --*/\r | |
137 | ;\r | |
138 | \r | |
139 | VOID\r | |
140 | Vect2Desc (\r | |
141 | DESCRIPTOR * DestDesc,\r | |
142 | VOID (*Vector) (VOID)\r | |
143 | )\r | |
144 | /*++\r | |
145 | \r | |
146 | Routine Description:\r | |
147 | \r | |
148 | Encodes an IDT descriptor with the given physical address\r | |
149 | \r | |
150 | Arguments:\r | |
151 | \r | |
152 | DestDesc - The IDT descriptor address\r | |
153 | Vector - The interrupt vector entry\r | |
154 | \r | |
155 | Returns:\r | |
156 | \r | |
157 | None\r | |
158 | \r | |
159 | --*/\r | |
160 | ;\r | |
161 | \r | |
162 | BOOLEAN\r | |
163 | WriteInterruptFlag (\r | |
164 | BOOLEAN NewState\r | |
165 | )\r | |
166 | /*++\r | |
167 | \r | |
168 | Routine Description:\r | |
169 | \r | |
170 | Programs interrupt flag to the requested state and returns previous\r | |
171 | state.\r | |
172 | \r | |
173 | Arguments:\r | |
174 | \r | |
175 | NewState - New interrupt status\r | |
176 | \r | |
177 | Returns:\r | |
178 | \r | |
179 | Old interrupt status\r | |
180 | \r | |
181 | --*/\r | |
182 | ;\r | |
183 | \r | |
184 | EFI_STATUS\r | |
185 | plInitializeDebugSupportDriver (\r | |
186 | VOID\r | |
187 | )\r | |
188 | /*++\r | |
189 | \r | |
190 | Routine Description:\r | |
191 | Initializes driver's handler registration database.\r | |
192 | \r | |
193 | This code executes in boot services context.\r | |
194 | \r | |
195 | Arguments:\r | |
196 | None\r | |
197 | \r | |
198 | Returns:\r | |
199 | EFI_SUCCESS\r | |
200 | EFI_UNSUPPORTED - if X64 processor does not support FXSTOR/FXRSTOR instructions,\r | |
201 | the context save will fail, so these processor's are not supported.\r | |
202 | EFI_OUT_OF_RESOURCES - not resource to finish initialization\r | |
203 | \r | |
204 | --*/\r | |
205 | ;\r | |
206 | \r | |
207 | EFI_STATUS\r | |
208 | EFIAPI\r | |
209 | plUnloadDebugSupportDriver (\r | |
210 | IN EFI_HANDLE ImageHandle\r | |
211 | )\r | |
212 | /*++\r | |
213 | \r | |
214 | Routine Description:\r | |
215 | This is the callback that is written to the LoadedImage protocol instance\r | |
216 | on the image handle. It uninstalls all registered handlers and frees all entry\r | |
217 | stub memory.\r | |
218 | \r | |
219 | This code executes in boot services context.\r | |
220 | \r | |
221 | Arguments:\r | |
222 | ImageHandle - The image handle of the unload handler\r | |
223 | \r | |
224 | Returns:\r | |
225 | \r | |
226 | EFI_SUCCESS - always return success\r | |
227 | \r | |
228 | --*/\r | |
229 | ;\r | |
230 | \r | |
231 | //\r | |
232 | // DebugSupport protocol member functions\r | |
233 | //\r | |
234 | EFI_STATUS\r | |
235 | EFIAPI\r | |
236 | GetMaximumProcessorIndex (\r | |
237 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
238 | OUT UINTN *MaxProcessorIndex\r | |
239 | )\r | |
240 | /*++\r | |
241 | \r | |
242 | Routine Description: This is a DebugSupport protocol member function.\r | |
243 | \r | |
244 | Arguments:\r | |
245 | This - The DebugSupport instance\r | |
246 | MaxProcessorIndex - The maximuim supported processor index\r | |
247 | \r | |
248 | Returns:\r | |
249 | Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r | |
250 | \r | |
251 | --*/\r | |
252 | ;\r | |
253 | \r | |
254 | EFI_STATUS\r | |
255 | EFIAPI\r | |
256 | RegisterPeriodicCallback (\r | |
257 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
258 | IN UINTN ProcessorIndex,\r | |
259 | IN EFI_PERIODIC_CALLBACK PeriodicCallback\r | |
260 | )\r | |
261 | /*++\r | |
262 | \r | |
263 | Routine Description: This is a DebugSupport protocol member function.\r | |
264 | \r | |
265 | Arguments:\r | |
266 | This - The DebugSupport instance\r | |
267 | ProcessorIndex - Which processor the callback applies to.\r | |
268 | PeriodicCallback - Callback function\r | |
269 | \r | |
270 | Returns:\r | |
271 | \r | |
272 | EFI_SUCCESS\r | |
273 | EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r | |
274 | no handler registered for it\r | |
275 | EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.\r | |
276 | \r | |
277 | Other possible return values are passed through from UnHookEntry and HookEntry.\r | |
278 | \r | |
279 | --*/\r | |
280 | ;\r | |
281 | \r | |
282 | EFI_STATUS\r | |
283 | EFIAPI\r | |
284 | RegisterExceptionCallback (\r | |
285 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
286 | IN UINTN ProcessorIndex,\r | |
287 | IN EFI_EXCEPTION_CALLBACK NewCallback,\r | |
288 | IN EFI_EXCEPTION_TYPE ExceptionType\r | |
289 | )\r | |
290 | /*++\r | |
291 | \r | |
292 | Routine Description:\r | |
293 | This is a DebugSupport protocol member function.\r | |
294 | \r | |
295 | This code executes in boot services context.\r | |
296 | \r | |
297 | Arguments:\r | |
298 | This - The DebugSupport instance\r | |
299 | ProcessorIndex - Which processor the callback applies to.\r | |
300 | NewCallback - Callback function\r | |
301 | ExceptionType - Which exception to hook\r | |
302 | \r | |
303 | Returns:\r | |
304 | \r | |
305 | EFI_SUCCESS\r | |
306 | EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r | |
307 | no handler registered for it\r | |
308 | EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.\r | |
309 | \r | |
310 | Other possible return values are passed through from UnHookEntry and HookEntry.\r | |
311 | \r | |
312 | --*/\r | |
313 | ;\r | |
314 | \r | |
315 | EFI_STATUS\r | |
316 | EFIAPI\r | |
317 | InvalidateInstructionCache (\r | |
318 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
319 | IN UINTN ProcessorIndex,\r | |
320 | IN VOID *Start,\r | |
321 | IN UINT64 Length\r | |
322 | )\r | |
323 | /*++\r | |
324 | \r | |
325 | Routine Description:\r | |
326 | This is a DebugSupport protocol member function.\r | |
327 | Calls assembly routine to flush cache.\r | |
328 | \r | |
329 | Arguments:\r | |
330 | This - The DebugSupport instance\r | |
331 | ProcessorIndex - Which processor the callback applies to.\r | |
332 | Start - Physical base of the memory range to be invalidated\r | |
333 | Length - mininum number of bytes in instruction cache to invalidate\r | |
334 | \r | |
335 | Returns:\r | |
336 | \r | |
337 | EFI_SUCCESS - always return success\r | |
338 | \r | |
339 | --*/\r | |
340 | ;\r | |
341 | \r | |
342 | #endif\r |