4 * Copyright 1995 Alexandre Julliard
7 #ifndef __WINE_REGISTERS_H
8 #define __WINE_REGISTERS_H
12 /* The Win32 register context */
14 #define CONTEXT_i386 0x00010000
15 #define CONTEXT_i486 CONTEXT_i386
16 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
17 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
18 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
19 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
20 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
21 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
23 #define SIZE_OF_80387_REGISTERS 80
34 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
42 /* These are selected by CONTEXT_DEBUG_REGISTERS */
50 /* These are selected by CONTEXT_FLOATING_POINT */
51 FLOATING_SAVE_AREA FloatSave;
53 /* These are selected by CONTEXT_SEGMENTS */
59 /* These are selected by CONTEXT_INTEGER */
67 /* These are selected by CONTEXT_CONTROL */
79 extern int runtime_cpu (void);
81 static inline int runtime_cpu(void) { return 3; }
87 unsigned short sc_gs, __gsh;
88 unsigned short sc_fs, __fsh;
89 unsigned short sc_es, __esh;
90 unsigned short sc_ds, __dsh;
99 unsigned long sc_trapno;
100 unsigned long sc_err;
101 unsigned long sc_eip;
102 unsigned short sc_cs, __csh;
103 unsigned long sc_eflags;
104 unsigned long esp_at_signal;
105 unsigned short sc_ss, __ssh;
107 unsigned long oldmask;
110 #define WINE_DATA_SELECTOR 0x2b
111 #define WINE_CODE_SELECTOR 0x23
116 typedef struct sigcontext SIGCONTEXT;
117 #define WINE_DATA_SELECTOR 0x1f
118 #define WINE_CODE_SELECTOR 0x17
121 #if defined(__svr4__) || defined(_SCO_DS)
124 #include <sys/regset.h>
126 #include <sys/ucontext.h>
127 typedef struct ucontext SIGCONTEXT;
128 #define WINE_DATA_SELECTOR 0x1f
129 #define WINE_CODE_SELECTOR 0x17
130 #endif /* svr4 || SCO_DS */
134 typedef struct sigcontext SIGCONTEXT;
135 #define WINE_DATA_SELECTOR 0x27
136 #define WINE_CODE_SELECTOR 0x1f
139 #if !defined(__svr4__) && !defined(_SCO_DS)
141 #define EAX_reg(context) ((context)->sc_eax)
142 #define EBX_reg(context) ((context)->sc_ebx)
143 #define ECX_reg(context) ((context)->sc_ecx)
144 #define EDX_reg(context) ((context)->sc_edx)
145 #define ESI_reg(context) ((context)->sc_esi)
146 #define EDI_reg(context) ((context)->sc_edi)
147 #define EBP_reg(context) ((context)->sc_ebp)
149 #define CS_reg(context) ((context)->sc_cs)
150 #define DS_reg(context) ((context)->sc_ds)
151 #define ES_reg(context) ((context)->sc_es)
152 #define SS_reg(context) ((context)->sc_ss)
155 /* fs and gs are not supported on *BSD. Hopefully we won't need them. */
156 #define FS_reg(context) ((context)->sc_fs)
157 #define GS_reg(context) ((context)->sc_gs)
161 #define EFL_reg(context) ((context)->sc_eflags)
163 #define EFL_reg(context) ((context)->sc_efl)
166 #define EIP_reg(context) ((context)->sc_eip)
167 #define ESP_reg(context) ((context)->sc_esp)
169 #else /* __svr4__ || _SCO_DS */
175 #define EAX_reg(context) ((context)->uc_mcontext.gregs[EAX])
176 #define EBX_reg(context) ((context)->uc_mcontext.gregs[EBX])
177 #define ECX_reg(context) ((context)->uc_mcontext.gregs[ECX])
178 #define EDX_reg(context) ((context)->uc_mcontext.gregs[EDX])
179 #define ESI_reg(context) ((context)->uc_mcontext.gregs[ESI])
180 #define EDI_reg(context) ((context)->uc_mcontext.gregs[EDI])
181 #define EBP_reg(context) ((context)->uc_mcontext.gregs[EBP])
183 #define CS_reg(context) ((context)->uc_mcontext.gregs[CS])
184 #define DS_reg(context) ((context)->uc_mcontext.gregs[DS])
185 #define ES_reg(context) ((context)->uc_mcontext.gregs[ES])
186 #define SS_reg(context) ((context)->uc_mcontext.gregs[SS])
188 #define FS_reg(context) ((context)->uc_mcontext.gregs[FS])
189 #define GS_reg(context) ((context)->uc_mcontext.gregs[GS])
191 #define EFL_reg(context) ((context)->uc_mcontext.gregs[EFL])
193 #define EIP_reg(context) ((context)->uc_mcontext.gregs[EIP])
195 #define ESP_reg(context) ((context)->uc_mcontext.gregs[R_ESP])
197 #define ESP_reg(context) ((context)->uc_mcontext.gregs[ESP])
200 #endif /* __svr4__ || _SCO_DS */
202 #define AX_reg(context) (*(WORD*)&EAX_reg(context))
203 #define BX_reg(context) (*(WORD*)&EBX_reg(context))
204 #define CX_reg(context) (*(WORD*)&ECX_reg(context))
205 #define DX_reg(context) (*(WORD*)&EDX_reg(context))
206 #define SI_reg(context) (*(WORD*)&ESI_reg(context))
207 #define DI_reg(context) (*(WORD*)&EDI_reg(context))
208 #define BP_reg(context) (*(WORD*)&EBP_reg(context))
210 #define AL_reg(context) (*(BYTE*)&EAX_reg(context))
211 #define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
212 #define BL_reg(context) (*(BYTE*)&EBX_reg(context))
213 #define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
214 #define CL_reg(context) (*(BYTE*)&ECX_reg(context))
215 #define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
216 #define DL_reg(context) (*(BYTE*)&EDX_reg(context))
217 #define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
219 #define IP_reg(context) (*(WORD*)&EIP_reg(context))
220 #define SP_reg(context) (*(WORD*)&ESP_reg(context))
222 #define FL_reg(context) (*(WORD*)&EFL_reg(context))
224 #define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
225 #define RESET_CFLAG(context) (EFL_reg(context) &= 0xfffffffe)
227 #else /* ifndef WINELIB */
229 typedef void SIGCONTEXT;
230 #define WINE_DATA_SELECTOR 0x00
231 #define WINE_CODE_SELECTOR 0x00
233 #endif /* ifndef WINELIB */
235 #endif /* __WINE_REGISTERS_H */