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