From 622d5cd5f9669ab98cb58200938254f6422b1967 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Wed, 26 Aug 2015 06:30:58 -0400 Subject: [PATCH] change uch to uc_struct (target-arm) --- qemu/target-arm/translate-a64.c | 4 ++-- qemu/target-arm/translate.c | 6 +++--- qemu/target-arm/unicorn.h | 12 ++++++------ qemu/target-arm/unicorn_aarch64.c | 21 ++++++--------------- qemu/target-arm/unicorn_arm.c | 14 +++++--------- 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/qemu/target-arm/translate-a64.c b/qemu/target-arm/translate-a64.c index 2e159f21..deeebabe 100644 --- a/qemu/target-arm/translate-a64.c +++ b/qemu/target-arm/translate-a64.c @@ -10984,7 +10984,7 @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) // Unicorn: trace this instruction on request if (env->uc->hook_insn) { - struct hook_struct *trace = hook_find((uch)s->uc, UC_HOOK_CODE, s->pc - 4); + struct hook_struct *trace = hook_find(s->uc, UC_HOOK_CODE, s->pc - 4); if (trace) gen_uc_tracecode(tcg_ctx, 4, trace->callback, env->uc, s->pc - 4, trace->user_data); // if requested to emulate only some instructions, check if @@ -11106,7 +11106,7 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu, // Unicorn: trace this block on request if (env->uc->hook_block) { - struct hook_struct *trace = hook_find((uch)env->uc, UC_HOOK_BLOCK, pc_start); + struct hook_struct *trace = hook_find(env->uc, UC_HOOK_BLOCK, pc_start); if (trace) { // save block address to see if we need to patch block size later env->uc->block_addr = pc_start; diff --git a/qemu/target-arm/translate.c b/qemu/target-arm/translate.c index 9a1b7914..e3aa07f7 100644 --- a/qemu/target-arm/translate.c +++ b/qemu/target-arm/translate.c @@ -7688,7 +7688,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) // qq // Unicorn: trace this instruction on request if (s->uc->hook_insn) { - struct hook_struct *trace = hook_find((uch)s->uc, UC_HOOK_CODE, s->pc - 4); + struct hook_struct *trace = hook_find(s->uc, UC_HOOK_CODE, s->pc - 4); if (trace) gen_uc_tracecode(tcg_ctx, 4, trace->callback, s->uc, s->pc - 4, trace->user_data); // if requested to emulate only some instructions, check if @@ -10411,7 +10411,7 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) // qq // Unicorn: trace this instruction on request if (env->uc->hook_insn) { - struct hook_struct *trace = hook_find((uch)s->uc, UC_HOOK_CODE, s->pc); + struct hook_struct *trace = hook_find(s->uc, UC_HOOK_CODE, s->pc); if (trace) gen_uc_tracecode(tcg_ctx, 2, trace->callback, env->uc, s->pc, trace->user_data); // if requested to emulate only some instructions, check to see @@ -11229,7 +11229,7 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu, // Unicorn: trace this block on request if (env->uc->hook_block) { - struct hook_struct *trace = hook_find((uch)env->uc, UC_HOOK_BLOCK, pc_start); + struct hook_struct *trace = hook_find(env->uc, UC_HOOK_BLOCK, pc_start); if (trace) { // save block address to see if we need to patch block size later env->uc->block_addr = pc_start; diff --git a/qemu/target-arm/unicorn.h b/qemu/target-arm/unicorn.h index 0c355a71..797ef979 100644 --- a/qemu/target-arm/unicorn.h +++ b/qemu/target-arm/unicorn.h @@ -5,13 +5,13 @@ #define UC_QEMU_TARGET_ARM_H // functions to read & write registers -int arm_reg_read(uch handle, unsigned int regid, void *value); -int arm_reg_write(uch handle, unsigned int regid, const void *value); -int arm64_reg_read(uch handle, unsigned int regid, void *value); -int arm64_reg_write(uch handle, unsigned int regid, const void *value); +int arm_reg_read(struct uc_struct *uc, unsigned int regid, void *value); +int arm_reg_write(struct uc_struct *uc, unsigned int regid, const void *value); +int arm64_reg_read(struct uc_struct *uc, unsigned int regid, void *value); +int arm64_reg_write(struct uc_struct *uc, unsigned int regid, const void *value); -void arm_reg_reset(uch handle); -void arm64_reg_reset(uch handle); +void arm_reg_reset(struct uc_struct *uc); +void arm64_reg_reset(struct uc_struct *uc); __attribute__ ((visibility ("default"))) void arm_uc_init(struct uc_struct* uc); diff --git a/qemu/target-arm/unicorn_aarch64.c b/qemu/target-arm/unicorn_aarch64.c index b9474155..a8a674b0 100644 --- a/qemu/target-arm/unicorn_aarch64.c +++ b/qemu/target-arm/unicorn_aarch64.c @@ -25,23 +25,17 @@ static void arm64_set_pc(struct uc_struct *uc, uint64_t address) ((CPUARMState *)uc->current_cpu->env_ptr)->pc = address; } -void arm64_reg_reset(uch handle) +void arm64_reg_reset(struct uc_struct *uc) { - struct uc_struct *uc = (struct uc_struct *) handle; - CPUArchState *env; - - env = first_cpu->env_ptr; + CPUArchState *env = first_cpu->env_ptr; memset(env->xregs, 0, sizeof(env->xregs)); env->pc = 0; } -int arm64_reg_read(uch handle, unsigned int regid, void *value) +int arm64_reg_read(struct uc_struct *uc, unsigned int regid, void *value) { - CPUState *mycpu; - struct uc_struct *uc = (struct uc_struct *) handle; - - mycpu = first_cpu; + CPUState *mycpu = first_cpu; if (regid >= UC_ARM64_REG_X0 && regid <= UC_ARM64_REG_X28) *(int64_t *)value = ARM_CPU(uc, mycpu)->env.xregs[regid - UC_ARM64_REG_X0]; @@ -68,12 +62,9 @@ int arm64_reg_read(uch handle, unsigned int regid, void *value) #define WRITE_BYTE_H(x, b) (x = (x & ~0xff00) | (b & 0xff)) #define WRITE_BYTE_L(x, b) (x = (x & ~0xff) | (b & 0xff)) -int arm64_reg_write(uch handle, unsigned int regid, const void *value) +int arm64_reg_write(struct uc_struct *uc, unsigned int regid, const void *value) { - CPUState *mycpu; - struct uc_struct *uc = (struct uc_struct *) handle; - - mycpu = first_cpu; + CPUState *mycpu = first_cpu; if (regid >= UC_ARM64_REG_X0 && regid <= UC_ARM64_REG_X28) ARM_CPU(uc, mycpu)->env.xregs[regid - UC_ARM64_REG_X0] = *(int64_t *)value; diff --git a/qemu/target-arm/unicorn_arm.c b/qemu/target-arm/unicorn_arm.c index 9737906c..dcb2a65f 100644 --- a/qemu/target-arm/unicorn_arm.c +++ b/qemu/target-arm/unicorn_arm.c @@ -25,9 +25,9 @@ static void arm_set_pc(struct uc_struct *uc, uint64_t address) ((CPUARMState *)uc->current_cpu->env_ptr)->regs[15] = address; } -void arm_reg_reset(uch handle) +void arm_reg_reset(struct uc_struct *uc) { - struct uc_struct *uc = (struct uc_struct *) handle; + (void)uc; CPUArchState *env; env = first_cpu->env_ptr; @@ -36,10 +36,9 @@ void arm_reg_reset(uch handle) env->pc = 0; } -int arm_reg_read(uch handle, unsigned int regid, void *value) +int arm_reg_read(struct uc_struct *uc, unsigned int regid, void *value) { CPUState *mycpu; - struct uc_struct *uc = (struct uc_struct *) handle; mycpu = first_cpu; @@ -78,12 +77,9 @@ int arm_reg_read(uch handle, unsigned int regid, void *value) #define WRITE_BYTE_H(x, b) (x = (x & ~0xff00) | (b & 0xff)) #define WRITE_BYTE_L(x, b) (x = (x & ~0xff) | (b & 0xff)) -int arm_reg_write(uch handle, unsigned int regid, const void *value) +int arm_reg_write(struct uc_struct *uc, unsigned int regid, const void *value) { - CPUState *mycpu; - struct uc_struct *uc = (struct uc_struct *) handle; - - mycpu = first_cpu; + CPUState *mycpu = first_cpu; switch(uc->mode) { default: