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