Add doxygen style comments for functions in EBC module.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5194 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2008-05-13 08:46:12 +00:00
parent 335b890e40
commit 8e3bc754c5
8 changed files with 2211 additions and 477 deletions

View File

@ -1,9 +1,9 @@
/** @file
Top level module for the EBC virtual machine implementation.
Provides auxilliary support routines for the VM. That is, routines
Provides auxiliary support routines for the VM. That is, routines
that are not particularly related to VM execution of EBC instructions.
Copyright (c) 2006, Intel Corporation
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -34,6 +34,20 @@ typedef struct _EBC_IMAGE_LIST {
EBC_THUNK_LIST *ThunkList;
} EBC_IMAGE_LIST;
/**
This routine is called by the core when an image is being unloaded from
memory. Basically we now have the opportunity to do any necessary cleanup.
Typically this will include freeing any memory allocated for thunk-creation.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param ImageHandle Handle of image for which the thunk is being
created.
@retval EFI_INVALID_PARAMETER The ImageHandle passed in was not found in the
internal list of EBC image handles.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
@ -42,6 +56,25 @@ EbcUnloadImage (
IN EFI_HANDLE ImageHandle
);
/**
This is the top-level routine plugged into the EBC protocol. Since thunks
are very processor-specific, from here we dispatch directly to the very
processor-specific routine EbcCreateThunks().
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param ImageHandle Handle of image for which the thunk is being
created. The EBC interpreter may use this to
keep track of any resource allocations
performed in loading and executing the image.
@param EbcEntryPoint Address of the actual EBC entry point or
protocol service the thunk should call.
@param Thunk Returned pointer to a thunk created.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Image entry point is not 2-byte aligned.
@retval EFI_OUT_OF_RESOURCES Memory could not be allocated for the thunk.
**/
STATIC
EFI_STATUS
EFIAPI
@ -52,6 +85,17 @@ EbcCreateThunk (
OUT VOID **Thunk
);
/**
Called to get the version of the interpreter.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param Version Pointer to where to store the returned version
of the interpreter.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Version pointer is NULL.
**/
STATIC
EFI_STATUS
EFIAPI
@ -60,6 +104,16 @@ EbcGetVersion (
IN OUT UINT64 *Version
);
/**
To install default Callback function for the VM interpreter.
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@retval EFI_SUCCESS The function completed successfully.
@retval Others Some error occurs when creating periodic event.
**/
STATIC
EFI_STATUS
EFIAPI
@ -67,6 +121,15 @@ InitializeEbcCallback (
IN EFI_DEBUG_SUPPORT_PROTOCOL *This
);
/**
The default Exception Callback for the VM interpreter.
In this function, we report status code, and print debug information
about EBC_CONTEXT, then dead loop.
@param InterruptType Interrupt type.
@param SystemContext EBC system context.
**/
STATIC
VOID
EFIAPI
@ -75,6 +138,14 @@ CommonEbcExceptionHandler (
IN EFI_SYSTEM_CONTEXT SystemContext
);
/**
The periodic callback function for EBC VM interpreter, which is used
to support the EFI debug support protocol.
@param Event The Periodic Callback Event.
@param Context It should be the address of VM_CONTEXT pointer.
**/
STATIC
VOID
EFIAPI
@ -83,6 +154,16 @@ EbcPeriodicNotifyFunction (
IN VOID *Context
);
/**
The VM interpreter calls this function on a periodic basis to support
the EFI debug support protocol.
@param VmPtr Pointer to a VM context for passing info to the
debugger.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
@ -94,18 +175,43 @@ EbcDebugPeriodic (
// These two functions and the GUID are used to produce an EBC test protocol.
// This functionality is definitely not required for execution.
//
/**
Produces an EBC VM test protocol that can be used for regression tests.
@param IHandle Handle on which to install the protocol.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
InitEbcVmTestProtocol (
IN EFI_HANDLE *Handle
);
/**
Returns the EFI_UNSUPPORTED Status.
@return EFI_UNSUPPORTED This function always return EFI_UNSUPPORTED status.
**/
STATIC
EFI_STATUS
EbcVmTestUnsupported (
VOID
);
/**
Registers a callback function that the EBC interpreter calls to flush the
processor instruction cache following creation of thunks.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param Flush Pointer to a function of type EBC_ICACH_FLUSH.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
@ -114,6 +220,17 @@ EbcRegisterICacheFlush (
IN EBC_ICACHE_FLUSH Flush
);
/**
This EBC debugger protocol service is called by the debug agent
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the
maximum supported processor index is returned.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
@ -122,6 +239,27 @@ EbcDebugGetMaximumProcessorIndex (
OUT UINTN *MaxProcessorIndex
);
/**
This protocol service is called by the debug agent to register a function
for us to call on a periodic basis.
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param ProcessorIndex Specifies which processor the callback function
applies to.
@param PeriodicCallback A pointer to a function of type
PERIODIC_CALLBACK that is the main periodic
entry point of the debug agent. It receives as a
parameter a pointer to the full context of the
interrupted execution thread.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a
callback function was previously registered.
@retval EFI_INVALID_PARAMETER Null PeriodicCallback parameter when no
callback function was previously registered.
**/
STATIC
EFI_STATUS
EFIAPI
@ -131,6 +269,31 @@ EbcDebugRegisterPeriodicCallback (
IN EFI_PERIODIC_CALLBACK PeriodicCallback
);
/**
This protocol service is called by the debug agent to register a function
for us to call when we detect an exception.
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param ProcessorIndex Specifies which processor the callback function
applies to.
@param ExceptionCallback A pointer to a function of type
EXCEPTION_CALLBACK that is called when the
processor exception specified by ExceptionType
occurs. Passing NULL unregisters any previously
registered function associated with
ExceptionType.
@param ExceptionType Specifies which processor exception to hook.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_ALREADY_STARTED Non-NULL ExceptionCallback parameter when a
callback function was previously registered.
@retval EFI_INVALID_PARAMETER ExceptionType parameter is negative or exceeds
MAX_EBC_EXCEPTION.
@retval EFI_INVALID_PARAMETER Null ExceptionCallback parameter when no
callback function was previously registered.
**/
STATIC
EFI_STATUS
EFIAPI
@ -141,6 +304,22 @@ EbcDebugRegisterExceptionCallback (
IN EFI_EXCEPTION_TYPE ExceptionType
);
/**
This EBC debugger protocol service is called by the debug agent. Required
for DebugSupport compliance but is only stubbed out for EBC.
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param ProcessorIndex Specifies which processor the callback function
applies to.
@param Start StartSpecifies the physical base of the memory
range to be invalidated.
@param Length Specifies the minimum number of bytes in the
processor's instruction cache to invalidate.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
@ -157,28 +336,28 @@ EbcDebugInvalidateInstructionCache (
// also be global since the execution of an EBC image does not provide
// a This pointer.
//
static EBC_IMAGE_LIST *mEbcImageList = NULL;
STATIC EBC_IMAGE_LIST *mEbcImageList = NULL;
//
// Callback function to flush the icache after thunk creation
//
static EBC_ICACHE_FLUSH mEbcICacheFlush;
STATIC EBC_ICACHE_FLUSH mEbcICacheFlush;
//
// These get set via calls by the debug agent
//
static EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL;
static EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};
static EFI_GUID mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID;
STATIC EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL;
STATIC EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};
STATIC EFI_GUID mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID;
static VOID* mStackBuffer[MAX_STACK_NUM];
static EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];
static UINTN mStackNum = 0;
STATIC VOID* mStackBuffer[MAX_STACK_NUM];
STATIC EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];
STATIC UINTN mStackNum = 0;
//
// Event for Periodic callback
//
static EFI_EVENT mEbcPeriodicEvent;
STATIC EFI_EVENT mEbcPeriodicEvent;
VM_CONTEXT *mVmPtr = NULL;
@ -378,16 +557,18 @@ ErrorExit:
are very processor-specific, from here we dispatch directly to the very
processor-specific routine EbcCreateThunks().
@param This protocol instance pointer
@param ImageHandle handle to the image. The EBC interpreter may use
this to keep track of any resource allocations
performed in loading and executing the image.
@param EbcEntryPoint the entry point for the image (as defined in the
file header)
@param Thunk pointer to thunk pointer where the address of the
created thunk is returned.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param ImageHandle Handle of image for which the thunk is being
created. The EBC interpreter may use this to
keep track of any resource allocations
performed in loading and executing the image.
@param EbcEntryPoint Address of the actual EBC entry point or
protocol service the thunk should call.
@param Thunk Returned pointer to a thunk created.
@return EFI_STATUS
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Image entry point is not 2-byte aligned.
@retval EFI_OUT_OF_RESOURCES Memory could not be allocated for the thunk.
**/
STATIC
@ -415,12 +596,12 @@ EbcCreateThunk (
/**
This EBC debugger protocol service is called by the debug agent
@param This pointer to the caller's debug support protocol
interface
@param MaxProcessorIndex pointer to a caller allocated UINTN in which the
maximum processor index is returned.
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the
maximum supported processor index is returned.
@return Standard EFI_STATUS
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
@ -440,11 +621,21 @@ EbcDebugGetMaximumProcessorIndex (
This protocol service is called by the debug agent to register a function
for us to call on a periodic basis.
@param This pointer to the caller's debug support protocol
interface
@param PeriodicCallback pointer to the function to call periodically
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param ProcessorIndex Specifies which processor the callback function
applies to.
@param PeriodicCallback A pointer to a function of type
PERIODIC_CALLBACK that is the main periodic
entry point of the debug agent. It receives as a
parameter a pointer to the full context of the
interrupted execution thread.
@return Always EFI_SUCCESS
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a
callback function was previously registered.
@retval EFI_INVALID_PARAMETER Null PeriodicCallback parameter when no
callback function was previously registered.
**/
STATIC
@ -472,11 +663,25 @@ EbcDebugRegisterPeriodicCallback (
This protocol service is called by the debug agent to register a function
for us to call when we detect an exception.
@param This pointer to the caller's debug support protocol
interface
@param ExceptionCallback pointer to the function to the exception
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param ProcessorIndex Specifies which processor the callback function
applies to.
@param ExceptionCallback A pointer to a function of type
EXCEPTION_CALLBACK that is called when the
processor exception specified by ExceptionType
occurs. Passing NULL unregisters any previously
registered function associated with
ExceptionType.
@param ExceptionType Specifies which processor exception to hook.
@return Always EFI_SUCCESS
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_ALREADY_STARTED Non-NULL ExceptionCallback parameter when a
callback function was previously registered.
@retval EFI_INVALID_PARAMETER ExceptionType parameter is negative or exceeds
MAX_EBC_EXCEPTION.
@retval EFI_INVALID_PARAMETER Null ExceptionCallback parameter when no
callback function was previously registered.
**/
STATIC
@ -507,8 +712,16 @@ EbcDebugRegisterExceptionCallback (
This EBC debugger protocol service is called by the debug agent. Required
for DebugSupport compliance but is only stubbed out for EBC.
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@param ProcessorIndex Specifies which processor the callback function
applies to.
@param Start StartSpecifies the physical base of the memory
range to be invalidated.
@param Length Specifies the minimum number of bytes in the
processor's instruction cache to invalidate.
@return EFI_SUCCESS
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
@ -528,10 +741,12 @@ EbcDebugInvalidateInstructionCache (
/**
The VM interpreter calls this function when an exception is detected.
@param VmPtr pointer to a VM context for passing info to the
@param ExceptionType Specifies the processor exception detected.
@param ExceptionFlags Specifies the exception context.
@param VmPtr Pointer to a VM context for passing info to the
EFI debugger.
@return EFI_SUCCESS if it returns at all
@retval EFI_SUCCESS This function completed successfully.
**/
EFI_STATUS
@ -605,13 +820,16 @@ EbcDebugSignalException (
/**
To install default Callback function for the VM interpreter.
@param This pointer to the instance of DebugSupport protocol
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
instance.
@return None
@retval EFI_SUCCESS The function completed successfully.
@retval Others Some error occurs when creating periodic event.
**/
STATIC
EFI_STATUS
EFIAPI
InitializeEbcCallback (
IN EFI_DEBUG_SUPPORT_PROTOCOL *This
)
@ -666,11 +884,10 @@ InitializeEbcCallback (
@param InterruptType Interrupt type.
@param SystemContext EBC system context.
@return None
**/
STATIC
VOID
EFIAPI
CommonEbcExceptionHandler (
IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_SYSTEM_CONTEXT SystemContext
@ -692,8 +909,6 @@ CommonEbcExceptionHandler (
@param Event The Periodic Callback Event.
@param Context It should be the address of VM_CONTEXT pointer.
@return None.
**/
STATIC
VOID
@ -719,14 +934,15 @@ EbcPeriodicNotifyFunction (
The VM interpreter calls this function on a periodic basis to support
the EFI debug support protocol.
@param VmPtr pointer to a VM context for passing info to the
@param VmPtr Pointer to a VM context for passing info to the
debugger.
@return Standard EFI status.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
EbcDebugPeriodic (
IN VM_CONTEXT *VmPtr
)
@ -781,12 +997,13 @@ EbcDebugPeriodic (
memory. Basically we now have the opportunity to do any necessary cleanup.
Typically this will include freeing any memory allocated for thunk-creation.
@param This protocol instance pointer
@param ImageHandle handle to the image being unloaded.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param ImageHandle Handle of image for which the thunk is being
created.
@retval EFI_INVALID_PARAMETER the ImageHandle passed in was not found in the
internal list of EBC image handles.
@retval EFI_STATUS completed successfully
@retval EFI_INVALID_PARAMETER The ImageHandle passed in was not found in the
internal list of EBC image handles.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
@ -855,12 +1072,12 @@ EbcUnloadImage (
Also flush the instruction cache since we've written thunk code
to memory that will be executed eventually.
@param ImageHandle the image handle to which the thunk is tied
@param ThunkBuffer the buffer we've created/allocated
@param ThunkSize the size of the thunk memory allocated
@param ImageHandle The image handle to which the thunk is tied.
@param ThunkBuffer The buffer that has been created/allocated.
@param ThunkSize The size of the thunk memory allocated.
@retval EFI_OUT_OF_RESOURCES memory allocation failed
@retval EFI_SUCCESS successful completion
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
@ -925,6 +1142,16 @@ EbcAddImageThunk (
return EFI_SUCCESS;
}
/**
Registers a callback function that the EBC interpreter calls to flush the
processor instruction cache following creation of thunks.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param Flush Pointer to a function of type EBC_ICACH_FLUSH.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
EFI_STATUS
EFIAPI
@ -937,6 +1164,17 @@ EbcRegisterICacheFlush (
return EFI_SUCCESS;
}
/**
Called to get the version of the interpreter.
@param This A pointer to the EFI_EBC_PROTOCOL instance.
@param Version Pointer to where to store the returned version
of the interpreter.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Version pointer is NULL.
**/
STATIC
EFI_STATUS
EFIAPI
@ -953,11 +1191,24 @@ EbcGetVersion (
return EFI_SUCCESS;
}
/**
Returns the stack index and buffer assosicated with the Handle parameter.
@param Handle The EFI handle as the index to the EBC stack.
@param StackBuffer A pointer to hold the returned stack buffer.
@param BufferIndex A pointer to hold the returned stack index.
@retval EFI_OUT_OF_RESOURCES The Handle parameter does not correspond to any
existing EBC stack.
@retval EFI_SUCCESS The stack index and buffer were found and
returned to the caller.
**/
EFI_STATUS
GetEBCStack(
EFI_HANDLE Handle,
VOID **StackBuffer,
UINTN *BufferIndex
IN EFI_HANDLE Handle,
OUT VOID **StackBuffer,
OUT UINTN *BufferIndex
)
{
UINTN Index;
@ -978,18 +1229,34 @@ GetEBCStack(
return EFI_SUCCESS;
}
/**
Returns from the EBC stack by stack Index.
@param Index Specifies which EBC stack to return from.
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
ReturnEBCStack(
UINTN Index
IN UINTN Index
)
{
mStackBufferIndex[Index] =NULL;
mStackBufferIndex[Index] = NULL;
return EFI_SUCCESS;
}
/**
Returns from the EBC stack associated with the Handle parameter.
@param Handle Specifies the EFI handle to find the EBC stack with.
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
ReturnEBCStackByHandle(
EFI_HANDLE Handle
IN EFI_HANDLE Handle
)
{
UINTN Index;
@ -1005,6 +1272,13 @@ ReturnEBCStackByHandle(
return EFI_SUCCESS;
}
/**
Allocates memory to hold all the EBC stacks.
@retval EFI_SUCCESS The EBC stacks were allocated successfully.
@retval EFI_OUT_OF_RESOURCES Not enough memory available for EBC stacks.
**/
EFI_STATUS
InitEBCStack (
VOID
@ -1023,6 +1297,13 @@ InitEBCStack (
return EFI_SUCCESS;
}
/**
Free all EBC stacks allocated before.
@retval EFI_SUCCESS All the EBC stacks were freed.
**/
EFI_STATUS
FreeEBCStack(
VOID
@ -1036,12 +1317,12 @@ FreeEBCStack(
}
/**
Produce an EBC VM test protocol that can be used for regression tests.
Produces an EBC VM test protocol that can be used for regression tests.
@param IHandle handle on which to install the protocol.
@param IHandle Handle on which to install the protocol.
@retval EFI_OUT_OF_RESOURCES memory allocation failed
@retval EFI_SUCCESS successful completion
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@retval EFI_SUCCESS The function completed successfully.
**/
STATIC
@ -1078,9 +1359,19 @@ InitEbcVmTestProtocol (
}
return Status;
}
/**
Returns the EFI_UNSUPPORTED Status.
@return EFI_UNSUPPORTED This function always return EFI_UNSUPPORTED status.
**/
STATIC
EFI_STATUS
EbcVmTestUnsupported ()
EbcVmTestUnsupported (
VOID
)
{
return EFI_UNSUPPORTED;
}