Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h	(revision 65902)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h	(revision 65903)
@@ -86,5 +86,5 @@
 } BS3CG1INSTR;
 AssertCompileSize(BS3CG1INSTR, 16);
-/** Pointer to a const test. */
+/** Pointer to a const instruction. */
 typedef BS3CG1INSTR const BS3_FAR *PCBS3CG1INSTR;
 
@@ -96,12 +96,215 @@
 
 
+/**
+ * Test header.
+ */
 typedef struct BS3CG1TESTHDR
 {
-    /** Number of tests left for this instruction. */
-    uint16_t    cLeft;
-    /** The size of this test. */
-    uint16_t    cbTest;
+    /** The size of the selector program in bytes.
+     * This is also the offset of the input context modification program.  */
+    uint32_t    cbSelector : 9;
+    /** The size of the input context modification program in bytes.
+     * This immediately follows the selector program.  */
+    uint32_t    cbInput    : 11;
+    /** The size of the output context modification program in bytes.
+     * This immediately follows the input context modification program.  The
+     * program takes the result of the input program as starting point. */
+    uint32_t    cbOutput   : 11;
+    /** Indicates whether this is the last test or not. */
+    uint32_t    fLast      : 1;
 } BS3CG1TESTHDR;
-
+AssertCompileSize(BS3CG1TESTHDR, 4);
+/** Pointer to a const test header. */
+typedef BS3CG1TESTHDR const BS3_FAR *PCBS3CG1TESTHDR;
+
+/** @name Opcode format for the BS3CG1 context modifier.
+ *
+ * Used by both the input and output context programs.
+ *
+ * The most common operations are encoded as a single byte opcode followed by
+ * one or more immediate bytes with data.
+ *
+ * @{ */
+#define BS3CG1_CTXOP_SIZE_MASK      UINT8_C(0x07)
+#define BS3CG1_CTXOP_1_BYTE         UINT8_C(0x00)
+#define BS3CG1_CTXOP_2_BYTE         UINT8_C(0x01)
+#define BS3CG1_CTXOP_4_BYTE         UINT8_C(0x02)
+#define BS3CG1_CTXOP_8_BYTE         UINT8_C(0x03)
+#define BS3CG1_CTXOP_16_BYTE        UINT8_C(0x04)
+#define BS3CG1_CTXOP_32_BYTE        UINT8_C(0x05)
+#define BS3CG1_CTXOP_12_BYTE        UINT8_C(0x06)
+#define BS3CG1_CTXOP_SIZE_ESC       UINT8_C(0x07)   /**< Separate byte encoding the value size follows immediately. */
+
+#define BS3CG1_CTXOP_DST_MASK       UINT8_C(0x18)
+#define BS3CG1_CTXOP_OP1            UINT8_C(0x00)
+#define BS3CG1_CTXOP_OP2            UINT8_C(0x08)
+#define BS3CG1_CTXOP_EFL            UINT8_C(0x10)
+#define BS3CG1_CTXOP_DST_ESC        UINT8_C(0x18)   /**< Separate byte giving the destination follows after any size byte.*/
+
+#define BS3CG1_CTXOP_SIGN_EXT       UINT8_C(0x20)   /**< Whether to sign-extend (set) the immediate value. */
+
+#define BS3CG1_CTXOP_OPERATOR_MASK  UINT8_C(0xc0)
+#define BS3CG1_CTXOP_ASSIGN         UINT8_C(0x00)   /**< Simple assignment operator (=) */
+#define BS3CG1_CTXOP_OR             UINT8_C(0x40)   /**< OR assignment operator (|=). */
+#define BS3CG1_CTXOP_AND            UINT8_C(0x80)   /**< AND assignment operator (&=). */
+#define BS3CG1_CTXOP_AND_INV        UINT8_C(0xc0)   /**< AND assignment operator of the inverted value (&~=). */
+/** @} */
+
+/**
+ * Escaped destination values
+ *
+ * These are just uppercased versions of TestInOut.kdFields, where dots are
+ * replaced by underscores.
+ */
+enum BS3CG1DST
+{
+    BS3CG1DST_INVALID = 0,
+    /* Operands. */
+    BS3CG1DST_OP1,
+    BS3CG1DST_OP2,
+    BS3CG1DST_OP3,
+    BS3CG1DST_OP4,
+    /* Flags. */
+    BS3CG1DST_EFL,
+    /* 8-bit GPRs. */
+    BS3CG1DST_AL,
+    BS3CG1DST_CL,
+    BS3CG1DST_DL,
+    BS3CG1DST_BL,
+    BS3CG1DST_AH,
+    BS3CG1DST_CH,
+    BS3CG1DST_DH,
+    BS3CG1DST_BH,
+    BS3CG1DST_R8L,
+    BS3CG1DST_R9L,
+    BS3CG1DST_R10L,
+    BS3CG1DST_R11L,
+    BS3CG1DST_R12L,
+    BS3CG1DST_R13L,
+    BS3CG1DST_R14L,
+    BS3CG1DST_R15L,
+    /* 16-bit GPRs. */
+    BS3CG1DST_AX,
+    BS3CG1DST_DX,
+    BS3CG1DST_CX,
+    BS3CG1DST_BX,
+    BS3CG1DST_SP,
+    BS3CG1DST_BP,
+    BS3CG1DST_SI,
+    BS3CG1DST_DI,
+    BS3CG1DST_R8W,
+    BS3CG1DST_R9W,
+    BS3CG1DST_R10W,
+    BS3CG1DST_R11W,
+    BS3CG1DST_R12W,
+    BS3CG1DST_R13W,
+    BS3CG1DST_R14W,
+    BS3CG1DST_R15W,
+    /* 32-bit GPRs. */
+    BS3CG1DST_EAX,
+    BS3CG1DST_EDX,
+    BS3CG1DST_ECX,
+    BS3CG1DST_EBX,
+    BS3CG1DST_ESP,
+    BS3CG1DST_EBP,
+    BS3CG1DST_ESI,
+    BS3CG1DST_EDI,
+    BS3CG1DST_R8D,
+    BS3CG1DST_R9D,
+    BS3CG1DST_R10D,
+    BS3CG1DST_R11D,
+    BS3CG1DST_R12D,
+    BS3CG1DST_R13D,
+    BS3CG1DST_R14D,
+    BS3CG1DST_R15D,
+    /* 64-bit GPRs. */
+    BS3CG1DST_RAX,
+    BS3CG1DST_RDX,
+    BS3CG1DST_RCX,
+    BS3CG1DST_RBX,
+    BS3CG1DST_RSP,
+    BS3CG1DST_RBP,
+    BS3CG1DST_RSI,
+    BS3CG1DST_RDI,
+    BS3CG1DST_R8,
+    BS3CG1DST_R9,
+    BS3CG1DST_R10,
+    BS3CG1DST_R11,
+    BS3CG1DST_R12,
+    BS3CG1DST_R13,
+    BS3CG1DST_R14,
+    BS3CG1DST_R15,
+    /* 16-bit, 32-bit or 64-bit registers according to operand size. */
+    BS3CG1DST_OZ_RAX,
+    BS3CG1DST_OZ_RDX,
+    BS3CG1DST_OZ_RCX,
+    BS3CG1DST_OZ_RBX,
+    BS3CG1DST_OZ_RSP,
+    BS3CG1DST_OZ_RBP,
+    BS3CG1DST_OZ_RSI,
+    BS3CG1DST_OZ_RDI,
+    BS3CG1DST_OZ_R8,
+    BS3CG1DST_OZ_R9,
+    BS3CG1DST_OZ_R10,
+    BS3CG1DST_OZ_R11,
+    BS3CG1DST_OZ_R12,
+    BS3CG1DST_OZ_R13,
+    BS3CG1DST_OZ_R14,
+    BS3CG1DST_OZ_R15,
+
+    BS3CG1DST_END
+} BS3CG1DST;
+
+/** @name Selector opcode definitions.
+ *
+ * Selector programs are very simple, they are zero or more predicate tests
+ * that are ANDed together.  If a predicate test fails, the test is skipped.
+ *
+ * One instruction is encoded as byte, where the first bit indicates what kind
+ * of test and the 7 remaining bits indicates which predicate to check.
+ *
+ * @{ */
+#define BS3CG1SEL_OP_KIND_MASK  UINT8_C(0x01)   /**< The operator part (put in lower bit to reduce switch value range). */
+#define BS3CG1SEL_OP_IS_TRUE    UINT8_C(0x00)   /**< Check that the predicate is true. */
+#define BS3CG1SEL_OP_IS_FALSE   UINT8_C(0x01)   /**< Check that the predicate is false. */
+#define BS3CG1SEL_OP_PRED_SHIFT 1               /**< Shift factor for getting/putting a BS3CG1PRED value into/from a byte. */
+/** @} */
+
+/**
+ * Test selector predicates (values are shifted by BS3CG1SEL_OP_PRED_SHIFT).
+ */
+typedef enum BS3CG1PRED
+{
+     BS3CG1PRED_INVALID = 0,
+
+     /* Operand size. */
+     BS3CG1PRED_SIZE_O16,
+     BS3CG1PRED_SIZE_O32,
+     BS3CG1PRED_SIZE_O64,
+     /* Execution ring. */
+     BS3CG1PRED_RING_0,
+     BS3CG1PRED_RING_1,
+     BS3CG1PRED_RING_2,
+     BS3CG1PRED_RING_3,
+     BS3CG1PRED_RING_0_THRU_2,
+     BS3CG1PRED_RING_1_THRU_3,
+     /* Basic code mode. */
+     BS3CG1PRED_CODE_64BIT,
+     BS3CG1PRED_CODE_32BIT,
+     BS3CG1PRED_CODE_16BIT,
+     /* CPU modes. */
+     BS3CG1PRED_MODE_REAL,
+     BS3CG1PRED_MODE_PROT,
+     BS3CG1PRED_MODE_LONG,
+     BS3CG1PRED_MODE_V86,
+     BS3CG1PRED_MODE_SMM,
+     BS3CG1PRED_MODE_VMX,
+     BS3CG1PRED_MODE_SVM,
+     /* Paging on/off */
+     BS3CG1PRED_PAGING_ON,
+     BS3CG1PRED_PAGING_OFF,
+
+     BS3CG1PRED_END
+} BS3CG1PRED;
 
 
