-/**@file\r
+/** @file\r
IPF specific debug support functions\r
\r
Copyright (c) 2006 - 2008, Intel Corporation \r
//\r
// private header files\r
//\r
-#include "plDebugSupport.h"\r
+#include "PlDebugSupport.h"\r
\r
BOOLEAN mInHandler = FALSE;\r
\r
VOID (*RegisteredCallback) ();\r
} IVT_ENTRY;\r
\r
+IVT_ENTRY IvtEntryTable[NUM_IVT_ENTRIES];\r
+\r
+//\r
+// IPF context record is overallocated by 512 bytes to guarantee a 512 byte alignment exists\r
+// within the buffer and still have a large enough buffer to hold a whole IPF context record.\r
+//\r
+UINT8 IpfContextBuf[sizeof (EFI_SYSTEM_CONTEXT_IPF) + 512];\r
+\r
+//\r
+// The PatchSaveBuffer is used to store the original bundles from the IVT where it is patched\r
+// with the common handler.\r
+//\r
+UINT8 PatchSaveBuffer[0x400];\r
+UINTN ExternalInterruptCount;\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 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 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
-// IPF context record is overallocated by 512 bytes to guarantee a 512 byte alignment exists\r
-// within the buffer and still have a large enough buffer to hold a whole IPF context record.\r
-//\r
-UINT8 IpfContextBuf[sizeof (EFI_SYSTEM_CONTEXT_IPF) + 512];\r
+/**\r
+ IPF specific DebugSupport driver initialization. \r
\r
-//\r
-// The PatchSaveBuffer is used to store the original bundles from the IVT where it is patched\r
-// with the common handler.\r
-//\r
-UINT8 PatchSaveBuffer[0x400];\r
-UINTN ExternalInterruptCount;\r
+ Must be public because it's referenced from DebugSupport.c\r
+\r
+ @retval EFI_SUCCESS Always.\r
\r
+**/\r
EFI_STATUS\r
-plInitializeDebugSupportDriver (\r
+PlInitializeDebugSupportDriver (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description:\r
- IPF specific DebugSupport driver initialization. Must be public because it's\r
- referenced from DebugSupport.c\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS\r
-\r
---*/\r
{\r
- SetMem (IvtEntryTable, sizeof (IvtEntryTable), 0);\r
+ ZeroMem (IvtEntryTable, sizeof (IvtEntryTable));\r
ExternalInterruptCount = 0;\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_STATUS\r
-EFIAPI\r
-plUnloadDebugSupportDriver (\r
- IN EFI_HANDLE ImageHandle\r
- )\r
-/*++\r
-\r
-Routine Description:\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
\r
-Arguments:\r
- ImageHandle - Image handle\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS Always.\r
\r
- EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PlUnloadDebugSupportDriver (\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
{\r
EFI_EXCEPTION_TYPE ExceptionType;\r
\r
return EFI_SUCCESS;\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
+\r
+ @param ExceptionType Exception Type\r
+ @param Context System Context\r
+**/\r
VOID\r
CommonHandler (\r
IN EFI_EXCEPTION_TYPE ExceptionType,\r
IN EFI_SYSTEM_CONTEXT Context\r
)\r
-/*++\r
-\r
-Routine Description:\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
-\r
-Arguments:\r
- ExceptionType - Exception Type\r
- Context - System Context\r
-\r
-Returns:\r
-\r
- Nothing\r
- \r
---*/\r
{\r
DEBUG_CODE_BEGIN ();\r
if (mInHandler) {\r
mInHandler = FALSE;\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
-\r
-Routine Description:\r
- Given an integer number, return the physical address of the entry point in the IFT\r
- \r
-Arguments:\r
- HandlerIndex - Index of the Handler \r
- EntryPoint - IFT Entrypoint\r
-\r
-Returns:\r
-\r
- Nothing\r
- \r
---*/\r
{\r
UINT8 *TempPtr;\r
\r
*EntryPoint = (VOID *) TempPtr;\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
+\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 EFI_EXCEPTION_TYPE ExceptionType,\r
IN BUNDLE NewBundles[NUM_BUNDLES_IN_STUB],\r
IN VOID (*NewCallback) ()\r
)\r
-/*++\r
-\r
-Routine Description:\r
- This is the worker function that installs and removes all handlers\r
- \r
-Arguments:\r
- ExceptionType - Exception Type\r
- NewBundles - New Boundles\r
- NewCallback - New Callback\r
-\r
-Returns:\r
-\r
- EFI_STATUS - any return other than EFI_SUCCESS indicates the request was not\r
- satisfied.\r
- EFI_ALEADY_STARTED - Ivt already hooked.\r
- \r
---*/\r
{\r
BUNDLE *B0Ptr;\r
UINT64 InterruptFlags;\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
return EFI_SUCCESS;\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
-Routine Description:\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
-Arguments:\r
- ExceptionType - Exception Type\r
- NewBundles - New Boundles\r
- NewCallback - New Callback\r
-\r
-Returns:\r
-\r
- Nothing\r
- \r
---*/\r
{\r
BUNDLE *FixupBundle;\r
BUNDLE *B0Ptr;\r
IvtEntryTable[ExceptionType].RegisteredCallback = 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
-Routine Description:\r
- Restores original IVT contents when unregistering a callback function\r
- \r
-Arguments:\r
- ExceptionType - Exception Type\r
- NewBundles - New Boundles\r
- NewCallback - New Callback\r
-\r
-Returns:\r
-\r
- Nothing\r
- \r
---*/\r
{\r
BUNDLE *B0Ptr;\r
\r
InstructionCacheFlush (B0Ptr, 5);\r
}\r
\r
-VOID\r
-ChainExternalInterrupt (\r
- IN VOID (*NewCallback) ()\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
Sets up cache flush and calls assembly function to chain external interrupt.\r
+\r
Records new callback in IvtEntryTable.\r
- \r
-Arguments:\r
- NewCallback - New Callback\r
\r
-Returns:\r
+ @param NewCallback New Callback\r
\r
- Nothing\r
- \r
---*/\r
+**/\r
+VOID\r
+ChainExternalInterrupt (\r
+ IN VOID (*NewCallback) ()\r
+ )\r
{\r
VOID *Start;\r
\r
InstructionCacheFlush (Start, 0x400);\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
-Routine Description:\r
- Sets up cache flush and calls assembly function to restore external interrupt.\r
- Removes registered callback from IvtEntryTable.\r
- \r
-Arguments:\r
- Nothing\r
- \r
-Returns:\r
-\r
- Nothing\r
- \r
---*/\r
{\r
VOID *Start;\r
\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
+\r
+ @param This The DebugSupport instance\r
+ @param MaxProcessorIndex The maximuim supported processor index\r
+\r
+ @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
GetMaximumProcessorIndex (\r
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
OUT UINTN *MaxProcessorIndex\r
)\r
-/*++\r
-\r
-Routine Description: This is a DebugSupport protocol member function. Hard\r
- coded to support only 1 processor for now.\r
-\r
-Arguments:\r
- This - The DebugSupport instance\r
- MaxProcessorIndex - The maximuim supported processor index\r
-\r
-Returns:\r
- Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
-\r
---*/\r
{\r
*MaxProcessorIndex = 0;\r
return (EFI_SUCCESS);\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
+**/\r
EFI_STATUS\r
EFIAPI\r
RegisterPeriodicCallback (\r
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
IN UINTN ProcessorIndex,\r
- IN EFI_PERIODIC_CALLBACK NewPeriodicCallback\r
+ IN EFI_PERIODIC_CALLBACK PeriodicCallback\r
)\r
-/*++\r
-\r
-Routine Description:\r
- DebugSupport protocol member function\r
-\r
-Arguments:\r
- This - The DebugSupport instance\r
- ProcessorIndex - Which processor the callback applies to.\r
- PeriodicCallback - Callback function\r
+{\r
+ return ManageIvtEntryTable (EXCEPT_IPF_EXTERNAL_INTERRUPT, NULL, PeriodicCallback);\r
+}\r
\r
-Returns:\r
+/**\r
+ DebugSupport protocol member function.\r
\r
- EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.\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
\r
---*/\r
-{\r
- return ManageIvtEntryTable (EXCEPT_IPF_EXTERNAL_INTERRUPT, NULL, NewPeriodicCallback);\r
-}\r
+ @retval EFI_SUCCESS Indicates the callback was registered.\r
+ @retval others Callback was not registered.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
RegisterExceptionCallback (\r
IN EFI_EXCEPTION_CALLBACK NewCallback,\r
IN EFI_EXCEPTION_TYPE ExceptionType\r
)\r
-/*++\r
-\r
-Routine Description:\r
- DebugSupport protocol member function\r
-\r
-Arguments:\r
- This - The DebugSupport instance\r
- ProcessorIndex - Which processor the callback applies to.\r
- NewCallback - Callback function\r
- ExceptionType - Which exception to hook\r
-\r
-Returns:\r
-\r
- EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.\r
-\r
---*/\r
{\r
return ManageIvtEntryTable (\r
ExceptionType,\r
);\r
}\r
\r
+/**\r
+ DebugSupport protocol member function. Calls assembly routine to flush cache.\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
+\r
+ @retval EFI_SUCCESS Always returned.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
InvalidateInstructionCache (\r
IN VOID *Start,\r
IN UINTN Length\r
)\r
-/*++\r
-\r
-Routine Description:\r
- DebugSupport protocol member function. Calls assembly routine to flush cache.\r
-\r
-Arguments:\r
- This - The DebugSupport instance\r
- ProcessorIndex - Which processor the callback applies to.\r
- Start - Physical base of the memory range to be invalidated\r
- Length - mininum number of bytes in instruction cache to invalidate\r
-\r
-Returns:\r
- EFI_SUCCESS\r
-\r
---*/\r
{\r
InstructionCacheFlush (Start, Length);\r
- return (EFI_SUCCESS);\r
+ return EFI_SUCCESS;\r
}\r