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