2 IPF specific types, macros, and definitions for Debug Support Driver.
4 Copyright (c) 2004 - 2008, 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
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
39 IPF specific DebugSupport driver initialization.
41 Must be public because it's referenced from DebugSupport.c
43 @retval EFI_SUCCESS Always.
47 PlInitializeDebugSupportDriver (
52 Unload handler that is called during UnloadImage() - deallocates pool memory
55 Must be public because it's referenced from DebugSuport.c
57 @param ImageHandle The firmware allocated handle for the EFI image.
59 @retval EFI_SUCCESS Always.
64 PlUnloadDebugSupportDriver (
65 IN EFI_HANDLE ImageHandle
69 C callable function to obtain the current value of IVA.
71 @return Current value of IVA.
80 C callable function that HookStub will be copied from it's loaded location into the IVT when
81 an IVT entry is hooked.
90 C callable function to chain an interrupt handler.
99 C callable function to unchain an interrupt handler.
108 C callable function to enable/disable interrupts.
110 @param NewInterruptState New Interrupt State.
112 @return Previous state of psr.ic.
116 ProgramInterruptFlags (
117 IN UINT64 NewInterruptState
121 Flushes instruction cache for specified number of bytes.
123 @param StartAddress Cache Start Address.
124 @param SizeInBytes Cache Size.
128 InstructionCacheFlush (
129 IN VOID
*StartAddress
,
134 Returns the maximum value that may be used for the ProcessorIndex parameter in
135 RegisterPeriodicCallback() and RegisterExceptionCallback().
137 Hard coded to support only 1 processor for now.
139 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
140 @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the maximum supported
141 processor index is returned. Always 0 returned.
143 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
148 GetMaximumProcessorIndex (
149 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
150 OUT UINTN
*MaxProcessorIndex
154 Registers a function to be called back periodically in interrupt context.
156 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
157 @param ProcessorIndex Specifies which processor the callback function applies to.
158 @param PeriodicCallback A pointer to a function of type PERIODIC_CALLBACK that is the main
159 periodic entry point of the debug agent.
161 @retval EFI_SUCCESS The function completed successfully.
162 @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
163 function was previously registered.
164 @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
169 RegisterPeriodicCallback (
170 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
171 IN UINTN ProcessorIndex
,
172 IN EFI_PERIODIC_CALLBACK PeriodicCallback
176 Registers a function to be called when a given processor exception occurs.
178 This code executes in boot services context.
180 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
181 @param ProcessorIndex Specifies which processor the callback function applies to.
182 @param ExceptionCallback A pointer to a function of type EXCEPTION_CALLBACK that is called
183 when the processor exception specified by ExceptionType occurs.
184 @param ExceptionType Specifies which processor exception to hook.
186 @retval EFI_SUCCESS The function completed successfully.
187 @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
188 function was previously registered.
189 @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
194 RegisterExceptionCallback (
195 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
196 IN UINTN ProcessorIndex
,
197 IN EFI_EXCEPTION_CALLBACK NewCallback
,
198 IN EFI_EXCEPTION_TYPE ExceptionType
202 Invalidates processor instruction cache for a memory range. Subsequent execution in this range
203 causes a fresh memory fetch to retrieve code to be executed.
205 @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
206 @param ProcessorIndex Specifies which processor's instruction cache is to be invalidated.
207 @param Start Specifies the physical base of the memory range to be invalidated.
208 @param Length Specifies the minimum number of bytes in the processor's instruction
211 @retval EFI_SUCCESS Always returned.
216 InvalidateInstructionCache (
217 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
218 IN UINTN ProcessorIndex
,
224 C routine that is called for all registered exceptions. This is the main
225 exception dispatcher.
227 Must be public because it's referenced from AsmFuncs.s.
229 @param ExceptionType Specifies which processor exception.
230 @param Context System Context.
234 IN EFI_EXCEPTION_TYPE ExceptionType
,
235 IN EFI_SYSTEM_CONTEXT Context
239 This is the worker function that uninstalls and removes all handlers.
241 @param ExceptionType Specifies which processor exception.
242 @param NewBundles New Boundles.
243 @param NewCallback A pointer to the new function to be registered.
245 @retval EFI_ALEADY_STARTED Ivt already hooked.
246 @retval EFI_SUCCESS Successfully uninstalled.
250 ManageIvtEntryTable (
251 IN EFI_EXCEPTION_TYPE ExceptionType
,
252 IN BUNDLE NewBundles
[4],
253 IN
VOID (*NewCallback
) ()
257 Saves original IVT contents and inserts a few new bundles which are fixed up
258 to store the ExceptionType and then call the common handler.
260 @param ExceptionType Specifies which processor exception.
261 @param NewBundles New Boundles.
262 @param NewCallback A pointer to the new function to be hooked.
267 IN EFI_EXCEPTION_TYPE ExceptionType
,
268 IN BUNDLE NewBundles
[4],
269 IN
VOID (*NewCallback
) ()
273 Restores original IVT contents when unregistering a callback function.
275 @param ExceptionType Specifies which processor exception.
280 IN EFI_EXCEPTION_TYPE ExceptionType
284 Sets up cache flush and calls assembly function to chain external interrupt.
286 Records new callback in IvtEntryTable.
288 @param NewCallback A pointer to the interrupt handle.
292 ChainExternalInterrupt (
293 IN
VOID (*NewCallback
) ()
297 Sets up cache flush and calls assembly function to restore external interrupt.
298 Removes registered callback from IvtEntryTable.
302 UnchainExternalInterrupt (
307 Given an integer number, return the physical address of the entry point in the IFT.
309 @param HandlerIndex Index of the Handler
310 @param EntryPoint IFT Entrypoint
314 GetHandlerEntryPoint (