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

Go to the source code of this file.

Data Structures

struct  VM_TABLE_ENTRY
 

Macros

#define DATA_SIZE_INVALID   0
 
#define DATA_SIZE_8   1
 
#define DATA_SIZE_16   2
 
#define DATA_SIZE_32   4
 
#define DATA_SIZE_64   8
 
#define DATA_SIZE_N   48
 

Typedefs

typedef UINT64(* DATA_MANIP_EXEC_FUNCTION) (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 

Functions

INT16 VmReadIndex16 (IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
 
INT32 VmReadIndex32 (IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
 
INT64 VmReadIndex64 (IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
 
UINT8 VmReadMem8 (IN VM_CONTEXT *VmPtr, IN UINTN Addr)
 
UINT16 VmReadMem16 (IN VM_CONTEXT *VmPtr, IN UINTN Addr)
 
UINT32 VmReadMem32 (IN VM_CONTEXT *VmPtr, IN UINTN Addr)
 
UINT64 VmReadMem64 (IN VM_CONTEXT *VmPtr, IN UINTN Addr)
 
UINTN VmReadMemN (IN VM_CONTEXT *VmPtr, IN UINTN Addr)
 
EFI_STATUS VmWriteMem8 (IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT8 Data)
 
EFI_STATUS VmWriteMem16 (IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT16 Data)
 
EFI_STATUS VmWriteMem32 (IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT32 Data)
 
UINT16 VmReadCode16 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
UINT32 VmReadCode32 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
UINT64 VmReadCode64 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
INT8 VmReadImmed8 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
INT16 VmReadImmed16 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
INT32 VmReadImmed32 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
INT64 VmReadImmed64 (IN VM_CONTEXT *VmPtr, IN UINT32 Offset)
 
UINTN ConvertStackAddr (IN VM_CONTEXT *VmPtr, IN UINTN Addr)
 
EFI_STATUS ExecuteDataManip (IN VM_CONTEXT *VmPtr, IN BOOLEAN IsSignedOp)
 
EFI_STATUS ExecuteBREAK (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteJMP (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteJMP8 (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteCALL (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteRET (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteCMP (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteCMPI (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteMOVxx (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteMOVI (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteMOVIn (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteMOVREL (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecutePUSHn (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecutePUSH (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecutePOPn (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecutePOP (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteSignedDataManip (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteUnsignedDataManip (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteLOADSP (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteSTORESP (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteMOVsnd (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS ExecuteMOVsnw (IN VM_CONTEXT *VmPtr)
 
UINT64 ExecuteNOT (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteNEG (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteADD (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteSUB (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteMUL (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteMULU (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteDIV (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteDIVU (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteMOD (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteMODU (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteAND (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteOR (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteXOR (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteSHL (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteSHR (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteASHR (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteEXTNDB (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteEXTNDW (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
UINT64 ExecuteEXTNDD (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
 
EFI_STATUS EFIAPI EbcExecuteInstructions (IN EFI_EBC_VM_TEST_PROTOCOL *This, IN VM_CONTEXT *VmPtr, IN OUT UINTN *InstructionCount)
 
EFI_STATUS EbcExecute (IN VM_CONTEXT *VmPtr)
 
EFI_STATUS VmWriteMem64 (IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT64 Data)
 
EFI_STATUS VmWriteMemN (IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINTN Data)
 
UINT64 GetVmVersion (VOID)
 

Variables

CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable []
 
CONST VM_TABLE_ENTRY mVmOpcodeTable []
 
CONST UINT8 mJMPLen [] = { 2, 2, 6, 10 }
 

Detailed Description

Contains code that implements the virtual machine.

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

Definition in file EbcExecute.c.

Macro Definition Documentation

◆ DATA_SIZE_16

#define DATA_SIZE_16   2

Definition at line 19 of file EbcExecute.c.

◆ DATA_SIZE_32

#define DATA_SIZE_32   4

Definition at line 20 of file EbcExecute.c.

◆ DATA_SIZE_64

#define DATA_SIZE_64   8

Definition at line 21 of file EbcExecute.c.

◆ DATA_SIZE_8

#define DATA_SIZE_8   1

Definition at line 18 of file EbcExecute.c.

◆ DATA_SIZE_INVALID

#define DATA_SIZE_INVALID   0

Definition at line 17 of file EbcExecute.c.

◆ DATA_SIZE_N

#define DATA_SIZE_N   48

Definition at line 22 of file EbcExecute.c.

Typedef Documentation

◆ DATA_MANIP_EXEC_FUNCTION

typedef UINT64(* DATA_MANIP_EXEC_FUNCTION) (IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)

Definition at line 33 of file EbcExecute.c.

Function Documentation

◆ ConvertStackAddr()

UINTN ConvertStackAddr ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr 
)

Given an address that EBC is going to read from or write to, return an appropriate address that accounts for a gap in the stack. The stack for this application looks like this (high addr on top) [EBC entry point arguments] [VM stack] [EBC stack] The EBC assumes that its arguments are at the top of its stack, which is where the VM stack is really. Therefore if the EBC does memory accesses into the VM stack area, then we need to convert the address to point to the EBC entry point arguments area. Do this here.

Parameters
VmPtrA Pointer to VM context.
AddrAddress of interest
Returns
The unchanged address if it's not in the VM stack region. Otherwise, adjust for the stack gap and return the modified address.

Definition at line 5355 of file EbcExecute.c.

◆ EbcExecute()

EFI_STATUS EbcExecute ( IN VM_CONTEXT VmPtr)

Execute an EBC image from an entry point or from a published protocol.

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDAt least one of the opcodes is not supported.
EFI_SUCCESSAll of the instructions are executed successfully.

Definition at line 1418 of file EbcExecute.c.

◆ EbcExecuteInstructions()

EFI_STATUS EFIAPI EbcExecuteInstructions ( IN EFI_EBC_VM_TEST_PROTOCOL This,
IN VM_CONTEXT VmPtr,
IN OUT UINTN InstructionCount 
)

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.

Parameters
ThisA pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.
VmPtrA pointer to a VM context.
InstructionCountA 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.
Return values
EFI_UNSUPPORTEDAt least one of the opcodes is not supported.
EFI_SUCCESSAll of the instructions are executed successfully.

Definition at line 1360 of file EbcExecute.c.

◆ ExecuteADD()

UINT64 ExecuteADD ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 + Op2

Definition at line 3610 of file EbcExecute.c.

◆ ExecuteAND()

UINT64 ExecuteAND ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 AND Op2

Definition at line 3876 of file EbcExecute.c.

◆ ExecuteASHR()

UINT64 ExecuteASHR ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 >> Op2 (signed)

Definition at line 3999 of file EbcExecute.c.

◆ ExecuteBREAK()

EFI_STATUS ExecuteBREAK ( IN VM_CONTEXT VmPtr)

Execute the EBC BREAK instruction.

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 1828 of file EbcExecute.c.

◆ ExecuteCALL()

EFI_STATUS ExecuteCALL ( IN VM_CONTEXT VmPtr)

R1 {Immed32}

If Rx == R0, then it's a PC relative call to PC = PC + imm32.

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2995 of file EbcExecute.c.

◆ ExecuteCMP()

EFI_STATUS ExecuteCMP ( IN VM_CONTEXT VmPtr)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 3196 of file EbcExecute.c.

◆ ExecuteCMPI()

EFI_STATUS ExecuteCMPI ( IN VM_CONTEXT VmPtr)

Rx {Index16}, Immed16|Immed32

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 3370 of file EbcExecute.c.

◆ ExecuteDataManip()

EFI_STATUS ExecuteDataManip ( IN VM_CONTEXT VmPtr,
IN BOOLEAN  IsSignedOp 
)

R2 {Immed16|Index16}

Parameters
VmPtrA pointer to VM context.
IsSignedOpIndicates whether the operand is signed or not.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 4197 of file EbcExecute.c.

◆ ExecuteDIV()

UINT64 ExecuteDIV ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 / Op2

Definition at line 3714 of file EbcExecute.c.

◆ ExecuteDIVU()

UINT64 ExecuteDIVU ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
(unsigned)Op1 / (unsigned)Op2

Definition at line 3756 of file EbcExecute.c.

◆ ExecuteEXTNDB()

UINT64 ExecuteEXTNDB ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
(INT64)(INT8)Op2

Definition at line 4026 of file EbcExecute.c.

◆ ExecuteEXTNDD()

UINT64 ExecuteEXTNDD ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
(INT64)(INT32)Op2

Definition at line 4101 of file EbcExecute.c.

◆ ExecuteEXTNDW()

UINT64 ExecuteEXTNDW ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
(INT64)(INT16)Op2

Definition at line 4059 of file EbcExecute.c.

◆ ExecuteJMP()

EFI_STATUS ExecuteJMP ( IN VM_CONTEXT VmPtr)

R1 {Immed32|Index32}

Encoding: b0.7 - immediate data present b0.6 - 1 = 64 bit immediate data 0 = 32 bit immediate data b1.7 - 1 = conditional b1.6 1 = CS (condition set) 0 = CC (condition clear) b1.4 1 = relative address 0 = absolute address b1.3 1 = operand1 indirect b1.2-0 operand 1

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 1958 of file EbcExecute.c.

◆ ExecuteJMP8()

EFI_STATUS ExecuteJMP8 ( IN VM_CONTEXT VmPtr)

Execute the EBC JMP8 instruction.

Instruction syntax: JMP8{cs|cc} Offset/2

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2135 of file EbcExecute.c.

◆ ExecuteLOADSP()

EFI_STATUS ExecuteLOADSP ( IN VM_CONTEXT VmPtr)

Execute the EBC LOADSP instruction.

Instruction syntax: LOADSP SP1, R2

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 4352 of file EbcExecute.c.

◆ ExecuteMOD()

UINT64 ExecuteMOD ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 MODULUS Op2

Definition at line 3800 of file EbcExecute.c.

◆ ExecuteMODU()

UINT64 ExecuteMODU ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 UNSIGNED_MODULUS Op2

Definition at line 3838 of file EbcExecute.c.

◆ ExecuteMOVI()

EFI_STATUS ExecuteMOVI ( IN VM_CONTEXT VmPtr)

R1 {Index16}, ImmData16|32|64

First variable character specifies the move size Second variable character specifies size of the immediate data

Sign-extend the immediate data to the size of the operation, and zero-extend if storing to a register.

Operand1 direct with index/immed is invalid.

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2199 of file EbcExecute.c.

◆ ExecuteMOVIn()

EFI_STATUS ExecuteMOVIn ( IN VM_CONTEXT VmPtr)

R1 {Index16}, Index16|32|64

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2320 of file EbcExecute.c.

◆ ExecuteMOVREL()

EFI_STATUS ExecuteMOVREL ( IN VM_CONTEXT VmPtr)

R1 {Index16}, ImmData16|32|64

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2424 of file EbcExecute.c.

◆ ExecuteMOVsnd()

EFI_STATUS ExecuteMOVsnd ( IN VM_CONTEXT VmPtr)

R2 {Index32|Immed32}

0:7 1=>operand1 index present 0:6 1=>operand2 index present

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2627 of file EbcExecute.c.

◆ ExecuteMOVsnw()

EFI_STATUS ExecuteMOVsnw ( IN VM_CONTEXT VmPtr)

R2 {Index16|Immed16}

0:7 1=>operand1 index present 0:6 1=>operand2 index present

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2532 of file EbcExecute.c.

◆ ExecuteMOVxx()

EFI_STATUS ExecuteMOVxx ( IN VM_CONTEXT VmPtr)

R2 {Index64}

Copies contents of [R2] -> [R1], zero extending where required.

First character indicates the size of the move. Second character indicates the size of the index(s).

Invalid to have R1 direct with index.

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 1554 of file EbcExecute.c.

◆ ExecuteMUL()

UINT64 ExecuteMUL ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 * Op2

Definition at line 3660 of file EbcExecute.c.

◆ ExecuteMULU()

UINT64 ExecuteMULU ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
(unsigned)Op1 * (unsigned)Op2

Definition at line 3687 of file EbcExecute.c.

◆ ExecuteNEG()

UINT64 ExecuteNEG ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op2 * -1

Definition at line 3587 of file EbcExecute.c.

◆ ExecuteNOT()

UINT64 ExecuteNOT ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
~Op2

Definition at line 3564 of file EbcExecute.c.

◆ ExecuteOR()

UINT64 ExecuteOR ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 OR Op2

Definition at line 3899 of file EbcExecute.c.

◆ ExecutePOP()

EFI_STATUS ExecutePOP ( IN VM_CONTEXT VmPtr)

R1 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2911 of file EbcExecute.c.

◆ ExecutePOPn()

EFI_STATUS ExecutePOPn ( IN VM_CONTEXT VmPtr)

R1 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2852 of file EbcExecute.c.

◆ ExecutePUSH()

EFI_STATUS ExecutePUSH ( IN VM_CONTEXT VmPtr)

R1 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2774 of file EbcExecute.c.

◆ ExecutePUSHn()

EFI_STATUS ExecutePUSHn ( IN VM_CONTEXT VmPtr)

R1 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 2714 of file EbcExecute.c.

◆ ExecuteRET()

EFI_STATUS ExecuteRET ( IN VM_CONTEXT VmPtr)

Execute the EBC RET instruction.

Instruction syntax: RET

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 3144 of file EbcExecute.c.

◆ ExecuteSHL()

UINT64 ExecuteSHL ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 << Op2

Definition at line 3945 of file EbcExecute.c.

◆ ExecuteSHR()

UINT64 ExecuteSHR ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 >> Op2 (unsigned operands)

Definition at line 3972 of file EbcExecute.c.

◆ ExecuteSignedDataManip()

EFI_STATUS ExecuteSignedDataManip ( IN VM_CONTEXT VmPtr)

R2 {Immed16|Index16}

Parameters
VmPtrA pointer to VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 4138 of file EbcExecute.c.

◆ ExecuteSTORESP()

EFI_STATUS ExecuteSTORESP ( IN VM_CONTEXT VmPtr)

Execute the EBC STORESP instruction.

Instruction syntax: STORESP Rx, FLAGS|IP

Parameters
VmPtrA pointer to a VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 4405 of file EbcExecute.c.

◆ ExecuteSUB()

UINT64 ExecuteSUB ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 - Op2

Definition at line 3633 of file EbcExecute.c.

◆ ExecuteUnsignedDataManip()

EFI_STATUS ExecuteUnsignedDataManip ( IN VM_CONTEXT VmPtr)

R2 {Immed16|Index16}

Parameters
VmPtrA pointer to VM context.
Return values
EFI_UNSUPPORTEDThe opcodes/operands is not supported.
EFI_SUCCESSThe instruction is executed successfully.

Definition at line 4167 of file EbcExecute.c.

◆ ExecuteXOR()

UINT64 ExecuteXOR ( IN VM_CONTEXT VmPtr,
IN UINT64  Op1,
IN UINT64  Op2 
)

R2 {Index16|Immed16}

Parameters
VmPtrA pointer to a VM context.
Op1Operand 1 from the instruction
Op2Operand 2 from the instruction
Returns
Op1 XOR Op2

Definition at line 3922 of file EbcExecute.c.

◆ GetVmVersion()

UINT64 GetVmVersion ( VOID  )

Returns the version of the EBC virtual machine.

Returns
The 64-bit version of EBC virtual machine.

Definition at line 5418 of file EbcExecute.c.

◆ VmReadCode16()

UINT16 VmReadCode16 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 16-bit unsigned data from the code stream.

This routine provides the ability to read raw unsigned data from the code stream.

Parameters
VmPtrA pointer to VM context
OffsetOffset from current IP to the raw data to read.
Returns
The raw unsigned 16-bit value from the code stream.

Definition at line 5100 of file EbcExecute.c.

◆ VmReadCode32()

UINT32 VmReadCode32 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 32-bit unsigned data from the code stream.

This routine provides the ability to read raw unsigned data from the code stream.

Parameters
VmPtrA pointer to VM context
OffsetOffset from current IP to the raw data to read.
Returns
The raw unsigned 32-bit value from the code stream.

Definition at line 5140 of file EbcExecute.c.

◆ VmReadCode64()

UINT64 VmReadCode64 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 64-bit unsigned data from the code stream.

This routine provides the ability to read raw unsigned data from the code stream.

Parameters
VmPtrA pointer to VM context
OffsetOffset from current IP to the raw data to read.
Returns
The raw unsigned 64-bit value from the code stream.

Definition at line 5175 of file EbcExecute.c.

◆ VmReadImmed16()

INT16 VmReadImmed16 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 16-bit immediate value at the offset.

This routine is called by the EBC execute functions to read EBC immediate values from the code stream. Since we can't assume alignment, each tries to read in the biggest chunks size available, but will revert to smaller reads if necessary.

Parameters
VmPtrA pointer to a VM context.
Offsetoffset from IP of the code bytes to read.
Returns
Signed data of the requested size from the specified address.

Definition at line 4980 of file EbcExecute.c.

◆ VmReadImmed32()

INT32 VmReadImmed32 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 32-bit immediate value at the offset.

This routine is called by the EBC execute functions to read EBC immediate values from the code stream. Since we can't assume alignment, each tries to read in the biggest chunks size available, but will revert to smaller reads if necessary.

Parameters
VmPtrA pointer to a VM context.
Offsetoffset from IP of the code bytes to read.
Returns
Signed data of the requested size from the specified address.

Definition at line 5022 of file EbcExecute.c.

◆ VmReadImmed64()

INT64 VmReadImmed64 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 64-bit immediate value at the offset.

This routine is called by the EBC execute functions to read EBC immediate values from the code stream. Since we can't assume alignment, each tries to read in the biggest chunks size available, but will revert to smaller reads if necessary.

Parameters
VmPtrA pointer to a VM context.
Offsetoffset from IP of the code bytes to read.
Returns
Signed data of the requested size from the specified address.

Definition at line 5059 of file EbcExecute.c.

◆ VmReadImmed8()

INT8 VmReadImmed8 ( IN VM_CONTEXT VmPtr,
IN UINT32  Offset 
)

Reads 8-bit immediate value at the offset.

This routine is called by the EBC execute functions to read EBC immediate values from the code stream. Since we can't assume alignment, each tries to read in the biggest chunks size available, but will revert to smaller reads if necessary.

Parameters
VmPtrA pointer to a VM context.
Offsetoffset from IP of the code bytes to read.
Returns
Signed data of the requested size from the specified address.

Definition at line 4954 of file EbcExecute.c.

◆ VmReadIndex16()

INT16 VmReadIndex16 ( IN VM_CONTEXT VmPtr,
IN UINT32  CodeOffset 
)

Decode a 16-bit index to determine the offset. Given an index value:

b15 - sign bit b14:12 - number of bits in this index assigned to natural units (=a) ba:11 - constant units = ConstUnits b0:a - natural units = NaturalUnits

Given this info, the offset can be computed by: offset = sign_bit * (ConstUnits + NaturalUnits * sizeof(UINTN))

Max offset is achieved with index = 0x7FFF giving an offset of 0x27B (32-bit machine) or 0x477 (64-bit machine). Min offset is achieved with index =

Parameters
VmPtrA pointer to VM context.
CodeOffsetOffset from IP of the location of the 16-bit index to decode.
Returns
The decoded offset.

Definition at line 4475 of file EbcExecute.c.

◆ VmReadIndex32()

INT32 VmReadIndex32 ( IN VM_CONTEXT VmPtr,
IN UINT32  CodeOffset 
)

Decode a 32-bit index to determine the offset.

Parameters
VmPtrA pointer to VM context.
CodeOffsetOffset from IP of the location of the 32-bit index to decode.
Returns
Converted index per EBC VM specification.

Definition at line 4545 of file EbcExecute.c.

◆ VmReadIndex64()

INT64 VmReadIndex64 ( IN VM_CONTEXT VmPtr,
IN UINT32  CodeOffset 
)

Decode a 64-bit index to determine the offset.

Parameters
VmPtrA pointer to VM context.s
CodeOffsetOffset from IP of the location of the 64-bit index to decode.
Returns
Converted index per EBC VM specification

Definition at line 4607 of file EbcExecute.c.

◆ VmReadMem16()

UINT16 VmReadMem16 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr 
)

Reads 16-bit data form the memory address.

Parameters
VmPtrA pointer to VM context.
AddrThe memory address.
Returns
The 16-bit value from the memory address.

Definition at line 5238 of file EbcExecute.c.

◆ VmReadMem32()

UINT32 VmReadMem32 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr 
)

Reads 32-bit data form the memory address.

Parameters
VmPtrA pointer to VM context.
AddrThe memory address.
Returns
The 32-bit value from the memory address.

Definition at line 5270 of file EbcExecute.c.

◆ VmReadMem64()

UINT64 VmReadMem64 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr 
)

Reads 64-bit data form the memory address.

Parameters
VmPtrA pointer to VM context.
AddrThe memory address.
Returns
The 64-bit value from the memory address.

Definition at line 5306 of file EbcExecute.c.

◆ VmReadMem8()

UINT8 VmReadMem8 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr 
)

Reads 8-bit data form the memory address.

Parameters
VmPtrA pointer to VM context.
AddrThe memory address.
Returns
The 8-bit value from the memory address.

Definition at line 5213 of file EbcExecute.c.

◆ VmReadMemN()

UINTN VmReadMemN ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr 
)

Read a natural value from memory. May or may not be aligned.

Parameters
VmPtrcurrent VM context
Addrthe address to read from
Returns
The natural value at address Addr.

Definition at line 5374 of file EbcExecute.c.

◆ VmWriteMem16()

EFI_STATUS VmWriteMem16 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr,
IN UINT16  Data 
)

Writes 16-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.

Parameters
VmPtrA pointer to a VM context.
AddrAddress to write to.
DataValue to write to Addr.
Return values
EFI_SUCCESSThe instruction is executed successfully.
OtherSome error occurs when writing data to the address.

Definition at line 4720 of file EbcExecute.c.

◆ VmWriteMem32()

EFI_STATUS VmWriteMem32 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr,
IN UINT32  Data 
)

Writes 32-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.

Parameters
VmPtrA pointer to a VM context.
AddrAddress to write to.
DataValue to write to Addr.
Return values
EFI_SUCCESSThe instruction is executed successfully.
OtherSome error occurs when writing data to the address.

Definition at line 4782 of file EbcExecute.c.

◆ VmWriteMem64()

EFI_STATUS VmWriteMem64 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr,
IN UINT64  Data 
)

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.

Parameters
VmPtrA pointer to a VM context.
AddrAddress to write to.
DataValue to write to Addr.
Return values
EFI_SUCCESSThe instruction is executed successfully.
OtherSome error occurs when writing data to the address.

Definition at line 4844 of file EbcExecute.c.

◆ VmWriteMem8()

EFI_STATUS VmWriteMem8 ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr,
IN UINT8  Data 
)

Writes 8-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.

Parameters
VmPtrA pointer to a VM context.
AddrAddress to write to.
DataValue to write to Addr.
Return values
EFI_SUCCESSThe instruction is executed successfully.
OtherSome error occurs when writing data to the address.

Definition at line 4682 of file EbcExecute.c.

◆ VmWriteMemN()

EFI_STATUS VmWriteMemN ( IN VM_CONTEXT VmPtr,
IN UINTN  Addr,
IN UINTN  Data 
)

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.

Parameters
VmPtrA pointer to a VM context.
AddrAddress to write to.
DataValue to write to Addr.
Return values
EFI_SUCCESSThe instruction is executed successfully.
OtherSome error occurs when writing data to the address.

Definition at line 4906 of file EbcExecute.c.

Variable Documentation

◆ mDataManipDispatchTable

CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[]
Initial value:
= {
}
UINT64 ExecuteDIV(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3714
UINT64 ExecuteMULU(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3687
UINT64 ExecuteMODU(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3838
UINT64 ExecuteEXTNDD(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:4101
UINT64 ExecuteSHR(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3972
UINT64 ExecuteXOR(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3922
UINT64 ExecuteADD(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3610
UINT64 ExecuteDIVU(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3756
UINT64 ExecuteSUB(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3633
UINT64 ExecuteOR(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3899
UINT64 ExecuteASHR(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3999
UINT64 ExecuteEXTNDB(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:4026
UINT64 ExecuteMUL(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3660
UINT64 ExecuteAND(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3876
UINT64 ExecuteMOD(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3800
UINT64 ExecuteNOT(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3564
UINT64 ExecuteSHL(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3945
UINT64 ExecuteEXTNDW(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:4059
UINT64 ExecuteNEG(IN VM_CONTEXT *VmPtr, IN UINT64 Op1, IN UINT64 Op2)
Definition: EbcExecute.c:3587

Definition at line 1250 of file EbcExecute.c.

◆ mJMPLen

CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 }

Definition at line 1342 of file EbcExecute.c.

◆ mVmOpcodeTable

CONST VM_TABLE_ENTRY mVmOpcodeTable[]

Definition at line 1272 of file EbcExecute.c.