-/*++\r
+/** @file\r
+ Top level module for the EBC virtual machine implementation.\r
+ Provides auxilliary support routines for the VM. That is, routines\r
+ that are not particularly related to VM execution of EBC instructions.\r
\r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\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
-Module Name:\r
-\r
- EbcInt.c\r
-\r
-Abstract:\r
-\r
- Top level module for the EBC virtual machine implementation.\r
- Provides auxilliary support routines for the VM. That is, routines\r
- that are not particularly related to VM execution of EBC instructions.\r
-\r
---*/\r
+**/\r
\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
static EFI_EVENT mEbcPeriodicEvent;\r
VM_CONTEXT *mVmPtr = NULL;\r
\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEbcDriver (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
Initializes the VM EFI interface. Allocates memory for the VM interface\r
and registers the VM protocol.\r
\r
-Arguments:\r
-\r
- ImageHandle - EFI image handle.\r
- SystemTable - Pointer to the EFI system table.\r
+ @param ImageHandle EFI image handle.\r
+ @param SystemTable Pointer to the EFI system table.\r
\r
-Returns:\r
- Standard EFI status code.\r
+ @return Standard EFI status code.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEbcDriver (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
{\r
EFI_EBC_PROTOCOL *EbcProtocol;\r
EFI_EBC_PROTOCOL *OldEbcProtocol;\r
return Status;\r
}\r
\r
+\r
+/**\r
+ This is the top-level routine plugged into the EBC protocol. Since thunks\r
+ are very processor-specific, from here we dispatch directly to the very\r
+ processor-specific routine EbcCreateThunks().\r
+\r
+ @param This protocol instance pointer\r
+ @param ImageHandle handle to the image. The EBC interpreter may use\r
+ this to keep track of any resource allocations\r
+ performed in loading and executing the image.\r
+ @param EbcEntryPoint the entry point for the image (as defined in the\r
+ file header)\r
+ @param Thunk pointer to thunk pointer where the address of the\r
+ created thunk is returned.\r
+\r
+ @return EFI_STATUS\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN VOID *EbcEntryPoint,\r
OUT VOID **Thunk\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This is the top-level routine plugged into the EBC protocol. Since thunks\r
- are very processor-specific, from here we dispatch directly to the very\r
- processor-specific routine EbcCreateThunks().\r
-\r
-Arguments:\r
-\r
- This - protocol instance pointer\r
- ImageHandle - handle to the image. The EBC interpreter may use this to keep\r
- track of any resource allocations performed in loading and\r
- executing the image.\r
- EbcEntryPoint - the entry point for the image (as defined in the file header)\r
- Thunk - pointer to thunk pointer where the address of the created\r
- thunk is returned.\r
-\r
-Returns:\r
-\r
- EFI_STATUS\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
\r
return Status;\r
}\r
\r
+\r
+/**\r
+ This EBC debugger protocol service is called by the debug agent\r
+\r
+ @param This pointer to the caller's debug support protocol\r
+ interface\r
+ @param MaxProcessorIndex pointer to a caller allocated UINTN in which the\r
+ maximum processor index is returned.\r
+\r
+ @return Standard EFI_STATUS\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
OUT UINTN *MaxProcessorIndex\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This EBC debugger protocol service is called by the debug agent\r
-\r
-Arguments:\r
-\r
- This - pointer to the caller's debug support protocol interface\r
- MaxProcessorIndex - pointer to a caller allocated UINTN in which the maximum\r
- processor index is returned.\r
-\r
-Returns:\r
-\r
- Standard EFI_STATUS\r
-\r
---*/\r
{\r
*MaxProcessorIndex = 0;\r
return EFI_SUCCESS;\r
}\r
\r
+\r
+/**\r
+ This protocol service is called by the debug agent to register a function\r
+ for us to call on a periodic basis.\r
+\r
+ @param This pointer to the caller's debug support protocol\r
+ interface\r
+ @param PeriodicCallback pointer to the function to call periodically\r
+\r
+ @return Always EFI_SUCCESS\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN UINTN ProcessorIndex,\r
IN EFI_PERIODIC_CALLBACK PeriodicCallback\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This protocol service is called by the debug agent to register a function\r
- for us to call on a periodic basis.\r
-\r
-\r
-Arguments:\r
-\r
- This - pointer to the caller's debug support protocol interface\r
- PeriodicCallback - pointer to the function to call periodically\r
-\r
-Returns:\r
-\r
- Always EFI_SUCCESS\r
-\r
---*/\r
{\r
if ((mDebugPeriodicCallback == NULL) && (PeriodicCallback == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
return EFI_SUCCESS;\r
}\r
\r
+\r
+/**\r
+ This protocol service is called by the debug agent to register a function\r
+ for us to call when we detect an exception.\r
+\r
+ @param This pointer to the caller's debug support protocol\r
+ interface\r
+ @param ExceptionCallback pointer to the function to the exception\r
+\r
+ @return Always EFI_SUCCESS\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN EFI_EXCEPTION_CALLBACK ExceptionCallback,\r
IN EFI_EXCEPTION_TYPE ExceptionType\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This protocol service is called by the debug agent to register a function\r
- for us to call when we detect an exception.\r
-\r
-\r
-Arguments:\r
-\r
- This - pointer to the caller's debug support protocol interface\r
- ExceptionCallback - pointer to the function to the exception\r
-\r
-Returns:\r
-\r
- Always EFI_SUCCESS\r
-\r
---*/\r
{\r
if ((ExceptionType < 0) || (ExceptionType > MAX_EBC_EXCEPTION)) {\r
return EFI_INVALID_PARAMETER;\r
return EFI_SUCCESS;\r
}\r
\r
+\r
+/**\r
+ This EBC debugger protocol service is called by the debug agent. Required\r
+ for DebugSupport compliance but is only stubbed out for EBC.\r
+\r
+\r
+ @return EFI_SUCCESS\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN VOID *Start,\r
IN UINT64 Length\r
)\r
-/*++\r
-\r
-Routine Description:\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
\r
- This EBC debugger protocol service is called by the debug agent. Required\r
- for DebugSupport compliance but is only stubbed out for EBC.\r
\r
-Arguments:\r
+/**\r
+ The VM interpreter calls this function when an exception is detected.\r
\r
-Returns:\r
+ @param VmPtr pointer to a VM context for passing info to the\r
+ EFI debugger.\r
\r
- EFI_SUCCESS\r
-\r
---*/\r
-{\r
- return EFI_SUCCESS;\r
-}\r
+ @return EFI_SUCCESS if it returns at all\r
\r
+**/\r
EFI_STATUS\r
EbcDebugSignalException (\r
IN EFI_EXCEPTION_TYPE ExceptionType,\r
IN EXCEPTION_FLAGS ExceptionFlags,\r
IN VM_CONTEXT *VmPtr\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- The VM interpreter calls this function when an exception is detected.\r
-\r
-Arguments:\r
-\r
- VmPtr - pointer to a VM context for passing info to the EFI debugger.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS if it returns at all\r
-\r
---*/\r
{\r
EFI_SYSTEM_CONTEXT_EBC EbcContext;\r
EFI_SYSTEM_CONTEXT SystemContext;\r
return EFI_SUCCESS;\r
}\r
\r
-STATIC\r
-EFI_STATUS\r
-InitializeEbcCallback (\r
- IN EFI_DEBUG_SUPPORT_PROTOCOL *This\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
To install default Callback function for the VM interpreter.\r
\r
-Arguments:\r
+ @param This pointer to the instance of DebugSupport protocol\r
\r
- This - pointer to the instance of DebugSupport protocol\r
+ @return None\r
\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+InitializeEbcCallback (\r
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *This\r
+ )\r
{\r
INTN Index;\r
EFI_STATUS Status;\r
return EFI_SUCCESS;\r
}\r
\r
-STATIC\r
-VOID\r
-CommonEbcExceptionHandler (\r
- IN EFI_EXCEPTION_TYPE InterruptType,\r
- IN EFI_SYSTEM_CONTEXT SystemContext\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
The default Exception Callback for the VM interpreter.\r
In this function, we report status code, and print debug information\r
about EBC_CONTEXT, then dead loop.\r
\r
-Arguments:\r
-\r
- InterruptType - Interrupt type.\r
- SystemContext - EBC system context.\r
-\r
-Returns:\r
+ @param InterruptType Interrupt type.\r
+ @param SystemContext EBC system context.\r
\r
- None\r
+ @return None\r
\r
---*/\r
+**/\r
+STATIC\r
+VOID\r
+CommonEbcExceptionHandler (\r
+ IN EFI_EXCEPTION_TYPE InterruptType,\r
+ IN EFI_SYSTEM_CONTEXT SystemContext\r
+ )\r
{\r
//\r
// We deadloop here to make it easy to debug this issue.\r
return ;\r
}\r
\r
+\r
+/**\r
+ The periodic callback function for EBC VM interpreter, which is used\r
+ to support the EFI debug support protocol.\r
+\r
+ @param Event The Periodic Callback Event.\r
+ @param Context It should be the address of VM_CONTEXT pointer.\r
+\r
+ @return None.\r
+\r
+**/\r
STATIC\r
VOID\r
EFIAPI\r
IN EFI_EVENT Event,\r
IN VOID *Context\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- The periodic callback function for EBC VM interpreter, which is used\r
- to support the EFI debug support protocol.\r
-\r
-Arguments:\r
-\r
- Event - The Periodic Callback Event.\r
- Context - It should be the address of VM_CONTEXT pointer.\r
-\r
-Returns:\r
-\r
- None.\r
-\r
---*/\r
{\r
VM_CONTEXT *VmPtr;\r
\r
return ;\r
}\r
\r
-STATIC\r
-EFI_STATUS\r
-EbcDebugPeriodic (\r
- IN VM_CONTEXT *VmPtr\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
The VM interpreter calls this function on a periodic basis to support\r
the EFI debug support protocol.\r
\r
-Arguments:\r
-\r
- VmPtr - pointer to a VM context for passing info to the debugger.\r
+ @param VmPtr pointer to a VM context for passing info to the\r
+ debugger.\r
\r
-Returns:\r
+ @return Standard EFI status.\r
\r
- Standard EFI status.\r
-\r
---*/\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EbcDebugPeriodic (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
{\r
EFI_SYSTEM_CONTEXT_EBC EbcContext;\r
EFI_SYSTEM_CONTEXT SystemContext;\r
return EFI_SUCCESS;\r
}\r
\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-EbcUnloadImage (\r
- IN EFI_EBC_PROTOCOL *This,\r
- IN EFI_HANDLE ImageHandle\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
This routine is called by the core when an image is being unloaded from\r
memory. Basically we now have the opportunity to do any necessary cleanup.\r
Typically this will include freeing any memory allocated for thunk-creation.\r
\r
-Arguments:\r
-\r
- This - protocol instance pointer\r
- ImageHandle - handle to the image being unloaded.\r
-\r
-Returns:\r
+ @param This protocol instance pointer\r
+ @param ImageHandle handle to the image being unloaded.\r
\r
- EFI_INVALID_PARAMETER - the ImageHandle passed in was not found in\r
- the internal list of EBC image handles.\r
- EFI_STATUS - completed successfully\r
+ @retval EFI_INVALID_PARAMETER the ImageHandle passed in was not found in the\r
+ internal list of EBC image handles.\r
+ @retval EFI_STATUS completed successfully\r
\r
---*/\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+EbcUnloadImage (\r
+ IN EFI_EBC_PROTOCOL *This,\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
{\r
EBC_THUNK_LIST *ThunkList;\r
EBC_THUNK_LIST *NextThunkList;\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_STATUS\r
-EbcAddImageThunk (\r
- IN EFI_HANDLE ImageHandle,\r
- IN VOID *ThunkBuffer,\r
- IN UINT32 ThunkSize\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
Add a thunk to our list of thunks for a given image handle.\r
Also flush the instruction cache since we've written thunk code\r
to memory that will be executed eventually.\r
\r
-Arguments:\r
-\r
- ImageHandle - the image handle to which the thunk is tied\r
- ThunkBuffer - the buffer we've created/allocated\r
- ThunkSize - the size of the thunk memory allocated\r
-\r
-Returns:\r
+ @param ImageHandle the image handle to which the thunk is tied\r
+ @param ThunkBuffer the buffer we've created/allocated\r
+ @param ThunkSize the size of the thunk memory allocated\r
\r
- EFI_OUT_OF_RESOURCES - memory allocation failed\r
- EFI_SUCCESS - successful completion\r
+ @retval EFI_OUT_OF_RESOURCES memory allocation failed\r
+ @retval EFI_SUCCESS successful completion\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EbcAddImageThunk (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN VOID *ThunkBuffer,\r
+ IN UINT32 ThunkSize\r
+ )\r
{\r
EBC_THUNK_LIST *ThunkList;\r
EBC_IMAGE_LIST *ImageList;\r
}\r
return EFI_SUCCESS;\r
}\r
-STATIC\r
-EFI_STATUS\r
-InitEbcVmTestProtocol (\r
- IN EFI_HANDLE *IHandle\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
Produce an EBC VM test protocol that can be used for regression tests.\r
\r
-Arguments:\r
-\r
- IHandle - handle on which to install the protocol.\r
+ @param IHandle handle on which to install the protocol.\r
\r
-Returns:\r
+ @retval EFI_OUT_OF_RESOURCES memory allocation failed\r
+ @retval EFI_SUCCESS successful completion\r
\r
- EFI_OUT_OF_RESOURCES - memory allocation failed\r
- EFI_SUCCESS - successful completion\r
-\r
---*/\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+InitEbcVmTestProtocol (\r
+ IN EFI_HANDLE *IHandle\r
+ )\r
{\r
EFI_HANDLE Handle;\r
EFI_STATUS Status;\r