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