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