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