]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Protocol/Ebc.h
MdePkg/Include/Protocol/Tls.h: pack structures from the TLS RFC
[mirror_edk2.git] / MdePkg / Include / Protocol / Ebc.h
index 7710b2144e086502b6e8d4e49b5c9b7262a97096..0fcb82bce85b10aa7f2e77e9aedf4350f7edc2f8 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Describes the protocol interface to the EBC interpreter.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
+  Copyright (c) 2006 - 2008, 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
   }\r
 \r
 //\r
-// Protocol Guid Name defined in spec.\r
+// Define OPCODES\r
 //\r
-#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID\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
+// 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
-// Define for forward reference.\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
+//\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
+/// Protocol Guid Name defined in spec.\r
+///\r
+#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID\r
+\r
+///\r
+/// Define for forward reference.\r
+///\r
 typedef struct _EFI_EBC_PROTOCOL EFI_EBC_PROTOCOL;\r
 \r
 /**\r
   Creates a thunk for an EBC entry point, returning the address of the thunk.\r
   \r
   A PE32+ EBC image, like any other PE32+ image, contains an optional header that specifies the\r
-  entry point for image execution. However for EBC images this is the entry point of EBC\r
-  instructions, so is not directly executable by the native processor. Therefore when an EBC image is\r
-  loaded, the loader must call this service to get a pointer to native code (thunk) that can be executed\r
+  entry point for image execution. However, for EBC images, this is the entry point of EBC\r
+  instructions, so is not directly executable by the native processor. Therefore, when an EBC image is\r
+  loaded, the loader must call this service to get a pointer to native code (thunk) that can be executed,\r
   which will invoke the interpreter to begin execution at the original EBC entry point.\r
 \r
   @param  This          A pointer to the EFI_EBC_PROTOCOL instance.\r
@@ -96,9 +257,8 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  This routine is called by the core firmware to provide the EBC driver with\r
-  a function to call to flush the CPU's instruction cache following creation\r
-  of a thunk. It is not required.\r
+  Registers a callback function that the EBC interpreter calls to flush \r
+  the processor instruction cache following creation of thunks.\r
 \r
   @param  This       A pointer to the EFI_EBC_PROTOCOL instance.\r
   @param  Flush      Pointer to a function of type EBC_ICACH_FLUSH.\r
@@ -120,7 +280,7 @@ EFI_STATUS
   returned version is identical to that returned by the EBC BREAK 1 instruction.\r
 \r
   @param  This       A pointer to the EFI_EBC_PROTOCOL instance.  \r
-  @param  Version Pointer to where to store the returned version of the interpreter.\r
+  @param  Version    Pointer to where to store the returned version of the interpreter.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
   @retval EFI_INVALID_PARAMETER  Version pointer is NULL.\r
@@ -133,34 +293,12 @@ EFI_STATUS
   IN OUT UINT64                 *Version\r
   );\r
 \r
-//\r
-// Prototype for the actual EBC protocol interface\r
-//\r
-/**\r
-  This protocol provides the services that allow execution of EBC images.\r
-\r
-  @par Protocol Description:\r
-  The EFI EBC protocol provides services to load and execute EBC images, which will typically be\r
-  loaded into option ROMs. The image loader will load the EBC image, perform standard relocations,\r
-  and invoke the CreateThunk() service to create a thunk for the EBC image's entry point. The\r
-  image can then be run using the standard EFI start image services.\r
-\r
-  @param CreateThunk \r
-  Creates a thunk for an EBC image entry point or protocol service,\r
-  and returns a pointer to the thunk. \r
-  \r
-  @param UnloadImage \r
-  Called when an EBC image is unloaded to allow the interpreter to\r
-  perform any cleanup associated with the image execution. \r
-  \r
-  @param RegisterICacheFlush\r
-  Called to register a callback function that the EBC interpreter can\r
-  call to flush the processor instruction cache after creating thunks.\r
-  \r
-  @param GetVersion \r
-  Called to get the version of the associated EBC interpreter.\r
-\r
-**/\r
+///\r
+/// The EFI EBC protocol provides services to load and execute EBC images, which will typically be\r
+/// loaded into option ROMs. The image loader will load the EBC image, perform standard relocations,\r
+/// and invoke the CreateThunk() service to create a thunk for the EBC image's entry point. The\r
+/// image can then be run using the standard EFI start image services.\r
+///\r
 struct _EFI_EBC_PROTOCOL {\r
   EFI_EBC_CREATE_THUNK          CreateThunk;\r
   EFI_EBC_UNLOAD_IMAGE          UnloadImage;\r