/** @file\r
- IPF specific debug support functions\r
+ IPF specific functions to support Debug Support protocol.\r
\r
-Copyright (c) 2006 - 2008, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2006 - 2010, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
**/\r
\r
-//\r
-// private header files\r
-//\r
#include "PlDebugSupport.h"\r
\r
BOOLEAN mInHandler = FALSE;\r
\r
-typedef struct {\r
- UINT64 low;\r
- UINT64 high;\r
-} BUNDLE;\r
-\r
//\r
// number of bundles to swap in ivt\r
//\r
#define NUM_IVT_ENTRIES 64\r
\r
typedef struct {\r
- BUNDLE OrigBundles[NUM_BUNDLES_IN_STUB];\r
- VOID (*RegisteredCallback) ();\r
+ BUNDLE OrigBundles[NUM_BUNDLES_IN_STUB];\r
+ CALLBACK_FUNC RegisteredCallback;\r
} IVT_ENTRY;\r
\r
-/**\r
- This is the worker function that uninstalls and removes all handlers.\r
-\r
- @param ExceptionType Exception Type\r
- @param NewBundles New Boundles\r
- @param NewCallback New Callback\r
-\r
- @retval EFI_ALEADY_STARTED Ivt already hooked.\r
- @retval others Indicates the request was not satisfied.\r
- @retval EFI_SUCCESS Successfully uninstalled.\r
-\r
-**/\r
-EFI_STATUS\r
-ManageIvtEntryTable (\r
- IN EFI_EXCEPTION_TYPE ExceptionType,\r
- IN BUNDLE NewBundles[4],\r
- IN VOID (*NewCallback) ()\r
- );\r
-\r
-/**\r
- Saves original IVT contents and inserts a few new bundles which are fixed up\r
- to store the ExceptionType and then call the common handler.\r
-\r
- @param ExceptionType Exception Type\r
- @param NewBundles New Boundles\r
- @param NewCallback New Callback\r
-\r
-**/\r
-VOID\r
-HookEntry (\r
- IN EFI_EXCEPTION_TYPE ExceptionType,\r
- IN BUNDLE NewBundles[4],\r
- IN VOID (*NewCallback) ()\r
- );\r
-\r
-/**\r
- Restores original IVT contents when unregistering a callback function.\r
-\r
- @param ExceptionType Exception Type\r
-\r
-**/\r
-VOID\r
-UnhookEntry (\r
- IN EFI_EXCEPTION_TYPE ExceptionType\r
- );\r
-\r
-/**\r
- Sets up cache flush and calls assembly function to chain external interrupt.\r
-\r
- Records new callback in IvtEntryTable.\r
-\r
- @param NewCallback New Callback.\r
-\r
-**/\r
-VOID\r
-ChainExternalInterrupt (\r
- IN VOID (*NewCallback) ()\r
- );\r
-\r
-/**\r
- Sets up cache flush and calls assembly function to restore external interrupt.\r
- Removes registered callback from IvtEntryTable.\r
-\r
-**/\r
-VOID\r
-UnchainExternalInterrupt (\r
- VOID\r
- );\r
-\r
-/**\r
- Given an integer number, return the physical address of the entry point in the IFT.\r
-\r
- @param HandlerIndex Index of the Handler \r
- @param EntryPoint IFT Entrypoint\r
-\r
-**/\r
-VOID\r
-GetHandlerEntryPoint (\r
- UINTN HandlerIndex,\r
- VOID **EntryPoint\r
- );\r
-\r
IVT_ENTRY IvtEntryTable[NUM_IVT_ENTRIES];\r
\r
//\r
UINT8 PatchSaveBuffer[0x400];\r
UINTN ExternalInterruptCount;\r
\r
+\r
/**\r
- IPF specific DebugSupport driver initialization. \r
+ IPF specific DebugSupport driver initialization.\r
\r
Must be public because it's referenced from DebugSupport.c\r
\r
VOID\r
)\r
{\r
- SetMem (IvtEntryTable, sizeof (IvtEntryTable), 0);\r
+ ZeroMem (IvtEntryTable, sizeof (IvtEntryTable));\r
ExternalInterruptCount = 0;\r
return EFI_SUCCESS;\r
}\r
\r
/**\r
Unload handler that is called during UnloadImage() - deallocates pool memory\r
- used by the driver. Must be public because it's referenced from DebugSuport.c\r
+ used by the driver.\r
+\r
+ Must be public because it's referenced from DebugSuport.c\r
\r
@param ImageHandle The firmware allocated handle for the EFI image.\r
\r
\r
/**\r
C routine that is called for all registered exceptions. This is the main\r
- exception dispatcher. Must be public because it's referenced from AsmFuncs.s.\r
+ exception dispatcher.\r
\r
- @param ExceptionType Exception Type\r
- @param Context System Context\r
+ Must be public because it's referenced from AsmFuncs.s.\r
+\r
+ @param ExceptionType Specifies which processor exception.\r
+ @param Context System Context.\r
**/\r
VOID\r
CommonHandler (\r
DEBUG ((EFI_D_INFO, "ERROR: Re-entered debugger!\n"\r
" ExceptionType == %X\n"\r
" Context == %X\n"\r
- " Context.SystemContextIpf->CrIip == %X\n"\r
- " Context.SystemContextIpf->CrIpsr == %X\n"\r
+ " Context.SystemContextIpf->CrIip == %LX\n"\r
+ " Context.SystemContextIpf->CrIpsr == %LX\n"\r
" mInHandler == %X\n",\r
- ExceptionType, \r
- Context, \r
+ (INT32)ExceptionType,\r
+ Context,\r
Context.SystemContextIpf->CrIip,\r
Context.SystemContextIpf->CrIpsr,\r
mInHandler));\r
/**\r
Given an integer number, return the physical address of the entry point in the IFT.\r
\r
- @param HandlerIndex Index of the Handler \r
+ @param HandlerIndex Index of the Handler\r
@param EntryPoint IFT Entrypoint\r
\r
**/\r
/**\r
This is the worker function that uninstalls and removes all handlers.\r
\r
- @param ExceptionType Exception Type\r
- @param NewBundles New Boundles\r
- @param NewCallback New Callback\r
+ @param ExceptionType Specifies which processor exception.\r
+ @param NewBundles New Boundles.\r
+ @param NewCallback A pointer to the new function to be registered.\r
\r
@retval EFI_ALEADY_STARTED Ivt already hooked.\r
- @retval others Indicates the request was not satisfied.\r
@retval EFI_SUCCESS Successfully uninstalled.\r
\r
**/\r
ManageIvtEntryTable (\r
IN EFI_EXCEPTION_TYPE ExceptionType,\r
IN BUNDLE NewBundles[NUM_BUNDLES_IN_STUB],\r
- IN VOID (*NewCallback) ()\r
+ IN CALLBACK_FUNC NewCallback\r
)\r
{\r
BUNDLE *B0Ptr;\r
//\r
// re-init IvtEntryTable\r
//\r
- SetMem (&IvtEntryTable[ExceptionType], sizeof (IVT_ENTRY), 0);\r
+ ZeroMem (&IvtEntryTable[ExceptionType], sizeof (IVT_ENTRY));\r
}\r
} else {\r
//\r
Saves original IVT contents and inserts a few new bundles which are fixed up\r
to store the ExceptionType and then call the common handler.\r
\r
- @param ExceptionType Exception Type\r
- @param NewBundles New Boundles\r
- @param NewCallback New Callback\r
+ @param ExceptionType Specifies which processor exception.\r
+ @param NewBundles New Boundles.\r
+ @param NewCallback A pointer to the new function to be hooked.\r
\r
**/\r
VOID\r
HookEntry (\r
IN EFI_EXCEPTION_TYPE ExceptionType,\r
IN BUNDLE NewBundles[4],\r
- IN VOID (*NewCallback) ()\r
+ IN CALLBACK_FUNC NewCallback\r
)\r
{\r
BUNDLE *FixupBundle;\r
// fixup IVT entry so it stores its index and whether or not to chain...\r
//\r
FixupBundle = B0Ptr + 2;\r
- FixupBundle->high |= ExceptionType << 36;\r
+ FixupBundle->High |= ExceptionType << 36;\r
\r
InstructionCacheFlush (B0Ptr, 5);\r
IvtEntryTable[ExceptionType].RegisteredCallback = NewCallback;\r
/**\r
Restores original IVT contents when unregistering a callback function.\r
\r
- @param ExceptionType Exception Type\r
+ @param ExceptionType Specifies which processor exception.\r
\r
**/\r
VOID\r
\r
Records new callback in IvtEntryTable.\r
\r
- @param NewCallback New Callback\r
+ @param NewCallback A pointer to the interrupt handle.\r
\r
**/\r
VOID\r
ChainExternalInterrupt (\r
- IN VOID (*NewCallback) ()\r
+ IN CALLBACK_FUNC NewCallback\r
)\r
{\r
VOID *Start;\r
IvtEntryTable[EXCEPT_IPF_EXTERNAL_INTERRUPT].RegisteredCallback = NULL;\r
}\r
\r
-//\r
-// The rest of the functions in this file are all member functions for the\r
-// DebugSupport protocol\r
-//\r
-\r
/**\r
- This is a DebugSupport protocol member function, hard\r
- coded to support only 1 processor for now.\r
+ Returns the maximum value that may be used for the ProcessorIndex parameter in\r
+ RegisterPeriodicCallback() and RegisterExceptionCallback().\r
\r
- @param This The DebugSupport instance\r
- @param MaxProcessorIndex The maximuim supported processor index\r
+ Hard coded to support only 1 processor for now.\r
\r
- @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r
+ @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+ @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the maximum supported\r
+ processor index is returned. Always 0 returned.\r
+\r
+ @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r
\r
**/\r
EFI_STATUS\r
}\r
\r
/**\r
- DebugSupport protocol member function.\r
-\r
- @param This The DebugSupport instance\r
- @param ProcessorIndex Which processor the callback applies to.\r
- @param PeriodicCallback Callback function\r
-\r
- @retval EFI_SUCCESS Indicates the callback was registered.\r
- @retval others Callback was not registered.\r
-\r
+ Registers a function to be called back periodically in interrupt context.\r
+\r
+ @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+ @param ProcessorIndex Specifies which processor the callback function applies to.\r
+ @param PeriodicCallback A pointer to a function of type PERIODIC_CALLBACK that is the main\r
+ periodic entry point of the debug agent.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback\r
+ function was previously registered.\r
+ @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback\r
+ function.\r
**/\r
EFI_STATUS\r
EFIAPI\r
}\r
\r
/**\r
- DebugSupport protocol member function.\r
+ Registers a function to be called when a given processor exception occurs.\r
\r
- @param This The DebugSupport instance\r
- @param ProcessorIndex Which processor the callback applies to.\r
- @param NewCallback Callback function\r
- @param ExceptionType Which exception to hook\r
+ This code executes in boot services context.\r
\r
- @retval EFI_SUCCESS Indicates the callback was registered.\r
- @retval others Callback was not registered.\r
+ @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+ @param ProcessorIndex Specifies which processor the callback function applies to.\r
+ @param ExceptionCallback A pointer to a function of type EXCEPTION_CALLBACK that is called\r
+ when the processor exception specified by ExceptionType occurs.\r
+ @param ExceptionType Specifies which processor exception to hook.\r
\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback\r
+ function was previously registered.\r
+ @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback\r
+ function.\r
**/\r
EFI_STATUS\r
EFIAPI\r
RegisterExceptionCallback (\r
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
IN UINTN ProcessorIndex,\r
- IN EFI_EXCEPTION_CALLBACK NewCallback,\r
+ IN EFI_EXCEPTION_CALLBACK ExceptionCallback,\r
IN EFI_EXCEPTION_TYPE ExceptionType\r
)\r
{\r
return ManageIvtEntryTable (\r
ExceptionType,\r
(BUNDLE *) ((EFI_PLABEL *) HookStub)->EntryPoint,\r
- NewCallback\r
+ ExceptionCallback\r
);\r
}\r
\r
/**\r
- DebugSupport protocol member function. Calls assembly routine to flush cache.\r
+ Invalidates processor instruction cache for a memory range. Subsequent execution in this range\r
+ causes a fresh memory fetch to retrieve code to be executed.\r
\r
- @param This The DebugSupport instance\r
- @param ProcessorIndex Which processor the callback applies to.\r
- @param Start Physical base of the memory range to be invalidated\r
- @param Length mininum number of bytes in instruction cache to invalidate\r
+ @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+ @param ProcessorIndex Specifies which processor's instruction cache is to be invalidated.\r
+ @param Start Specifies the physical base of the memory range to be invalidated.\r
+ @param Length Specifies the minimum number of bytes in the processor's instruction\r
+ cache to invalidate.\r
\r
- @retval EFI_SUCCESS Always returned.\r
+ @retval EFI_SUCCESS Always returned.\r
\r
**/\r
EFI_STATUS\r