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