VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.16.0/regs.h@ 54853

最後變更 在這個檔案從54853是 52145,由 vboxsync 提交於 10 年 前

Additions/x11/x11include: add header files for X.Org Server 1.16.

  • 屬性 svn:eol-style 設為 native
檔案大小: 10.2 KB
 
1/****************************************************************************
2*
3* Realmode X86 Emulator Library
4*
5* Copyright (C) 1996-1999 SciTech Software, Inc.
6* Copyright (C) David Mosberger-Tang
7* Copyright (C) 1999 Egbert Eich
8*
9* ========================================================================
10*
11* Permission to use, copy, modify, distribute, and sell this software and
12* its documentation for any purpose is hereby granted without fee,
13* provided that the above copyright notice appear in all copies and that
14* both that copyright notice and this permission notice appear in
15* supporting documentation, and that the name of the authors not be used
16* in advertising or publicity pertaining to distribution of the software
17* without specific, written prior permission. The authors makes no
18* representations about the suitability of this software for any purpose.
19* It is provided "as is" without express or implied warranty.
20*
21* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
22* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
23* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
25* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27* PERFORMANCE OF THIS SOFTWARE.
28*
29* ========================================================================
30*
31* Language: ANSI C
32* Environment: Any
33* Developer: Kendall Bennett
34*
35* Description: Header file for x86 register definitions.
36*
37****************************************************************************/
38
39#ifndef __X86EMU_REGS_H
40#define __X86EMU_REGS_H
41
42#include <X11/Xfuncproto.h>
43
44/*---------------------- Macros and type definitions ----------------------*/
45
46#ifdef PACK
47#pragma PACK
48#endif
49
50/*
51 * General EAX, EBX, ECX, EDX type registers. Note that for
52 * portability, and speed, the issue of byte swapping is not addressed
53 * in the registers. All registers are stored in the default format
54 * available on the host machine. The only critical issue is that the
55 * registers should line up EXACTLY in the same manner as they do in
56 * the 386. That is:
57 *
58 * EAX & 0xff === AL
59 * EAX & 0xffff == AX
60 *
61 * etc. The result is that alot of the calculations can then be
62 * done using the native instruction set fully.
63 */
64
65#ifdef __BIG_ENDIAN__
66
67typedef struct {
68 u32 e_reg;
69} I32_reg_t;
70
71typedef struct {
72 u16 filler0, x_reg;
73} I16_reg_t;
74
75typedef struct {
76 u8 filler0, filler1, h_reg, l_reg;
77} I8_reg_t;
78
79#else /* !__BIG_ENDIAN__ */
80
81typedef struct {
82 u32 e_reg;
83} I32_reg_t;
84
85typedef struct {
86 u16 x_reg;
87} I16_reg_t;
88
89typedef struct {
90 u8 l_reg, h_reg;
91} I8_reg_t;
92
93#endif /* BIG_ENDIAN */
94
95typedef union {
96 I32_reg_t I32_reg;
97 I16_reg_t I16_reg;
98 I8_reg_t I8_reg;
99} i386_general_register;
100
101struct i386_general_regs {
102 i386_general_register A, B, C, D;
103};
104
105typedef struct i386_general_regs Gen_reg_t;
106
107struct i386_special_regs {
108 i386_general_register SP, BP, SI, DI, IP;
109 u32 FLAGS;
110};
111
112/*
113 * Segment registers here represent the 16 bit quantities
114 * CS, DS, ES, SS.
115 */
116
117#if defined(__sun) && defined(CS) /* avoid conflicts with Solaris sys/regset.h */
118# undef CS
119# undef DS
120# undef SS
121# undef ES
122# undef FS
123# undef GS
124#endif
125
126struct i386_segment_regs {
127 u16 CS, DS, SS, ES, FS, GS;
128};
129
130/* 8 bit registers */
131#define R_AH gen.A.I8_reg.h_reg
132#define R_AL gen.A.I8_reg.l_reg
133#define R_BH gen.B.I8_reg.h_reg
134#define R_BL gen.B.I8_reg.l_reg
135#define R_CH gen.C.I8_reg.h_reg
136#define R_CL gen.C.I8_reg.l_reg
137#define R_DH gen.D.I8_reg.h_reg
138#define R_DL gen.D.I8_reg.l_reg
139
140/* 16 bit registers */
141#define R_AX gen.A.I16_reg.x_reg
142#define R_BX gen.B.I16_reg.x_reg
143#define R_CX gen.C.I16_reg.x_reg
144#define R_DX gen.D.I16_reg.x_reg
145
146/* 32 bit extended registers */
147#define R_EAX gen.A.I32_reg.e_reg
148#define R_EBX gen.B.I32_reg.e_reg
149#define R_ECX gen.C.I32_reg.e_reg
150#define R_EDX gen.D.I32_reg.e_reg
151
152/* special registers */
153#define R_SP spc.SP.I16_reg.x_reg
154#define R_BP spc.BP.I16_reg.x_reg
155#define R_SI spc.SI.I16_reg.x_reg
156#define R_DI spc.DI.I16_reg.x_reg
157#define R_IP spc.IP.I16_reg.x_reg
158#define R_FLG spc.FLAGS
159
160/* special registers */
161#define R_SP spc.SP.I16_reg.x_reg
162#define R_BP spc.BP.I16_reg.x_reg
163#define R_SI spc.SI.I16_reg.x_reg
164#define R_DI spc.DI.I16_reg.x_reg
165#define R_IP spc.IP.I16_reg.x_reg
166#define R_FLG spc.FLAGS
167
168/* special registers */
169#define R_ESP spc.SP.I32_reg.e_reg
170#define R_EBP spc.BP.I32_reg.e_reg
171#define R_ESI spc.SI.I32_reg.e_reg
172#define R_EDI spc.DI.I32_reg.e_reg
173#define R_EIP spc.IP.I32_reg.e_reg
174#define R_EFLG spc.FLAGS
175
176/* segment registers */
177#define R_CS seg.CS
178#define R_DS seg.DS
179#define R_SS seg.SS
180#define R_ES seg.ES
181#define R_FS seg.FS
182#define R_GS seg.GS
183
184/* flag conditions */
185#define FB_CF 0x0001 /* CARRY flag */
186#define FB_PF 0x0004 /* PARITY flag */
187#define FB_AF 0x0010 /* AUX flag */
188#define FB_ZF 0x0040 /* ZERO flag */
189#define FB_SF 0x0080 /* SIGN flag */
190#define FB_TF 0x0100 /* TRAP flag */
191#define FB_IF 0x0200 /* INTERRUPT ENABLE flag */
192#define FB_DF 0x0400 /* DIR flag */
193#define FB_OF 0x0800 /* OVERFLOW flag */
194
195/* 80286 and above always have bit#1 set */
196#define F_ALWAYS_ON (0x0002) /* flag bits always on */
197
198/*
199 * Define a mask for only those flag bits we will ever pass back
200 * (via PUSHF)
201 */
202#define F_MSK (FB_CF|FB_PF|FB_AF|FB_ZF|FB_SF|FB_TF|FB_IF|FB_DF|FB_OF)
203
204/* following bits masked in to a 16bit quantity */
205
206#define F_CF 0x0001 /* CARRY flag */
207#define F_PF 0x0004 /* PARITY flag */
208#define F_AF 0x0010 /* AUX flag */
209#define F_ZF 0x0040 /* ZERO flag */
210#define F_SF 0x0080 /* SIGN flag */
211#define F_TF 0x0100 /* TRAP flag */
212#define F_IF 0x0200 /* INTERRUPT ENABLE flag */
213#define F_DF 0x0400 /* DIR flag */
214#define F_OF 0x0800 /* OVERFLOW flag */
215
216#define TOGGLE_FLAG(flag) (M.x86.R_FLG ^= (flag))
217#define SET_FLAG(flag) (M.x86.R_FLG |= (flag))
218#define CLEAR_FLAG(flag) (M.x86.R_FLG &= ~(flag))
219#define ACCESS_FLAG(flag) (M.x86.R_FLG & (flag))
220#define CLEARALL_FLAG(m) (M.x86.R_FLG = 0)
221
222#define CONDITIONAL_SET_FLAG(COND,FLAG) \
223 if (COND) SET_FLAG(FLAG); else CLEAR_FLAG(FLAG)
224
225#define F_PF_CALC 0x010000 /* PARITY flag has been calced */
226#define F_ZF_CALC 0x020000 /* ZERO flag has been calced */
227#define F_SF_CALC 0x040000 /* SIGN flag has been calced */
228
229#define F_ALL_CALC 0xff0000 /* All have been calced */
230
231/*
232 * Emulator machine state.
233 * Segment usage control.
234 */
235#define SYSMODE_SEG_DS_SS 0x00000001
236#define SYSMODE_SEGOVR_CS 0x00000002
237#define SYSMODE_SEGOVR_DS 0x00000004
238#define SYSMODE_SEGOVR_ES 0x00000008
239#define SYSMODE_SEGOVR_FS 0x00000010
240#define SYSMODE_SEGOVR_GS 0x00000020
241#define SYSMODE_SEGOVR_SS 0x00000040
242#define SYSMODE_PREFIX_REPE 0x00000080
243#define SYSMODE_PREFIX_REPNE 0x00000100
244#define SYSMODE_PREFIX_DATA 0x00000200
245#define SYSMODE_PREFIX_ADDR 0x00000400
246#define SYSMODE_INTR_PENDING 0x10000000
247#define SYSMODE_EXTRN_INTR 0x20000000
248#define SYSMODE_HALTED 0x40000000
249
250#define SYSMODE_SEGMASK (SYSMODE_SEG_DS_SS | \
251 SYSMODE_SEGOVR_CS | \
252 SYSMODE_SEGOVR_DS | \
253 SYSMODE_SEGOVR_ES | \
254 SYSMODE_SEGOVR_FS | \
255 SYSMODE_SEGOVR_GS | \
256 SYSMODE_SEGOVR_SS)
257#define SYSMODE_CLRMASK (SYSMODE_SEG_DS_SS | \
258 SYSMODE_SEGOVR_CS | \
259 SYSMODE_SEGOVR_DS | \
260 SYSMODE_SEGOVR_ES | \
261 SYSMODE_SEGOVR_FS | \
262 SYSMODE_SEGOVR_GS | \
263 SYSMODE_SEGOVR_SS | \
264 SYSMODE_PREFIX_DATA | \
265 SYSMODE_PREFIX_ADDR)
266
267#define INTR_SYNCH 0x1
268#define INTR_ASYNCH 0x2
269#define INTR_HALTED 0x4
270
271typedef struct {
272 struct i386_general_regs gen;
273 struct i386_special_regs spc;
274 struct i386_segment_regs seg;
275 /*
276 * MODE contains information on:
277 * REPE prefix 2 bits repe,repne
278 * SEGMENT overrides 5 bits normal,DS,SS,CS,ES
279 * Delayed flag set 3 bits (zero, signed, parity)
280 * reserved 6 bits
281 * interrupt # 8 bits instruction raised interrupt
282 * BIOS video segregs 4 bits
283 * Interrupt Pending 1 bits
284 * Extern interrupt 1 bits
285 * Halted 1 bits
286 */
287 u32 mode;
288 volatile int intr; /* mask of pending interrupts */
289 int debug;
290#ifdef DEBUG
291 int check;
292 u16 saved_ip;
293 u16 saved_cs;
294 int enc_pos;
295 int enc_str_pos;
296 char decode_buf[32]; /* encoded byte stream */
297 char decoded_buf[256]; /* disassembled strings */
298#endif
299 u8 intno;
300 u8 __pad[3];
301} X86EMU_regs;
302
303/****************************************************************************
304REMARKS:
305Structure maintaining the emulator machine state.
306
307MEMBERS:
308mem_base - Base real mode memory for the emulator
309mem_size - Size of the real mode memory block for the emulator
310private - private data pointer
311x86 - X86 registers
312****************************************************************************/
313typedef struct {
314 unsigned long mem_base;
315 unsigned long mem_size;
316 void *private;
317 X86EMU_regs x86;
318} X86EMU_sysEnv;
319
320#ifdef END_PACK
321#pragma END_PACK
322#endif
323
324/*----------------------------- Global Variables --------------------------*/
325
326#ifdef __cplusplus
327extern "C" { /* Use "C" linkage when in C++ mode */
328#endif
329
330/* Global emulator machine state.
331 *
332 * We keep it global to avoid pointer dereferences in the code for speed.
333 */
334
335 extern X86EMU_sysEnv _X86EMU_env;
336#define M _X86EMU_env
337
338/*-------------------------- Function Prototypes --------------------------*/
339
340/* Function to log information at runtime */
341
342 void printk(const char *fmt, ...)
343 _X_ATTRIBUTE_PRINTF(1, 2);
344
345#ifdef __cplusplus
346} /* End of "C" linkage for C++ */
347#endif
348#endif /* __X86EMU_REGS_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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