diff --git a/qemu/target-i386/helper.h b/qemu/target-i386/helper.h index d3b52d1f..b83c7784 100644 --- a/qemu/target-i386/helper.h +++ b/qemu/target-i386/helper.h @@ -88,12 +88,12 @@ DEF_HELPER_1(wrmsr, void, env) DEF_HELPER_2(check_iob, void, env, i32) DEF_HELPER_2(check_iow, void, env, i32) DEF_HELPER_2(check_iol, void, env, i32) -DEF_HELPER_3(outb, void, ptr, i32, i32) -DEF_HELPER_2(inb, tl, ptr, i32) -DEF_HELPER_3(outw, void, ptr, i32, i32) -DEF_HELPER_2(inw, tl, ptr, i32) -DEF_HELPER_3(outl, void, ptr, i32, i32) -DEF_HELPER_2(inl, tl, ptr, i32) +DEF_HELPER_3(outb, void, env, i32, i32) +DEF_HELPER_2(inb, tl, env, i32) +DEF_HELPER_3(outw, void, env, i32, i32) +DEF_HELPER_2(inw, tl, env, i32) +DEF_HELPER_3(outl, void, env, i32, i32) +DEF_HELPER_2(inl, tl, env, i32) DEF_HELPER_3(svm_check_intercept_param, void, env, i32, i64) DEF_HELPER_3(vmexit, void, env, i32, i64) diff --git a/qemu/target-i386/misc_helper.c b/qemu/target-i386/misc_helper.c index 579fe72d..4cdc3290 100644 --- a/qemu/target-i386/misc_helper.c +++ b/qemu/target-i386/misc_helper.c @@ -24,34 +24,67 @@ #include "uc_priv.h" -void helper_outb(void *handle, uint32_t port, uint32_t data) +void helper_outb(CPUX86State *env, uint32_t port, uint32_t data) { - cpu_outb(handle, port, data & 0xff); +#ifdef CONFIG_USER_ONLY + fprintf(stderr, "outb: port=0x%04x, data=%02x\n", port, data); +#else + address_space_stb(&env->uc->as, port, data, + cpu_get_mem_attrs(env), NULL); +#endif } -target_ulong helper_inb(void *handle, uint32_t port) +target_ulong helper_inb(CPUX86State *env, uint32_t port) { - return cpu_inb(handle, port); +#ifdef CONFIG_USER_ONLY + fprintf(stderr, "inb: port=0x%04x\n", port); + return 0; +#else + return address_space_ldub(&env->uc->as, port, + cpu_get_mem_attrs(env), NULL); +#endif } -void helper_outw(void *handle, uint32_t port, uint32_t data) +void helper_outw(CPUX86State *env, uint32_t port, uint32_t data) { - cpu_outw(handle, port, data & 0xffff); +#ifdef CONFIG_USER_ONLY + fprintf(stderr, "outw: port=0x%04x, data=%04x\n", port, data); +#else + address_space_stw(&env->uc->as, port, data, + cpu_get_mem_attrs(env), NULL); +#endif } -target_ulong helper_inw(void *handle, uint32_t port) +target_ulong helper_inw(CPUX86State *env, uint32_t port) { - return cpu_inw(handle, port); +#ifdef CONFIG_USER_ONLY + fprintf(stderr, "inw: port=0x%04x\n", port); + return 0; +#else + return address_space_lduw(&env->uc->as, port, + cpu_get_mem_attrs(env), NULL); +#endif } -void helper_outl(void *handle, uint32_t port, uint32_t data) +void helper_outl(CPUX86State *env, uint32_t port, uint32_t data) { - cpu_outl(handle, port, data); +#ifdef CONFIG_USER_ONLY + fprintf(stderr, "outw: port=0x%04x, data=%08x\n", port, data); +#else + address_space_stl(&env->uc->as, port, data, + cpu_get_mem_attrs(env), NULL); +#endif } -target_ulong helper_inl(void *handle, uint32_t port) +target_ulong helper_inl(CPUX86State *env, uint32_t port) { - return cpu_inl(handle, port); +#ifdef CONFIG_USER_ONLY + fprintf(stderr, "inl: port=0x%04x\n", port); + return 0; +#else + return address_space_ldl(&env->uc->as, port, + cpu_get_mem_attrs(env), NULL); +#endif } void helper_into(CPUX86State *env, int next_eip_addend) diff --git a/qemu/target-i386/translate.c b/qemu/target-i386/translate.c index 793f30f2..3ada893f 100644 --- a/qemu/target-i386/translate.c +++ b/qemu/target-i386/translate.c @@ -760,13 +760,13 @@ static void gen_helper_in_func(TCGContext *s, TCGMemOp ot, TCGv v, TCGv_i32 n) { switch (ot) { case MO_8: - gen_helper_inb(s, v, tcg_const_ptr(s, s->uc), n); + gen_helper_inb(s, v, s->cpu_env, n); break; case MO_16: - gen_helper_inw(s, v, tcg_const_ptr(s, s->uc), n); + gen_helper_inw(s, v, s->cpu_env, n); break; case MO_32: - gen_helper_inl(s, v, tcg_const_ptr(s, s->uc), n); + gen_helper_inl(s, v, s->cpu_env, n); break; default: tcg_abort(); @@ -777,13 +777,13 @@ static void gen_helper_out_func(TCGContext *s, TCGMemOp ot, TCGv_i32 v, TCGv_i32 { switch (ot) { case MO_8: - gen_helper_outb(s, tcg_const_ptr(s, s->uc), v, n); + gen_helper_outb(s, s->cpu_env, v, n); break; case MO_16: - gen_helper_outw(s, tcg_const_ptr(s, s->uc), v, n); + gen_helper_outw(s, s->cpu_env, v, n); break; case MO_32: - gen_helper_outl(s, tcg_const_ptr(s, s->uc), v, n); + gen_helper_outl(s, s->cpu_env, v, n); break; default: tcg_abort();