]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DebugSupportDxe/Ipf/PlDebugSupport.h
code scrub for DebugSpport Module.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ipf / PlDebugSupport.h
1 /** @file
2 IPF specific debugsupport types, macros, and definitions.
3
4 Copyright (c) 2004 - 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 #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. Must be public because it's referenced from DebugSuport.c
54
55 @param ImageHandle The firmware allocated handle for the EFI image.
56
57 @retval EFI_SUCCESS Always.
58
59 **/
60 EFI_STATUS
61 EFIAPI
62 PlUnloadDebugSupportDriver (
63 IN EFI_HANDLE ImageHandle
64 );
65
66 /**
67 C callable function to obtain the current value of IVA.
68
69 @return Current value of IVA.
70
71 **/
72 VOID *
73 GetIva (
74 VOID
75 );
76
77 /**
78 HookStub will be copied from it's loaded location into the IVT when
79 an IVT entry is hooked.
80
81 **/
82 VOID
83 HookStub (
84 VOID
85 );
86
87 /**
88 Chains an interrupt handler.
89
90 **/
91 VOID
92 ChainHandler (
93 VOID
94 );
95
96 /**
97 Unchains an interrupt handler.
98
99 **/
100 VOID
101 UnchainHandler (
102 VOID
103 );
104
105 /**
106 C callable function to enable/disable interrupts.
107
108 @param NewInterruptState New Interrupt State.
109
110 @return Previous state of psr.ic.
111
112 **/
113 UINT64
114 ProgramInterruptFlags (
115 IN UINT64 NewInterruptState
116 );
117
118 /**
119 Flushes instruction cache for specified number of bytes.
120
121 @param StartAddress Cache Start Address.
122 @param SizeInBytes Cache Size.
123
124 **/
125 VOID
126 InstructionCacheFlush (
127 IN VOID *StartAddress,
128 IN UINTN SizeInBytes
129 );
130
131 /**
132 This is a DebugSupport protocol member function, hard
133 coded to support only 1 processor for now.
134
135 @param This The DebugSupport instance
136 @param MaxProcessorIndex The maximuim supported processor index
137
138 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
139
140 **/
141 EFI_STATUS
142 EFIAPI
143 GetMaximumProcessorIndex (
144 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
145 OUT UINTN *MaxProcessorIndex
146 );
147
148 /**
149 DebugSupport protocol member function.
150
151 @param This The DebugSupport instance
152 @param ProcessorIndex Which processor the callback applies to.
153 @param PeriodicCallback Callback function
154
155 @retval EFI_SUCCESS Indicates the callback was registered.
156 @retval others Callback was not registered.
157
158 **/
159 EFI_STATUS
160 EFIAPI
161 RegisterPeriodicCallback (
162 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
163 IN UINTN ProcessorIndex,
164 IN EFI_PERIODIC_CALLBACK PeriodicCallback
165 );
166
167 /**
168 DebugSupport protocol member function.
169
170 @param This The DebugSupport instance
171 @param ProcessorIndex Which processor the callback applies to.
172 @param NewCallback Callback function
173 @param ExceptionType Which exception to hook
174
175 @retval EFI_SUCCESS Indicates the callback was registered.
176 @retval others Callback was not registered.
177
178 **/
179 EFI_STATUS
180 EFIAPI
181 RegisterExceptionCallback (
182 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
183 IN UINTN ProcessorIndex,
184 IN EFI_EXCEPTION_CALLBACK NewCallback,
185 IN EFI_EXCEPTION_TYPE ExceptionType
186 );
187
188 /**
189 DebugSupport protocol member function. Calls assembly routine to flush cache.
190
191 @param This The DebugSupport instance
192 @param ProcessorIndex Which processor the callback applies to.
193 @param Start Physical base of the memory range to be invalidated
194 @param Length mininum number of bytes in instruction cache to invalidate
195
196 @retval EFI_SUCCESS Always returned.
197
198 **/
199 EFI_STATUS
200 EFIAPI
201 InvalidateInstructionCache (
202 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
203 IN UINTN ProcessorIndex,
204 IN VOID *Start,
205 IN UINTN Length
206 );
207
208 /**
209 C routine that is called for all registered exceptions. This is the main
210 exception dispatcher. Must be public because it's referenced from AsmFuncs.s.
211
212 @param ExceptionType Exception Type
213 @param Context System Context
214 **/
215 VOID
216 CommonHandler (
217 IN EFI_EXCEPTION_TYPE ExceptionType,
218 IN EFI_SYSTEM_CONTEXT Context
219 );
220
221 /**
222 This is the worker function that uninstalls and removes all handlers.
223
224 @param ExceptionType Exception Type
225 @param NewBundles New Boundles
226 @param NewCallback New Callback
227
228 @retval EFI_ALEADY_STARTED Ivt already hooked.
229 @retval others Indicates the request was not satisfied.
230 @retval EFI_SUCCESS Successfully uninstalled.
231
232 **/
233 EFI_STATUS
234 ManageIvtEntryTable (
235 IN EFI_EXCEPTION_TYPE ExceptionType,
236 IN BUNDLE NewBundles[4],
237 IN VOID (*NewCallback) ()
238 );
239
240 /**
241 Saves original IVT contents and inserts a few new bundles which are fixed up
242 to store the ExceptionType and then call the common handler.
243
244 @param ExceptionType Exception Type
245 @param NewBundles New Boundles
246 @param NewCallback New Callback
247
248 **/
249 VOID
250 HookEntry (
251 IN EFI_EXCEPTION_TYPE ExceptionType,
252 IN BUNDLE NewBundles[4],
253 IN VOID (*NewCallback) ()
254 );
255
256 /**
257 Restores original IVT contents when unregistering a callback function.
258
259 @param ExceptionType Exception Type
260
261 **/
262 VOID
263 UnhookEntry (
264 IN EFI_EXCEPTION_TYPE ExceptionType
265 );
266
267 /**
268 Sets up cache flush and calls assembly function to chain external interrupt.
269
270 Records new callback in IvtEntryTable.
271
272 @param NewCallback New Callback.
273
274 **/
275 VOID
276 ChainExternalInterrupt (
277 IN VOID (*NewCallback) ()
278 );
279
280 /**
281 Sets up cache flush and calls assembly function to restore external interrupt.
282 Removes registered callback from IvtEntryTable.
283
284 **/
285 VOID
286 UnchainExternalInterrupt (
287 VOID
288 );
289
290 /**
291 Given an integer number, return the physical address of the entry point in the IFT.
292
293 @param HandlerIndex Index of the Handler
294 @param EntryPoint IFT Entrypoint
295
296 **/
297 VOID
298 GetHandlerEntryPoint (
299 UINTN HandlerIndex,
300 VOID **EntryPoint
301 );
302
303 #endif