]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EbcDxe/EbcExecute.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcExecute.h
index 88bf9d5843a81575375cb31e5db519eacdba9594..b7489514b919c51c9fe7d916377b3d434116d765 100644 (file)
@@ -3,8 +3,8 @@
   be of use to a disassembler for the most part. Also provides function\r
   prototypes for VM functions.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -17,215 +17,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _EBC_EXECUTE_H_\r
 #define _EBC_EXECUTE_H_\r
 \r
-//\r
-// VM major/minor version\r
-//\r
-#define VM_MAJOR_VERSION  1\r
-#define VM_MINOR_VERSION  0\r
-\r
 //\r
 // Macros to check and set alignment\r
 //\r
 #define ASSERT_ALIGNED(addr, size)  ASSERT (!((UINT32) (addr) & (size - 1)))\r
 #define IS_ALIGNED(addr, size)      !((UINT32) (addr) & (size - 1))\r
 \r
-//\r
-// Define a macro to get the operand. Then we can change it to be either a\r
-// direct read or have it call a function to read memory.\r
-//\r
-#define GETOPERANDS(pVM)  (UINT8) (*(UINT8 *) (pVM->Ip + 1))\r
-#define GETOPCODE(pVM)    (UINT8) (*(UINT8 *) pVM->Ip)\r
-\r
-//\r
-// Bit masks for opcode encodings\r
-//\r
-#define OPCODE_M_OPCODE       0x3F  // bits of interest for first level decode\r
-#define OPCODE_M_IMMDATA      0x80\r
-#define OPCODE_M_IMMDATA64    0x40\r
-#define OPCODE_M_64BIT        0x40  // for CMP\r
-#define OPCODE_M_RELADDR      0x10  // for CALL instruction\r
-#define OPCODE_M_CMPI32_DATA  0x80  // for CMPI\r
-#define OPCODE_M_CMPI64       0x40  // for CMPI 32 or 64 bit comparison\r
-#define OPERAND_M_MOVIN_N     0x80\r
-#define OPERAND_M_CMPI_INDEX  0x10\r
-\r
-//\r
-// Masks for instructions that encode presence of indexes for operand1 and/or\r
-// operand2.\r
-//\r
-#define OPCODE_M_IMMED_OP1  0x80\r
-#define OPCODE_M_IMMED_OP2  0x40\r
-\r
-//\r
-// Bit masks for operand encodings\r
-//\r
-#define OPERAND_M_INDIRECT1 0x08\r
-#define OPERAND_M_INDIRECT2 0x80\r
-#define OPERAND_M_OP1       0x07\r
-#define OPERAND_M_OP2       0x70\r
-\r
-//\r
-// Masks for data manipulation instructions\r
-//\r
-#define DATAMANIP_M_64      0x40  // 64-bit width operation\r
-#define DATAMANIP_M_IMMDATA 0x80\r
-\r
-//\r
-// For MOV instructions, need a mask for the opcode when immediate\r
-// data applies to R2.\r
-//\r
-#define OPCODE_M_IMMED_OP2  0x40\r
-\r
-//\r
-// The MOVI/MOVIn instructions use bit 6 of operands byte to indicate\r
-// if an index is present. Then bits 4 and 5 are used to indicate the width\r
-// of the move.\r
-//\r
-#define MOVI_M_IMMDATA    0x40\r
-#define MOVI_M_DATAWIDTH  0xC0\r
-#define MOVI_DATAWIDTH16  0x40\r
-#define MOVI_DATAWIDTH32  0x80\r
-#define MOVI_DATAWIDTH64  0xC0\r
-#define MOVI_M_MOVEWIDTH  0x30\r
-#define MOVI_MOVEWIDTH8   0x00\r
-#define MOVI_MOVEWIDTH16  0x10\r
-#define MOVI_MOVEWIDTH32  0x20\r
-#define MOVI_MOVEWIDTH64  0x30\r
-\r
-//\r
-// Masks for CALL instruction encodings\r
-//\r
-#define OPERAND_M_RELATIVE_ADDR 0x10\r
-#define OPERAND_M_NATIVE_CALL   0x20\r
-\r
-//\r
-// Masks for decoding push/pop instructions\r
-//\r
-#define PUSHPOP_M_IMMDATA 0x80  // opcode bit indicating immediate data\r
-#define PUSHPOP_M_64      0x40  // opcode bit indicating 64-bit operation\r
-//\r
-// Mask for operand of JMP instruction\r
-//\r
-#define JMP_M_RELATIVE    0x10\r
-#define JMP_M_CONDITIONAL 0x80\r
-#define JMP_M_CS          0x40\r
-\r
-//\r
-// Macros to determine if a given operand is indirect\r
-//\r
-#define OPERAND1_INDIRECT(op) ((op) & OPERAND_M_INDIRECT1)\r
-#define OPERAND2_INDIRECT(op) ((op) & OPERAND_M_INDIRECT2)\r
-\r
-//\r
-// Macros to extract the operands from second byte of instructions\r
-//\r
-#define OPERAND1_REGNUM(op)       ((op) & OPERAND_M_OP1)\r
-#define OPERAND2_REGNUM(op)       (((op) & OPERAND_M_OP2) >> 4)\r
-\r
-#define OPERAND1_CHAR(op)         ('0' + OPERAND1_REGNUM (op))\r
-#define OPERAND2_CHAR(op)         ('0' + OPERAND2_REGNUM (op))\r
-\r
-#define OPERAND1_REGDATA(pvm, op) pvm->R[OPERAND1_REGNUM (op)]\r
-#define OPERAND2_REGDATA(pvm, op) pvm->R[OPERAND2_REGNUM (op)]\r
-\r
-//\r
-// Condition masks usually for byte 1 encodings of code\r
-//\r
-#define CONDITION_M_CONDITIONAL 0x80\r
-#define CONDITION_M_CS          0x40\r
-\r
-//\r
-// Bits in the VM->StopFlags field\r
-//\r
-#define STOPFLAG_APP_DONE         0x0001\r
-#define STOPFLAG_BREAKPOINT       0x0002\r
-#define STOPFLAG_INVALID_BREAK    0x0004\r
-#define STOPFLAG_BREAK_ON_CALLEX  0x0008\r
-\r
-//\r
-// Masks for working with the VM flags register\r
-//\r
-#define VMFLAGS_CC        0x0001  // condition flag\r
-#define VMFLAGS_STEP      0x0002  // step instruction mode\r
-#define VMFLAGS_ALL_VALID (VMFLAGS_CC | VMFLAGS_STEP)\r
-\r
-//\r
-// Macros for operating on the VM flags register\r
-//\r
-#define VMFLAG_SET(pVM, Flag)   (pVM->Flags |= (Flag))\r
-#define VMFLAG_ISSET(pVM, Flag) ((pVM->Flags & (Flag)) ? 1 : 0)\r
-#define VMFLAG_CLEAR(pVM, Flag) (pVM->Flags &= ~(Flag))\r
-\r
 //\r
 // Debug macro\r
 //\r
 #define EBCMSG(s) gST->ConOut->OutputString (gST->ConOut, s)\r
 \r
-//\r
-// Define OPCODES\r
-//\r
-#define OPCODE_BREAK    0x00\r
-#define OPCODE_JMP      0x01\r
-#define OPCODE_JMP8     0x02\r
-#define OPCODE_CALL     0x03\r
-#define OPCODE_RET      0x04\r
-#define OPCODE_CMPEQ    0x05\r
-#define OPCODE_CMPLTE   0x06\r
-#define OPCODE_CMPGTE   0x07\r
-#define OPCODE_CMPULTE  0x08\r
-#define OPCODE_CMPUGTE  0x09\r
-#define OPCODE_NOT      0x0A\r
-#define OPCODE_NEG      0x0B\r
-#define OPCODE_ADD      0x0C\r
-#define OPCODE_SUB      0x0D\r
-#define OPCODE_MUL      0x0E\r
-#define OPCODE_MULU     0x0F\r
-#define OPCODE_DIV      0x10\r
-#define OPCODE_DIVU     0x11\r
-#define OPCODE_MOD      0x12\r
-#define OPCODE_MODU     0x13\r
-#define OPCODE_AND      0x14\r
-#define OPCODE_OR       0x15\r
-#define OPCODE_XOR      0x16\r
-#define OPCODE_SHL      0x17\r
-#define OPCODE_SHR      0x18\r
-#define OPCODE_ASHR     0x19\r
-#define OPCODE_EXTNDB   0x1A\r
-#define OPCODE_EXTNDW   0x1B\r
-#define OPCODE_EXTNDD   0x1C\r
-#define OPCODE_MOVBW    0x1D\r
-#define OPCODE_MOVWW    0x1E\r
-#define OPCODE_MOVDW    0x1F\r
-#define OPCODE_MOVQW    0x20\r
-#define OPCODE_MOVBD    0x21\r
-#define OPCODE_MOVWD    0x22\r
-#define OPCODE_MOVDD    0x23\r
-#define OPCODE_MOVQD    0x24\r
-#define OPCODE_MOVSNW   0x25  // Move signed natural with word index\r
-#define OPCODE_MOVSND   0x26  // Move signed natural with dword index\r
-//\r
-// #define OPCODE_27         0x27\r
-//\r
-#define OPCODE_MOVQQ    0x28  // Does this go away?\r
-#define OPCODE_LOADSP   0x29\r
-#define OPCODE_STORESP  0x2A\r
-#define OPCODE_PUSH     0x2B\r
-#define OPCODE_POP      0x2C\r
-#define OPCODE_CMPIEQ   0x2D\r
-#define OPCODE_CMPILTE  0x2E\r
-#define OPCODE_CMPIGTE  0x2F\r
-#define OPCODE_CMPIULTE 0x30\r
-#define OPCODE_CMPIUGTE 0x31\r
-#define OPCODE_MOVNW    0x32\r
-#define OPCODE_MOVND    0x33\r
-//\r
-// #define OPCODE_34         0x34\r
-//\r
-#define OPCODE_PUSHN  0x35\r
-#define OPCODE_POPN   0x36\r
-#define OPCODE_MOVI   0x37\r
-#define OPCODE_MOVIN  0x38\r
-#define OPCODE_MOVREL 0x39\r
 \r
 /**\r
   Execute an EBC image from an entry point or from a published protocol.\r
@@ -270,7 +72,7 @@ GetVmVersion (
   VM stack) to point into the EBC entry point arguments.\r
 \r
   @param  VmPtr             A pointer to a VM context.\r
-  @param  Addr              Adddress to write to.\r
+  @param  Addr              Address to write to.\r
   @param  Data              Value to write to Addr.\r
 \r
   @retval EFI_SUCCESS       The instruction is executed successfully.\r
@@ -300,7 +102,7 @@ VmWriteMemN (
   VM stack) to point into the EBC entry point arguments.\r
 \r
   @param  VmPtr             A pointer to a VM context.\r
-  @param  Addr              Adddress to write to.\r
+  @param  Addr              Address to write to.\r
   @param  Data              Value to write to Addr.\r
 \r
   @retval EFI_SUCCESS       The instruction is executed successfully.\r
@@ -314,54 +116,6 @@ VmWriteMem64 (
   IN UINT64       Data\r
   );\r
 \r
-//\r
-// Define a protocol for an EBC VM test interface.\r
-//\r
-#define EFI_EBC_VM_TEST_PROTOCOL_GUID \\r
-  { \\r
-    0xAAEACCFDL, 0xF27B, 0x4C17, { 0xB6, 0x10, 0x75, 0xCA, 0x1F, 0x2D, 0xFB, 0x52 } \\r
-  }\r
-\r
-//\r
-// Define for forward reference.\r
-//\r
-typedef struct _EFI_EBC_VM_TEST_PROTOCOL EFI_EBC_VM_TEST_PROTOCOL;\r
-\r
-typedef\r
-EFI_STATUS\r
-(*EBC_VM_TEST_EXECUTE) (\r
-  IN EFI_EBC_VM_TEST_PROTOCOL         * This,\r
-  IN VM_CONTEXT                       * VmPtr,\r
-  IN OUT UINTN                        *InstructionCount\r
-  );\r
-\r
-typedef\r
-EFI_STATUS\r
-(*EBC_VM_TEST_ASM) (\r
-  IN EFI_EBC_VM_TEST_PROTOCOL         * This,\r
-  IN CHAR16                           *AsmText,\r
-  IN OUT INT8                         *Buffer,\r
-  IN OUT UINTN                        *BufferLen\r
-  );\r
-\r
-typedef\r
-EFI_STATUS\r
-(*EBC_VM_TEST_DASM) (\r
-  IN EFI_EBC_VM_TEST_PROTOCOL         * This,\r
-  IN OUT CHAR16                       *AsmText,\r
-  IN OUT INT8                         *Buffer,\r
-  IN OUT UINTN                        *Len\r
-  );\r
-\r
-//\r
-// Prototype for the actual EBC test protocol interface\r
-//\r
-struct _EFI_EBC_VM_TEST_PROTOCOL {\r
-  EBC_VM_TEST_EXECUTE Execute;\r
-  EBC_VM_TEST_ASM     Assemble;\r
-  EBC_VM_TEST_DASM    Disassemble;\r
-};\r
-\r
 /**\r
   Given a pointer to a new VM context, execute one or more instructions. This\r
   function is only used for test purposes via the EBC VM test protocol.\r
@@ -377,6 +131,7 @@ struct _EFI_EBC_VM_TEST_PROTOCOL {
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 EbcExecuteInstructions (\r
   IN EFI_EBC_VM_TEST_PROTOCOL *This,\r
   IN VM_CONTEXT               *VmPtr,\r