2 * i386 TCG cpu class initialization
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 "qemu/osdep.h"
23 #include "exec/exec-all.h"
24 #include "sysemu/runstate.h"
25 #include "helper-tcg.h"
27 #if !defined(CONFIG_USER_ONLY)
28 #include "hw/i386/apic.h"
31 /* Frob eflags into and out of the CPU temporary format. */
33 static void x86_cpu_exec_enter(CPUState
*cs
)
35 X86CPU
*cpu
= X86_CPU(cs
);
36 CPUX86State
*env
= &cpu
->env
;
38 CC_SRC
= env
->eflags
& (CC_O
| CC_S
| CC_Z
| CC_A
| CC_P
| CC_C
);
39 env
->df
= 1 - (2 * ((env
->eflags
>> 10) & 1));
41 env
->eflags
&= ~(DF_MASK
| CC_O
| CC_S
| CC_Z
| CC_A
| CC_P
| CC_C
);
44 static void x86_cpu_exec_exit(CPUState
*cs
)
46 X86CPU
*cpu
= X86_CPU(cs
);
47 CPUX86State
*env
= &cpu
->env
;
49 env
->eflags
= cpu_compute_eflags(env
);
52 static void x86_cpu_synchronize_from_tb(CPUState
*cs
,
53 const TranslationBlock
*tb
)
55 X86CPU
*cpu
= X86_CPU(cs
);
57 cpu
->env
.eip
= tb
->pc
- tb
->cs_base
;
60 #include "hw/core/tcg-cpu-ops.h"
62 static struct TCGCPUOps x86_tcg_ops
= {
63 .initialize
= tcg_x86_init
,
64 .synchronize_from_tb
= x86_cpu_synchronize_from_tb
,
65 .cpu_exec_enter
= x86_cpu_exec_enter
,
66 .cpu_exec_exit
= x86_cpu_exec_exit
,
67 .cpu_exec_interrupt
= x86_cpu_exec_interrupt
,
68 .do_interrupt
= x86_cpu_do_interrupt
,
69 .tlb_fill
= x86_cpu_tlb_fill
,
70 #ifndef CONFIG_USER_ONLY
71 .debug_excp_handler
= breakpoint_handler
,
72 #endif /* !CONFIG_USER_ONLY */
75 void tcg_cpu_common_class_init(CPUClass
*cc
)
77 cc
->tcg_ops
= &x86_tcg_ops
;