mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 08:05:36 +00:00
cpu-exec: Purge all uses of ENV_GET_CPU()
Remove un-needed usages of ENV_GET_CPU() by converting the APIs to use CPUState pointers and retrieving the env_ptr as minimally needed. Scripted conversion for target-* change: for I in target-*/cpu.h; do sed -i \ 's/\(^int cpu_[^_]*_exec(\)[^ ][^ ]* \*s);$/\1CPUState *cpu);/' \ $I; done Backports commit ea3e9847408131abc840240bd61e892d28459452 from qemu
This commit is contained in:
parent
9e23308b66
commit
e51f8c9f6f
|
@ -28,10 +28,10 @@
|
||||||
#include "uc_priv.h"
|
#include "uc_priv.h"
|
||||||
|
|
||||||
static tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr);
|
static tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr);
|
||||||
static TranslationBlock *tb_find_slow(CPUArchState *env, target_ulong pc,
|
static TranslationBlock *tb_find_slow(CPUState *cpu, target_ulong pc,
|
||||||
target_ulong cs_base, uint64_t flags);
|
target_ulong cs_base, uint64_t flags);
|
||||||
static TranslationBlock *tb_find_fast(CPUArchState *env);
|
static TranslationBlock *tb_find_fast(CPUState *cpu);
|
||||||
static void cpu_handle_debug_exception(CPUArchState *env);
|
static void cpu_handle_debug_exception(CPUState *cpu);
|
||||||
|
|
||||||
void cpu_loop_exit(CPUState *cpu)
|
void cpu_loop_exit(CPUState *cpu)
|
||||||
{
|
{
|
||||||
|
@ -55,9 +55,9 @@ void cpu_resume_from_signal(CPUState *cpu, void *puc)
|
||||||
|
|
||||||
/* main execution loop */
|
/* main execution loop */
|
||||||
|
|
||||||
int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
|
int cpu_exec(struct uc_struct *uc, CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUState *cpu = ENV_GET_CPU(env);
|
CPUArchState *env = cpu->env_ptr;
|
||||||
TCGContext *tcg_ctx = env->uc->tcg_ctx;
|
TCGContext *tcg_ctx = env->uc->tcg_ctx;
|
||||||
CPUClass *cc = CPU_GET_CLASS(uc, cpu);
|
CPUClass *cc = CPU_GET_CLASS(uc, cpu);
|
||||||
#ifdef TARGET_I386
|
#ifdef TARGET_I386
|
||||||
|
@ -116,7 +116,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
|
||||||
/* exit request from the cpu execution loop */
|
/* exit request from the cpu execution loop */
|
||||||
ret = cpu->exception_index;
|
ret = cpu->exception_index;
|
||||||
if (ret == EXCP_DEBUG) {
|
if (ret == EXCP_DEBUG) {
|
||||||
cpu_handle_debug_exception(env);
|
cpu_handle_debug_exception(cpu);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -211,7 +211,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
|
||||||
cpu->exception_index = EXCP_INTERRUPT;
|
cpu->exception_index = EXCP_INTERRUPT;
|
||||||
cpu_loop_exit(cpu);
|
cpu_loop_exit(cpu);
|
||||||
}
|
}
|
||||||
tb = tb_find_fast(env); // qq
|
tb = tb_find_fast(cpu); // UNICORN
|
||||||
if (!tb) { // invalid TB due to invalid code?
|
if (!tb) { // invalid TB due to invalid code?
|
||||||
uc->invalid_error = UC_ERR_FETCH_UNMAPPED;
|
uc->invalid_error = UC_ERR_FETCH_UNMAPPED;
|
||||||
ret = EXCP_HLT;
|
ret = EXCP_HLT;
|
||||||
|
@ -243,7 +243,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
|
||||||
if (likely(!cpu->exit_request)) {
|
if (likely(!cpu->exit_request)) {
|
||||||
tc_ptr = tb->tc_ptr;
|
tc_ptr = tb->tc_ptr;
|
||||||
/* execute the generated code */
|
/* execute the generated code */
|
||||||
next_tb = cpu_tb_exec(cpu, tc_ptr); // qq
|
next_tb = cpu_tb_exec(cpu, tc_ptr); // UNICORN
|
||||||
|
|
||||||
switch (next_tb & TB_EXIT_MASK) {
|
switch (next_tb & TB_EXIT_MASK) {
|
||||||
case TB_EXIT_REQUESTED:
|
case TB_EXIT_REQUESTED:
|
||||||
|
@ -335,10 +335,12 @@ static tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr)
|
||||||
return next_tb;
|
return next_tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TranslationBlock *tb_find_slow(CPUArchState *env, target_ulong pc,
|
static TranslationBlock *tb_find_slow(CPUState *cpu,
|
||||||
target_ulong cs_base, uint64_t flags) // qq
|
target_ulong pc,
|
||||||
|
target_ulong cs_base,
|
||||||
|
uint64_t flags)
|
||||||
{
|
{
|
||||||
CPUState *cpu = ENV_GET_CPU(env);
|
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
|
||||||
TCGContext *tcg_ctx = env->uc->tcg_ctx;
|
TCGContext *tcg_ctx = env->uc->tcg_ctx;
|
||||||
TranslationBlock *tb, **ptb1;
|
TranslationBlock *tb, **ptb1;
|
||||||
unsigned int h;
|
unsigned int h;
|
||||||
|
@ -394,9 +396,9 @@ found:
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TranslationBlock *tb_find_fast(CPUArchState *env) // qq
|
static TranslationBlock *tb_find_fast(CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUState *cpu = ENV_GET_CPU(env);
|
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
|
||||||
TranslationBlock *tb;
|
TranslationBlock *tb;
|
||||||
target_ulong cs_base, pc;
|
target_ulong cs_base, pc;
|
||||||
int flags;
|
int flags;
|
||||||
|
@ -408,15 +410,14 @@ static TranslationBlock *tb_find_fast(CPUArchState *env) // qq
|
||||||
tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
|
tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
|
||||||
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
|
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
|
||||||
tb->flags != flags)) {
|
tb->flags != flags)) {
|
||||||
tb = tb_find_slow(env, pc, cs_base, flags); // qq
|
tb = tb_find_slow(cpu, pc, cs_base, flags); // qq
|
||||||
}
|
}
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_handle_debug_exception(CPUArchState *env)
|
static void cpu_handle_debug_exception(CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUState *cpu = ENV_GET_CPU(env);
|
CPUClass *cc = CPU_GET_CLASS(cpu->uc, cpu);
|
||||||
CPUClass *cc = CPU_GET_CLASS(env->uc, cpu);
|
|
||||||
CPUWatchpoint *wp;
|
CPUWatchpoint *wp;
|
||||||
|
|
||||||
if (!cpu->watchpoint_hit) {
|
if (!cpu->watchpoint_hit) {
|
||||||
|
|
|
@ -117,8 +117,7 @@ static int qemu_tcg_init_vcpu(CPUState *cpu)
|
||||||
|
|
||||||
static int tcg_cpu_exec(struct uc_struct *uc, CPUState *cpu)
|
static int tcg_cpu_exec(struct uc_struct *uc, CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUArchState *env = cpu->env_ptr;
|
return cpu_exec(uc, cpu);
|
||||||
return cpu_exec(uc, env);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tcg_exec_all(struct uc_struct* uc)
|
static bool tcg_exec_all(struct uc_struct* uc)
|
||||||
|
|
|
@ -507,7 +507,7 @@ typedef struct CPUARMState {
|
||||||
#include "cpu-qom.h"
|
#include "cpu-qom.h"
|
||||||
|
|
||||||
ARMCPU *cpu_arm_init(struct uc_struct *uc, const char *cpu_model);
|
ARMCPU *cpu_arm_init(struct uc_struct *uc, const char *cpu_model);
|
||||||
int cpu_arm_exec(struct uc_struct *uc, CPUARMState *s);
|
int cpu_arm_exec(struct uc_struct *uc, CPUState *cpu);
|
||||||
uint32_t do_arm_semihosting(CPUARMState *env);
|
uint32_t do_arm_semihosting(CPUARMState *env);
|
||||||
void aarch64_sync_32_to_64(CPUARMState *env);
|
void aarch64_sync_32_to_64(CPUARMState *env);
|
||||||
void aarch64_sync_64_to_32(CPUARMState *env);
|
void aarch64_sync_64_to_32(CPUARMState *env);
|
||||||
|
|
|
@ -980,7 +980,7 @@ typedef struct CPUX86State {
|
||||||
#include "cpu-qom.h"
|
#include "cpu-qom.h"
|
||||||
|
|
||||||
X86CPU *cpu_x86_create(struct uc_struct *uc, const char *cpu_model, Error **errp);
|
X86CPU *cpu_x86_create(struct uc_struct *uc, const char *cpu_model, Error **errp);
|
||||||
int cpu_x86_exec(struct uc_struct *uc, CPUX86State *s);
|
int cpu_x86_exec(struct uc_struct *uc, CPUState *cpu);
|
||||||
void x86_cpudef_setup(void);
|
void x86_cpudef_setup(void);
|
||||||
int cpu_x86_support_mca_broadcast(CPUX86State *env);
|
int cpu_x86_support_mca_broadcast(CPUX86State *env);
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ typedef struct CPUM68KState {
|
||||||
|
|
||||||
void m68k_tcg_init(struct uc_struct *uc);
|
void m68k_tcg_init(struct uc_struct *uc);
|
||||||
M68kCPU *cpu_m68k_init(struct uc_struct *uc, const char *cpu_model);
|
M68kCPU *cpu_m68k_init(struct uc_struct *uc, const char *cpu_model);
|
||||||
int cpu_m68k_exec(struct uc_struct *uc, CPUM68KState *s);
|
int cpu_m68k_exec(struct uc_struct *uc, CPUState *cpu);
|
||||||
/* you can call this signal handler from your SIGBUS and SIGSEGV
|
/* you can call this signal handler from your SIGBUS and SIGSEGV
|
||||||
signal handlers to inform the virtual CPU of exceptions. non zero
|
signal handlers to inform the virtual CPU of exceptions. non zero
|
||||||
is returned if the signal was handled by the virtual CPU. */
|
is returned if the signal was handled by the virtual CPU. */
|
||||||
|
|
|
@ -752,7 +752,7 @@ enum {
|
||||||
*/
|
*/
|
||||||
#define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0
|
#define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0
|
||||||
|
|
||||||
int cpu_mips_exec(struct uc_struct *uc, CPUMIPSState *s);
|
int cpu_mips_exec(struct uc_struct *uc, CPUState *cpu);
|
||||||
void mips_tcg_init(struct uc_struct *uc);
|
void mips_tcg_init(struct uc_struct *uc);
|
||||||
MIPSCPU *cpu_mips_init(struct uc_struct *uc, const char *cpu_model);
|
MIPSCPU *cpu_mips_init(struct uc_struct *uc, const char *cpu_model);
|
||||||
int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
|
int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
|
||||||
|
|
|
@ -542,7 +542,7 @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
|
||||||
void gen_intermediate_code_init(CPUSPARCState *env);
|
void gen_intermediate_code_init(CPUSPARCState *env);
|
||||||
|
|
||||||
/* cpu-exec.c */
|
/* cpu-exec.c */
|
||||||
int cpu_sparc_exec(struct uc_struct *uc, CPUSPARCState *s);
|
int cpu_sparc_exec(struct uc_struct *uc, CPUState *cpu);
|
||||||
|
|
||||||
/* win_helper.c */
|
/* win_helper.c */
|
||||||
target_ulong cpu_get_psr(CPUSPARCState *env1);
|
target_ulong cpu_get_psr(CPUSPARCState *env1);
|
||||||
|
|
Loading…
Reference in a new issue