]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DebugSupportDxe/Ipf/PlDebugSupport.h
202033 make .h more clear, seperate ComponentName.h IScsiInitiatorName.h from IScsiDr...
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ipf / PlDebugSupport.h
CommitLineData
9e604fe4 1/** @file\r
c1f23d63 2 IPF specific debugsupport types, macros, and definitions.\r
3 \r
4Copyright (c) 2004 - 2006 Intel Corporation \r
5All rights reserved. This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
9e604fe4 15#ifndef _PLDEBUG_SUPPORT_H_\r
16#define _PLDEBUG_SUPPORT_H_\r
c1f23d63 17\r
60c93673 18#include <Uefi.h>\r
ed7748fe 19\r
c1f23d63 20#include <Protocol/DebugSupport.h>\r
21#include <Protocol/LoadedImage.h>\r
ed7748fe 22\r
c1f23d63 23#include <Library/DebugLib.h>\r
24#include <Library/UefiDriverEntryPoint.h>\r
25#include <Library/BaseMemoryLib.h>\r
26#include <Library/MemoryAllocationLib.h>\r
27#include <Library/UefiBootServicesTableLib.h>\r
c1f23d63 28\r
29#define DISABLE_INTERRUPTS 0UL\r
30\r
c1f23d63 31#define EFI_ISA IsaIpf\r
32\r
c84507ab 33typedef struct {\r
34 UINT64 low;\r
35 UINT64 high;\r
36} BUNDLE;\r
37\r
9e604fe4 38/**\r
39 IPF specific DebugSupport driver initialization. \r
c1f23d63 40\r
9e604fe4 41 Must be public because it's referenced from DebugSupport.c\r
c1f23d63 42\r
9e604fe4 43 @retval EFI_SUCCESS Always.\r
c1f23d63 44\r
9e604fe4 45**/\r
c1f23d63 46EFI_STATUS\r
9e604fe4 47PlInitializeDebugSupportDriver (\r
48 VOID\r
49 );\r
c1f23d63 50\r
9e604fe4 51/**\r
c1f23d63 52 Unload handler that is called during UnloadImage() - deallocates pool memory\r
53 used by the driver. Must be public because it's referenced from DebugSuport.c\r
54\r
9e604fe4 55 @param ImageHandle The firmware allocated handle for the EFI image.\r
c1f23d63 56\r
9e604fe4 57 @retval EFI_SUCCESS Always.\r
c1f23d63 58\r
9e604fe4 59**/\r
60EFI_STATUS\r
61EFIAPI\r
62PlUnloadDebugSupportDriver (\r
63 IN EFI_HANDLE ImageHandle\r
64 );\r
c1f23d63 65\r
9e604fe4 66/**\r
67 C callable function to obtain the current value of IVA.\r
c1f23d63 68\r
9e604fe4 69 @return Current value of IVA.\r
70\r
71**/\r
c1f23d63 72VOID *\r
73GetIva (\r
74 VOID\r
9e604fe4 75 );\r
c1f23d63 76\r
9e604fe4 77/**\r
78 HookStub will be copied from it's loaded location into the IVT when\r
79 an IVT entry is hooked.\r
c1f23d63 80\r
9e604fe4 81**/\r
c1f23d63 82VOID\r
83HookStub (\r
84 VOID\r
9e604fe4 85 );\r
c1f23d63 86\r
9e604fe4 87/**\r
88 Chains an interrupt handler.\r
c1f23d63 89\r
9e604fe4 90**/\r
c1f23d63 91VOID\r
92ChainHandler (\r
93 VOID\r
9e604fe4 94 );\r
c1f23d63 95\r
9e604fe4 96/**\r
97 Unchains an interrupt handler.\r
c1f23d63 98\r
9e604fe4 99**/\r
c1f23d63 100VOID\r
101UnchainHandler (\r
102 VOID\r
9e604fe4 103 );\r
c1f23d63 104\r
9e604fe4 105/**\r
106 C callable function to enable/disable interrupts.\r
c1f23d63 107\r
9e604fe4 108 @param NewInterruptState New Interrupt State.\r
c1f23d63 109\r
9e604fe4 110 @return Previous state of psr.ic.\r
c1f23d63 111\r
9e604fe4 112**/\r
c1f23d63 113UINT64\r
114ProgramInterruptFlags (\r
115 IN UINT64 NewInterruptState\r
9e604fe4 116 );\r
c1f23d63 117\r
9e604fe4 118/**\r
119 Flushes instruction cache for specified number of bytes.\r
c1f23d63 120\r
9e604fe4 121 @param StartAddress Cache Start Address.\r
122 @param SizeInBytes Cache Size.\r
c1f23d63 123\r
9e604fe4 124**/\r
c1f23d63 125VOID\r
126InstructionCacheFlush (\r
127 IN VOID *StartAddress,\r
128 IN UINTN SizeInBytes\r
9e604fe4 129 );\r
c1f23d63 130\r
9e604fe4 131/**\r
132 This is a DebugSupport protocol member function, hard\r
133 coded to support only 1 processor for now.\r
c1f23d63 134\r
9e604fe4 135 @param This The DebugSupport instance\r
136 @param MaxProcessorIndex The maximuim supported processor index\r
c1f23d63 137\r
9e604fe4 138 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r
c1f23d63 139\r
9e604fe4 140**/\r
c1f23d63 141EFI_STATUS\r
142EFIAPI\r
143GetMaximumProcessorIndex (\r
144 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
145 OUT UINTN *MaxProcessorIndex\r
9e604fe4 146 );\r
c1f23d63 147\r
9e604fe4 148/**\r
149 DebugSupport protocol member function.\r
c1f23d63 150\r
9e604fe4 151 @param This The DebugSupport instance\r
152 @param ProcessorIndex Which processor the callback applies to.\r
153 @param PeriodicCallback Callback function\r
c1f23d63 154\r
9e604fe4 155 @retval EFI_SUCCESS Indicates the callback was registered.\r
156 @retval others Callback was not registered.\r
c1f23d63 157\r
9e604fe4 158**/\r
c1f23d63 159EFI_STATUS\r
160EFIAPI\r
161RegisterPeriodicCallback (\r
162 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
163 IN UINTN ProcessorIndex,\r
164 IN EFI_PERIODIC_CALLBACK PeriodicCallback\r
9e604fe4 165 );\r
c1f23d63 166\r
9e604fe4 167/**\r
168 DebugSupport protocol member function.\r
c1f23d63 169\r
9e604fe4 170 @param This The DebugSupport instance\r
171 @param ProcessorIndex Which processor the callback applies to.\r
172 @param NewCallback Callback function\r
173 @param ExceptionType Which exception to hook\r
c1f23d63 174\r
9e604fe4 175 @retval EFI_SUCCESS Indicates the callback was registered.\r
176 @retval others Callback was not registered.\r
c1f23d63 177\r
9e604fe4 178**/\r
c1f23d63 179EFI_STATUS\r
180EFIAPI\r
181RegisterExceptionCallback (\r
182 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
183 IN UINTN ProcessorIndex,\r
9e604fe4 184 IN EFI_EXCEPTION_CALLBACK NewCallback,\r
c1f23d63 185 IN EFI_EXCEPTION_TYPE ExceptionType\r
9e604fe4 186 );\r
c1f23d63 187\r
9e604fe4 188/**\r
189 DebugSupport protocol member function. Calls assembly routine to flush cache.\r
c1f23d63 190\r
9e604fe4 191 @param This The DebugSupport instance\r
192 @param ProcessorIndex Which processor the callback applies to.\r
193 @param Start Physical base of the memory range to be invalidated\r
194 @param Length mininum number of bytes in instruction cache to invalidate\r
c1f23d63 195\r
9e604fe4 196 @retval EFI_SUCCESS Always returned.\r
c1f23d63 197\r
9e604fe4 198**/\r
c1f23d63 199EFI_STATUS\r
200EFIAPI\r
201InvalidateInstructionCache (\r
202 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
203 IN UINTN ProcessorIndex,\r
204 IN VOID *Start,\r
205 IN UINTN Length\r
9e604fe4 206 );\r
c1f23d63 207\r
9e604fe4 208/**\r
209 C routine that is called for all registered exceptions. This is the main\r
210 exception dispatcher. Must be public because it's referenced from AsmFuncs.s.\r
c1f23d63 211\r
9e604fe4 212 @param ExceptionType Exception Type\r
213 @param Context System Context\r
214**/\r
c1f23d63 215VOID\r
216CommonHandler (\r
217 IN EFI_EXCEPTION_TYPE ExceptionType,\r
218 IN EFI_SYSTEM_CONTEXT Context\r
9e604fe4 219 );\r
c1f23d63 220\r
c84507ab 221/**\r
222 This is the worker function that uninstalls and removes all handlers.\r
223\r
224 @param ExceptionType Exception Type\r
225 @param NewBundles New Boundles\r
226 @param NewCallback New Callback\r
227\r
228 @retval EFI_ALEADY_STARTED Ivt already hooked.\r
229 @retval others Indicates the request was not satisfied.\r
230 @retval EFI_SUCCESS Successfully uninstalled.\r
231\r
232**/\r
233EFI_STATUS\r
234ManageIvtEntryTable (\r
235 IN EFI_EXCEPTION_TYPE ExceptionType,\r
236 IN BUNDLE NewBundles[4],\r
237 IN VOID (*NewCallback) ()\r
238 );\r
239\r
240/**\r
241 Saves original IVT contents and inserts a few new bundles which are fixed up\r
242 to store the ExceptionType and then call the common handler.\r
243\r
244 @param ExceptionType Exception Type\r
245 @param NewBundles New Boundles\r
246 @param NewCallback New Callback\r
247\r
248**/\r
249VOID\r
250HookEntry (\r
251 IN EFI_EXCEPTION_TYPE ExceptionType,\r
252 IN BUNDLE NewBundles[4],\r
253 IN VOID (*NewCallback) ()\r
254 );\r
255\r
256/**\r
257 Restores original IVT contents when unregistering a callback function.\r
258\r
259 @param ExceptionType Exception Type\r
260\r
261**/\r
262VOID\r
263UnhookEntry (\r
264 IN EFI_EXCEPTION_TYPE ExceptionType\r
265 );\r
266\r
267/**\r
268 Sets up cache flush and calls assembly function to chain external interrupt.\r
269\r
270 Records new callback in IvtEntryTable.\r
271\r
272 @param NewCallback New Callback.\r
273\r
274**/\r
275VOID\r
276ChainExternalInterrupt (\r
277 IN VOID (*NewCallback) ()\r
278 );\r
279\r
280/**\r
281 Sets up cache flush and calls assembly function to restore external interrupt.\r
282 Removes registered callback from IvtEntryTable.\r
283\r
284**/\r
285VOID\r
286UnchainExternalInterrupt (\r
287 VOID\r
288 );\r
289\r
290/**\r
291 Given an integer number, return the physical address of the entry point in the IFT.\r
292\r
293 @param HandlerIndex Index of the Handler \r
294 @param EntryPoint IFT Entrypoint\r
295\r
296**/\r
297VOID\r
298GetHandlerEntryPoint (\r
299 UINTN HandlerIndex,\r
300 VOID **EntryPoint\r
301 );\r
302\r
c1f23d63 303#endif\r