TianoCore EDK2 master
Loading...
Searching...
No Matches
EbcSupport.c File Reference
#include "EbcInt.h"
#include "EbcExecute.h"
#include "EbcDebuggerHook.h"

Go to the source code of this file.

Macros

#define VM_STACK_SIZE   (1024 * 4)
 
#define STACK_REMAIN_SIZE   (1024 * 4)
 
#define EBC_ENTRYPOINT_SIGNATURE   0xAFAFAFAF
 
#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE   0xFAFAFAFA
 

Functions

UINT64 EFIAPI EbcLLEbcInterpret (VOID)
 
UINT64 EFIAPI EbcLLExecuteEbcImageEntryPoint (VOID)
 
VOID EbcLLCALLEX (IN VM_CONTEXT *VmPtr, IN UINTN FuncAddr, IN UINTN NewStackPointer, IN VOID *FramePtr, IN UINT8 Size)
 
UINT64 EFIAPI EbcInterpret (IN UINTN EntryPoint, IN UINTN Arg1, IN UINTN Arg2, IN UINTN Arg3, IN UINTN Arg4, IN UINTN Arg5, IN UINTN Arg6, IN UINTN Arg7, IN UINTN Arg8, IN UINTN Arg9, IN UINTN Arg10, IN UINTN Arg11, IN UINTN Arg12, IN UINTN Arg13, IN UINTN Arg14, IN UINTN Arg15, IN UINTN Arg16)
 
UINT64 EFIAPI ExecuteEbcImageEntryPoint (IN UINTN EntryPoint, IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EbcCreateThunks (IN EFI_HANDLE ImageHandle, IN VOID *EbcEntryPoint, OUT VOID **Thunk, IN UINT32 Flags)
 

Variables

UINT8 mInstructionBufferTemplate []
 

Detailed Description

This module contains EBC support routines that are customized based on the target ia32 processor.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EbcSupport.c.

Macro Definition Documentation

◆ EBC_ENTRYPOINT_SIGNATURE

#define EBC_ENTRYPOINT_SIGNATURE   0xAFAFAFAF

Definition at line 27 of file EbcSupport.c.

◆ EBC_LL_EBC_ENTRYPOINT_SIGNATURE

#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE   0xFAFAFAFA

Definition at line 28 of file EbcSupport.c.

◆ STACK_REMAIN_SIZE

#define STACK_REMAIN_SIZE   (1024 * 4)

Definition at line 22 of file EbcSupport.c.

◆ VM_STACK_SIZE

#define VM_STACK_SIZE   (1024 * 4)

Definition at line 20 of file EbcSupport.c.

Function Documentation

◆ EbcCreateThunks()

EFI_STATUS EbcCreateThunks ( IN EFI_HANDLE  ImageHandle,
IN VOID *  EbcEntryPoint,
OUT VOID **  Thunk,
IN UINT32  Flags 
)

Create thunks for an EBC image entry point, or an EBC protocol service.

Parameters
ImageHandleImage handle for the EBC image. If not null, then we're creating a thunk for an image entry point.
EbcEntryPointAddress of the EBC code that the thunk is to call
ThunkReturned thunk we create here
FlagsFlags indicating options for creating the thunk
Return values
EFI_SUCCESSThe thunk was created successfully.
EFI_INVALID_PARAMETERThe parameter of EbcEntryPoint is not 16-bit aligned.
EFI_OUT_OF_RESOURCESThere is not enough memory to created the EBC Thunk.
EFI_BUFFER_TOO_SMALLEBC_THUNK_SIZE is not larger enough.

Definition at line 461 of file EbcSupport.c.

◆ EbcInterpret()

UINT64 EFIAPI EbcInterpret ( IN UINTN  EntryPoint,
IN UINTN  Arg1,
IN UINTN  Arg2,
IN UINTN  Arg3,
IN UINTN  Arg4,
IN UINTN  Arg5,
IN UINTN  Arg6,
IN UINTN  Arg7,
IN UINTN  Arg8,
IN UINTN  Arg9,
IN UINTN  Arg10,
IN UINTN  Arg11,
IN UINTN  Arg12,
IN UINTN  Arg13,
IN UINTN  Arg14,
IN UINTN  Arg15,
IN UINTN  Arg16 
)

Begin executing an EBC image.

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.

Parameters
EntryPointThe entrypoint of EBC code.
Arg1The 1st argument.
Arg2The 2nd argument.
Arg3The 3rd argument.
Arg4The 4th argument.
Arg5The 5th argument.
Arg6The 6th argument.
Arg7The 7th argument.
Arg8The 8th argument.
Arg9The 9th argument.
Arg10The 10th argument.
Arg11The 11th argument.
Arg12The 12th argument.
Arg13The 13th argument.
Arg14The 14th argument.
Arg15The 15th argument.
Arg16The 16th argument.
Returns
The value returned by the EBC application we're going to run.

Definition at line 205 of file EbcSupport.c.

◆ EbcLLCALLEX()

VOID EbcLLCALLEX ( IN VM_CONTEXT VmPtr,
IN UINTN  FuncAddr,
IN UINTN  NewStackPointer,
IN VOID *  FramePtr,
IN UINT8  Size 
)

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.

Parameters
VmPtrPointer to a VM context.
FuncAddrCallee's address
NewStackPointerNew stack pointer after the call
FramePtrNew frame pointer after the call
SizeThe size of call instruction

Definition at line 104 of file EbcSupport.c.

◆ EbcLLEbcInterpret()

UINT64 EFIAPI EbcLLEbcInterpret ( VOID  )

Begin executing an EBC image. This is used for Ebc Thunk call.

Returns
The value returned by the EBC application we're going to run.

◆ EbcLLExecuteEbcImageEntryPoint()

UINT64 EFIAPI EbcLLExecuteEbcImageEntryPoint ( VOID  )

Begin executing an EBC image. This is used for Ebc image entrypoint.

Returns
The value returned by the EBC application we're going to run.

◆ ExecuteEbcImageEntryPoint()

UINT64 EFIAPI ExecuteEbcImageEntryPoint ( IN UINTN  EntryPoint,
IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Begin executing an EBC image.

Parameters
EntryPointThe entrypoint of EBC code.
ImageHandleimage handle for the EBC application we're executing
SystemTablestandard system table passed into an driver's entry point
Returns
The value returned by the EBC application we're going to run.

Definition at line 355 of file EbcSupport.c.

Variable Documentation

◆ mInstructionBufferTemplate

UINT8 mInstructionBufferTemplate[]

Definition at line 29 of file EbcSupport.c.