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