1*27458df8SWei Liu /* 2*27458df8SWei Liu * Copyright (C) 2016 Veertu Inc, 3*27458df8SWei Liu * Copyright (C) 2017 Google Inc, 4*27458df8SWei Liu * 5*27458df8SWei Liu * This program is free software; you can redistribute it and/or 6*27458df8SWei Liu * modify it under the terms of the GNU Lesser General Public 7*27458df8SWei Liu * License as published by the Free Software Foundation; either 8*27458df8SWei Liu * version 2.1 of the License, or (at your option) any later version. 9*27458df8SWei Liu * 10*27458df8SWei Liu * This program is distributed in the hope that it will be useful, 11*27458df8SWei Liu * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*27458df8SWei Liu * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13*27458df8SWei Liu * Lesser General Public License for more details. 14*27458df8SWei Liu * 15*27458df8SWei Liu * You should have received a copy of the GNU Lesser General Public 16*27458df8SWei Liu * License along with this program; if not, see <http://www.gnu.org/licenses/>. 17*27458df8SWei Liu */ 18*27458df8SWei Liu 19*27458df8SWei Liu #ifndef X86_EMU_H 20*27458df8SWei Liu #define X86_EMU_H 21*27458df8SWei Liu 22*27458df8SWei Liu #include "x86.h" 23*27458df8SWei Liu #include "x86_decode.h" 24*27458df8SWei Liu #include "cpu.h" 25*27458df8SWei Liu 26*27458df8SWei Liu struct x86_emul_ops { 27*27458df8SWei Liu void (*read_mem)(CPUState *cpu, void *data, target_ulong addr, int bytes); 28*27458df8SWei Liu void (*write_mem)(CPUState *cpu, void *data, target_ulong addr, int bytes); 29*27458df8SWei Liu void (*read_segment_descriptor)(CPUState *cpu, struct x86_segment_descriptor *desc, 30*27458df8SWei Liu enum X86Seg seg); 31*27458df8SWei Liu void (*handle_io)(CPUState *cpu, uint16_t port, void *data, int direction, 32*27458df8SWei Liu int size, int count); 33*27458df8SWei Liu void (*simulate_rdmsr)(CPUState *cs); 34*27458df8SWei Liu void (*simulate_wrmsr)(CPUState *cs); 35*27458df8SWei Liu }; 36*27458df8SWei Liu 37*27458df8SWei Liu extern const struct x86_emul_ops *emul_ops; 38*27458df8SWei Liu 39*27458df8SWei Liu void init_emu(const struct x86_emul_ops *ops); 40*27458df8SWei Liu bool exec_instruction(CPUX86State *env, struct x86_decode *ins); 41*27458df8SWei Liu void x86_emul_raise_exception(CPUX86State *env, int exception_index, int error_code); 42*27458df8SWei Liu 43*27458df8SWei Liu target_ulong read_reg(CPUX86State *env, int reg, int size); 44*27458df8SWei Liu void write_reg(CPUX86State *env, int reg, target_ulong val, int size); 45*27458df8SWei Liu target_ulong read_val_from_reg(target_ulong reg_ptr, int size); 46*27458df8SWei Liu void write_val_to_reg(target_ulong reg_ptr, target_ulong val, int size); 47*27458df8SWei Liu void write_val_ext(CPUX86State *env, target_ulong ptr, target_ulong val, int size); 48*27458df8SWei Liu uint8_t *read_mmio(CPUX86State *env, target_ulong ptr, int bytes); 49*27458df8SWei Liu target_ulong read_val_ext(CPUX86State *env, target_ulong ptr, int size); 50*27458df8SWei Liu 51*27458df8SWei Liu void exec_movzx(CPUX86State *env, struct x86_decode *decode); 52*27458df8SWei Liu void exec_shl(CPUX86State *env, struct x86_decode *decode); 53*27458df8SWei Liu void exec_movsx(CPUX86State *env, struct x86_decode *decode); 54*27458df8SWei Liu void exec_ror(CPUX86State *env, struct x86_decode *decode); 55*27458df8SWei Liu void exec_rol(CPUX86State *env, struct x86_decode *decode); 56*27458df8SWei Liu void exec_rcl(CPUX86State *env, struct x86_decode *decode); 57*27458df8SWei Liu void exec_rcr(CPUX86State *env, struct x86_decode *decode); 58*27458df8SWei Liu #endif 59