2 IPF specific types, macros, and definitions for Debug Support Driver.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 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
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.
15 #ifndef _PLDEBUG_SUPPORT_H_
16 #define _PLDEBUG_SUPPORT_H_
20 #include <Protocol/DebugSupport.h>
21 #include <Protocol/LoadedImage.h>
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>
29 #define DISABLE_INTERRUPTS 0UL
31 #define EFI_ISA IsaIpf
44 IPF specific DebugSupport driver initialization.
46 Must be public because it's referenced from DebugSupport.c
48 @retval EFI_SUCCESS Always.
52 PlInitializeDebugSupportDriver (
57 Unload handler that is called during UnloadImage() - deallocates pool memory
60 Must be public because it's referenced from DebugSuport.c
62 @param ImageHandle The firmware allocated handle for the EFI image.
64 @retval EFI_SUCCESS Always.
69 PlUnloadDebugSupportDriver (
70 IN EFI_HANDLE ImageHandle
74 C callable function to obtain the current value of IVA.
76 @return Current value of IVA.
85 C callable function that HookStub will be copied from it's loaded location into the IVT when
86 an IVT entry is hooked.
95 C callable function to chain an interrupt handler.
104 C callable function to unchain an interrupt handler.
113 C callable function to enable/disable interrupts.
115 @param NewInterruptState New Interrupt State.
117 @return Previous state of psr.ic.
121 ProgramInterruptFlags (
122 IN UINT64 NewInterruptState
126 Flushes instruction cache for specified number of bytes.
128 @param StartAddress Cache Start Address.
129 @param SizeInBytes Cache Size.
133 InstructionCacheFlush (
134 IN VOID
*StartAddress
,
139 Returns the maximum value that may be used for the ProcessorIndex parameter in
140 RegisterPeriodicCallback() and RegisterExceptionCallback().
142 Hard coded to support only 1 processor for now.
144 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
145 @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the maximum supported
146 processor index is returned. Always 0 returned.
148 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
153 GetMaximumProcessorIndex (
154 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
155 OUT UINTN
*MaxProcessorIndex
159 Registers a function to be called back periodically in interrupt context.
161 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
162 @param ProcessorIndex Specifies which processor the callback function applies to.
163 @param PeriodicCallback A pointer to a function of type PERIODIC_CALLBACK that is the main
164 periodic entry point of the debug agent.
166 @retval EFI_SUCCESS The function completed successfully.
167 @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
168 function was previously registered.
169 @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
174 RegisterPeriodicCallback (
175 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
176 IN UINTN ProcessorIndex
,
177 IN EFI_PERIODIC_CALLBACK PeriodicCallback
181 Registers a function to be called when a given processor exception occurs.
183 This code executes in boot services context.
185 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
186 @param ProcessorIndex Specifies which processor the callback function applies to.
187 @param ExceptionCallback A pointer to a function of type EXCEPTION_CALLBACK that is called
188 when the processor exception specified by ExceptionType occurs.
189 @param ExceptionType Specifies which processor exception to hook.
191 @retval EFI_SUCCESS The function completed successfully.
192 @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
193 function was previously registered.
194 @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
199 RegisterExceptionCallback (
200 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
201 IN UINTN ProcessorIndex
,
202 IN EFI_EXCEPTION_CALLBACK ExceptionCallback
,
203 IN EFI_EXCEPTION_TYPE ExceptionType
207 Invalidates processor instruction cache for a memory range. Subsequent execution in this range
208 causes a fresh memory fetch to retrieve code to be executed.
210 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
211 @param ProcessorIndex Specifies which processor's instruction cache is to be invalidated.
212 @param Start Specifies the physical base of the memory range to be invalidated.
213 @param Length Specifies the minimum number of bytes in the processor's instruction
216 @retval EFI_SUCCESS Always returned.
221 InvalidateInstructionCache (
222 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
223 IN UINTN ProcessorIndex
,
229 C routine that is called for all registered exceptions. This is the main
230 exception dispatcher.
232 Must be public because it's referenced from AsmFuncs.s.
234 @param ExceptionType Specifies which processor exception.
235 @param Context System Context.
239 IN EFI_EXCEPTION_TYPE ExceptionType
,
240 IN EFI_SYSTEM_CONTEXT Context
244 This is the worker function that uninstalls and removes all handlers.
246 @param ExceptionType Specifies which processor exception.
247 @param NewBundles New Boundles.
248 @param NewCallback A pointer to the new function to be registered.
250 @retval EFI_ALEADY_STARTED Ivt already hooked.
251 @retval EFI_SUCCESS Successfully uninstalled.
255 ManageIvtEntryTable (
256 IN EFI_EXCEPTION_TYPE ExceptionType
,
257 IN BUNDLE NewBundles
[4],
258 IN CALLBACK_FUNC NewCallback
262 Saves original IVT contents and inserts a few new bundles which are fixed up
263 to store the ExceptionType and then call the common handler.
265 @param ExceptionType Specifies which processor exception.
266 @param NewBundles New Boundles.
267 @param NewCallback A pointer to the new function to be hooked.
272 IN EFI_EXCEPTION_TYPE ExceptionType
,
273 IN BUNDLE NewBundles
[4],
274 IN CALLBACK_FUNC NewCallback
278 Restores original IVT contents when unregistering a callback function.
280 @param ExceptionType Specifies which processor exception.
285 IN EFI_EXCEPTION_TYPE ExceptionType
289 Sets up cache flush and calls assembly function to chain external interrupt.
291 Records new callback in IvtEntryTable.
293 @param NewCallback A pointer to the interrupt handle.
297 ChainExternalInterrupt (
298 IN CALLBACK_FUNC NewCallback
302 Sets up cache flush and calls assembly function to restore external interrupt.
303 Removes registered callback from IvtEntryTable.
307 UnchainExternalInterrupt (
312 Given an integer number, return the physical address of the entry point in the IFT.
314 @param HandlerIndex Index of the Handler
315 @param EntryPoint IFT Entrypoint
319 GetHandlerEntryPoint (