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