]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DebugSupportDxe/Ipf/PlDebugSupport.h
9f6bd3efdd9b739b36eb3cd9bbe10406ccdf6fd8
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ipf / PlDebugSupport.h
1 /** @file
2 IPF specific types, macros, and definitions for Debug Support Driver.
3
4 Copyright (c) 2004 - 2008, 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 #include <Uefi.h>
19
20 #include <Protocol/DebugSupport.h>
21 #include <Protocol/LoadedImage.h>
22
23 #include <Library/DebugLib.h>
24 #include <Library/UefiDriverEntryPoint.h>
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28
29 #define DISABLE_INTERRUPTS 0UL
30
31 #define EFI_ISA IsaIpf
32
33 typedef struct {
34 UINT64 low;
35 UINT64 high;
36 } BUNDLE;
37
38 /**
39 IPF specific DebugSupport driver initialization.
40
41 Must be public because it's referenced from DebugSupport.c
42
43 @retval EFI_SUCCESS Always.
44
45 **/
46 EFI_STATUS
47 PlInitializeDebugSupportDriver (
48 VOID
49 );
50
51 /**
52 Unload handler that is called during UnloadImage() - deallocates pool memory
53 used by the driver.
54
55 Must be public because it's referenced from DebugSuport.c
56
57 @param ImageHandle The firmware allocated handle for the EFI image.
58
59 @retval EFI_SUCCESS Always.
60
61 **/
62 EFI_STATUS
63 EFIAPI
64 PlUnloadDebugSupportDriver (
65 IN EFI_HANDLE ImageHandle
66 );
67
68 /**
69 C callable function to obtain the current value of IVA.
70
71 @return Current value of IVA.
72
73 **/
74 VOID *
75 GetIva (
76 VOID
77 );
78
79 /**
80 C callable function that HookStub will be copied from it's loaded location into the IVT when
81 an IVT entry is hooked.
82
83 **/
84 VOID
85 HookStub (
86 VOID
87 );
88
89 /**
90 C callable function to chain an interrupt handler.
91
92 **/
93 VOID
94 ChainHandler (
95 VOID
96 );
97
98 /**
99 C callable function to unchain an interrupt handler.
100
101 **/
102 VOID
103 UnchainHandler (
104 VOID
105 );
106
107 /**
108 C callable function to enable/disable interrupts.
109
110 @param NewInterruptState New Interrupt State.
111
112 @return Previous state of psr.ic.
113
114 **/
115 UINT64
116 ProgramInterruptFlags (
117 IN UINT64 NewInterruptState
118 );
119
120 /**
121 Flushes instruction cache for specified number of bytes.
122
123 @param StartAddress Cache Start Address.
124 @param SizeInBytes Cache Size.
125
126 **/
127 VOID
128 InstructionCacheFlush (
129 IN VOID *StartAddress,
130 IN UINTN SizeInBytes
131 );
132
133 /**
134 Returns the maximum value that may be used for the ProcessorIndex parameter in
135 RegisterPeriodicCallback() and RegisterExceptionCallback().
136
137 Hard coded to support only 1 processor for now.
138
139 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
140 @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the maximum supported
141 processor index is returned. Always 0 returned.
142
143 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
144
145 **/
146 EFI_STATUS
147 EFIAPI
148 GetMaximumProcessorIndex (
149 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
150 OUT UINTN *MaxProcessorIndex
151 );
152
153 /**
154 Registers a function to be called back periodically in interrupt context.
155
156 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
157 @param ProcessorIndex Specifies which processor the callback function applies to.
158 @param PeriodicCallback A pointer to a function of type PERIODIC_CALLBACK that is the main
159 periodic entry point of the debug agent.
160
161 @retval EFI_SUCCESS The function completed successfully.
162 @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
163 function was previously registered.
164 @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
165 function.
166 **/
167 EFI_STATUS
168 EFIAPI
169 RegisterPeriodicCallback (
170 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
171 IN UINTN ProcessorIndex,
172 IN EFI_PERIODIC_CALLBACK PeriodicCallback
173 );
174
175 /**
176 Registers a function to be called when a given processor exception occurs.
177
178 This code executes in boot services context.
179
180 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
181 @param ProcessorIndex Specifies which processor the callback function applies to.
182 @param ExceptionCallback A pointer to a function of type EXCEPTION_CALLBACK that is called
183 when the processor exception specified by ExceptionType occurs.
184 @param ExceptionType Specifies which processor exception to hook.
185
186 @retval EFI_SUCCESS The function completed successfully.
187 @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
188 function was previously registered.
189 @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
190 function.
191 **/
192 EFI_STATUS
193 EFIAPI
194 RegisterExceptionCallback (
195 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
196 IN UINTN ProcessorIndex,
197 IN EFI_EXCEPTION_CALLBACK ExceptionCallback,
198 IN EFI_EXCEPTION_TYPE ExceptionType
199 );
200
201 /**
202 Invalidates processor instruction cache for a memory range. Subsequent execution in this range
203 causes a fresh memory fetch to retrieve code to be executed.
204
205 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
206 @param ProcessorIndex Specifies which processor's instruction cache is to be invalidated.
207 @param Start Specifies the physical base of the memory range to be invalidated.
208 @param Length Specifies the minimum number of bytes in the processor's instruction
209 cache to invalidate.
210
211 @retval EFI_SUCCESS Always returned.
212
213 **/
214 EFI_STATUS
215 EFIAPI
216 InvalidateInstructionCache (
217 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
218 IN UINTN ProcessorIndex,
219 IN VOID *Start,
220 IN UINTN Length
221 );
222
223 /**
224 C routine that is called for all registered exceptions. This is the main
225 exception dispatcher.
226
227 Must be public because it's referenced from AsmFuncs.s.
228
229 @param ExceptionType Specifies which processor exception.
230 @param Context System Context.
231 **/
232 VOID
233 CommonHandler (
234 IN EFI_EXCEPTION_TYPE ExceptionType,
235 IN EFI_SYSTEM_CONTEXT Context
236 );
237
238 /**
239 This is the worker function that uninstalls and removes all handlers.
240
241 @param ExceptionType Specifies which processor exception.
242 @param NewBundles New Boundles.
243 @param NewCallback A pointer to the new function to be registered.
244
245 @retval EFI_ALEADY_STARTED Ivt already hooked.
246 @retval EFI_SUCCESS Successfully uninstalled.
247
248 **/
249 EFI_STATUS
250 ManageIvtEntryTable (
251 IN EFI_EXCEPTION_TYPE ExceptionType,
252 IN BUNDLE NewBundles[4],
253 IN VOID (*NewCallback) ()
254 );
255
256 /**
257 Saves original IVT contents and inserts a few new bundles which are fixed up
258 to store the ExceptionType and then call the common handler.
259
260 @param ExceptionType Specifies which processor exception.
261 @param NewBundles New Boundles.
262 @param NewCallback A pointer to the new function to be hooked.
263
264 **/
265 VOID
266 HookEntry (
267 IN EFI_EXCEPTION_TYPE ExceptionType,
268 IN BUNDLE NewBundles[4],
269 IN VOID (*NewCallback) ()
270 );
271
272 /**
273 Restores original IVT contents when unregistering a callback function.
274
275 @param ExceptionType Specifies which processor exception.
276
277 **/
278 VOID
279 UnhookEntry (
280 IN EFI_EXCEPTION_TYPE ExceptionType
281 );
282
283 /**
284 Sets up cache flush and calls assembly function to chain external interrupt.
285
286 Records new callback in IvtEntryTable.
287
288 @param NewCallback A pointer to the interrupt handle.
289
290 **/
291 VOID
292 ChainExternalInterrupt (
293 IN VOID (*NewCallback) ()
294 );
295
296 /**
297 Sets up cache flush and calls assembly function to restore external interrupt.
298 Removes registered callback from IvtEntryTable.
299
300 **/
301 VOID
302 UnchainExternalInterrupt (
303 VOID
304 );
305
306 /**
307 Given an integer number, return the physical address of the entry point in the IFT.
308
309 @param HandlerIndex Index of the Handler
310 @param EntryPoint IFT Entrypoint
311
312 **/
313 VOID
314 GetHandlerEntryPoint (
315 UINTN HandlerIndex,
316 VOID **EntryPoint
317 );
318
319 #endif