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