summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/EbcDxe/EbcExecute.c')
-rw-r--r--MdeModulePkg/Universal/EbcDxe/EbcExecute.c1960
1 files changed, 1000 insertions, 960 deletions
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
index 1c4a4f5155..82a7782fb9 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
@@ -10,31 +10,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "EbcExecute.h"
#include "EbcDebuggerHook.h"
-
//
// Define some useful data size constants to allow switch statements based on
// size of operands or data.
//
-#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 // 4 or 8
+#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 // 4 or 8
//
// Structure we'll use to dispatch opcodes to execute functions.
//
typedef struct {
- EFI_STATUS (*ExecuteFunction) (IN VM_CONTEXT * VmPtr);
-}
-VM_TABLE_ENTRY;
+ EFI_STATUS (*ExecuteFunction)(
+ IN VM_CONTEXT *VmPtr
+ );
+} VM_TABLE_ENTRY;
typedef
UINT64
(*DATA_MANIP_EXEC_FUNCTION) (
- IN VM_CONTEXT * VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -61,8 +61,8 @@ UINT64
**/
INT16
VmReadIndex16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
);
/**
@@ -77,8 +77,8 @@ VmReadIndex16 (
**/
INT32
VmReadIndex32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
);
/**
@@ -93,8 +93,8 @@ VmReadIndex32 (
**/
INT64
VmReadIndex64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
);
/**
@@ -108,8 +108,8 @@ VmReadIndex64 (
**/
UINT8
VmReadMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -123,8 +123,8 @@ VmReadMem8 (
**/
UINT16
VmReadMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -138,8 +138,8 @@ VmReadMem16 (
**/
UINT32
VmReadMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -153,8 +153,8 @@ VmReadMem32 (
**/
UINT64
VmReadMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -168,8 +168,8 @@ VmReadMem64 (
**/
UINTN
VmReadMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -197,9 +197,9 @@ VmReadMemN (
**/
EFI_STATUS
VmWriteMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT8 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT8 Data
);
/**
@@ -227,9 +227,9 @@ VmWriteMem8 (
**/
EFI_STATUS
VmWriteMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT16 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT16 Data
);
/**
@@ -257,9 +257,9 @@ VmWriteMem16 (
**/
EFI_STATUS
VmWriteMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT32 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT32 Data
);
/**
@@ -276,8 +276,8 @@ VmWriteMem32 (
**/
UINT16
VmReadCode16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -294,8 +294,8 @@ VmReadCode16 (
**/
UINT32
VmReadCode32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -312,8 +312,8 @@ VmReadCode32 (
**/
UINT64
VmReadCode64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -332,8 +332,8 @@ VmReadCode64 (
**/
INT8
VmReadImmed8 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -352,8 +352,8 @@ VmReadImmed8 (
**/
INT16
VmReadImmed16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -372,8 +372,8 @@ VmReadImmed16 (
**/
INT32
VmReadImmed32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -392,8 +392,8 @@ VmReadImmed32 (
**/
INT64
VmReadImmed64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -417,8 +417,8 @@ VmReadImmed64 (
**/
UINTN
ConvertStackAddr (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -441,13 +441,14 @@ ConvertStackAddr (
**/
EFI_STATUS
ExecuteDataManip (
- IN VM_CONTEXT *VmPtr,
- IN BOOLEAN IsSignedOp
+ IN VM_CONTEXT *VmPtr,
+ IN BOOLEAN IsSignedOp
);
//
// Functions that execute VM opcodes
//
+
/**
Execute the EBC BREAK instruction.
@@ -458,7 +459,7 @@ ExecuteDataManip (
**/
EFI_STATUS
ExecuteBREAK (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -488,7 +489,7 @@ ExecuteBREAK (
**/
EFI_STATUS
ExecuteJMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -504,7 +505,7 @@ ExecuteJMP (
**/
EFI_STATUS
ExecuteJMP8 (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -525,7 +526,7 @@ ExecuteJMP8 (
**/
EFI_STATUS
ExecuteCALL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -541,7 +542,7 @@ ExecuteCALL (
**/
EFI_STATUS
ExecuteRET (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -558,7 +559,7 @@ ExecuteRET (
**/
EFI_STATUS
ExecuteCMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -575,7 +576,7 @@ ExecuteCMP (
**/
EFI_STATUS
ExecuteCMPI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -601,7 +602,7 @@ ExecuteCMPI (
**/
EFI_STATUS
ExecuteMOVxx (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -627,7 +628,7 @@ ExecuteMOVxx (
**/
EFI_STATUS
ExecuteMOVI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -646,7 +647,7 @@ ExecuteMOVI (
**/
EFI_STATUS
ExecuteMOVIn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -665,7 +666,7 @@ ExecuteMOVIn (
**/
EFI_STATUS
ExecuteMOVREL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -681,7 +682,7 @@ ExecuteMOVREL (
**/
EFI_STATUS
ExecutePUSHn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -697,7 +698,7 @@ ExecutePUSHn (
**/
EFI_STATUS
ExecutePUSH (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -713,7 +714,7 @@ ExecutePUSH (
**/
EFI_STATUS
ExecutePOPn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -729,7 +730,7 @@ ExecutePOPn (
**/
EFI_STATUS
ExecutePOP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -751,7 +752,7 @@ ExecutePOP (
**/
EFI_STATUS
ExecuteSignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -773,7 +774,7 @@ ExecuteSignedDataManip (
**/
EFI_STATUS
ExecuteUnsignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -790,7 +791,7 @@ ExecuteUnsignedDataManip (
**/
EFI_STATUS
ExecuteLOADSP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -807,7 +808,7 @@ ExecuteLOADSP (
**/
EFI_STATUS
ExecuteSTORESP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -831,7 +832,7 @@ ExecuteSTORESP (
**/
EFI_STATUS
ExecuteMOVsnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -855,12 +856,13 @@ ExecuteMOVsnd (
**/
EFI_STATUS
ExecuteMOVsnw (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
//
// Data manipulation subfunctions
//
+
/**
Execute the EBC NOT instruction.s
@@ -876,9 +878,9 @@ ExecuteMOVsnw (
**/
UINT64
ExecuteNOT (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -896,9 +898,9 @@ ExecuteNOT (
**/
UINT64
ExecuteNEG (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -916,9 +918,9 @@ ExecuteNEG (
**/
UINT64
ExecuteADD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -936,9 +938,9 @@ ExecuteADD (
**/
UINT64
ExecuteSUB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -956,9 +958,9 @@ ExecuteSUB (
**/
UINT64
ExecuteMUL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -976,9 +978,9 @@ ExecuteMUL (
**/
UINT64
ExecuteMULU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -996,9 +998,9 @@ ExecuteMULU (
**/
UINT64
ExecuteDIV (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1016,9 +1018,9 @@ ExecuteDIV (
**/
UINT64
ExecuteDIVU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1036,9 +1038,9 @@ ExecuteDIVU (
**/
UINT64
ExecuteMOD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1056,9 +1058,9 @@ ExecuteMOD (
**/
UINT64
ExecuteMODU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1076,9 +1078,9 @@ ExecuteMODU (
**/
UINT64
ExecuteAND (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1096,9 +1098,9 @@ ExecuteAND (
**/
UINT64
ExecuteOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1116,9 +1118,9 @@ ExecuteOR (
**/
UINT64
ExecuteXOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1136,9 +1138,9 @@ ExecuteXOR (
**/
UINT64
ExecuteSHL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1156,9 +1158,9 @@ ExecuteSHL (
**/
UINT64
ExecuteSHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1176,9 +1178,9 @@ ExecuteSHR (
**/
UINT64
ExecuteASHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1196,9 +1198,9 @@ ExecuteASHR (
**/
UINT64
ExecuteEXTNDB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1216,9 +1218,9 @@ ExecuteEXTNDB (
**/
UINT64
ExecuteEXTNDW (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1236,16 +1238,16 @@ ExecuteEXTNDW (
**/
UINT64
ExecuteEXTNDD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
//
// Once we retrieve the operands for the data manipulation instructions,
// call these functions to perform the operation.
//
-CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {
+CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {
ExecuteNOT,
ExecuteNEG,
ExecuteADD,
@@ -1267,77 +1269,77 @@ CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {
ExecuteEXTNDD,
};
-CONST VM_TABLE_ENTRY mVmOpcodeTable[] = {
- { ExecuteBREAK }, // opcode 0x00
- { ExecuteJMP }, // opcode 0x01
- { ExecuteJMP8 }, // opcode 0x02
- { ExecuteCALL }, // opcode 0x03
- { ExecuteRET }, // opcode 0x04
- { ExecuteCMP }, // opcode 0x05 CMPeq
- { ExecuteCMP }, // opcode 0x06 CMPlte
- { ExecuteCMP }, // opcode 0x07 CMPgte
- { ExecuteCMP }, // opcode 0x08 CMPulte
- { ExecuteCMP }, // opcode 0x09 CMPugte
+CONST VM_TABLE_ENTRY mVmOpcodeTable[] = {
+ { ExecuteBREAK }, // opcode 0x00
+ { ExecuteJMP }, // opcode 0x01
+ { ExecuteJMP8 }, // opcode 0x02
+ { ExecuteCALL }, // opcode 0x03
+ { ExecuteRET }, // opcode 0x04
+ { ExecuteCMP }, // opcode 0x05 CMPeq
+ { ExecuteCMP }, // opcode 0x06 CMPlte
+ { ExecuteCMP }, // opcode 0x07 CMPgte
+ { ExecuteCMP }, // opcode 0x08 CMPulte
+ { ExecuteCMP }, // opcode 0x09 CMPugte
{ ExecuteUnsignedDataManip }, // opcode 0x0A NOT
- { ExecuteSignedDataManip }, // opcode 0x0B NEG
- { ExecuteSignedDataManip }, // opcode 0x0C ADD
- { ExecuteSignedDataManip }, // opcode 0x0D SUB
- { ExecuteSignedDataManip }, // opcode 0x0E MUL
+ { ExecuteSignedDataManip }, // opcode 0x0B NEG
+ { ExecuteSignedDataManip }, // opcode 0x0C ADD
+ { ExecuteSignedDataManip }, // opcode 0x0D SUB
+ { ExecuteSignedDataManip }, // opcode 0x0E MUL
{ ExecuteUnsignedDataManip }, // opcode 0x0F MULU
- { ExecuteSignedDataManip }, // opcode 0x10 DIV
+ { ExecuteSignedDataManip }, // opcode 0x10 DIV
{ ExecuteUnsignedDataManip }, // opcode 0x11 DIVU
- { ExecuteSignedDataManip }, // opcode 0x12 MOD
+ { ExecuteSignedDataManip }, // opcode 0x12 MOD
{ ExecuteUnsignedDataManip }, // opcode 0x13 MODU
{ ExecuteUnsignedDataManip }, // opcode 0x14 AND
{ ExecuteUnsignedDataManip }, // opcode 0x15 OR
{ ExecuteUnsignedDataManip }, // opcode 0x16 XOR
{ ExecuteUnsignedDataManip }, // opcode 0x17 SHL
{ ExecuteUnsignedDataManip }, // opcode 0x18 SHR
- { ExecuteSignedDataManip }, // opcode 0x19 ASHR
+ { ExecuteSignedDataManip }, // opcode 0x19 ASHR
{ ExecuteUnsignedDataManip }, // opcode 0x1A EXTNDB
{ ExecuteUnsignedDataManip }, // opcode 0x1B EXTNDW
{ ExecuteUnsignedDataManip }, // opcode 0x1C EXTNDD
- { ExecuteMOVxx }, // opcode 0x1D MOVBW
- { ExecuteMOVxx }, // opcode 0x1E MOVWW
- { ExecuteMOVxx }, // opcode 0x1F MOVDW
- { ExecuteMOVxx }, // opcode 0x20 MOVQW
- { ExecuteMOVxx }, // opcode 0x21 MOVBD
- { ExecuteMOVxx }, // opcode 0x22 MOVWD
- { ExecuteMOVxx }, // opcode 0x23 MOVDD
- { ExecuteMOVxx }, // opcode 0x24 MOVQD
- { ExecuteMOVsnw }, // opcode 0x25 MOVsnw
- { ExecuteMOVsnd }, // opcode 0x26 MOVsnd
- { NULL }, // opcode 0x27
- { ExecuteMOVxx }, // opcode 0x28 MOVqq
- { ExecuteLOADSP }, // opcode 0x29 LOADSP SP1, R2
- { ExecuteSTORESP }, // opcode 0x2A STORESP R1, SP2
- { ExecutePUSH }, // opcode 0x2B PUSH {@}R1 [imm16]
- { ExecutePOP }, // opcode 0x2C POP {@}R1 [imm16]
- { ExecuteCMPI }, // opcode 0x2D CMPIEQ
- { ExecuteCMPI }, // opcode 0x2E CMPILTE
- { ExecuteCMPI }, // opcode 0x2F CMPIGTE
- { ExecuteCMPI }, // opcode 0x30 CMPIULTE
- { ExecuteCMPI }, // opcode 0x31 CMPIUGTE
- { ExecuteMOVxx }, // opcode 0x32 MOVN
- { ExecuteMOVxx }, // opcode 0x33 MOVND
- { NULL }, // opcode 0x34
- { ExecutePUSHn }, // opcode 0x35
- { ExecutePOPn }, // opcode 0x36
- { ExecuteMOVI }, // opcode 0x37 - mov immediate data
- { ExecuteMOVIn }, // opcode 0x38 - mov immediate natural
- { ExecuteMOVREL }, // opcode 0x39 - move data relative to PC
- { NULL }, // opcode 0x3a
- { NULL }, // opcode 0x3b
- { NULL }, // opcode 0x3c
- { NULL }, // opcode 0x3d
- { NULL }, // opcode 0x3e
- { NULL } // opcode 0x3f
+ { ExecuteMOVxx }, // opcode 0x1D MOVBW
+ { ExecuteMOVxx }, // opcode 0x1E MOVWW
+ { ExecuteMOVxx }, // opcode 0x1F MOVDW
+ { ExecuteMOVxx }, // opcode 0x20 MOVQW
+ { ExecuteMOVxx }, // opcode 0x21 MOVBD
+ { ExecuteMOVxx }, // opcode 0x22 MOVWD
+ { ExecuteMOVxx }, // opcode 0x23 MOVDD
+ { ExecuteMOVxx }, // opcode 0x24 MOVQD
+ { ExecuteMOVsnw }, // opcode 0x25 MOVsnw
+ { ExecuteMOVsnd }, // opcode 0x26 MOVsnd
+ { NULL }, // opcode 0x27
+ { ExecuteMOVxx }, // opcode 0x28 MOVqq
+ { ExecuteLOADSP }, // opcode 0x29 LOADSP SP1, R2
+ { ExecuteSTORESP }, // opcode 0x2A STORESP R1, SP2
+ { ExecutePUSH }, // opcode 0x2B PUSH {@}R1 [imm16]
+ { ExecutePOP }, // opcode 0x2C POP {@}R1 [imm16]
+ { ExecuteCMPI }, // opcode 0x2D CMPIEQ
+ { ExecuteCMPI }, // opcode 0x2E CMPILTE
+ { ExecuteCMPI }, // opcode 0x2F CMPIGTE
+ { ExecuteCMPI }, // opcode 0x30 CMPIULTE
+ { ExecuteCMPI }, // opcode 0x31 CMPIUGTE
+ { ExecuteMOVxx }, // opcode 0x32 MOVN
+ { ExecuteMOVxx }, // opcode 0x33 MOVND
+ { NULL }, // opcode 0x34
+ { ExecutePUSHn }, // opcode 0x35
+ { ExecutePOPn }, // opcode 0x36
+ { ExecuteMOVI }, // opcode 0x37 - mov immediate data
+ { ExecuteMOVIn }, // opcode 0x38 - mov immediate natural
+ { ExecuteMOVREL }, // opcode 0x39 - move data relative to PC
+ { NULL }, // opcode 0x3a
+ { NULL }, // opcode 0x3b
+ { NULL }, // opcode 0x3c
+ { NULL }, // opcode 0x3d
+ { NULL }, // opcode 0x3e
+ { NULL } // opcode 0x3f
};
//
// Length of JMP instructions, depending on upper two bits of opcode.
//
-CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 };
+CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 };
/**
Given a pointer to a new VM context, execute one or more instructions. This
@@ -1356,9 +1358,9 @@ CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 };
EFI_STATUS
EFIAPI
EbcExecuteInstructions (
- IN EFI_EBC_VM_TEST_PROTOCOL *This,
- IN VM_CONTEXT *VmPtr,
- IN OUT UINTN *InstructionCount
+ IN EFI_EBC_VM_TEST_PROTOCOL *This,
+ IN VM_CONTEXT *VmPtr,
+ IN OUT UINTN *InstructionCount
)
{
UINTN ExecFunc;
@@ -1383,8 +1385,8 @@ EbcExecuteInstructions (
// call it if it's not null.
//
while (InstructionsLeft != 0) {
- ExecFunc = (UINTN) mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
- if (ExecFunc == (UINTN) NULL) {
+ ExecFunc = (UINTN)mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
+ if (ExecFunc == (UINTN)NULL) {
EbcDebugSignalException (EXCEPT_EBC_INVALID_OPCODE, EXCEPTION_FLAG_FATAL, VmPtr);
return EFI_UNSUPPORTED;
} else {
@@ -1403,7 +1405,6 @@ EbcExecuteInstructions (
return Status;
}
-
/**
Execute an EBC image from an entry point or from a published protocol.
@@ -1415,7 +1416,7 @@ EbcExecuteInstructions (
**/
EFI_STATUS
EbcExecute (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINTN ExecFunc;
@@ -1431,24 +1432,25 @@ EbcExecute (
//
// Make sure the magic value has been put on the stack before we got here.
//
- if (*VmPtr->StackMagicPtr != (UINTN) VM_STACK_KEY_VALUE) {
+ if (*VmPtr->StackMagicPtr != (UINTN)VM_STACK_KEY_VALUE) {
StackCorrupted = 1;
}
- VmPtr->FramePtr = (VOID *) ((UINT8 *) (UINTN) VmPtr->Gpr[0] + 8);
+ VmPtr->FramePtr = (VOID *)((UINT8 *)(UINTN)VmPtr->Gpr[0] + 8);
//
// Try to get the debug support for EBC
//
DEBUG_CODE_BEGIN ();
- Status = gBS->LocateProtocol (
- &gEfiEbcSimpleDebuggerProtocolGuid,
- NULL,
- (VOID **) &EbcSimpleDebugger
- );
- if (EFI_ERROR (Status)) {
- EbcSimpleDebugger = NULL;
- }
+ Status = gBS->LocateProtocol (
+ &gEfiEbcSimpleDebuggerProtocolGuid,
+ NULL,
+ (VOID **)&EbcSimpleDebugger
+ );
+ if (EFI_ERROR (Status)) {
+ EbcSimpleDebugger = NULL;
+ }
+
DEBUG_CODE_END ();
//
@@ -1456,7 +1458,7 @@ EbcExecute (
// can print out the location of the exception relative to the entry point,
// which could then be used in a disassembly listing to find the problem.
//
- VmPtr->EntryPoint = (VOID *) VmPtr->Ip;
+ VmPtr->EntryPoint = (VOID *)VmPtr->Ip;
//
// We'll wait for this flag to know when we're done. The RET
@@ -1468,17 +1470,18 @@ EbcExecute (
// If we've found a simple debugger protocol, call it
//
DEBUG_CODE_BEGIN ();
- if (EbcSimpleDebugger != NULL) {
- EbcSimpleDebugger->Debugger (EbcSimpleDebugger, VmPtr);
- }
+ if (EbcSimpleDebugger != NULL) {
+ EbcSimpleDebugger->Debugger (EbcSimpleDebugger, VmPtr);
+ }
+
DEBUG_CODE_END ();
//
// Use the opcode bits to index into the opcode dispatch table. If the
// function pointer is null then generate an exception.
//
- ExecFunc = (UINTN) mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
- if (ExecFunc == (UINTN) NULL) {
+ ExecFunc = (UINTN)mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
+ if (ExecFunc == (UINTN)NULL) {
EbcDebugSignalException (EXCEPT_EBC_INVALID_OPCODE, EXCEPTION_FLAG_FATAL, VmPtr);
Status = EFI_UNSUPPORTED;
goto Done;
@@ -1505,26 +1508,27 @@ EbcExecute (
if (VMFLAG_ISSET (VmPtr, VMFLAGS_STEP)) {
EbcDebugSignalException (EXCEPT_EBC_STEP, EXCEPTION_FLAG_NONE, VmPtr);
}
+
//
// Make sure stack has not been corrupted. Only report it once though.
//
- if ((StackCorrupted == 0) && (*VmPtr->StackMagicPtr != (UINTN) VM_STACK_KEY_VALUE)) {
+ if ((StackCorrupted == 0) && (*VmPtr->StackMagicPtr != (UINTN)VM_STACK_KEY_VALUE)) {
EbcDebugSignalException (EXCEPT_EBC_STACK_FAULT, EXCEPTION_FLAG_FATAL, VmPtr);
StackCorrupted = 1;
}
- if ((StackCorrupted == 0) && ((UINT64)VmPtr->Gpr[0] <= (UINT64)(UINTN) VmPtr->StackTop)) {
+
+ if ((StackCorrupted == 0) && ((UINT64)VmPtr->Gpr[0] <= (UINT64)(UINTN)VmPtr->StackTop)) {
EbcDebugSignalException (EXCEPT_EBC_STACK_FAULT, EXCEPTION_FLAG_FATAL, VmPtr);
StackCorrupted = 1;
}
}
Done:
- mVmPtr = NULL;
+ mVmPtr = NULL;
return Status;
}
-
/**
Execute the MOVxx instructions.
@@ -1548,7 +1552,7 @@ Done:
**/
EFI_STATUS
ExecuteMOVxx (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -1565,7 +1569,7 @@ ExecuteMOVxx (
UINTN Source;
Opcode = GETOPCODE (VmPtr);
- OpcMasked = (UINT8) (Opcode & OPCODE_M_OPCODE);
+ OpcMasked = (UINT8)(Opcode & OPCODE_M_OPCODE);
//
// Get the operands byte so we can get R1 and R2
@@ -1575,9 +1579,9 @@ ExecuteMOVxx (
//
// Assume no indexes
//
- Index64Op1 = 0;
- Index64Op2 = 0;
- Data64 = 0;
+ Index64Op1 = 0;
+ Index64Op2 = 0;
+ Data64 = 0;
//
// Determine if we have an index/immediate data. Base instruction size
@@ -1594,30 +1598,30 @@ ExecuteMOVxx (
// Get one or both index values.
//
if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
- Index16 = VmReadIndex16 (VmPtr, 2);
- Index64Op1 = (INT64) Index16;
- Size += sizeof (UINT16);
+ Index16 = VmReadIndex16 (VmPtr, 2);
+ Index64Op1 = (INT64)Index16;
+ Size += sizeof (UINT16);
}
if ((Opcode & OPCODE_M_IMMED_OP2) != 0) {
- Index16 = VmReadIndex16 (VmPtr, Size);
- Index64Op2 = (INT64) Index16;
- Size += sizeof (UINT16);
+ Index16 = VmReadIndex16 (VmPtr, Size);
+ Index64Op2 = (INT64)Index16;
+ Size += sizeof (UINT16);
}
} else if ((OpcMasked <= OPCODE_MOVQD) || (OpcMasked == OPCODE_MOVND)) {
//
// MOVBD, MOVWD, MOVDD, MOVQD, and MOVND have 32-bit immediate index
//
if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
- Index32 = VmReadIndex32 (VmPtr, 2);
- Index64Op1 = (INT64) Index32;
- Size += sizeof (UINT32);
+ Index32 = VmReadIndex32 (VmPtr, 2);
+ Index64Op1 = (INT64)Index32;
+ Size += sizeof (UINT32);
}
if ((Opcode & OPCODE_M_IMMED_OP2) != 0) {
- Index32 = VmReadIndex32 (VmPtr, Size);
- Index64Op2 = (INT64) Index32;
- Size += sizeof (UINT32);
+ Index32 = VmReadIndex32 (VmPtr, Size);
+ Index64Op2 = (INT64)Index32;
+ Size += sizeof (UINT32);
}
} else if (OpcMasked == OPCODE_MOVQQ) {
//
@@ -1625,12 +1629,12 @@ ExecuteMOVxx (
//
if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
Index64Op1 = VmReadIndex64 (VmPtr, 2);
- Size += sizeof (UINT64);
+ Size += sizeof (UINT64);
}
if ((Opcode & OPCODE_M_IMMED_OP2) != 0) {
Index64Op2 = VmReadIndex64 (VmPtr, Size);
- Size += sizeof (UINT64);
+ Size += sizeof (UINT64);
}
} else {
//
@@ -1644,25 +1648,26 @@ ExecuteMOVxx (
return EFI_UNSUPPORTED;
}
}
+
//
// Determine the size of the move, and create a mask for it so we can
// clear unused bits.
//
if ((OpcMasked == OPCODE_MOVBW) || (OpcMasked == OPCODE_MOVBD)) {
- MoveSize = DATA_SIZE_8;
- DataMask = 0xFF;
+ MoveSize = DATA_SIZE_8;
+ DataMask = 0xFF;
} else if ((OpcMasked == OPCODE_MOVWW) || (OpcMasked == OPCODE_MOVWD)) {
- MoveSize = DATA_SIZE_16;
- DataMask = 0xFFFF;
+ MoveSize = DATA_SIZE_16;
+ DataMask = 0xFFFF;
} else if ((OpcMasked == OPCODE_MOVDW) || (OpcMasked == OPCODE_MOVDD)) {
- MoveSize = DATA_SIZE_32;
- DataMask = 0xFFFFFFFF;
+ MoveSize = DATA_SIZE_32;
+ DataMask = 0xFFFFFFFF;
} else if ((OpcMasked == OPCODE_MOVQW) || (OpcMasked == OPCODE_MOVQD) || (OpcMasked == OPCODE_MOVQQ)) {
- MoveSize = DATA_SIZE_64;
- DataMask = (UINT64)~0;
+ MoveSize = DATA_SIZE_64;
+ DataMask = (UINT64) ~0;
} else if ((OpcMasked == OPCODE_MOVNW) || (OpcMasked == OPCODE_MOVND)) {
- MoveSize = DATA_SIZE_N;
- DataMask = (UINT64)~0 >> (64 - 8 * sizeof (UINTN));
+ MoveSize = DATA_SIZE_N;
+ DataMask = (UINT64) ~0 >> (64 - 8 * sizeof (UINTN));
} else {
//
// We were dispatched to this function and we don't recognize the opcode
@@ -1670,6 +1675,7 @@ ExecuteMOVxx (
EbcDebugSignalException (EXCEPT_EBC_UNDEFINED, EXCEPTION_FLAG_FATAL, VmPtr);
return EFI_UNSUPPORTED;
}
+
//
// Now get the source address
//
@@ -1677,43 +1683,43 @@ ExecuteMOVxx (
//
// Indirect form @R2. Compute address of operand2
//
- Source = (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
+ Source = (UINTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
//
// Now get the data from the source. Always 0-extend and let the compiler
// sign-extend where required.
//
switch (MoveSize) {
- case DATA_SIZE_8:
- Data64 = (UINT64) (UINT8) VmReadMem8 (VmPtr, Source);
- break;
-
- case DATA_SIZE_16:
- Data64 = (UINT64) (UINT16) VmReadMem16 (VmPtr, Source);
- break;
-
- case DATA_SIZE_32:
- Data64 = (UINT64) (UINT32) VmReadMem32 (VmPtr, Source);
- break;
-
- case DATA_SIZE_64:
- Data64 = (UINT64) VmReadMem64 (VmPtr, Source);
- break;
-
- case DATA_SIZE_N:
- Data64 = (UINT64) (UINTN) VmReadMemN (VmPtr, Source);
- break;
-
- default:
- //
- // not reached
- //
- break;
+ case DATA_SIZE_8:
+ Data64 = (UINT64)(UINT8)VmReadMem8 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_16:
+ Data64 = (UINT64)(UINT16)VmReadMem16 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_32:
+ Data64 = (UINT64)(UINT32)VmReadMem32 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_64:
+ Data64 = (UINT64)VmReadMem64 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_N:
+ Data64 = (UINT64)(UINTN)VmReadMemN (VmPtr, Source);
+ break;
+
+ default:
+ //
+ // not reached
+ //
+ break;
}
} else {
//
// Not indirect source: MOVxx {@}Rx, Ry [Index]
//
- Data64 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
+ Data64 = (UINT64)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
//
// Did Operand2 have an index? If so, treat as two signed values since
// indexes are signed values.
@@ -1737,11 +1743,13 @@ ExecuteMOVxx (
(Index64Op2 > 0) &&
(OPERAND1_REGNUM (Operands) == 0) &&
(OPERAND1_INDIRECT (Operands))
- ) {
- Data64 = (UINT64) ConvertStackAddr (VmPtr, (UINTN) (INT64) Data64);
+ )
+ {
+ Data64 = (UINT64)ConvertStackAddr (VmPtr, (UINTN)(INT64)Data64);
}
}
}
+
//
// Now write it back
//
@@ -1749,36 +1757,36 @@ ExecuteMOVxx (
//
// Reuse the Source variable to now be dest.
//
- Source = (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index64Op1);
+ Source = (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index64Op1);
//
// Do the write based on the size
//
switch (MoveSize) {
- case DATA_SIZE_8:
- VmWriteMem8 (VmPtr, Source, (UINT8) Data64);
- break;
-
- case DATA_SIZE_16:
- VmWriteMem16 (VmPtr, Source, (UINT16) Data64);
- break;
-
- case DATA_SIZE_32:
- VmWriteMem32 (VmPtr, Source, (UINT32) Data64);
- break;
-
- case DATA_SIZE_64:
- VmWriteMem64 (VmPtr, Source, Data64);
- break;
-
- case DATA_SIZE_N:
- VmWriteMemN (VmPtr, Source, (UINTN) Data64);
- break;
-
- default:
- //
- // not reached
- //
- break;
+ case DATA_SIZE_8:
+ VmWriteMem8 (VmPtr, Source, (UINT8)Data64);
+ break;
+
+ case DATA_SIZE_16:
+ VmWriteMem16 (VmPtr, Source, (UINT16)Data64);
+ break;
+
+ case DATA_SIZE_32:
+ VmWriteMem32 (VmPtr, Source, (UINT32)Data64);
+ break;
+
+ case DATA_SIZE_64:
+ VmWriteMem64 (VmPtr, Source, Data64);
+ break;
+
+ case DATA_SIZE_N:
+ VmWriteMemN (VmPtr, Source, (UINTN)Data64);
+ break;
+
+ default:
+ //
+ // not reached
+ //
+ break;
}
} else {
//
@@ -1793,12 +1801,14 @@ ExecuteMOVxx (
);
return EFI_UNSUPPORTED;
}
+
//
// Direct storage in register. Clear unused bits and store back to
// register.
//
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Data64 & DataMask;
}
+
//
// Advance the instruction pointer
//
@@ -1806,7 +1816,6 @@ ExecuteMOVxx (
return EFI_SUCCESS;
}
-
/**
Execute the EBC BREAK instruction.
@@ -1817,7 +1826,7 @@ ExecuteMOVxx (
**/
EFI_STATUS
ExecuteBREAK (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
EFI_STATUS Status;
@@ -1827,91 +1836,92 @@ ExecuteBREAK (
UINT64 U64EbcEntryPoint;
INT32 Offset;
- Thunk = NULL;
+ Thunk = NULL;
Operands = GETOPERANDS (VmPtr);
switch (Operands) {
- //
- // Runaway program break. Generate an exception and terminate
- //
- case 0:
- EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
- break;
-
- //
- // Get VM version -- return VM revision number in R7
- //
- case 1:
//
- // Bits:
- // 63-17 = 0
- // 16-8 = Major version
- // 7-0 = Minor version
+ // Runaway program break. Generate an exception and terminate
//
- VmPtr->Gpr[7] = GetVmVersion ();
- break;
+ case 0:
+ EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
+ break;
- //
- // Debugger breakpoint
- //
- case 3:
- VmPtr->StopFlags |= STOPFLAG_BREAKPOINT;
//
- // See if someone has registered a handler
+ // Get VM version -- return VM revision number in R7
//
- EbcDebugSignalException (
- EXCEPT_EBC_BREAKPOINT,
- EXCEPTION_FLAG_NONE,
- VmPtr
- );
- break;
-
- //
- // System call, which there are none, so NOP it.
- //
- case 4:
- break;
+ case 1:
+ //
+ // Bits:
+ // 63-17 = 0
+ // 16-8 = Major version
+ // 7-0 = Minor version
+ //
+ VmPtr->Gpr[7] = GetVmVersion ();
+ break;
- //
- // Create a thunk for EBC code. R7 points to a 32-bit (in a 64-bit slot)
- // "offset from self" pointer to the EBC entry point.
- // After we're done, *(UINT64 *)R7 will be the address of the new thunk.
- //
- case 5:
- Offset = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->Gpr[7]);
- U64EbcEntryPoint = (UINT64) (VmPtr->Gpr[7] + Offset + 4);
- EbcEntryPoint = (VOID *) (UINTN) U64EbcEntryPoint;
+ //
+ // Debugger breakpoint
+ //
+ case 3:
+ VmPtr->StopFlags |= STOPFLAG_BREAKPOINT;
+ //
+ // See if someone has registered a handler
+ //
+ EbcDebugSignalException (
+ EXCEPT_EBC_BREAKPOINT,
+ EXCEPTION_FLAG_NONE,
+ VmPtr
+ );
+ break;
//
- // Now create a new thunk
+ // System call, which there are none, so NOP it.
//
- Status = EbcCreateThunks (VmPtr->ImageHandle, EbcEntryPoint, &Thunk, 0);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ case 4:
+ break;
//
- // Finally replace the EBC entry point memory with the thunk address
+ // Create a thunk for EBC code. R7 points to a 32-bit (in a 64-bit slot)
+ // "offset from self" pointer to the EBC entry point.
+ // After we're done, *(UINT64 *)R7 will be the address of the new thunk.
//
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[7], (UINT64) (UINTN) Thunk);
- break;
+ case 5:
+ Offset = (INT32)VmReadMem32 (VmPtr, (UINTN)VmPtr->Gpr[7]);
+ U64EbcEntryPoint = (UINT64)(VmPtr->Gpr[7] + Offset + 4);
+ EbcEntryPoint = (VOID *)(UINTN)U64EbcEntryPoint;
+
+ //
+ // Now create a new thunk
+ //
+ Status = EbcCreateThunks (VmPtr->ImageHandle, EbcEntryPoint, &Thunk, 0);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Finally replace the EBC entry point memory with the thunk address
+ //
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[7], (UINT64)(UINTN)Thunk);
+ break;
- //
- // Compiler setting version per value in R7
- //
- case 6:
- VmPtr->CompilerVersion = (UINT32) VmPtr->Gpr[7];
//
- // Check compiler version against VM version?
+ // Compiler setting version per value in R7
//
- break;
+ case 6:
+ VmPtr->CompilerVersion = (UINT32)VmPtr->Gpr[7];
+ //
+ // Check compiler version against VM version?
+ //
+ break;
- //
- // Unhandled break code. Signal exception.
- //
- default:
- EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
- break;
+ //
+ // Unhandled break code. Signal exception.
+ //
+ default:
+ EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
+ break;
}
+
//
// Advance IP
//
@@ -1919,7 +1929,6 @@ ExecuteBREAK (
return EFI_SUCCESS;
}
-
/**
Execute the JMP instruction.
@@ -1947,7 +1956,7 @@ ExecuteBREAK (
**/
EFI_STATUS
ExecuteJMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -1972,8 +1981,8 @@ ExecuteJMP (
// Decode instruction conditions
// If we haven't met the condition, then simply advance the IP and return.
//
- CompareSet = (UINT8) (((Operand & JMP_M_CS) != 0) ? 1 : 0);
- ConditionFlag = (UINT8) VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
+ CompareSet = (UINT8)(((Operand & JMP_M_CS) != 0) ? 1 : 0);
+ ConditionFlag = (UINT8)VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
if ((Operand & CONDITION_M_CONDITIONAL) != 0) {
if (CompareSet != ConditionFlag) {
EbcDebuggerHookJMPStart (VmPtr);
@@ -1982,6 +1991,7 @@ ExecuteJMP (
return EFI_SUCCESS;
}
}
+
//
// Check for 64-bit form and do it right away since it's the most
// straight-forward form.
@@ -1999,12 +2009,13 @@ ExecuteJMP (
);
return EFI_UNSUPPORTED;
}
+
//
// 64-bit immediate data is full address. Read the immediate data,
// check for alignment, and jump absolute.
//
- Data64 = (UINT64) VmReadImmed64 (VmPtr, 2);
- if (!IS_ALIGNED ((UINTN) Data64, sizeof (UINT16))) {
+ Data64 = (UINT64)VmReadImmed64 (VmPtr, 2);
+ if (!IS_ALIGNED ((UINTN)Data64, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2019,14 +2030,16 @@ ExecuteJMP (
//
EbcDebuggerHookJMPStart (VmPtr);
if ((Operand & JMP_M_RELATIVE) != 0) {
- VmPtr->Ip += (UINTN) Data64 + Size;
+ VmPtr->Ip += (UINTN)Data64 + Size;
} else {
- VmPtr->Ip = (VMIP) (UINTN) Data64;
+ VmPtr->Ip = (VMIP)(UINTN)Data64;
}
+
EbcDebuggerHookJMPEnd (VmPtr);
return EFI_SUCCESS;
}
+
//
// 32-bit forms:
// Get the index if there is one. May be either an index, or an immediate
@@ -2043,14 +2056,16 @@ ExecuteJMP (
} else {
Index32 = 0;
}
+
//
// Get the register data. If R == 0, then special case where it's ignored.
//
if (OPERAND1_REGNUM (Operand) == 0) {
Data64 = 0;
} else {
- Data64 = (UINT64) OPERAND1_REGDATA (VmPtr, Operand);
+ Data64 = (UINT64)OPERAND1_REGDATA (VmPtr, Operand);
}
+
//
// Decode the forms
//
@@ -2058,8 +2073,8 @@ ExecuteJMP (
//
// Form: JMP32 @Rx {Index32}
//
- Addr = VmReadMemN (VmPtr, (UINTN) Data64 + Index32);
- if (!IS_ALIGNED ((UINTN) Addr, sizeof (UINT16))) {
+ Addr = VmReadMemN (VmPtr, (UINTN)Data64 + Index32);
+ if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2071,18 +2086,18 @@ ExecuteJMP (
EbcDebuggerHookJMPStart (VmPtr);
if ((Operand & JMP_M_RELATIVE) != 0) {
- VmPtr->Ip += (UINTN) Addr + Size;
+ VmPtr->Ip += (UINTN)Addr + Size;
} else {
- VmPtr->Ip = (VMIP) Addr;
+ VmPtr->Ip = (VMIP)Addr;
}
- EbcDebuggerHookJMPEnd (VmPtr);
+ EbcDebuggerHookJMPEnd (VmPtr);
} else {
//
// Form: JMP32 Rx {Immed32}
//
- Addr = (UINTN) (Data64 + Index32);
- if (!IS_ALIGNED ((UINTN) Addr, sizeof (UINT16))) {
+ Addr = (UINTN)(Data64 + Index32);
+ if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2094,18 +2109,17 @@ ExecuteJMP (
EbcDebuggerHookJMPStart (VmPtr);
if ((Operand & JMP_M_RELATIVE) != 0) {
- VmPtr->Ip += (UINTN) Addr + Size;
+ VmPtr->Ip += (UINTN)Addr + Size;
} else {
- VmPtr->Ip = (VMIP) Addr;
+ VmPtr->Ip = (VMIP)Addr;
}
- EbcDebuggerHookJMPEnd (VmPtr);
+ EbcDebuggerHookJMPEnd (VmPtr);
}
return EFI_SUCCESS;
}
-
/**
Execute the EBC JMP8 instruction.
@@ -2119,20 +2133,20 @@ ExecuteJMP (
**/
EFI_STATUS
ExecuteJMP8 (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 ConditionFlag;
- UINT8 CompareSet;
- INT8 Offset;
+ UINT8 Opcode;
+ UINT8 ConditionFlag;
+ UINT8 CompareSet;
+ INT8 Offset;
//
// Decode instruction.
//
Opcode = GETOPCODE (VmPtr);
- CompareSet = (UINT8) (((Opcode & JMP_M_CS) != 0) ? 1 : 0);
- ConditionFlag = (UINT8) VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
+ CompareSet = (UINT8)(((Opcode & JMP_M_CS) != 0) ? 1 : 0);
+ ConditionFlag = (UINT8)VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
//
// If we haven't met the condition, then simply advance the IP and return
@@ -2145,6 +2159,7 @@ ExecuteJMP8 (
return EFI_SUCCESS;
}
}
+
//
// Get the offset from the instruction stream. It's relative to the
// following instruction, and divided by 2.
@@ -2159,7 +2174,6 @@ ExecuteJMP8 (
return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVI.
@@ -2183,7 +2197,7 @@ ExecuteJMP8 (
**/
EFI_STATUS
ExecuteMOVI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2197,8 +2211,8 @@ ExecuteMOVI (
//
// Get the opcode and operands byte so we can get R1 and R2
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the index (16-bit) if present
@@ -2210,18 +2224,19 @@ ExecuteMOVI (
Index16 = 0;
Size = 2;
}
+
//
// Extract the immediate data. Sign-extend always.
//
if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
- ImmData64 = (INT64) (INT16) VmReadImmed16 (VmPtr, Size);
- Size += 2;
+ ImmData64 = (INT64)(INT16)VmReadImmed16 (VmPtr, Size);
+ Size += 2;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
- ImmData64 = (INT64) (INT32) VmReadImmed32 (VmPtr, Size);
- Size += 4;
+ ImmData64 = (INT64)(INT32)VmReadImmed32 (VmPtr, Size);
+ Size += 4;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
- ImmData64 = (INT64) VmReadImmed64 (VmPtr, Size);
- Size += 8;
+ ImmData64 = (INT64)VmReadImmed64 (VmPtr, Size);
+ Size += 8;
} else {
//
// Invalid encoding
@@ -2233,6 +2248,7 @@ ExecuteMOVI (
);
return EFI_UNSUPPORTED;
}
+
//
// Now write back the result
//
@@ -2248,6 +2264,7 @@ ExecuteMOVI (
);
return EFI_UNSUPPORTED;
}
+
//
// Writing directly to a register. Clear unused bits.
//
@@ -2258,7 +2275,7 @@ ExecuteMOVI (
} else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH32) {
Mask64 = 0x00000000FFFFFFFF;
} else {
- Mask64 = (UINT64)~0;
+ Mask64 = (UINT64) ~0;
}
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = ImmData64 & Mask64;
@@ -2266,17 +2283,18 @@ ExecuteMOVI (
//
// Get the address then write back based on size of the move
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH8) {
- VmWriteMem8 (VmPtr, (UINTN) Op1, (UINT8) ImmData64);
+ VmWriteMem8 (VmPtr, (UINTN)Op1, (UINT8)ImmData64);
} else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH16) {
- VmWriteMem16 (VmPtr, (UINTN) Op1, (UINT16) ImmData64);
+ VmWriteMem16 (VmPtr, (UINTN)Op1, (UINT16)ImmData64);
} else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH32) {
- VmWriteMem32 (VmPtr, (UINTN) Op1, (UINT32) ImmData64);
+ VmWriteMem32 (VmPtr, (UINTN)Op1, (UINT32)ImmData64);
} else {
- VmWriteMem64 (VmPtr, (UINTN) Op1, (UINT64) ImmData64);
+ VmWriteMem64 (VmPtr, (UINTN)Op1, (UINT64)ImmData64);
}
}
+
//
// Advance the instruction pointer
//
@@ -2284,7 +2302,6 @@ ExecuteMOVI (
return EFI_SUCCESS;
}
-
/**
Execute the EBC MOV immediate natural. This instruction moves an immediate
index value into a register or memory location.
@@ -2301,7 +2318,7 @@ ExecuteMOVI (
**/
EFI_STATUS
ExecuteMOVIn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2316,8 +2333,8 @@ ExecuteMOVIn (
//
// Get the opcode and operands byte so we can get R1 and R2
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the operand1 index (16-bit) if present
@@ -2329,20 +2346,21 @@ ExecuteMOVIn (
Index16 = 0;
Size = 2;
}
+
//
// Extract the immediate data and convert to a 64-bit index.
//
if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
- ImmedIndex16 = VmReadIndex16 (VmPtr, Size);
- ImmedIndex64 = (INT64) ImmedIndex16;
- Size += 2;
+ ImmedIndex16 = VmReadIndex16 (VmPtr, Size);
+ ImmedIndex64 = (INT64)ImmedIndex16;
+ Size += 2;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
- ImmedIndex32 = VmReadIndex32 (VmPtr, Size);
- ImmedIndex64 = (INT64) ImmedIndex32;
- Size += 4;
+ ImmedIndex32 = VmReadIndex32 (VmPtr, Size);
+ ImmedIndex64 = (INT64)ImmedIndex32;
+ Size += 4;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
ImmedIndex64 = VmReadIndex64 (VmPtr, Size);
- Size += 8;
+ Size += 8;
} else {
//
// Invalid encoding
@@ -2354,6 +2372,7 @@ ExecuteMOVIn (
);
return EFI_UNSUPPORTED;
}
+
//
// Now write back the result
//
@@ -2376,9 +2395,10 @@ ExecuteMOVIn (
//
// Get the address
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
- VmWriteMemN (VmPtr, (UINTN) Op1, (UINTN)(INTN) ImmedIndex64);
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ VmWriteMemN (VmPtr, (UINTN)Op1, (UINTN)(INTN)ImmedIndex64);
}
+
//
// Advance the instruction pointer
//
@@ -2386,7 +2406,6 @@ ExecuteMOVIn (
return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVREL instruction.
Dest <- Ip + ImmData
@@ -2403,7 +2422,7 @@ ExecuteMOVIn (
**/
EFI_STATUS
ExecuteMOVREL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2417,8 +2436,8 @@ ExecuteMOVREL (
//
// Get the opcode and operands byte so we can get R1 and R2
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the Operand 1 index (16-bit) if present
@@ -2430,18 +2449,19 @@ ExecuteMOVREL (
Index16 = 0;
Size = 2;
}
+
//
// Get the immediate data.
//
if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
- ImmData64 = (INT64) VmReadImmed16 (VmPtr, Size);
- Size += 2;
+ ImmData64 = (INT64)VmReadImmed16 (VmPtr, Size);
+ Size += 2;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
- ImmData64 = (INT64) VmReadImmed32 (VmPtr, Size);
- Size += 4;
+ ImmData64 = (INT64)VmReadImmed32 (VmPtr, Size);
+ Size += 4;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
ImmData64 = VmReadImmed64 (VmPtr, Size);
- Size += 8;
+ Size += 8;
} else {
//
// Invalid encoding
@@ -2453,10 +2473,11 @@ ExecuteMOVREL (
);
return EFI_UNSUPPORTED;
}
+
//
// Compute the value and write back the result
//
- Op2 = (UINT64) ((INT64) ((UINT64) (UINTN) VmPtr->Ip) + (INT64) ImmData64 + Size);
+ Op2 = (UINT64)((INT64)((UINT64)(UINTN)VmPtr->Ip) + (INT64)ImmData64 + Size);
if (!OPERAND1_INDIRECT (Operands)) {
//
// Check for illegal combination of operand1 direct with immediate data
@@ -2470,16 +2491,17 @@ ExecuteMOVREL (
return EFI_UNSUPPORTED;
}
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (VM_REGISTER) Op2;
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (VM_REGISTER)Op2;
} else {
//
// Get the address = [Rx] + Index16
// Write back the result. Always a natural size write, since
// we're talking addresses here.
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
- VmWriteMemN (VmPtr, (UINTN) Op1, (UINTN) Op2);
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ VmWriteMemN (VmPtr, (UINTN)Op1, (UINTN)Op2);
}
+
//
// Advance the instruction pointer
//
@@ -2487,7 +2509,6 @@ ExecuteMOVREL (
return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVsnw instruction. This instruction loads a signed
natural value from memory or register to another memory or register. On
@@ -2509,7 +2530,7 @@ ExecuteMOVREL (
**/
EFI_STATUS
ExecuteMOVsnw (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2522,16 +2543,16 @@ ExecuteMOVsnw (
//
// Get the opcode and operand bytes
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
- Op1Index = Op2Index = 0;
+ Op1Index = Op2Index = 0;
//
// Get the indexes if present.
//
Size = 2;
- if ((Opcode & OPCODE_M_IMMED_OP1) !=0) {
+ if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
if (OPERAND1_INDIRECT (Operands)) {
Op1Index = VmReadIndex16 (VmPtr, 2);
} else {
@@ -2558,21 +2579,24 @@ ExecuteMOVsnw (
Size += sizeof (UINT16);
}
+
//
// Get the data from the source.
//
Op2 = (UINT64)(INT64)(INTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
if (OPERAND2_INDIRECT (Operands)) {
- Op2 = (UINT64)(INT64)(INTN)VmReadMemN (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)(INT64)(INTN)VmReadMemN (VmPtr, (UINTN)Op2);
}
+
//
// Now write back the result.
//
if (!OPERAND1_INDIRECT (Operands)) {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;
} else {
- VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);
+ VmWriteMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN)Op2);
}
+
//
// Advance the instruction pointer
//
@@ -2580,7 +2604,6 @@ ExecuteMOVsnw (
return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVsnw instruction. This instruction loads a signed
natural value from memory or register to another memory or register. On
@@ -2602,7 +2625,7 @@ ExecuteMOVsnw (
**/
EFI_STATUS
ExecuteMOVsnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2615,10 +2638,10 @@ ExecuteMOVsnd (
//
// Get the opcode and operand bytes
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
- Op1Index = Op2Index = 0;
+ Op1Index = Op2Index = 0;
//
// Get the indexes if present.
@@ -2651,21 +2674,24 @@ ExecuteMOVsnd (
Size += sizeof (UINT32);
}
+
//
// Get the data from the source.
//
Op2 = (UINT64)(INT64)(INTN)(INT64)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
if (OPERAND2_INDIRECT (Operands)) {
- Op2 = (UINT64)(INT64)(INTN)(INT64)VmReadMemN (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)(INT64)(INTN)(INT64)VmReadMemN (VmPtr, (UINTN)Op2);
}
+
//
// Now write back the result.
//
if (!OPERAND1_INDIRECT (Operands)) {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;
} else {
- VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);
+ VmWriteMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN)Op2);
}
+
//
// Advance the instruction pointer
//
@@ -2673,7 +2699,6 @@ ExecuteMOVsnd (
return EFI_SUCCESS;
}
-
/**
Execute the EBC PUSHn instruction
@@ -2687,19 +2712,19 @@ ExecuteMOVsnd (
**/
EFI_STATUS
ExecutePUSHn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 Operands;
- INT16 Index16;
- UINTN DataN;
+ UINT8 Opcode;
+ UINT8 Operands;
+ INT16 Index16;
+ UINTN DataN;
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get index if present
@@ -2713,26 +2738,27 @@ ExecutePUSHn (
VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Get the data to push
//
if (OPERAND1_INDIRECT (Operands)) {
- DataN = VmReadMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
+ DataN = VmReadMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
} else {
- DataN = (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16);
+ DataN = (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16);
}
+
//
// Adjust the stack down.
//
VmPtr->Gpr[0] -= sizeof (UINTN);
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], DataN);
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], DataN);
return EFI_SUCCESS;
}
-
/**
Execute the EBC PUSH instruction.
@@ -2746,7 +2772,7 @@ ExecutePUSHn (
**/
EFI_STATUS
ExecutePUSH (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2758,8 +2784,8 @@ ExecutePUSH (
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get immediate index if present, then advance the IP.
//
@@ -2772,43 +2798,45 @@ ExecutePUSH (
VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Get the data to push
//
if ((Opcode & PUSHPOP_M_64) != 0) {
if (OPERAND1_INDIRECT (Operands)) {
- Data64 = VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
+ Data64 = VmReadMem64 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
} else {
- Data64 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ Data64 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
}
+
//
// Adjust the stack down, then write back the data
//
VmPtr->Gpr[0] -= sizeof (UINT64);
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], Data64);
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], Data64);
} else {
//
// 32-bit data
//
if (OPERAND1_INDIRECT (Operands)) {
- Data32 = VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
+ Data32 = VmReadMem32 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
} else {
- Data32 = (UINT32) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ Data32 = (UINT32)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
}
+
//
// Adjust the stack down and write the data
//
VmPtr->Gpr[0] -= sizeof (UINT32);
- VmWriteMem32 (VmPtr, (UINTN) VmPtr->Gpr[0], Data32);
+ VmWriteMem32 (VmPtr, (UINTN)VmPtr->Gpr[0], Data32);
}
return EFI_SUCCESS;
}
-
/**
Execute the EBC POPn instruction.
@@ -2822,19 +2850,19 @@ ExecutePUSH (
**/
EFI_STATUS
ExecutePOPn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 Operands;
- INT16 Index16;
- UINTN DataN;
+ UINT8 Opcode;
+ UINT8 Operands;
+ INT16 Index16;
+ UINTN DataN;
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get immediate data if present, and advance the IP
//
@@ -2847,27 +2875,27 @@ ExecutePOPn (
VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Read the data off the stack, then adjust the stack pointer
//
- DataN = VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);
+ DataN = VmReadMemN (VmPtr, (UINTN)VmPtr->Gpr[0]);
VmPtr->Gpr[0] += sizeof (UINTN);
//
// Do the write-back
//
if (OPERAND1_INDIRECT (Operands)) {
- VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);
+ VmWriteMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);
} else {
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) (UINTN) (DataN + Index16);
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64)(UINT64)(UINTN)(DataN + Index16);
}
return EFI_SUCCESS;
}
-
/**
Execute the EBC POP instruction.
@@ -2881,7 +2909,7 @@ ExecutePOPn (
**/
EFI_STATUS
ExecutePOP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2893,8 +2921,8 @@ ExecutePOP (
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get immediate data if present, and advance the IP.
//
@@ -2907,9 +2935,10 @@ ExecutePOP (
VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Get the data off the stack, then write it to the appropriate location
//
@@ -2917,13 +2946,13 @@ ExecutePOP (
//
// Read the data off the stack, then adjust the stack pointer
//
- Data64 = VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);
+ Data64 = VmReadMem64 (VmPtr, (UINTN)VmPtr->Gpr[0]);
VmPtr->Gpr[0] += sizeof (UINT64);
//
// Do the write-back
//
if (OPERAND1_INDIRECT (Operands)) {
- VmWriteMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data64);
+ VmWriteMem64 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data64);
} else {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Data64 + Index16;
}
@@ -2931,22 +2960,21 @@ ExecutePOP (
//
// 32-bit pop. Read it off the stack and adjust the stack pointer
//
- Data32 = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->Gpr[0]);
+ Data32 = (INT32)VmReadMem32 (VmPtr, (UINTN)VmPtr->Gpr[0]);
VmPtr->Gpr[0] += sizeof (UINT32);
//
// Do the write-back
//
if (OPERAND1_INDIRECT (Operands)) {
- VmWriteMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data32);
+ VmWriteMem32 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data32);
} else {
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) Data32 + Index16;
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64)Data32 + Index16;
}
}
return EFI_SUCCESS;
}
-
/**
Implements the EBC CALL instruction.
@@ -2965,21 +2993,21 @@ ExecutePOP (
**/
EFI_STATUS
ExecuteCALL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 Operands;
- INT32 Immed32;
- UINT8 Size;
- INT64 Immed64;
- VOID *FramePtr;
+ UINT8 Opcode;
+ UINT8 Operands;
+ INT32 Immed32;
+ UINT8 Size;
+ INT64 Immed64;
+ VOID *FramePtr;
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
if ((Operands & OPERAND_M_NATIVE_CALL) != 0) {
EbcDebuggerHookCALLEXStart (VmPtr);
@@ -2990,10 +3018,10 @@ ExecuteCALL (
//
// Assign these as well to avoid compiler warnings
//
- Immed64 = 0;
- Immed32 = 0;
+ Immed64 = 0;
+ Immed32 = 0;
- FramePtr = VmPtr->FramePtr;
+ FramePtr = VmPtr->FramePtr;
//
// Determine the instruction size, and get immediate data if present
//
@@ -3016,17 +3044,19 @@ ExecuteCALL (
} else {
Size = 2;
}
+
//
// If it's a call to EBC, adjust the stack pointer down 16 bytes and
// put our return address and frame pointer on the VM stack.
//
if ((Operands & OPERAND_M_NATIVE_CALL) == 0) {
VmPtr->Gpr[0] -= 8;
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);
- VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];
- VmPtr->Gpr[0] -= 8;
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], (UINTN)FramePtr);
+ VmPtr->FramePtr = (VOID *)(UINTN)VmPtr->Gpr[0];
+ VmPtr->Gpr[0] -= 8;
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], (UINT64)(UINTN)(VmPtr->Ip + Size));
}
+
//
// If 64-bit data, then absolute jump only
//
@@ -3035,12 +3065,12 @@ ExecuteCALL (
// Native or EBC call?
//
if ((Operands & OPERAND_M_NATIVE_CALL) == 0) {
- VmPtr->Ip = (VMIP) (UINTN) Immed64;
+ VmPtr->Ip = (VMIP)(UINTN)Immed64;
} else {
//
// Call external function, get the return value, and advance the IP
//
- EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->Gpr[0], FramePtr, Size);
+ EbcLLCALLEX (VmPtr, (UINTN)Immed64, (UINTN)VmPtr->Gpr[0], FramePtr, Size);
}
} else {
//
@@ -3049,16 +3079,18 @@ ExecuteCALL (
// Compiler should take care of upper bits if 32-bit machine.
//
if (OPERAND1_REGNUM (Operands) != 0) {
- Immed64 = (UINT64) (UINTN) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Immed64 = (UINT64)(UINTN)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
}
+
//
// Get final address
//
if (OPERAND1_INDIRECT (Operands)) {
- Immed64 = (INT64) (UINT64) (UINTN) VmReadMemN (VmPtr, (UINTN) (Immed64 + Immed32));
+ Immed64 = (INT64)(UINT64)(UINTN)VmReadMemN (VmPtr, (UINTN)(Immed64 + Immed32));
} else {
Immed64 += Immed32;
}
+
//
// Now determine if external call, and then if relative or absolute
//
@@ -3070,20 +3102,20 @@ ExecuteCALL (
if ((Operands & OPERAND_M_RELATIVE_ADDR) != 0) {
VmPtr->Ip += Immed64 + Size;
} else {
- VmPtr->Ip = (VMIP) (UINTN) Immed64;
+ VmPtr->Ip = (VMIP)(UINTN)Immed64;
}
} else {
//
// Native call. Relative or absolute?
//
if ((Operands & OPERAND_M_RELATIVE_ADDR) != 0) {
- EbcLLCALLEX (VmPtr, (UINTN) (Immed64 + VmPtr->Ip + Size), (UINTN) VmPtr->Gpr[0], FramePtr, Size);
+ EbcLLCALLEX (VmPtr, (UINTN)(Immed64 + VmPtr->Ip + Size), (UINTN)VmPtr->Gpr[0], FramePtr, Size);
} else {
if ((VmPtr->StopFlags & STOPFLAG_BREAK_ON_CALLEX) != 0) {
CpuBreakpoint ();
}
- EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->Gpr[0], FramePtr, Size);
+ EbcLLCALLEX (VmPtr, (UINTN)Immed64, (UINTN)VmPtr->Gpr[0], FramePtr, Size);
}
}
}
@@ -3097,7 +3129,6 @@ ExecuteCALL (
return EFI_SUCCESS;
}
-
/**
Execute the EBC RET instruction.
@@ -3111,46 +3142,44 @@ ExecuteCALL (
**/
EFI_STATUS
ExecuteRET (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
-
EbcDebuggerHookRETStart (VmPtr);
//
// If we're at the top of the stack, then simply set the done
// flag and return
//
- if (VmPtr->StackRetAddr == (UINT64) VmPtr->Gpr[0]) {
+ if (VmPtr->StackRetAddr == (UINT64)VmPtr->Gpr[0]) {
VmPtr->StopFlags |= STOPFLAG_APP_DONE;
} else {
//
// Pull the return address off the VM app's stack and set the IP
// to it
//
- if (!IS_ALIGNED ((UINTN) VmPtr->Gpr[0], sizeof (UINT16))) {
+ if (!IS_ALIGNED ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
VmPtr
);
}
+
//
// Restore the IP and frame pointer from the stack
//
- VmPtr->Ip = (VMIP) (UINTN) VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);
- VmPtr->Gpr[0] += 8;
- VmPtr->FramePtr = (VOID *) VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);
- VmPtr->Gpr[0] += 8;
+ VmPtr->Ip = (VMIP)(UINTN)VmReadMem64 (VmPtr, (UINTN)VmPtr->Gpr[0]);
+ VmPtr->Gpr[0] += 8;
+ VmPtr->FramePtr = (VOID *)VmReadMemN (VmPtr, (UINTN)VmPtr->Gpr[0]);
+ VmPtr->Gpr[0] += 8;
}
-
EbcDebuggerHookRETEnd (VmPtr);
return EFI_SUCCESS;
}
-
/**
Execute the EBC CMP instruction.
@@ -3165,7 +3194,7 @@ ExecuteRET (
**/
EFI_STATUS
ExecuteCMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -3179,8 +3208,8 @@ ExecuteCMP (
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the register data we're going to compare to
//
@@ -3200,21 +3229,23 @@ ExecuteCMP (
Index16 = 0;
Size = 2;
}
+
//
// Now get Op2
//
if (OPERAND2_INDIRECT (Operands)) {
if ((Opcode & OPCODE_M_64BIT) != 0) {
- Op2 = (INT64) VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16));
+ Op2 = (INT64)VmReadMem64 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16));
} else {
//
// 32-bit operations. 0-extend the values for all cases.
//
- Op2 = (INT64) (UINT64) ((UINT32) VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16)));
+ Op2 = (INT64)(UINT64)((UINT32)VmReadMem32 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16)));
}
} else {
Op2 = VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;
}
+
//
// Now do the compare
//
@@ -3224,78 +3255,89 @@ ExecuteCMP (
// 64-bit compares
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPEQ:
- if (Op1 == Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPEQ:
+ if (Op1 == Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPLTE:
- if (Op1 <= Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPGTE:
- if (Op1 >= Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPLTE:
+ if (Op1 <= Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPULTE:
- if ((UINT64) Op1 <= (UINT64) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPUGTE:
- if ((UINT64) Op1 >= (UINT64) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPGTE:
+ if (Op1 >= Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPULTE:
+ if ((UINT64)Op1 <= (UINT64)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPUGTE:
+ if ((UINT64)Op1 >= (UINT64)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
} else {
//
// 32-bit compares
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPEQ:
- if ((INT32) Op1 == (INT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPEQ:
+ if ((INT32)Op1 == (INT32)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPLTE:
- if ((INT32) Op1 <= (INT32) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPGTE:
- if ((INT32) Op1 >= (INT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPLTE:
+ if ((INT32)Op1 <= (INT32)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPULTE:
- if ((UINT32) Op1 <= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPUGTE:
- if ((UINT32) Op1 >= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPGTE:
+ if ((INT32)Op1 >= (INT32)Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPULTE:
+ if ((UINT32)Op1 <= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPUGTE:
+ if ((UINT32)Op1 >= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
}
+
//
// Now set the flag accordingly for the comparison
//
@@ -3304,6 +3346,7 @@ ExecuteCMP (
} else {
VMFLAG_CLEAR (VmPtr, (UINT64)VMFLAGS_CC);
}
+
//
// Advance the IP
//
@@ -3311,7 +3354,6 @@ ExecuteCMP (
return EFI_SUCCESS;
}
-
/**
Execute the EBC CMPI instruction
@@ -3326,7 +3368,7 @@ ExecuteCMP (
**/
EFI_STATUS
ExecuteCMPI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -3340,8 +3382,8 @@ ExecuteCMPI (
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get operand1 index if present
@@ -3349,22 +3391,23 @@ ExecuteCMPI (
Size = 2;
if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
Index16 = VmReadIndex16 (VmPtr, 2);
- Size += 2;
+ Size += 2;
} else {
Index16 = 0;
}
+
//
// Get operand1 data we're going to compare to
//
- Op1 = (INT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Op1 = (INT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
if (OPERAND1_INDIRECT (Operands)) {
//
// Indirect operand1. Fetch 32 or 64-bit value based on compare size.
//
if ((Opcode & OPCODE_M_CMPI64) != 0) {
- Op1 = (INT64) VmReadMem64 (VmPtr, (UINTN) Op1 + Index16);
+ Op1 = (INT64)VmReadMem64 (VmPtr, (UINTN)Op1 + Index16);
} else {
- Op1 = (INT64) VmReadMem32 (VmPtr, (UINTN) Op1 + Index16);
+ Op1 = (INT64)VmReadMem32 (VmPtr, (UINTN)Op1 + Index16);
}
} else {
//
@@ -3381,19 +3424,21 @@ ExecuteCMPI (
return EFI_UNSUPPORTED;
}
}
+
//
// Get immediate data -- 16- or 32-bit sign extended
//
if ((Opcode & OPCODE_M_CMPI32_DATA) != 0) {
- Op2 = (INT64) VmReadImmed32 (VmPtr, Size);
+ Op2 = (INT64)VmReadImmed32 (VmPtr, Size);
Size += 4;
} else {
//
// 16-bit immediate data. Sign extend always.
//
- Op2 = (INT64) ((INT16) VmReadImmed16 (VmPtr, Size));
+ Op2 = (INT64)((INT16)VmReadImmed16 (VmPtr, Size));
Size += 2;
}
+
//
// Now do the compare
//
@@ -3403,78 +3448,89 @@ ExecuteCMPI (
// 64 bit comparison
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPIEQ:
- if (Op1 == (INT64) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIEQ:
+ if (Op1 == (INT64)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPILTE:
- if (Op1 <= (INT64) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIGTE:
- if (Op1 >= (INT64) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPILTE:
+ if (Op1 <= (INT64)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPIULTE:
- if ((UINT64) Op1 <= (UINT64) ((UINT32) Op2)) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIUGTE:
- if ((UINT64) Op1 >= (UINT64) ((UINT32) Op2)) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIGTE:
+ if (Op1 >= (INT64)Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPIULTE:
+ if ((UINT64)Op1 <= (UINT64)((UINT32)Op2)) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPIUGTE:
+ if ((UINT64)Op1 >= (UINT64)((UINT32)Op2)) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
} else {
//
// 32-bit comparisons
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPIEQ:
- if ((INT32) Op1 == Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIEQ:
+ if ((INT32)Op1 == Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPILTE:
- if ((INT32) Op1 <= Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIGTE:
- if ((INT32) Op1 >= Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPILTE:
+ if ((INT32)Op1 <= Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPIULTE:
- if ((UINT32) Op1 <= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIUGTE:
- if ((UINT32) Op1 >= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIGTE:
+ if ((INT32)Op1 >= Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPIULTE:
+ if ((UINT32)Op1 <= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPIUGTE:
+ if ((UINT32)Op1 >= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
}
+
//
// Now set the flag accordingly for the comparison
//
@@ -3483,6 +3539,7 @@ ExecuteCMPI (
} else {
VMFLAG_CLEAR (VmPtr, (UINT64)VMFLAGS_CC);
}
+
//
// Advance the IP
//
@@ -3490,7 +3547,6 @@ ExecuteCMPI (
return EFI_SUCCESS;
}
-
/**
Execute the EBC NOT instruction.s
@@ -3506,15 +3562,14 @@ ExecuteCMPI (
**/
UINT64
ExecuteNOT (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return ~Op2;
}
-
/**
Execute the EBC NEG instruction.
@@ -3530,15 +3585,14 @@ ExecuteNOT (
**/
UINT64
ExecuteNEG (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return ~Op2 + 1;
}
-
/**
Execute the EBC ADD instruction.
@@ -3554,15 +3608,14 @@ ExecuteNEG (
**/
UINT64
ExecuteADD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 + Op2;
}
-
/**
Execute the EBC SUB instruction.
@@ -3578,19 +3631,18 @@ ExecuteADD (
**/
UINT64
ExecuteSUB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
- return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2));
+ return (UINT64)((INT64)((INT64)Op1 - (INT64)Op2));
} else {
- return (UINT64) ((INT64) ((INT32) ((INT32) Op1 - (INT32) Op2)));
+ return (UINT64)((INT64)((INT32)((INT32)Op1 - (INT32)Op2)));
}
}
-
/**
Execute the EBC MUL instruction.
@@ -3606,19 +3658,18 @@ ExecuteSUB (
**/
UINT64
ExecuteMUL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultS64x64 ((INT64)Op1, (INT64)Op2);
} else {
- return (UINT64) ((INT64) ((INT32) ((INT32) Op1 * (INT32) Op2)));
+ return (UINT64)((INT64)((INT32)((INT32)Op1 * (INT32)Op2)));
}
}
-
/**
Execute the EBC MULU instruction
@@ -3634,19 +3685,18 @@ ExecuteMUL (
**/
UINT64
ExecuteMULU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultU64x64 (Op1, Op2);
} else {
- return (UINT64) ((UINT32) ((UINT32) Op1 * (UINT32) Op2));
+ return (UINT64)((UINT32)((UINT32)Op1 * (UINT32)Op2));
}
}
-
/**
Execute the EBC DIV instruction.
@@ -3662,12 +3712,12 @@ ExecuteMULU (
**/
UINT64
ExecuteDIV (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT64 Remainder;
+ INT64 Remainder;
//
// Check for divide-by-0
@@ -3682,14 +3732,13 @@ ExecuteDIV (
return 0;
} else {
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
- return (UINT64) (DivS64x64Remainder (Op1, Op2, &Remainder));
+ return (UINT64)(DivS64x64Remainder (Op1, Op2, &Remainder));
} else {
- return (UINT64) ((INT64) ((INT32) Op1 / (INT32) Op2));
+ return (UINT64)((INT64)((INT32)Op1 / (INT32)Op2));
}
}
}
-
/**
Execute the EBC DIVU instruction
@@ -3705,9 +3754,9 @@ ExecuteDIV (
**/
UINT64
ExecuteDIVU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
UINT64 Remainder;
@@ -3727,14 +3776,13 @@ ExecuteDIVU (
// Get the destination register
//
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
- return (UINT64) (DivU64x64Remainder (Op1, Op2, &Remainder));
+ return (UINT64)(DivU64x64Remainder (Op1, Op2, &Remainder));
} else {
- return (UINT64) ((UINT32) Op1 / (UINT32) Op2);
+ return (UINT64)((UINT32)Op1 / (UINT32)Op2);
}
}
}
-
/**
Execute the EBC MOD instruction.
@@ -3750,12 +3798,12 @@ ExecuteDIVU (
**/
UINT64
ExecuteMOD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT64 Remainder;
+ INT64 Remainder;
//
// Check for divide-by-0
@@ -3773,7 +3821,6 @@ ExecuteMOD (
}
}
-
/**
Execute the EBC MODU instruction.
@@ -3789,9 +3836,9 @@ ExecuteMOD (
**/
UINT64
ExecuteMODU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
UINT64 Remainder;
@@ -3812,7 +3859,6 @@ ExecuteMODU (
}
}
-
/**
Execute the EBC AND instruction.
@@ -3828,15 +3874,14 @@ ExecuteMODU (
**/
UINT64
ExecuteAND (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 & Op2;
}
-
/**
Execute the EBC OR instruction.
@@ -3852,15 +3897,14 @@ ExecuteAND (
**/
UINT64
ExecuteOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 | Op2;
}
-
/**
Execute the EBC XOR instruction.
@@ -3876,15 +3920,14 @@ ExecuteOR (
**/
UINT64
ExecuteXOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 ^ Op2;
}
-
/**
Execute the EBC SHL shift left instruction.
@@ -3900,19 +3943,18 @@ ExecuteXOR (
**/
UINT64
ExecuteSHL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return LShiftU64 (Op1, (UINTN)Op2);
} else {
- return (UINT64) ((UINT32) ((UINT32) Op1 << (UINT32) Op2));
+ return (UINT64)((UINT32)((UINT32)Op1 << (UINT32)Op2));
}
}
-
/**
Execute the EBC SHR instruction.
@@ -3928,19 +3970,18 @@ ExecuteSHL (
**/
UINT64
ExecuteSHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return RShiftU64 (Op1, (UINTN)Op2);
} else {
- return (UINT64) ((UINT32) Op1 >> (UINT32) Op2);
+ return (UINT64)((UINT32)Op1 >> (UINT32)Op2);
}
}
-
/**
Execute the EBC ASHR instruction.
@@ -3956,19 +3997,18 @@ ExecuteSHR (
**/
UINT64
ExecuteASHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return ARShiftU64 (Op1, (UINTN)Op2);
} else {
- return (UINT64) ((INT64) ((INT32) Op1 >> (UINT32) Op2));
+ return (UINT64)((INT64)((INT32)Op1 >> (UINT32)Op2));
}
}
-
/**
Execute the EBC EXTNDB instruction to sign-extend a byte value.
@@ -3984,24 +4024,24 @@ ExecuteASHR (
**/
UINT64
ExecuteEXTNDB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT8 Data8;
- INT64 Data64;
+ INT8 Data8;
+ INT64 Data64;
+
//
// Convert to byte, then return as 64-bit signed value to let compiler
// sign-extend the value
//
- Data8 = (INT8) Op2;
- Data64 = (INT64) Data8;
+ Data8 = (INT8)Op2;
+ Data64 = (INT64)Data8;
- return (UINT64) Data64;
+ return (UINT64)Data64;
}
-
/**
Execute the EBC EXTNDW instruction to sign-extend a 16-bit value.
@@ -4017,22 +4057,24 @@ ExecuteEXTNDB (
**/
UINT64
ExecuteEXTNDW (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT16 Data16;
- INT64 Data64;
+ INT16 Data16;
+ INT64 Data64;
+
//
// Convert to word, then return as 64-bit signed value to let compiler
// sign-extend the value
//
- Data16 = (INT16) Op2;
- Data64 = (INT64) Data16;
+ Data16 = (INT16)Op2;
+ Data64 = (INT64)Data16;
- return (UINT64) Data64;
+ return (UINT64)Data64;
}
+
//
// Execute the EBC EXTNDD instruction.
//
@@ -4057,24 +4099,24 @@ ExecuteEXTNDW (
**/
UINT64
ExecuteEXTNDD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT32 Data32;
- INT64 Data64;
+ INT32 Data32;
+ INT64 Data64;
+
//
// Convert to 32-bit value, then return as 64-bit signed value to let compiler
// sign-extend the value
//
- Data32 = (INT32) Op2;
- Data64 = (INT64) Data32;
+ Data32 = (INT32)Op2;
+ Data64 = (INT64)Data32;
- return (UINT64) Data64;
+ return (UINT64)Data64;
}
-
/**
Execute all the EBC signed data manipulation instructions.
Since the EBC data manipulation instructions all have the same basic form,
@@ -4094,7 +4136,7 @@ ExecuteEXTNDD (
**/
EFI_STATUS
ExecuteSignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
//
@@ -4104,7 +4146,6 @@ ExecuteSignedDataManip (
return ExecuteDataManip (VmPtr, TRUE);
}
-
/**
Execute all the EBC unsigned data manipulation instructions.
Since the EBC data manipulation instructions all have the same basic form,
@@ -4124,7 +4165,7 @@ ExecuteSignedDataManip (
**/
EFI_STATUS
ExecuteUnsignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
//
@@ -4134,7 +4175,6 @@ ExecuteUnsignedDataManip (
return ExecuteDataManip (VmPtr, FALSE);
}
-
/**
Execute all the EBC data manipulation instructions.
Since the EBC data manipulation instructions all have the same basic form,
@@ -4155,8 +4195,8 @@ ExecuteUnsignedDataManip (
**/
EFI_STATUS
ExecuteDataManip (
- IN VM_CONTEXT *VmPtr,
- IN BOOLEAN IsSignedOp
+ IN VM_CONTEXT *VmPtr,
+ IN BOOLEAN IsSignedOp
)
{
UINT8 Opcode;
@@ -4170,8 +4210,8 @@ ExecuteDataManip (
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Determine if we have immediate data by the opcode
@@ -4191,65 +4231,69 @@ ExecuteDataManip (
Index16 = 0;
Size = 2;
}
+
//
// Now get operand2 (source). It's of format {@}R2 {Index16|Immed16}
//
- Op2 = (UINT64) VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;
+ Op2 = (UINT64)VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;
if (OPERAND2_INDIRECT (Operands)) {
//
// Indirect form: @R2 Index16. Fetch as 32- or 64-bit data
//
if ((Opcode & DATAMANIP_M_64) != 0) {
- Op2 = VmReadMem64 (VmPtr, (UINTN) Op2);
+ Op2 = VmReadMem64 (VmPtr, (UINTN)Op2);
} else {
//
// Read as signed value where appropriate.
//
if (IsSignedOp) {
- Op2 = (UINT64) (INT64) ((INT32) VmReadMem32 (VmPtr, (UINTN) Op2));
+ Op2 = (UINT64)(INT64)((INT32)VmReadMem32 (VmPtr, (UINTN)Op2));
} else {
- Op2 = (UINT64) VmReadMem32 (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)VmReadMem32 (VmPtr, (UINTN)Op2);
}
}
} else {
if ((Opcode & DATAMANIP_M_64) == 0) {
if (IsSignedOp) {
- Op2 = (UINT64) (INT64) ((INT32) Op2);
+ Op2 = (UINT64)(INT64)((INT32)Op2);
} else {
- Op2 = (UINT64) ((UINT32) Op2);
+ Op2 = (UINT64)((UINT32)Op2);
}
}
}
+
//
// Get operand1 (destination and sometimes also an actual operand)
// of form {@}R1
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
if (OPERAND1_INDIRECT (Operands)) {
if ((Opcode & DATAMANIP_M_64) != 0) {
- Op1 = VmReadMem64 (VmPtr, (UINTN) Op1);
+ Op1 = VmReadMem64 (VmPtr, (UINTN)Op1);
} else {
if (IsSignedOp) {
- Op1 = (UINT64) (INT64) ((INT32) VmReadMem32 (VmPtr, (UINTN) Op1));
+ Op1 = (UINT64)(INT64)((INT32)VmReadMem32 (VmPtr, (UINTN)Op1));
} else {
- Op1 = (UINT64) VmReadMem32 (VmPtr, (UINTN) Op1);
+ Op1 = (UINT64)VmReadMem32 (VmPtr, (UINTN)Op1);
}
}
} else {
if ((Opcode & DATAMANIP_M_64) == 0) {
if (IsSignedOp) {
- Op1 = (UINT64) (INT64) ((INT32) Op1);
+ Op1 = (UINT64)(INT64)((INT32)Op1);
} else {
- Op1 = (UINT64) ((UINT32) Op1);
+ Op1 = (UINT64)((UINT32)Op1);
}
}
}
+
//
// Dispatch to the computation function
//
DataManipDispatchTableIndex = (Opcode & OPCODE_M_OPCODE) - OPCODE_NOT;
if ((DataManipDispatchTableIndex < 0) ||
- (DataManipDispatchTableIndex >= ARRAY_SIZE (mDataManipDispatchTable))) {
+ (DataManipDispatchTableIndex >= ARRAY_SIZE (mDataManipDispatchTable)))
+ {
EbcDebugSignalException (
EXCEPT_EBC_INVALID_OPCODE,
EXCEPTION_FLAG_ERROR,
@@ -4263,15 +4307,16 @@ ExecuteDataManip (
} else {
Op2 = mDataManipDispatchTable[DataManipDispatchTableIndex](VmPtr, Op1, Op2);
}
+
//
// Write back the result.
//
if (OPERAND1_INDIRECT (Operands)) {
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
if ((Opcode & DATAMANIP_M_64) != 0) {
- VmWriteMem64 (VmPtr, (UINTN) Op1, Op2);
+ VmWriteMem64 (VmPtr, (UINTN)Op1, Op2);
} else {
- VmWriteMem32 (VmPtr, (UINTN) Op1, (UINT32) Op2);
+ VmWriteMem32 (VmPtr, (UINTN)Op1, (UINT32)Op2);
}
} else {
//
@@ -4283,6 +4328,7 @@ ExecuteDataManip (
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] &= 0xFFFFFFFF;
}
}
+
//
// Advance the instruction pointer
//
@@ -4290,7 +4336,6 @@ ExecuteDataManip (
return EFI_SUCCESS;
}
-
/**
Execute the EBC LOADSP instruction.
@@ -4305,10 +4350,10 @@ ExecuteDataManip (
**/
EFI_STATUS
ExecuteLOADSP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Operands;
+ UINT8 Operands;
//
// Get the operands
@@ -4319,32 +4364,31 @@ ExecuteLOADSP (
// Do the operation
//
switch (OPERAND1_REGNUM (Operands)) {
- //
- // Set flags
- //
- case 0:
//
- // Spec states that this instruction will not modify reserved bits in
- // the flags register.
+ // Set flags
//
- VmPtr->Flags = (VmPtr->Flags &~VMFLAGS_ALL_VALID) | (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] & VMFLAGS_ALL_VALID);
- break;
+ case 0:
+ //
+ // Spec states that this instruction will not modify reserved bits in
+ // the flags register.
+ //
+ VmPtr->Flags = (VmPtr->Flags &~VMFLAGS_ALL_VALID) | (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] & VMFLAGS_ALL_VALID);
+ break;
- default:
- EbcDebugSignalException (
- EXCEPT_EBC_INSTRUCTION_ENCODING,
- EXCEPTION_FLAG_WARNING,
- VmPtr
- );
- VmPtr->Ip += 2;
- return EFI_UNSUPPORTED;
+ default:
+ EbcDebugSignalException (
+ EXCEPT_EBC_INSTRUCTION_ENCODING,
+ EXCEPTION_FLAG_WARNING,
+ VmPtr
+ );
+ VmPtr->Ip += 2;
+ return EFI_UNSUPPORTED;
}
VmPtr->Ip += 2;
return EFI_SUCCESS;
}
-
/**
Execute the EBC STORESP instruction.
@@ -4359,10 +4403,10 @@ ExecuteLOADSP (
**/
EFI_STATUS
ExecuteSTORESP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Operands;
+ UINT8 Operands;
//
// Get the operands
@@ -4373,39 +4417,38 @@ ExecuteSTORESP (
// Do the operation
//
switch (OPERAND2_REGNUM (Operands)) {
- //
- // Get flags
- //
- case 0:
//
- // Retrieve the value in the flags register, then clear reserved bits
+ // Get flags
//
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64) (VmPtr->Flags & VMFLAGS_ALL_VALID);
- break;
+ case 0:
+ //
+ // Retrieve the value in the flags register, then clear reserved bits
+ //
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64)(VmPtr->Flags & VMFLAGS_ALL_VALID);
+ break;
- //
- // Get IP -- address of following instruction
- //
- case 1:
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64) (UINTN) VmPtr->Ip + 2;
- break;
+ //
+ // Get IP -- address of following instruction
+ //
+ case 1:
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64)(UINTN)VmPtr->Ip + 2;
+ break;
- default:
- EbcDebugSignalException (
- EXCEPT_EBC_INSTRUCTION_ENCODING,
- EXCEPTION_FLAG_WARNING,
- VmPtr
- );
- VmPtr->Ip += 2;
- return EFI_UNSUPPORTED;
- break;
+ default:
+ EbcDebugSignalException (
+ EXCEPT_EBC_INSTRUCTION_ENCODING,
+ EXCEPTION_FLAG_WARNING,
+ VmPtr
+ );
+ VmPtr->Ip += 2;
+ return EFI_UNSUPPORTED;
+ break;
}
VmPtr->Ip += 2;
return EFI_SUCCESS;
}
-
/**
Decode a 16-bit index to determine the offset. Given an index value:
@@ -4430,8 +4473,8 @@ ExecuteSTORESP (
**/
INT16
VmReadIndex16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
)
{
UINT16 Index;
@@ -4449,7 +4492,7 @@ VmReadIndex16 (
//
// Get the mask for NaturalUnits. First get the number of bits from the index.
//
- NBits = (INT16) ((Index & 0x7000) >> 12);
+ NBits = (INT16)((Index & 0x7000) >> 12);
//
// Scale it for 16-bit indexes
@@ -4459,19 +4502,19 @@ VmReadIndex16 (
//
// Now using the number of bits, create a mask.
//
- Mask = (INT16) ((INT16)~0 << NBits);
+ Mask = (INT16)((INT16) ~0 << NBits);
//
// Now using the mask, extract NaturalUnits from the lower bits of the index.
//
- NaturalUnits = (INT16) (Index &~Mask);
+ NaturalUnits = (INT16)(Index &~Mask);
//
// Now compute ConstUnits
//
- ConstUnits = (INT16) (((Index &~0xF000) & Mask) >> NBits);
+ ConstUnits = (INT16)(((Index &~0xF000) & Mask) >> NBits);
- Offset = (INT16) (NaturalUnits * sizeof (UINTN) + ConstUnits);
+ Offset = (INT16)(NaturalUnits * sizeof (UINTN) + ConstUnits);
//
// Now set the sign
@@ -4482,13 +4525,12 @@ VmReadIndex16 (
//
// Offset = -1 * Offset;
//
- Offset = (INT16) ((INT32) Offset * -1);
+ Offset = (INT16)((INT32)Offset * -1);
}
return Offset;
}
-
/**
Decode a 32-bit index to determine the offset.
@@ -4501,8 +4543,8 @@ VmReadIndex16 (
**/
INT32
VmReadIndex32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
)
{
UINT32 Index;
@@ -4527,7 +4569,7 @@ VmReadIndex32 (
//
// Now using the number of bits, create a mask.
//
- Mask = (INT32)~0 << NBits;
+ Mask = (INT32) ~0 << NBits;
//
// Now using the mask, extract NaturalUnits from the lower bits of the index.
@@ -4537,9 +4579,9 @@ VmReadIndex32 (
//
// Now compute ConstUnits
//
- ConstUnits = ((Index &~0xF0000000) & Mask) >> NBits;
+ ConstUnits = ((Index &~0xF0000000) & Mask) >> NBits;
- Offset = NaturalUnits * sizeof (UINTN) + ConstUnits;
+ Offset = NaturalUnits * sizeof (UINTN) + ConstUnits;
//
// Now set the sign
@@ -4551,7 +4593,6 @@ VmReadIndex32 (
return Offset;
}
-
/**
Decode a 64-bit index to determine the offset.
@@ -4564,8 +4605,8 @@ VmReadIndex32 (
**/
INT64
VmReadIndex64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
)
{
UINT64 Index;
@@ -4590,7 +4631,7 @@ VmReadIndex64 (
//
// Now using the number of bits, create a mask.
//
- Mask = (LShiftU64 ((UINT64)~0, (UINTN)NBits));
+ Mask = (LShiftU64 ((UINT64) ~0, (UINTN)NBits));
//
// Now using the mask, extract NaturalUnits from the lower bits of the index.
@@ -4602,7 +4643,7 @@ VmReadIndex64 (
//
ConstUnits = ARShiftU64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN)NBits);
- Offset = MultU64x64 ((UINT64) NaturalUnits, sizeof (UINTN)) + ConstUnits;
+ Offset = MultU64x64 ((UINT64)NaturalUnits, sizeof (UINTN)) + ConstUnits;
//
// Now set the sign
@@ -4614,7 +4655,6 @@ VmReadIndex64 (
return Offset;
}
-
/**
Writes 8-bit data to memory address.
@@ -4640,16 +4680,16 @@ VmReadIndex64 (
**/
EFI_STATUS
VmWriteMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT8 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT8 Data
)
{
//
// Convert the address if it's in the stack gap
//
- Addr = ConvertStackAddr (VmPtr, Addr);
- *(UINT8 *) Addr = Data;
+ Addr = ConvertStackAddr (VmPtr, Addr);
+ *(UINT8 *)Addr = Data;
return EFI_SUCCESS;
}
@@ -4678,9 +4718,9 @@ VmWriteMem8 (
**/
EFI_STATUS
VmWriteMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT16 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT16 Data
)
{
EFI_STATUS Status;
@@ -4694,18 +4734,18 @@ VmWriteMem16 (
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT16))) {
- *(UINT16 *) Addr = Data;
+ *(UINT16 *)Addr = Data;
} else {
//
// Write as two bytes
//
MemoryFence ();
- if ((Status = VmWriteMem8 (VmPtr, Addr, (UINT8) Data)) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem8 (VmPtr, Addr, (UINT8)Data)) != EFI_SUCCESS) {
return Status;
}
MemoryFence ();
- if ((Status = VmWriteMem8 (VmPtr, Addr + 1, (UINT8) (Data >> 8))) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem8 (VmPtr, Addr + 1, (UINT8)(Data >> 8))) != EFI_SUCCESS) {
return Status;
}
@@ -4715,7 +4755,6 @@ VmWriteMem16 (
return EFI_SUCCESS;
}
-
/**
Writes 32-bit data to memory address.
@@ -4741,9 +4780,9 @@ VmWriteMem16 (
**/
EFI_STATUS
VmWriteMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT32 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT32 Data
)
{
EFI_STATUS Status;
@@ -4757,18 +4796,18 @@ VmWriteMem32 (
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT32))) {
- *(UINT32 *) Addr = Data;
+ *(UINT32 *)Addr = Data;
} else {
//
// Write as two words
//
MemoryFence ();
- if ((Status = VmWriteMem16 (VmPtr, Addr, (UINT16) Data)) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem16 (VmPtr, Addr, (UINT16)Data)) != EFI_SUCCESS) {
return Status;
}
MemoryFence ();
- if ((Status = VmWriteMem16 (VmPtr, Addr + sizeof (UINT16), (UINT16) (Data >> 16))) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem16 (VmPtr, Addr + sizeof (UINT16), (UINT16)(Data >> 16))) != EFI_SUCCESS) {
return Status;
}
@@ -4778,7 +4817,6 @@ VmWriteMem32 (
return EFI_SUCCESS;
}
-
/**
Writes 64-bit data to memory address.
@@ -4804,9 +4842,9 @@ VmWriteMem32 (
**/
EFI_STATUS
VmWriteMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT64 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT64 Data
)
{
EFI_STATUS Status;
@@ -4820,18 +4858,18 @@ VmWriteMem64 (
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT64))) {
- *(UINT64 *) Addr = Data;
+ *(UINT64 *)Addr = Data;
} else {
//
// Write as two 32-bit words
//
MemoryFence ();
- if ((Status = VmWriteMem32 (VmPtr, Addr, (UINT32) Data)) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem32 (VmPtr, Addr, (UINT32)Data)) != EFI_SUCCESS) {
return Status;
}
MemoryFence ();
- if ((Status = VmWriteMem32 (VmPtr, Addr + sizeof (UINT32), (UINT32) RShiftU64(Data, 32))) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem32 (VmPtr, Addr + sizeof (UINT32), (UINT32)RShiftU64 (Data, 32))) != EFI_SUCCESS) {
return Status;
}
@@ -4841,7 +4879,6 @@ VmWriteMem64 (
return EFI_SUCCESS;
}
-
/**
Writes UINTN data to memory address.
@@ -4867,9 +4904,9 @@ VmWriteMem64 (
**/
EFI_STATUS
VmWriteMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINTN Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINTN Data
)
{
EFI_STATUS Status;
@@ -4886,20 +4923,19 @@ VmWriteMemN (
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINTN))) {
- *(UINTN *) Addr = Data;
+ *(UINTN *)Addr = Data;
} else {
for (Index = 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) {
MemoryFence ();
- Status = VmWriteMem32 (VmPtr, Addr + Index * sizeof (UINT32), (UINT32) Data);
+ Status = VmWriteMem32 (VmPtr, Addr + Index * sizeof (UINT32), (UINT32)Data);
MemoryFence ();
- Data = (UINTN) RShiftU64 ((UINT64)Data, 32);
+ Data = (UINTN)RShiftU64 ((UINT64)Data, 32);
}
}
return Status;
}
-
/**
Reads 8-bit immediate value at the offset.
@@ -4916,14 +4952,14 @@ VmWriteMemN (
**/
INT8
VmReadImmed8 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
//
// Simply return the data in flat memory space
//
- return * (INT8 *) (VmPtr->Ip + Offset);
+ return *(INT8 *)(VmPtr->Ip + Offset);
}
/**
@@ -4942,15 +4978,15 @@ VmReadImmed8 (
**/
INT16
VmReadImmed16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (INT16))) {
- return * (INT16 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) {
+ return *(INT16 *)(VmPtr->Ip + Offset);
} else {
//
// All code word reads should be aligned
@@ -4961,13 +4997,13 @@ VmReadImmed16 (
VmPtr
);
}
+
//
// Return unaligned data
//
- return (INT16) (*(UINT8 *) (VmPtr->Ip + Offset) + (*(UINT8 *) (VmPtr->Ip + Offset + 1) << 8));
+ return (INT16)(*(UINT8 *)(VmPtr->Ip + Offset) + (*(UINT8 *)(VmPtr->Ip + Offset + 1) << 8));
}
-
/**
Reads 32-bit immediate value at the offset.
@@ -4984,8 +5020,8 @@ VmReadImmed16 (
**/
INT32
VmReadImmed32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT32 Data;
@@ -4993,18 +5029,18 @@ VmReadImmed32 (
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT32))) {
- return * (INT32 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
+ return *(INT32 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data
//
- Data = (UINT32) VmReadCode16 (VmPtr, Offset);
+ Data = (UINT32)VmReadCode16 (VmPtr, Offset);
Data |= (UINT32)(VmReadCode16 (VmPtr, Offset + 2) << 16);
return Data;
}
-
/**
Reads 64-bit immediate value at the offset.
@@ -5021,8 +5057,8 @@ VmReadImmed32 (
**/
INT64
VmReadImmed64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT64 Data64;
@@ -5032,22 +5068,22 @@ VmReadImmed64 (
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT64))) {
- return * (UINT64 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
+ return *(UINT64 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data.
//
- Ptr = (UINT8 *) &Data64;
- Data32 = VmReadCode32 (VmPtr, Offset);
- *(UINT32 *) Ptr = Data32;
- Ptr += sizeof (Data32);
- Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
- *(UINT32 *) Ptr = Data32;
+ Ptr = (UINT8 *)&Data64;
+ Data32 = VmReadCode32 (VmPtr, Offset);
+ *(UINT32 *)Ptr = Data32;
+ Ptr += sizeof (Data32);
+ Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
+ *(UINT32 *)Ptr = Data32;
return Data64;
}
-
/**
Reads 16-bit unsigned data from the code stream.
@@ -5062,15 +5098,15 @@ VmReadImmed64 (
**/
UINT16
VmReadCode16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT16))) {
- return * (UINT16 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) {
+ return *(UINT16 *)(VmPtr->Ip + Offset);
} else {
//
// All code word reads should be aligned
@@ -5081,13 +5117,13 @@ VmReadCode16 (
VmPtr
);
}
+
//
// Return unaligned data
//
- return (UINT16) (*(UINT8 *) (VmPtr->Ip + Offset) + (*(UINT8 *) (VmPtr->Ip + Offset + 1) << 8));
+ return (UINT16)(*(UINT8 *)(VmPtr->Ip + Offset) + (*(UINT8 *)(VmPtr->Ip + Offset + 1) << 8));
}
-
/**
Reads 32-bit unsigned data from the code stream.
@@ -5102,26 +5138,27 @@ VmReadCode16 (
**/
UINT32
VmReadCode32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT32 Data;
+
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT32))) {
- return * (UINT32 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
+ return *(UINT32 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data
//
- Data = (UINT32) VmReadCode16 (VmPtr, Offset);
+ Data = (UINT32)VmReadCode16 (VmPtr, Offset);
Data |= (VmReadCode16 (VmPtr, Offset + 2) << 16);
return Data;
}
-
/**
Reads 64-bit unsigned data from the code stream.
@@ -5136,8 +5173,8 @@ VmReadCode32 (
**/
UINT64
VmReadCode64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT64 Data64;
@@ -5147,22 +5184,22 @@ VmReadCode64 (
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT64))) {
- return * (UINT64 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
+ return *(UINT64 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data.
//
- Ptr = (UINT8 *) &Data64;
- Data32 = VmReadCode32 (VmPtr, Offset);
- *(UINT32 *) Ptr = Data32;
- Ptr += sizeof (Data32);
- Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
- *(UINT32 *) Ptr = Data32;
+ Ptr = (UINT8 *)&Data64;
+ Data32 = VmReadCode32 (VmPtr, Offset);
+ *(UINT32 *)Ptr = Data32;
+ Ptr += sizeof (Data32);
+ Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
+ *(UINT32 *)Ptr = Data32;
return Data64;
}
-
/**
Reads 8-bit data form the memory address.
@@ -5174,8 +5211,8 @@ VmReadCode64 (
**/
UINT8
VmReadMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
//
@@ -5185,7 +5222,7 @@ VmReadMem8 (
//
// Simply return the data in flat memory space
//
- return * (UINT8 *) Addr;
+ return *(UINT8 *)Addr;
}
/**
@@ -5199,8 +5236,8 @@ VmReadMem8 (
**/
UINT16
VmReadMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
//
@@ -5211,12 +5248,13 @@ VmReadMem16 (
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT16))) {
- return * (UINT16 *) Addr;
+ return *(UINT16 *)Addr;
}
+
//
// Return unaligned data
//
- return (UINT16) (*(UINT8 *) Addr + (*(UINT8 *) (Addr + 1) << 8));
+ return (UINT16)(*(UINT8 *)Addr + (*(UINT8 *)(Addr + 1) << 8));
}
/**
@@ -5230,8 +5268,8 @@ VmReadMem16 (
**/
UINT32
VmReadMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
UINT32 Data;
@@ -5244,12 +5282,13 @@ VmReadMem32 (
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT32))) {
- return * (UINT32 *) Addr;
+ return *(UINT32 *)Addr;
}
+
//
// Return unaligned data
//
- Data = (UINT32) VmReadMem16 (VmPtr, Addr);
+ Data = (UINT32)VmReadMem16 (VmPtr, Addr);
Data |= (VmReadMem16 (VmPtr, Addr + 2) << 16);
return Data;
}
@@ -5265,8 +5304,8 @@ VmReadMem32 (
**/
UINT64
VmReadMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
UINT64 Data;
@@ -5281,18 +5320,18 @@ VmReadMem64 (
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT64))) {
- return * (UINT64 *) Addr;
+ return *(UINT64 *)Addr;
}
+
//
// Return unaligned data. Assume little endian.
//
Data32 = VmReadMem32 (VmPtr, Addr);
- Data = (UINT64) VmReadMem32 (VmPtr, Addr + sizeof (UINT32));
- Data = LShiftU64 (Data, 32) | Data32;
+ Data = (UINT64)VmReadMem32 (VmPtr, Addr + sizeof (UINT32));
+ Data = LShiftU64 (Data, 32) | Data32;
return Data;
}
-
/**
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.
@@ -5314,15 +5353,14 @@ VmReadMem64 (
**/
UINTN
ConvertStackAddr (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
- ASSERT(((Addr < VmPtr->LowStackTop) || (Addr > VmPtr->HighStackBottom)));
+ ASSERT (((Addr < VmPtr->LowStackTop) || (Addr > VmPtr->HighStackBottom)));
return Addr;
}
-
/**
Read a natural value from memory. May or may not be aligned.
@@ -5334,14 +5372,15 @@ ConvertStackAddr (
**/
UINTN
VmReadMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
- UINTN Data;
+ UINTN Data;
volatile UINT32 Size;
- UINT8 *FromPtr;
- UINT8 *ToPtr;
+ UINT8 *FromPtr;
+ UINT8 *ToPtr;
+
//
// Convert the address if it's in the stack gap
//
@@ -5350,14 +5389,15 @@ VmReadMemN (
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINTN))) {
- return * (UINTN *) Addr;
+ return *(UINTN *)Addr;
}
+
//
// Return unaligned data
//
Data = 0;
- FromPtr = (UINT8 *) Addr;
- ToPtr = (UINT8 *) &Data;
+ FromPtr = (UINT8 *)Addr;
+ ToPtr = (UINT8 *)&Data;
for (Size = 0; Size < sizeof (Data); Size++) {
*ToPtr = *FromPtr;
@@ -5379,5 +5419,5 @@ GetVmVersion (
VOID
)
{
- return (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)));
+ return (UINT64)(((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)));
}