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