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