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

File diff suppressed because it is too large Load Diff

View File

@ -227,6 +227,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define OPCODE_MOVIN 0x38
#define OPCODE_MOVREL 0x39
/**
Execute an EBC image from an entry point or from a published protocol.
@param VmPtr A pointer to a VM context.
@retval EFI_UNSUPPORTED At least one of the opcodes is not supported.
@retval EFI_SUCCESS All of the instructions are executed successfully.
**/
EFI_STATUS
EbcExecute (
IN VM_CONTEXT *VmPtr
@ -235,12 +244,41 @@ EbcExecute (
/**
Returns the version of the EBC virtual machine.
@return The 64-bit version of EBC virtual machine.
**/
UINT64
GetVmVersion (
VOID
)
;
/**
Writes UINTN data to memory address.
This routine is called by the EBC data
movement instructions that write to memory. Since these writes
may be to the stack, which looks like (high address on top) this,
[EBC entry point arguments]
[VM stack]
[EBC stack]
we need to detect all attempts to write to the EBC entry point argument
stack area and adjust the address (which will initially point into the
VM stack) to point into the EBC entry point arguments.
@param VmPtr A pointer to a VM context.
@param Addr Adddress to write to.
@param Data Value to write to Addr.
@retval EFI_SUCCESS The instruction is executed successfully.
@retval Other Some error occurs when writing data to the address.
**/
EFI_STATUS
VmWriteMemN (
IN VM_CONTEXT *VmPtr,
@ -249,6 +287,29 @@ VmWriteMemN (
)
;
/**
Writes 64-bit data to memory address.
This routine is called by the EBC data
movement instructions that write to memory. Since these writes
may be to the stack, which looks like (high address on top) this,
[EBC entry point arguments]
[VM stack]
[EBC stack]
we need to detect all attempts to write to the EBC entry point argument
stack area and adjust the address (which will initially point into the
VM stack) to point into the EBC entry point arguments.
@param VmPtr A pointer to a VM context.
@param Addr Adddress to write to.
@param Data Value to write to Addr.
@retval EFI_SUCCESS The instruction is executed successfully.
@retval Other Some error occurs when writing data to the address.
**/
EFI_STATUS
VmWriteMem64 (
IN VM_CONTEXT *VmPtr,
@ -305,6 +366,20 @@ struct _EFI_EBC_VM_TEST_PROTOCOL {
EBC_VM_TEST_DASM Disassemble;
};
/**
Given a pointer to a new VM context, execute one or more instructions. This
function is only used for test purposes via the EBC VM test protocol.
@param This A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.
@param VmPtr A pointer to a VM context.
@param InstructionCount A pointer to a UINTN value holding the number of
instructions to execute. If it holds value of 0,
then the instruction to be executed is 1.
@retval EFI_UNSUPPORTED At least one of the opcodes is not supported.
@retval EFI_SUCCESS All of the instructions are executed successfully.
**/
EFI_STATUS
EbcExecuteInstructions (
IN EFI_EBC_VM_TEST_PROTOCOL *This,

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;
}

View File

@ -79,6 +79,23 @@ extern VM_CONTEXT *mVmPtr;
//
#define VM_STACK_KEY_VALUE 0xDEADBEEF
/**
Create thunks for an EBC image entry point, or an EBC protocol service.
@param ImageHandle Image handle for the EBC image. If not null, then
we're creating a thunk for an image entry point.
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param Flags Flags indicating options for creating the thunk
@retval EFI_SUCCESS The thunk was created successfully.
@retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit
aligned.
@retval EFI_OUT_OF_RESOURCES There is not enough memory to created the EBC
Thunk.
@retval EFI_BUFFER_TOO_SMALL EBC_THUNK_SIZE is not larger enough.
**/
EFI_STATUS
EbcCreateThunks (
IN EFI_HANDLE ImageHandle,
@ -88,6 +105,19 @@ EbcCreateThunks (
)
;
/**
Add a thunk to our list of thunks for a given image handle.
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 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 The function completed successfully.
**/
EFI_STATUS
EbcAddImageThunk (
IN EFI_HANDLE ImageHandle,
@ -100,6 +130,17 @@ EbcAddImageThunk (
// The interpreter calls these when an exception is detected,
// or as a periodic callback.
//
/**
The VM interpreter calls this function when an exception is detected.
@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.
@retval EFI_SUCCESS This function completed successfully.
**/
EFI_STATUS
EbcDebugSignalException (
IN EFI_EXCEPTION_TYPE ExceptionType,
@ -117,28 +158,56 @@ EbcDebugSignalException (
#define STACK_POOL_SIZE (1024 * 1020)
#define MAX_STACK_NUM 4
EFI_STATUS
EbcDebugSignalPeriodic (
IN VM_CONTEXT *VmPtr
)
;
//
// External low level functions that are native-processor dependent
//
//
/**
The VM thunk code stuffs an EBC entry point into a processor
register. Since we can't use inline assembly to get it from
the interpreter C code, stuff it into the return value
register and return.
@return The contents of the register in which the entry point is passed.
**/
UINTN
EFIAPI
EbcLLGetEbcEntryPoint (
VOID
)
;
/**
Returns the caller's value of the stack pointer.
We adjust it by 4 here because when they called us, the return address
is put on the stack, thereby lowering it by 4 bytes.
@return The current value of the stack pointer for the caller.
**/
UINTN
EFIAPI
EbcLLGetStackPointer (
VOID
)
;
/**
This function is called to execute an EBC CALLEX instruction.
This instruction requires that we thunk out to external native
code. For x64, we switch stacks, copy the arguments to the stack
and jump to the specified function.
On return, we restore the stack pointer to its original location.
Destroys no working registers.
@param CallAddr The function address.
@param EbcSp The new EBC stack pointer.
@param FramePtr The frame pointer.
**/
VOID
EFIAPI
EbcLLCALLEXNative (
IN UINTN CallAddr,
IN UINTN EbcSp,
@ -146,47 +215,114 @@ EbcLLCALLEXNative (
)
;
/**
This function is called to execute an EBC CALLEX instruction.
The function check the callee's content to see whether it is common native
code or a thunk to another piece of EBC code.
If the callee is common native code, use EbcLLCAllEXASM to manipulate,
otherwise, set the VM->IP to target EBC code directly to avoid another VM
be startup which cost time and stack space.
@param VmPtr Pointer to a VM context.
@param FuncAddr Callee's address
@param NewStackPointer New stack pointer after the call
@param FramePtr New frame pointer after the call
@param Size The size of call instruction
**/
VOID
EbcLLCALLEX (
IN VM_CONTEXT *VmPtr,
IN UINTN CallAddr,
IN UINTN EbcSp,
IN UINTN FuncAddr,
IN UINTN NewStackPointer,
IN VOID *FramePtr,
IN UINT8 Size
)
;
/**
When EBC calls native, on return the VM has to stuff the return
value into a VM register. It's assumed here that the value is still
in the register, so simply return and the caller should get the
return result properly.
@return The unmodified value returned by the native code.
**/
INT64
EFIAPI
EbcLLGetReturnValue (
VOID
)
;
/**
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
);
/**
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
);
/**
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
);
/**
Free all EBC stacks allocated before.
@retval EFI_SUCCESS All the EBC stacks were freed.
**/
EFI_STATUS
FreeEBCStack(
VOID
);
/**
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
);
//
// Defines for a simple EBC debugger interface
@ -255,13 +391,6 @@ typedef struct {
#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')
struct _EBC_PROTOCOL_PRIVATE_DATA {
UINT32 Signature;
EFI_EBC_PROTOCOL EbcProtocol;
UINTN StackBase;
UINTN StackTop;
UINTN StackSize;
} ;
#define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)

View File

@ -36,13 +36,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
otherwise, set the VM->IP to target EBC code directly to avoid another VM
be startup which cost time and stack space.
@parm VmPtr Pointer to a VM context.
@parm FuncAddr Callee's address
@parm NewStackPointer New stack pointer after the call
@parm FramePtr New frame pointer after the call
@parm Size The size of call instruction
@return None.
@param VmPtr Pointer to a VM context.
@param FuncAddr Callee's address
@param NewStackPointer New stack pointer after the call
@param FramePtr New frame pointer after the call
@param Size The size of call instruction
**/
VOID
@ -137,9 +135,26 @@ Action:
in via a processor register, so we'll need to make a call to get the
value.
None. Since we're called from a fixed up thunk (which we want to keep
small), our only so-called argument is the EBC entry point passed in
to us in a processor register.
This is a thunk function. Microsoft x64 compiler only provide fast_call
calling convention, so the first four arguments are passed by rcx, rdx,
r8, and r9, while other arguments are passed in stack.
@param Arg1 The 1st argument.
@param Arg2 The 2nd argument.
@param Arg3 The 3rd argument.
@param Arg4 The 4th argument.
@param Arg5 The 5th argument.
@param Arg6 The 6th argument.
@param Arg7 The 7th argument.
@param Arg8 The 8th argument.
@param Arg9 The 9th argument.
@param Arg10 The 10th argument.
@param Arg11 The 11th argument.
@param Arg12 The 12th argument.
@param Arg13 The 13th argument.
@param Arg14 The 14th argument.
@param Arg15 The 15th argument.
@param Arg16 The 16th argument.
@return The value returned by the EBC application we're going to run.
@ -286,8 +301,9 @@ EbcInterpret (
in via a processor register, so we'll need to make a call to get the
value.
@param ImageHandle image handle for the EBC application we're executing
@param SystemTable standard system table passed into an driver's entry point
@param ImageHandle image handle for the EBC application we're executing
@param SystemTable standard system table passed into an driver's entry
point
@return The value returned by the EBC application we're going to run.
@ -385,13 +401,20 @@ ExecuteEbcImageEntryPoint (
/**
Create an IA32 thunk for the given EBC entry point.
Create thunks for an EBC image entry point, or an EBC protocol service.
@param ImageHandle Handle of image for which this thunk is being created
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param ImageHandle Image handle for the EBC image. If not null, then
we're creating a thunk for an image entry point.
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param Flags Flags indicating options for creating the thunk
@return Standard EFI status.
@retval EFI_SUCCESS The thunk was created successfully.
@retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit
aligned.
@retval EFI_OUT_OF_RESOURCES There is not enough memory to created the EBC
Thunk.
@retval EFI_BUFFER_TOO_SMALL EBC_THUNK_SIZE is not larger enough.
**/
EFI_STATUS
@ -404,7 +427,7 @@ EbcCreateThunks (
{
UINT8 *Ptr;
UINT8 *ThunkBase;
UINT32 I;
UINT32 Index;
UINT32 Addr;
INT32 Size;
INT32 ThunkSize;
@ -444,7 +467,7 @@ EbcCreateThunks (
Ptr++;
Size--;
Addr = (UINT32) 0xCA112EBC;
for (I = 0; I < sizeof (Addr); I++) {
for (Index = 0; Index < sizeof (Addr); Index++) {
*Ptr = (UINT8) (UINTN) Addr;
Addr >>= 8;
Ptr++;
@ -461,7 +484,7 @@ EbcCreateThunks (
Ptr++;
Size--;
Addr = (UINT32) EbcEntryPoint;
for (I = 0; I < sizeof (Addr); I++) {
for (Index = 0; Index < sizeof (Addr); Index++) {
*Ptr = (UINT8) (UINTN) Addr;
Addr >>= 8;
Ptr++;
@ -483,7 +506,7 @@ EbcCreateThunks (
*Ptr = 0xB9;
Ptr++;
Size--;
for (I = 0; I < sizeof (Addr); I++) {
for (Index = 0; Index < sizeof (Addr); Index++) {
*Ptr = (UINT8) Addr;
Addr >>= 8;
Ptr++;

View File

@ -17,6 +17,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "EbcExecute.h"
#include "EbcSupport.h"
/**
Given raw bytes of Itanium based code, format them into a bundle and
write them out.
@param MemPtr pointer to memory location to write the bundles
to.
@param Template 5-bit template.
@param Slot0 Instruction slot 0 data for the bundle.
@param Slot1 Instruction slot 1 data for the bundle.
@param Slot2 Instruction slot 2 data for the bundle.
@retval EFI_INVALID_PARAMETER Pointer is not aligned
@retval EFI_INVALID_PARAMETER No more than 5 bits in template
@retval EFI_INVALID_PARAMETER More than 41 bits used in code
@retval EFI_SUCCESS All data is written.
**/
STATIC
EFI_STATUS
WriteBundle (
@ -27,11 +44,18 @@ WriteBundle (
IN UINT64 Slot2
);
/**
Pushes a 64 bit unsigned value to the VM stack.
@param VmPtr The pointer to current VM context.
@param Arg The value to be pushed.
**/
STATIC
VOID
PushU64 (
VM_CONTEXT *VmPtr,
UINT64 Arg
IN VM_CONTEXT *VmPtr,
IN UINT64 Arg
)
{
//
@ -42,6 +66,21 @@ PushU64 (
*(UINT64 *) VmPtr->R[0] = Arg;
}
/**
Begin executing an EBC image. The address of the entry point is passed
in via a processor register, so we'll need to make a call to get the
value.
This is a thunk function. Microsoft x64 compiler only provide fast_call
calling convention, so the first four arguments are passed by rcx, rdx,
r8, and r9, while other arguments are passed in stack.
@param Arg1 The 1st argument.
@param ... The variable arguments list.
@return The value returned by the EBC application we're going to run.
**/
STATIC
UINT64
EbcInterpret (
@ -189,15 +228,13 @@ EbcInterpret (
/**
IPF implementation.
Begin executing an EBC image. The address of the entry point is passed
in via a processor register, so we'll need to make a call to get the
value.
@param ImageHandle image handle for the EBC application we're
executing
@param SystemTable standard system table passed into an driver's
entry point
@param ImageHandle image handle for the EBC application we're executing
@param SystemTable standard system table passed into an driver's entry
point
@return The value returned by the EBC application we're going to run.
@ -312,13 +349,18 @@ ExecuteEbcImageEntryPoint (
/**
Create thunks for an EBC image entry point, or an EBC protocol service.
@param ImageHandle Image handle for the EBC image. If not null, then
we're creating a thunk for an image entry point.
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param Flags Flags indicating options for creating the thunk
@param ImageHandle Image handle for the EBC image. If not null, then
we're creating a thunk for an image entry point.
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param Flags Flags indicating options for creating the thunk
@return Standard EFI status.
@retval EFI_SUCCESS The thunk was created successfully.
@retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit
aligned.
@retval EFI_OUT_OF_RESOURCES There is not enough memory to created the EBC
Thunk.
@retval EFI_BUFFER_TOO_SMALL EBC_THUNK_SIZE is not larger enough.
**/
EFI_STATUS
@ -334,11 +376,11 @@ EbcCreateThunks (
UINT64 Addr;
UINT64 Code[3]; // Code in a bundle
UINT64 RegNum; // register number for MOVL
UINT64 I; // bits of MOVL immediate data
UINT64 Ic; // bits of MOVL immediate data
UINT64 Imm5c; // bits of MOVL immediate data
UINT64 Imm9d; // bits of MOVL immediate data
UINT64 Imm7b; // bits of MOVL immediate data
UINT64 BitI; // bits of MOVL immediate data
UINT64 BitIc; // bits of MOVL immediate data
UINT64 BitImm5c; // bits of MOVL immediate data
UINT64 BitImm9d; // bits of MOVL immediate data
UINT64 BitImm7b; // bits of MOVL immediate data
UINT64 Br; // branch register for loading and jumping
UINT64 *Data64Ptr;
UINT32 ThunkSize;
@ -436,23 +478,23 @@ EbcCreateThunks (
// Extract bits from the address for insertion into the instruction
// i = Addr[63:63]
//
I = RShiftU64 (Addr, 63) & 0x01;
BitI = RShiftU64 (Addr, 63) & 0x01;
//
// ic = Addr[21:21]
//
Ic = RShiftU64 (Addr, 21) & 0x01;
BitIc = RShiftU64 (Addr, 21) & 0x01;
//
// imm5c = Addr[20:16] for 5 bits
//
Imm5c = RShiftU64 (Addr, 16) & 0x1F;
BitImm5c = RShiftU64 (Addr, 16) & 0x1F;
//
// imm9d = Addr[15:7] for 9 bits
//
Imm9d = RShiftU64 (Addr, 7) & 0x1FF;
BitImm9d = RShiftU64 (Addr, 7) & 0x1FF;
//
// imm7b = Addr[6:0] for 7 bits
//
Imm7b = Addr & 0x7F;
BitImm7b = Addr & 0x7F;
//
// The EBC entry point will be put into r8, so r8 can be used here
@ -463,12 +505,12 @@ EbcCreateThunks (
//
// Next is jumbled data, including opcode and rest of address
//
Code[2] = LShiftU64 (Imm7b, 13);
Code[2] = LShiftU64 (BitImm7b, 13);
Code[2] = Code[2] | LShiftU64 (0x00, 20); // vc
Code[2] = Code[2] | LShiftU64 (Ic, 21);
Code[2] = Code[2] | LShiftU64 (Imm5c, 22);
Code[2] = Code[2] | LShiftU64 (Imm9d, 27);
Code[2] = Code[2] | LShiftU64 (I, 36);
Code[2] = Code[2] | LShiftU64 (BitIc, 21);
Code[2] = Code[2] | LShiftU64 (BitImm5c, 22);
Code[2] = Code[2] | LShiftU64 (BitImm9d, 27);
Code[2] = Code[2] | LShiftU64 (BitI, 36);
Code[2] = Code[2] | LShiftU64 ((UINT64)MOVL_OPCODE, 37);
Code[2] = Code[2] | LShiftU64 ((RegNum & 0x7F), 6);
@ -501,23 +543,23 @@ EbcCreateThunks (
// Extract bits from the address for insertion into the instruction
// i = Addr[63:63]
//
I = RShiftU64 (Addr, 63) & 0x01;
BitI = RShiftU64 (Addr, 63) & 0x01;
//
// ic = Addr[21:21]
//
Ic = RShiftU64 (Addr, 21) & 0x01;
BitIc = RShiftU64 (Addr, 21) & 0x01;
//
// imm5c = Addr[20:16] for 5 bits
//
Imm5c = RShiftU64 (Addr, 16) & 0x1F;
BitImm5c = RShiftU64 (Addr, 16) & 0x1F;
//
// imm9d = Addr[15:7] for 9 bits
//
Imm9d = RShiftU64 (Addr, 7) & 0x1FF;
BitImm9d = RShiftU64 (Addr, 7) & 0x1FF;
//
// imm7b = Addr[6:0] for 7 bits
//
Imm7b = Addr & 0x7F;
BitImm7b = Addr & 0x7F;
//
// Put the EBC entry point in r8, which is the location of the return value
@ -528,12 +570,12 @@ EbcCreateThunks (
//
// Next is jumbled data, including opcode and rest of address
//
Code[2] = LShiftU64 (Imm7b, 13);
Code[2] = LShiftU64 (BitImm7b, 13);
Code[2] = Code[2] | LShiftU64 (0x00, 20); // vc
Code[2] = Code[2] | LShiftU64 (Ic, 21);
Code[2] = Code[2] | LShiftU64 (Imm5c, 22);
Code[2] = Code[2] | LShiftU64 (Imm9d, 27);
Code[2] = Code[2] | LShiftU64 (I, 36);
Code[2] = Code[2] | LShiftU64 (BitIc, 21);
Code[2] = Code[2] | LShiftU64 (BitImm5c, 22);
Code[2] = Code[2] | LShiftU64 (BitImm9d, 27);
Code[2] = Code[2] | LShiftU64 (BitI, 36);
Code[2] = Code[2] | LShiftU64 ((UINT64)MOVL_OPCODE, 37);
Code[2] = Code[2] | LShiftU64 ((RegNum & 0x7F), 6);
@ -573,23 +615,23 @@ EbcCreateThunks (
// Extract bits from the address for insertion into the instruction
// i = Addr[63:63]
//
I = RShiftU64 (Addr, 63) & 0x01;
BitI = RShiftU64 (Addr, 63) & 0x01;
//
// ic = Addr[21:21]
//
Ic = RShiftU64 (Addr, 21) & 0x01;
BitIc = RShiftU64 (Addr, 21) & 0x01;
//
// imm5c = Addr[20:16] for 5 bits
//
Imm5c = RShiftU64 (Addr, 16) & 0x1F;
BitImm5c = RShiftU64 (Addr, 16) & 0x1F;
//
// imm9d = Addr[15:7] for 9 bits
//
Imm9d = RShiftU64 (Addr, 7) & 0x1FF;
BitImm9d = RShiftU64 (Addr, 7) & 0x1FF;
//
// imm7b = Addr[6:0] for 7 bits
//
Imm7b = Addr & 0x7F;
BitImm7b = Addr & 0x7F;
//
// Put it in r31, a scratch register
@ -599,12 +641,12 @@ EbcCreateThunks (
//
// Next is jumbled data, including opcode and rest of address
//
Code[2] = LShiftU64(Imm7b, 13);
Code[2] = LShiftU64(BitImm7b, 13);
Code[2] = Code[2] | LShiftU64 (0x00, 20); // vc
Code[2] = Code[2] | LShiftU64 (Ic, 21);
Code[2] = Code[2] | LShiftU64 (Imm5c, 22);
Code[2] = Code[2] | LShiftU64 (Imm9d, 27);
Code[2] = Code[2] | LShiftU64 (I, 36);
Code[2] = Code[2] | LShiftU64 (BitIc, 21);
Code[2] = Code[2] | LShiftU64 (BitImm5c, 22);
Code[2] = Code[2] | LShiftU64 (BitImm9d, 27);
Code[2] = Code[2] | LShiftU64 (BitI, 36);
Code[2] = Code[2] | LShiftU64 ((UINT64)MOVL_OPCODE, 37);
Code[2] = Code[2] | LShiftU64 ((RegNum & 0x7F), 6);
@ -667,13 +709,16 @@ EbcCreateThunks (
Given raw bytes of Itanium based code, format them into a bundle and
write them out.
@param MemPtr pointer to memory location to write the bundles to
@param Template 5-bit template
@param Slot0-2 instruction slot data for the bundle
@param MemPtr pointer to memory location to write the bundles
to.
@param Template 5-bit template.
@param Slot0 Instruction slot 0 data for the bundle.
@param Slot1 Instruction slot 1 data for the bundle.
@param Slot2 Instruction slot 2 data for the bundle.
@retval EFI_INVALID_PARAMETER Pointer is not aligned
@retval No more than 5 bits in template
@retval More than 41 bits used in code
@retval EFI_INVALID_PARAMETER No more than 5 bits in template
@retval EFI_INVALID_PARAMETER More than 41 bits used in code
@retval EFI_SUCCESS All data is written.
**/
@ -745,13 +790,11 @@ WriteBundle (
otherwise, set the VM->IP to target EBC code directly to avoid another VM
be startup which cost time and stack space.
@param VmPtr Pointer to a VM context.
@param FuncAddr Callee's address
@param NewStackPointer New stack pointer after the call
@param FramePtr New frame pointer after the call
@param Size The size of call instruction
@return None.
@param VmPtr Pointer to a VM context.
@param FuncAddr Callee's address
@param NewStackPointer New stack pointer after the call
@param FramePtr New frame pointer after the call
@param Size The size of call instruction
**/
VOID

View File

@ -38,10 +38,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
#define MOVL_OPCODE 0x06
VOID
EbcAsmLLCALLEX (
IN UINTN CallAddr,
IN UINTN EbcSp
);
#endif

View File

@ -27,28 +27,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define STACK_REMAIN_SIZE (1024 * 4)
/**
Pushes a 64 bit unsigned value to the VM stack.
@param VmPtr The pointer to current VM context.
@param Arg The value to be pushed.
**/
STATIC
VOID
PushU64 (
VM_CONTEXT *VmPtr,
UINT64 Arg
IN VM_CONTEXT *VmPtr,
IN UINT64 Arg
)
/*++
Routine Description:
Push a 64 bit unsigned value to the VM stack.
Arguments:
VmPtr - The pointer to current VM context.
Arg - The value to be pushed
Returns:
VOID
--*/
{
//
// Advance the VM stack down, and then copy the argument to the stack.
@ -69,28 +61,45 @@ Returns:
calling convention, so the first four arguments are passed by rcx, rdx,
r8, and r9, while other arguments are passed in stack.
@param Arg1 The 1st argument.
@param Arg2 The 2nd argument.
@param Arg3 The 3rd argument.
@param Arg4 The 4th argument.
@param Arg5 The 5th argument.
@param Arg6 The 6th argument.
@param Arg7 The 7th argument.
@param Arg8 The 8th argument.
@param Arg9 The 9th argument.
@param Arg10 The 10th argument.
@param Arg11 The 11th argument.
@param Arg12 The 12th argument.
@param Arg13 The 13th argument.
@param Arg14 The 14th argument.
@param Arg15 The 15th argument.
@param Arg16 The 16th argument.
@return The value returned by the EBC application we're going to run.
**/
STATIC
UINT64
EbcInterpret (
UINTN Arg1,
UINTN Arg2,
UINTN Arg3,
UINTN Arg4,
UINTN Arg5,
UINTN Arg6,
UINTN Arg7,
UINTN Arg8,
UINTN Arg9,
UINTN Arg10,
UINTN Arg11,
UINTN Arg12,
UINTN Arg13,
UINTN Arg14,
UINTN Arg15,
UINTN Arg16
IN OUT UINTN Arg1,
IN OUT UINTN Arg2,
IN OUT UINTN Arg3,
IN OUT UINTN Arg4,
IN OUT UINTN Arg5,
IN OUT UINTN Arg6,
IN OUT UINTN Arg7,
IN OUT UINTN Arg8,
IN OUT UINTN Arg9,
IN OUT UINTN Arg10,
IN OUT UINTN Arg11,
IN OUT UINTN Arg12,
IN OUT UINTN Arg13,
IN OUT UINTN Arg14,
IN OUT UINTN Arg15,
IN OUT UINTN Arg16
)
{
//
@ -328,13 +337,20 @@ ExecuteEbcImageEntryPoint (
/**
Create an IA32 thunk for the given EBC entry point.
Create thunks for an EBC image entry point, or an EBC protocol service.
@param ImageHandle Handle of image for which this thunk is being created
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param ImageHandle Image handle for the EBC image. If not null, then
we're creating a thunk for an image entry point.
@param EbcEntryPoint Address of the EBC code that the thunk is to call
@param Thunk Returned thunk we create here
@param Flags Flags indicating options for creating the thunk
@return Standard EFI status.
@retval EFI_SUCCESS The thunk was created successfully.
@retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit
aligned.
@retval EFI_OUT_OF_RESOURCES There is not enough memory to created the EBC
Thunk.
@retval EFI_BUFFER_TOO_SMALL EBC_THUNK_SIZE is not larger enough.
**/
EFI_STATUS
@ -347,7 +363,7 @@ EbcCreateThunks (
{
UINT8 *Ptr;
UINT8 *ThunkBase;
UINT32 I;
UINT32 Index;
UINT64 Addr;
INT32 Size;
INT32 ThunkSize;
@ -390,7 +406,7 @@ EbcCreateThunks (
Ptr++;
Size--;
Addr = (UINT64) 0xCA112EBCCA112EBCULL;
for (I = 0; I < sizeof (Addr); I++) {
for (Index = 0; Index < sizeof (Addr); Index++) {
*Ptr = (UINT8) (UINTN) Addr;
Addr >>= 8;
Ptr++;
@ -410,7 +426,7 @@ EbcCreateThunks (
Ptr++;
Size--;
Addr = (UINT64) EbcEntryPoint;
for (I = 0; I < sizeof (Addr); I++) {
for (Index = 0; Index < sizeof (Addr); Index++) {
*Ptr = (UINT8) (UINTN) Addr;
Addr >>= 8;
Ptr++;
@ -438,7 +454,7 @@ EbcCreateThunks (
*Ptr = 0xBB;
Ptr++;
Size--;
for (I = 0; I < sizeof (Addr); I++) {
for (Index = 0; Index < sizeof (Addr); Index++) {
*Ptr = (UINT8) Addr;
Addr >>= 8;
Ptr++;
@ -487,8 +503,6 @@ EbcCreateThunks (
@param FramePtr New frame pointer after the call
@param Size The size of call instruction
@return None.
**/
VOID
EbcLLCALLEX (