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