127458df8SWei Liu /* 227458df8SWei Liu * Copyright (C) 2016 Veertu Inc, 327458df8SWei Liu * Copyright (C) 2017 Google Inc, 427458df8SWei Liu * 527458df8SWei Liu * This program is free software; you can redistribute it and/or 627458df8SWei Liu * modify it under the terms of the GNU Lesser General Public 727458df8SWei Liu * License as published by the Free Software Foundation; either 827458df8SWei Liu * version 2.1 of the License, or (at your option) any later version. 927458df8SWei Liu * 1027458df8SWei Liu * This program is distributed in the hope that it will be useful, 1127458df8SWei Liu * but WITHOUT ANY WARRANTY; without even the implied warranty of 1227458df8SWei Liu * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1327458df8SWei Liu * Lesser General Public License for more details. 1427458df8SWei Liu * 1527458df8SWei Liu * You should have received a copy of the GNU Lesser General Public 1627458df8SWei Liu * License along with this program; if not, see <http://www.gnu.org/licenses/>. 1727458df8SWei Liu */ 1827458df8SWei Liu 1927458df8SWei Liu #ifndef X86_EMU_H 2027458df8SWei Liu #define X86_EMU_H 2127458df8SWei Liu 2227458df8SWei Liu #include "x86.h" 2327458df8SWei Liu #include "x86_decode.h" 2427458df8SWei Liu #include "cpu.h" 2527458df8SWei Liu 2627458df8SWei Liu struct x86_emul_ops { 2727458df8SWei Liu void (*read_mem)(CPUState *cpu, void *data, target_ulong addr, int bytes); 2827458df8SWei Liu void (*write_mem)(CPUState *cpu, void *data, target_ulong addr, int bytes); 2927458df8SWei Liu void (*read_segment_descriptor)(CPUState *cpu, struct x86_segment_descriptor *desc, 3027458df8SWei Liu enum X86Seg seg); 3127458df8SWei Liu void (*handle_io)(CPUState *cpu, uint16_t port, void *data, int direction, 3227458df8SWei Liu int size, int count); 3327458df8SWei Liu void (*simulate_rdmsr)(CPUState *cs); 3427458df8SWei Liu void (*simulate_wrmsr)(CPUState *cs); 3527458df8SWei Liu }; 3627458df8SWei Liu 3727458df8SWei Liu extern const struct x86_emul_ops *emul_ops; 3827458df8SWei Liu 3927458df8SWei Liu void init_emu(const struct x86_emul_ops *ops); 4027458df8SWei Liu bool exec_instruction(CPUX86State *env, struct x86_decode *ins); 4127458df8SWei Liu void x86_emul_raise_exception(CPUX86State *env, int exception_index, int error_code); 4227458df8SWei Liu 4327458df8SWei Liu target_ulong read_reg(CPUX86State *env, int reg, int size); 4427458df8SWei Liu 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); 4827458df8SWei Liu 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); 5027458df8SWei Liu 5127458df8SWei Liu void exec_movzx(CPUX86State *env, struct x86_decode *decode); 5227458df8SWei Liu void exec_shl(CPUX86State *env, struct x86_decode *decode); 5327458df8SWei Liu void exec_movsx(CPUX86State *env, struct x86_decode *decode); 5427458df8SWei Liu void exec_ror(CPUX86State *env, struct x86_decode *decode); 5527458df8SWei Liu void exec_rol(CPUX86State *env, struct x86_decode *decode); 5627458df8SWei Liu void exec_rcl(CPUX86State *env, struct x86_decode *decode); 5727458df8SWei Liu void exec_rcr(CPUX86State *env, struct x86_decode *decode); 5827458df8SWei Liu #endif 59