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