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