]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DebugSupportDxe/Ia32/plDebugSupport.h
The driver and library in MdePkg, MdeModulePkg and Nt32Pkg that don't depend on PI...
[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
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
43typedef UINT64 DESCRIPTOR;\r
44\r
45typedef\r
46VOID\r
47(*DEBUG_PROC) (\r
48 VOID\r
49 )\r
50;\r
51\r
52typedef 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
60extern EFI_SYSTEM_CONTEXT SystemContext;\r
61extern UINT8 InterruptEntryStub[];\r
62extern UINT32 StubSize;\r
63extern VOID (*OrigVector) (VOID);\r
64\r
65VOID\r
66CommonIdtEntry (\r
67 VOID\r
68 )\r
69/*++\r
70\r
71Routine Description:\r
72\r
73 Generic IDT entry\r
74\r
75Arguments:\r
76\r
77 None\r
78\r
79Returns:\r
80\r
81 None\r
82\r
83--*/\r
84;\r
85\r
86\r
87BOOLEAN\r
88FxStorSupport (\r
89 VOID\r
90 )\r
91/*++\r
92\r
93Routine Description:\r
94\r
95 Check whether FXSTOR is supported\r
96\r
97Arguments:\r
98\r
99 None\r
100\r
101Returns:\r
102\r
103 TRUE - supported\r
104 FALSE - not supported\r
105\r
106--*/\r
107;\r
108\r
109DESCRIPTOR *\r
110GetIdtr (\r
111 VOID\r
112 )\r
113/*++\r
114\r
115Routine Description:\r
116\r
117 Return the physical address of IDTR\r
118\r
119Arguments:\r
120\r
121 None\r
122\r
123Returns:\r
124\r
125 The physical address of IDTR\r
126\r
127--*/\r
128;\r
129\r
130VOID\r
131Vect2Desc (\r
132 DESCRIPTOR * DestDesc,\r
133 VOID (*Vector) (VOID)\r
134 )\r
135/*++\r
136\r
137Routine Description:\r
138\r
139 Encodes an IDT descriptor with the given physical address\r
140\r
141Arguments:\r
142\r
143 DestDesc - The IDT descriptor address\r
144 Vector - The interrupt vector entry\r
145\r
146Returns:\r
147\r
148 None\r
149\r
150--*/\r
151;\r
152\r
153BOOLEAN\r
154WriteInterruptFlag (\r
155 BOOLEAN NewState\r
156 )\r
157/*++\r
158\r
159Routine Description:\r
160\r
161 Programs interrupt flag to the requested state and returns previous\r
162 state.\r
163\r
164Arguments:\r
165\r
166 NewState - New interrupt status\r
167\r
168Returns:\r
169\r
170 Old interrupt status\r
171\r
172--*/\r
173;\r
174\r
175EFI_STATUS\r
176plInitializeDebugSupportDriver (\r
177 VOID\r
178 )\r
179/*++\r
180\r
181Routine Description:\r
182 Initializes driver's handler registration database.\r
183\r
184 This code executes in boot services context.\r
185\r
186Arguments:\r
187 None\r
188\r
189Returns:\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
198EFI_STATUS\r
199EFIAPI\r
200plUnloadDebugSupportDriver (\r
201 IN EFI_HANDLE ImageHandle\r
202 )\r
203/*++\r
204\r
205Routine 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
212Arguments:\r
213 ImageHandle - The image handle of the unload handler\r
214\r
215Returns:\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
225EFI_STATUS\r
226EFIAPI\r
227GetMaximumProcessorIndex (\r
228 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
229 OUT UINTN *MaxProcessorIndex\r
230 )\r
231/*++\r
232\r
233Routine Description: This is a DebugSupport protocol member function.\r
234\r
235Arguments:\r
236 This - The DebugSupport instance\r
237 MaxProcessorIndex - The maximuim supported processor index\r
238\r
239Returns:\r
240 Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
241\r
242--*/\r
243;\r
244\r
245EFI_STATUS\r
246EFIAPI\r
247RegisterPeriodicCallback (\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
254Routine Description: This is a DebugSupport protocol member function.\r
255\r
256Arguments:\r
257 This - The DebugSupport instance\r
258 ProcessorIndex - Which processor the callback applies to.\r
259 PeriodicCallback - Callback function\r
260\r
261Returns:\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
273EFI_STATUS\r
274EFIAPI\r
275RegisterExceptionCallback (\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
283Routine Description:\r
284 This is a DebugSupport protocol member function.\r
285\r
286 This code executes in boot services context.\r
287\r
288Arguments:\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
294Returns:\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
306EFI_STATUS\r
307EFIAPI\r
308InvalidateInstructionCache (\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
316Routine Description:\r
317 This is a DebugSupport protocol member function.\r
318 Calls assembly routine to flush cache.\r
319\r
320Arguments:\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
326Returns:\r
327\r
328 EFI_SUCCESS - always return success\r
329\r
330--*/\r
331;\r
332\r
333#endif\r