VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1.h@ 65903

Last change on this file since 65903 was 65903, checked in by vboxsync, 8 years ago

bs3-cpu-generated-1: updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.0 KB
Line 
1/* $Id: bs3-cpu-generated-1.h 65903 2017-02-28 15:25:30Z vboxsync $ */
2/** @file
3 * BS3Kit - bs3-cpu-generated-1, common header file.
4 */
5
6/*
7 * Copyright (C) 2007-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28#ifndef ___bs3_cpu_generated_1_h___
29#define ___bs3_cpu_generated_1_h___
30
31#include <bs3kit.h>
32#include <iprt/assert.h>
33
34
35
36/** Instruction encoding format. */
37typedef enum BS3CG1ENC
38{
39 BS3CG1ENC_INVALID = 0,
40 BS3CG1ENC_FIXED,
41 BS3CG1ENC_MODRM,
42 BS3CG1ENC_END
43} BS3CG1ENC;
44
45
46/**
47 * Operand details.
48 *
49 * Currently simply using the encoding from the reference manuals.
50 */
51typedef enum BS3CG1OP
52{
53 BS3CG1OP_INVALID = 0,
54
55 BS3CG1OP_Eb,
56 BS3CG1OP_Ev,
57
58 BS3CG1OP_Gb,
59 BS3CG1OP_Gv,
60
61 BS3CG1OP_END
62} BS3CG1OP;
63
64
65/**
66 * Generated instruction info.
67 */
68typedef struct BS3CG1INSTR
69{
70 /** Opcode bytes. */
71 uint8_t abOpcode[4];
72 /** BS3CG1OP values for each operand. */
73 uint8_t aenmOperands[4];
74 /** The opcode size. */
75 uint32_t cbOpcode : 2;
76 /** The number of operands. */
77 uint32_t cOperands : 2;
78 /** BS3CG1ENC values. */
79 uint32_t enmEncoding : 5;
80 /** The length of the mnemonic. */
81 uint32_t cchMnemonic : 4;
82 /** Index of the test header into g_aBs3Cg1Tests */
83 uint32_t idxTestHdr : 19;
84 /** BS3CG1INSTR_F_XXX. */
85 uint32_t fFlags;
86} BS3CG1INSTR;
87AssertCompileSize(BS3CG1INSTR, 16);
88/** Pointer to a const instruction. */
89typedef BS3CG1INSTR const BS3_FAR *PCBS3CG1INSTR;
90
91
92/** @name BS3CG1INSTR_F_XXX
93 * @{ */
94#define BS3CG1INSTR_F_ UINT32_C(0x00000000)
95/** @} */
96
97
98/**
99 * Test header.
100 */
101typedef struct BS3CG1TESTHDR
102{
103 /** The size of the selector program in bytes.
104 * This is also the offset of the input context modification program. */
105 uint32_t cbSelector : 9;
106 /** The size of the input context modification program in bytes.
107 * This immediately follows the selector program. */
108 uint32_t cbInput : 11;
109 /** The size of the output context modification program in bytes.
110 * This immediately follows the input context modification program. The
111 * program takes the result of the input program as starting point. */
112 uint32_t cbOutput : 11;
113 /** Indicates whether this is the last test or not. */
114 uint32_t fLast : 1;
115} BS3CG1TESTHDR;
116AssertCompileSize(BS3CG1TESTHDR, 4);
117/** Pointer to a const test header. */
118typedef BS3CG1TESTHDR const BS3_FAR *PCBS3CG1TESTHDR;
119
120/** @name Opcode format for the BS3CG1 context modifier.
121 *
122 * Used by both the input and output context programs.
123 *
124 * The most common operations are encoded as a single byte opcode followed by
125 * one or more immediate bytes with data.
126 *
127 * @{ */
128#define BS3CG1_CTXOP_SIZE_MASK UINT8_C(0x07)
129#define BS3CG1_CTXOP_1_BYTE UINT8_C(0x00)
130#define BS3CG1_CTXOP_2_BYTE UINT8_C(0x01)
131#define BS3CG1_CTXOP_4_BYTE UINT8_C(0x02)
132#define BS3CG1_CTXOP_8_BYTE UINT8_C(0x03)
133#define BS3CG1_CTXOP_16_BYTE UINT8_C(0x04)
134#define BS3CG1_CTXOP_32_BYTE UINT8_C(0x05)
135#define BS3CG1_CTXOP_12_BYTE UINT8_C(0x06)
136#define BS3CG1_CTXOP_SIZE_ESC UINT8_C(0x07) /**< Separate byte encoding the value size follows immediately. */
137
138#define BS3CG1_CTXOP_DST_MASK UINT8_C(0x18)
139#define BS3CG1_CTXOP_OP1 UINT8_C(0x00)
140#define BS3CG1_CTXOP_OP2 UINT8_C(0x08)
141#define BS3CG1_CTXOP_EFL UINT8_C(0x10)
142#define BS3CG1_CTXOP_DST_ESC UINT8_C(0x18) /**< Separate byte giving the destination follows after any size byte.*/
143
144#define BS3CG1_CTXOP_SIGN_EXT UINT8_C(0x20) /**< Whether to sign-extend (set) the immediate value. */
145
146#define BS3CG1_CTXOP_OPERATOR_MASK UINT8_C(0xc0)
147#define BS3CG1_CTXOP_ASSIGN UINT8_C(0x00) /**< Simple assignment operator (=) */
148#define BS3CG1_CTXOP_OR UINT8_C(0x40) /**< OR assignment operator (|=). */
149#define BS3CG1_CTXOP_AND UINT8_C(0x80) /**< AND assignment operator (&=). */
150#define BS3CG1_CTXOP_AND_INV UINT8_C(0xc0) /**< AND assignment operator of the inverted value (&~=). */
151/** @} */
152
153/**
154 * Escaped destination values
155 *
156 * These are just uppercased versions of TestInOut.kdFields, where dots are
157 * replaced by underscores.
158 */
159enum BS3CG1DST
160{
161 BS3CG1DST_INVALID = 0,
162 /* Operands. */
163 BS3CG1DST_OP1,
164 BS3CG1DST_OP2,
165 BS3CG1DST_OP3,
166 BS3CG1DST_OP4,
167 /* Flags. */
168 BS3CG1DST_EFL,
169 /* 8-bit GPRs. */
170 BS3CG1DST_AL,
171 BS3CG1DST_CL,
172 BS3CG1DST_DL,
173 BS3CG1DST_BL,
174 BS3CG1DST_AH,
175 BS3CG1DST_CH,
176 BS3CG1DST_DH,
177 BS3CG1DST_BH,
178 BS3CG1DST_R8L,
179 BS3CG1DST_R9L,
180 BS3CG1DST_R10L,
181 BS3CG1DST_R11L,
182 BS3CG1DST_R12L,
183 BS3CG1DST_R13L,
184 BS3CG1DST_R14L,
185 BS3CG1DST_R15L,
186 /* 16-bit GPRs. */
187 BS3CG1DST_AX,
188 BS3CG1DST_DX,
189 BS3CG1DST_CX,
190 BS3CG1DST_BX,
191 BS3CG1DST_SP,
192 BS3CG1DST_BP,
193 BS3CG1DST_SI,
194 BS3CG1DST_DI,
195 BS3CG1DST_R8W,
196 BS3CG1DST_R9W,
197 BS3CG1DST_R10W,
198 BS3CG1DST_R11W,
199 BS3CG1DST_R12W,
200 BS3CG1DST_R13W,
201 BS3CG1DST_R14W,
202 BS3CG1DST_R15W,
203 /* 32-bit GPRs. */
204 BS3CG1DST_EAX,
205 BS3CG1DST_EDX,
206 BS3CG1DST_ECX,
207 BS3CG1DST_EBX,
208 BS3CG1DST_ESP,
209 BS3CG1DST_EBP,
210 BS3CG1DST_ESI,
211 BS3CG1DST_EDI,
212 BS3CG1DST_R8D,
213 BS3CG1DST_R9D,
214 BS3CG1DST_R10D,
215 BS3CG1DST_R11D,
216 BS3CG1DST_R12D,
217 BS3CG1DST_R13D,
218 BS3CG1DST_R14D,
219 BS3CG1DST_R15D,
220 /* 64-bit GPRs. */
221 BS3CG1DST_RAX,
222 BS3CG1DST_RDX,
223 BS3CG1DST_RCX,
224 BS3CG1DST_RBX,
225 BS3CG1DST_RSP,
226 BS3CG1DST_RBP,
227 BS3CG1DST_RSI,
228 BS3CG1DST_RDI,
229 BS3CG1DST_R8,
230 BS3CG1DST_R9,
231 BS3CG1DST_R10,
232 BS3CG1DST_R11,
233 BS3CG1DST_R12,
234 BS3CG1DST_R13,
235 BS3CG1DST_R14,
236 BS3CG1DST_R15,
237 /* 16-bit, 32-bit or 64-bit registers according to operand size. */
238 BS3CG1DST_OZ_RAX,
239 BS3CG1DST_OZ_RDX,
240 BS3CG1DST_OZ_RCX,
241 BS3CG1DST_OZ_RBX,
242 BS3CG1DST_OZ_RSP,
243 BS3CG1DST_OZ_RBP,
244 BS3CG1DST_OZ_RSI,
245 BS3CG1DST_OZ_RDI,
246 BS3CG1DST_OZ_R8,
247 BS3CG1DST_OZ_R9,
248 BS3CG1DST_OZ_R10,
249 BS3CG1DST_OZ_R11,
250 BS3CG1DST_OZ_R12,
251 BS3CG1DST_OZ_R13,
252 BS3CG1DST_OZ_R14,
253 BS3CG1DST_OZ_R15,
254
255 BS3CG1DST_END
256} BS3CG1DST;
257
258/** @name Selector opcode definitions.
259 *
260 * Selector programs are very simple, they are zero or more predicate tests
261 * that are ANDed together. If a predicate test fails, the test is skipped.
262 *
263 * One instruction is encoded as byte, where the first bit indicates what kind
264 * of test and the 7 remaining bits indicates which predicate to check.
265 *
266 * @{ */
267#define BS3CG1SEL_OP_KIND_MASK UINT8_C(0x01) /**< The operator part (put in lower bit to reduce switch value range). */
268#define BS3CG1SEL_OP_IS_TRUE UINT8_C(0x00) /**< Check that the predicate is true. */
269#define BS3CG1SEL_OP_IS_FALSE UINT8_C(0x01) /**< Check that the predicate is false. */
270#define BS3CG1SEL_OP_PRED_SHIFT 1 /**< Shift factor for getting/putting a BS3CG1PRED value into/from a byte. */
271/** @} */
272
273/**
274 * Test selector predicates (values are shifted by BS3CG1SEL_OP_PRED_SHIFT).
275 */
276typedef enum BS3CG1PRED
277{
278 BS3CG1PRED_INVALID = 0,
279
280 /* Operand size. */
281 BS3CG1PRED_SIZE_O16,
282 BS3CG1PRED_SIZE_O32,
283 BS3CG1PRED_SIZE_O64,
284 /* Execution ring. */
285 BS3CG1PRED_RING_0,
286 BS3CG1PRED_RING_1,
287 BS3CG1PRED_RING_2,
288 BS3CG1PRED_RING_3,
289 BS3CG1PRED_RING_0_THRU_2,
290 BS3CG1PRED_RING_1_THRU_3,
291 /* Basic code mode. */
292 BS3CG1PRED_CODE_64BIT,
293 BS3CG1PRED_CODE_32BIT,
294 BS3CG1PRED_CODE_16BIT,
295 /* CPU modes. */
296 BS3CG1PRED_MODE_REAL,
297 BS3CG1PRED_MODE_PROT,
298 BS3CG1PRED_MODE_LONG,
299 BS3CG1PRED_MODE_V86,
300 BS3CG1PRED_MODE_SMM,
301 BS3CG1PRED_MODE_VMX,
302 BS3CG1PRED_MODE_SVM,
303 /* Paging on/off */
304 BS3CG1PRED_PAGING_ON,
305 BS3CG1PRED_PAGING_OFF,
306
307 BS3CG1PRED_END
308} BS3CG1PRED;
309
310
311/** The number of test instructions (generated). */
312extern uint16_t BS3_FAR_DATA g_cBs3Cg1Instructions;
313/** The test instructions (generated). */
314extern const char BS3_FAR_DATA g_aBs3Cg1Instructions[];
315/** The test data that BS3CG1INSTR. */
316extern BS3CG1TESTHDR BS3_FAR_DATA g_aBs3Cg1Tests[];
317/** The mnemonics (generated).
318 * Variable length sequence of mnemonics that runs in parallel to
319 * g_aBs3Cg1Instructions. */
320extern const char BS3_FAR_DATA g_achBs3Cg1Mnemonics[];
321
322
323#endif
324
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette