xref: /qemu/target/i386/emulate/x86_emu.h (revision 77a2dba45cc9a1be7fec6ab88f43d2fa18af52a3)
1c97d6d2cSSergio Andres Gomez Del Real /*
2c97d6d2cSSergio Andres Gomez Del Real  * Copyright (C) 2016 Veertu Inc,
3c97d6d2cSSergio Andres Gomez Del Real  * Copyright (C) 2017 Google Inc,
4c97d6d2cSSergio Andres Gomez Del Real  *
5c97d6d2cSSergio Andres Gomez Del Real  * This program is free software; you can redistribute it and/or
6996feed4SSergio Andres Gomez Del Real  * modify it under the terms of the GNU Lesser General Public
7996feed4SSergio Andres Gomez Del Real  * License as published by the Free Software Foundation; either
88af82b8eSChetan Pant  * version 2.1 of the License, or (at your option) any later version.
9c97d6d2cSSergio Andres Gomez Del Real  *
10c97d6d2cSSergio Andres Gomez Del Real  * This program is distributed in the hope that it will be useful,
11c97d6d2cSSergio Andres Gomez Del Real  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12996feed4SSergio Andres Gomez Del Real  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13996feed4SSergio Andres Gomez Del Real  * Lesser General Public License for more details.
14c97d6d2cSSergio Andres Gomez Del Real  *
15996feed4SSergio Andres Gomez Del Real  * You should have received a copy of the GNU Lesser General Public
16996feed4SSergio Andres Gomez Del Real  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
17c97d6d2cSSergio Andres Gomez Del Real  */
18a8b991b5SMarkus Armbruster 
19a8b991b5SMarkus Armbruster #ifndef X86_EMU_H
20a8b991b5SMarkus Armbruster #define X86_EMU_H
21c97d6d2cSSergio Andres Gomez Del Real 
22c97d6d2cSSergio Andres Gomez Del Real #include "x86.h"
23c97d6d2cSSergio Andres Gomez Del Real #include "x86_decode.h"
24c97d6d2cSSergio Andres Gomez Del Real #include "cpu.h"
25c97d6d2cSSergio Andres Gomez Del Real 
2626a44d9dSWei Liu struct x86_emul_ops {
2726a44d9dSWei Liu     void (*read_mem)(CPUState *cpu, void *data, target_ulong addr, int bytes);
2863d8bc66SWei Liu     void (*write_mem)(CPUState *cpu, void *data, target_ulong addr, int bytes);
2926a44d9dSWei Liu     void (*read_segment_descriptor)(CPUState *cpu, struct x86_segment_descriptor *desc,
3026a44d9dSWei Liu                                     enum X86Seg seg);
31444bae08SWei Liu     void (*handle_io)(CPUState *cpu, uint16_t port, void *data, int direction,
32444bae08SWei Liu                       int size, int count);
3358567864SWei Liu     void (*simulate_rdmsr)(CPUState *cs);
3458567864SWei Liu     void (*simulate_wrmsr)(CPUState *cs);
3526a44d9dSWei Liu };
3626a44d9dSWei Liu 
3726a44d9dSWei Liu extern const struct x86_emul_ops *emul_ops;
3826a44d9dSWei Liu 
3926a44d9dSWei Liu void init_emu(const struct x86_emul_ops *ops);
4036861198SPhilippe Mathieu-Daudé bool exec_instruction(CPUX86State *env, struct x86_decode *ins);
4199e5aaf9SWei Liu void x86_emul_raise_exception(CPUX86State *env, int exception_index, int error_code);
42c97d6d2cSSergio Andres Gomez Del Real 
43ff2de166SPaolo Bonzini target_ulong read_reg(CPUX86State *env, int reg, int size);
44ff2de166SPaolo Bonzini void write_reg(CPUX86State *env, int reg, target_ulong val, int size);
45*77a2dba4SPaolo Bonzini target_ulong read_val_from_reg(void *reg_ptr, int size);
46*77a2dba4SPaolo Bonzini void write_val_to_reg(void *reg_ptr, target_ulong val, int size);
47*77a2dba4SPaolo Bonzini void write_val_ext(CPUX86State *env, struct x86_decode_op *decode, target_ulong val, int size);
4836861198SPhilippe Mathieu-Daudé uint8_t *read_mmio(CPUX86State *env, target_ulong ptr, int bytes);
49*77a2dba4SPaolo Bonzini target_ulong read_val_ext(CPUX86State *env, struct x86_decode_op *decode, int size);
50c97d6d2cSSergio Andres Gomez Del Real 
5136861198SPhilippe Mathieu-Daudé void exec_movzx(CPUX86State *env, struct x86_decode *decode);
5236861198SPhilippe Mathieu-Daudé void exec_shl(CPUX86State *env, struct x86_decode *decode);
5336861198SPhilippe Mathieu-Daudé void exec_movsx(CPUX86State *env, struct x86_decode *decode);
5436861198SPhilippe Mathieu-Daudé void exec_ror(CPUX86State *env, struct x86_decode *decode);
5536861198SPhilippe Mathieu-Daudé void exec_rol(CPUX86State *env, struct x86_decode *decode);
5636861198SPhilippe Mathieu-Daudé void exec_rcl(CPUX86State *env, struct x86_decode *decode);
5736861198SPhilippe Mathieu-Daudé void exec_rcr(CPUX86State *env, struct x86_decode *decode);
58c97d6d2cSSergio Andres Gomez Del Real #endif
59