]>
git.proxmox.com Git - qemu.git/blob - target-i386/exec.h
2 * i386 execution defines
4 * Copyright (c) 2003 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "dyngen-exec.h"
22 /* XXX: factorize this mess */
24 #define TARGET_LONG_BITS 64
26 #define TARGET_LONG_BITS 32
31 register struct CPUX86State
*env
asm(AREG0
);
33 #include "qemu-common.h"
37 #define EAX (env->regs[R_EAX])
39 #define ECX (env->regs[R_ECX])
41 #define EDX (env->regs[R_EDX])
43 #define EBX (env->regs[R_EBX])
45 #define ESP (env->regs[R_ESP])
47 #define EBP (env->regs[R_EBP])
49 #define ESI (env->regs[R_ESI])
51 #define EDI (env->regs[R_EDI])
53 #define EIP (env->eip)
56 #define CC_SRC (env->cc_src)
57 #define CC_DST (env->cc_dst)
58 #define CC_OP (env->cc_op)
61 #define FT0 (env->ft0)
62 #define ST0 (env->fpregs[env->fpstt].d)
63 #define ST(n) (env->fpregs[(env->fpstt + (n)) & 7].d)
70 void QEMU_NORETURN
raise_exception_err(int exception_index
, int error_code
);
71 void QEMU_NORETURN
raise_exception(int exception_index
);
72 void QEMU_NORETURN
raise_exception_env(int exception_index
, CPUState
*nenv
);
74 /* n must be a constant to be efficient */
75 static inline target_long
lshift(target_long x
, int n
)
85 #if !defined(CONFIG_USER_ONLY)
87 #include "softmmu_exec.h"
89 #endif /* !defined(CONFIG_USER_ONLY) */
97 #define MAXTAN 9223372036854775808.0
99 /* the following deal with x86 long double-precision numbers */
100 #define MAXEXPD 0x7fff
101 #define EXPBIAS 16383
102 #define EXPD(fp) (fp.l.upper & 0x7fff)
103 #define SIGND(fp) ((fp.l.upper) & 0x8000)
104 #define MANTD(fp) (fp.l.lower)
105 #define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7fff)) | EXPBIAS
107 static inline void fpush(void)
109 env
->fpstt
= (env
->fpstt
- 1) & 7;
110 env
->fptags
[env
->fpstt
] = 0; /* validate stack entry */
113 static inline void fpop(void)
115 env
->fptags
[env
->fpstt
] = 1; /* invvalidate stack entry */
116 env
->fpstt
= (env
->fpstt
+ 1) & 7;
119 static inline floatx80
helper_fldt(target_ulong ptr
)
123 temp
.l
.lower
= ldq(ptr
);
124 temp
.l
.upper
= lduw(ptr
+ 8);
128 static inline void helper_fstt(floatx80 f
, target_ulong ptr
)
133 stq(ptr
, temp
.l
.lower
);
134 stw(ptr
+ 8, temp
.l
.upper
);
137 #define FPUS_IE (1 << 0)
138 #define FPUS_DE (1 << 1)
139 #define FPUS_ZE (1 << 2)
140 #define FPUS_OE (1 << 3)
141 #define FPUS_UE (1 << 4)
142 #define FPUS_PE (1 << 5)
143 #define FPUS_SF (1 << 6)
144 #define FPUS_SE (1 << 7)
145 #define FPUS_B (1 << 15)
149 static inline uint32_t compute_eflags(void)
151 return env
->eflags
| helper_cc_compute_all(CC_OP
) | (DF
& DF_MASK
);
154 /* NOTE: CC_OP must be modified manually to CC_OP_EFLAGS */
155 static inline void load_eflags(int eflags
, int update_mask
)
157 CC_SRC
= eflags
& (CC_O
| CC_S
| CC_Z
| CC_A
| CC_P
| CC_C
);
158 DF
= 1 - (2 * ((eflags
>> 10) & 1));
159 env
->eflags
= (env
->eflags
& ~update_mask
) |
160 (eflags
& update_mask
) | 0x2;
163 static inline int cpu_has_work(CPUState
*env
)
165 return ((env
->interrupt_request
& CPU_INTERRUPT_HARD
) &&
166 (env
->eflags
& IF_MASK
)) ||
167 (env
->interrupt_request
& (CPU_INTERRUPT_NMI
|
173 /* load efer and update the corresponding hflags. XXX: do consistency
174 checks with cpuid bits ? */
175 static inline void cpu_load_efer(CPUState
*env
, uint64_t val
)
178 env
->hflags
&= ~(HF_LMA_MASK
| HF_SVME_MASK
);
179 if (env
->efer
& MSR_EFER_LMA
)
180 env
->hflags
|= HF_LMA_MASK
;
181 if (env
->efer
& MSR_EFER_SVME
)
182 env
->hflags
|= HF_SVME_MASK
;
185 static inline void cpu_pc_from_tb(CPUState
*env
, TranslationBlock
*tb
)
187 env
->eip
= tb
->pc
- tb
->cs_base
;