Add clang-format and format code to qemu code style
This commit is contained in:
@ -5,26 +5,38 @@
|
||||
#define UC_QEMU_TARGET_ARM_H
|
||||
|
||||
// functions to read & write registers
|
||||
int arm_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int arm_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int arm64_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int arm64_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int arm_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int arm_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
int arm64_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int arm64_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
|
||||
int arm_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int arm_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int armeb_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int armeb_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int arm64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int arm64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int arm64eb_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int arm64eb_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int arm_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int arm_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int armeb_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int armeb_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int arm64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int arm64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int arm64eb_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int arm64eb_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void arm_reg_reset(struct uc_struct *uc);
|
||||
void arm64_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void arm_uc_init(struct uc_struct* uc);
|
||||
void armeb_uc_init(struct uc_struct* uc);
|
||||
void arm_uc_init(struct uc_struct *uc);
|
||||
void armeb_uc_init(struct uc_struct *uc);
|
||||
|
||||
void arm64_uc_init(struct uc_struct* uc);
|
||||
void arm64eb_uc_init(struct uc_struct* uc);
|
||||
void arm64_uc_init(struct uc_struct *uc);
|
||||
void arm64eb_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,12 +6,16 @@
|
||||
#define UC_QEMU_TARGET_I386_H
|
||||
|
||||
// functions to read & write registers
|
||||
int x86_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int x86_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int x86_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int x86_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int x86_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int x86_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
int x86_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int x86_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void x86_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void x86_uc_init(struct uc_struct* uc);
|
||||
void x86_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@ static void m68k_set_pc(struct uc_struct *uc, uint64_t address)
|
||||
((CPUM68KState *)uc->cpu->env_ptr)->pc = address;
|
||||
}
|
||||
|
||||
static void m68k_release(void* ctx)
|
||||
static void m68k_release(void *ctx)
|
||||
{
|
||||
int i;
|
||||
TCGContext *tcg_ctx = (TCGContext *)ctx;
|
||||
@ -51,11 +51,12 @@ static void reg_read(CPUM68KState *env, unsigned int regid, void *value)
|
||||
else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7)
|
||||
*(int32_t *)value = env->dregs[regid - UC_M68K_REG_D0];
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_M68K_REG_PC:
|
||||
*(int32_t *)value = env->pc;
|
||||
break;
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_M68K_REG_PC:
|
||||
*(int32_t *)value = env->pc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,18 +70,20 @@ static void reg_write(CPUM68KState *env, unsigned int regid, const void *value)
|
||||
else if (regid >= UC_M68K_REG_D0 && regid <= UC_M68K_REG_D7)
|
||||
env->dregs[regid - UC_M68K_REG_D0] = *(uint32_t *)value;
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_M68K_REG_PC:
|
||||
env->pc = *(uint32_t *)value;
|
||||
break;
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_M68K_REG_PC:
|
||||
env->pc = *(uint32_t *)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||
int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count)
|
||||
{
|
||||
CPUM68KState* env = &(M68K_CPU(uc->cpu)->env);
|
||||
CPUM68KState *env = &(M68K_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@ -92,16 +95,17 @@ int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int cou
|
||||
return 0;
|
||||
}
|
||||
|
||||
int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||
int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count)
|
||||
{
|
||||
CPUM68KState* env = &(M68K_CPU(uc->cpu)->env);
|
||||
CPUM68KState *env = &(M68K_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
unsigned int regid = regs[i];
|
||||
const void *value = vals[i];
|
||||
reg_write(env, regid, value);
|
||||
if (regid == UC_M68K_REG_PC){
|
||||
if (regid == UC_M68K_REG_PC) {
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
@ -112,9 +116,10 @@ int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
}
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
int m68k_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int m68k_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
{
|
||||
CPUM68KState* env = (CPUM68KState* )ctx->data;
|
||||
CPUM68KState *env = (CPUM68KState *)ctx->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@ -127,9 +132,10 @@ int m68k_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **val
|
||||
}
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
int m68k_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int m68k_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
{
|
||||
CPUM68KState* env = (CPUM68KState* )ctx->data;
|
||||
CPUM68KState *env = (CPUM68KState *)ctx->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@ -153,7 +159,7 @@ static int m68k_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
}
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
void m68k_uc_init(struct uc_struct* uc)
|
||||
void m68k_uc_init(struct uc_struct *uc)
|
||||
{
|
||||
uc->release = m68k_release;
|
||||
uc->reg_read = m68k_reg_read;
|
||||
|
@ -5,12 +5,16 @@
|
||||
#define UC_QEMU_TARGET_M68K_H
|
||||
|
||||
// functions to read & write registers
|
||||
int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int m68k_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int m68k_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int m68k_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int m68k_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
int m68k_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int m68k_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void m68k_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void m68k_uc_init(struct uc_struct* uc);
|
||||
void m68k_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
@ -37,7 +37,6 @@ static void mips_set_pc(struct uc_struct *uc, uint64_t address)
|
||||
((CPUMIPSState *)uc->cpu->env_ptr)->active_tc.PC = address;
|
||||
}
|
||||
|
||||
|
||||
static void mips_release(void *ctx)
|
||||
{
|
||||
int i;
|
||||
@ -75,20 +74,21 @@ static void reg_read(CPUMIPSState *env, unsigned int regid, void *value)
|
||||
if (regid >= UC_MIPS_REG_0 && regid <= UC_MIPS_REG_31)
|
||||
*(mipsreg_t *)value = env->active_tc.gpr[regid - UC_MIPS_REG_0];
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_MIPS_REG_PC:
|
||||
*(mipsreg_t *)value = env->active_tc.PC;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_CONFIG3:
|
||||
*(mipsreg_t *)value = env->CP0_Config3;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_STATUS:
|
||||
*(mipsreg_t *)value = env->CP0_Status;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
*(mipsreg_t *)value = env->active_tc.CP0_UserLocal;
|
||||
break;
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_MIPS_REG_PC:
|
||||
*(mipsreg_t *)value = env->active_tc.PC;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_CONFIG3:
|
||||
*(mipsreg_t *)value = env->CP0_Config3;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_STATUS:
|
||||
*(mipsreg_t *)value = env->CP0_Status;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
*(mipsreg_t *)value = env->active_tc.CP0_UserLocal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,31 +100,33 @@ static void reg_write(CPUMIPSState *env, unsigned int regid, const void *value)
|
||||
if (regid >= UC_MIPS_REG_0 && regid <= UC_MIPS_REG_31)
|
||||
env->active_tc.gpr[regid - UC_MIPS_REG_0] = *(mipsreg_t *)value;
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_MIPS_REG_PC:
|
||||
env->active_tc.PC = *(mipsreg_t *)value;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_CONFIG3:
|
||||
env->CP0_Config3 = *(mipsreg_t *)value;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_STATUS:
|
||||
// TODO: ALL CP0 REGS
|
||||
// https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00090-2B-MIPS32PRA-AFP-06.02.pdf
|
||||
// https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00582-2B-microMIPS32-AFP-05.04.pdf
|
||||
env->CP0_Status = *(mipsreg_t *)value;
|
||||
compute_hflags(env);
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
env->active_tc.CP0_UserLocal = *(mipsreg_t *)value;
|
||||
break;
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_MIPS_REG_PC:
|
||||
env->active_tc.PC = *(mipsreg_t *)value;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_CONFIG3:
|
||||
env->CP0_Config3 = *(mipsreg_t *)value;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_STATUS:
|
||||
// TODO: ALL CP0 REGS
|
||||
// https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00090-2B-MIPS32PRA-AFP-06.02.pdf
|
||||
// https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00582-2B-microMIPS32-AFP-05.04.pdf
|
||||
env->CP0_Status = *(mipsreg_t *)value;
|
||||
compute_hflags(env);
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
env->active_tc.CP0_UserLocal = *(mipsreg_t *)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int mips_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||
int mips_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count)
|
||||
{
|
||||
CPUMIPSState *env = &(MIPS_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -138,7 +140,8 @@ int mips_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int cou
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mips_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||
int mips_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count)
|
||||
{
|
||||
CPUMIPSState *env = &(MIPS_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -147,7 +150,7 @@ int mips_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
unsigned int regid = regs[i];
|
||||
const void *value = vals[i];
|
||||
reg_write(env, regid, value);
|
||||
if(regid == UC_MIPS_REG_PC){
|
||||
if (regid == UC_MIPS_REG_PC) {
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
@ -160,15 +163,19 @@ int mips_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_MIPS64
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
int mips64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int mips64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#else
|
||||
int mips64el_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int mips64el_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#endif
|
||||
#else // if TARGET_MIPS
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
int mips_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int mips_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#else
|
||||
int mipsel_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int mipsel_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
@ -187,15 +194,19 @@ DEFAULT_VISIBILITY
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_MIPS64
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
int mips64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int mips64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#else
|
||||
int mips64el_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int mips64el_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#endif
|
||||
#else // if TARGET_MIPS
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
int mips_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int mips_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#else
|
||||
int mipsel_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int mipsel_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
@ -226,15 +237,15 @@ static int mips_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_MIPS64
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
void mips64_uc_init(struct uc_struct* uc)
|
||||
void mips64_uc_init(struct uc_struct *uc)
|
||||
#else
|
||||
void mips64el_uc_init(struct uc_struct* uc)
|
||||
void mips64el_uc_init(struct uc_struct *uc)
|
||||
#endif
|
||||
#else // if TARGET_MIPS
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
void mips_uc_init(struct uc_struct* uc)
|
||||
void mips_uc_init(struct uc_struct *uc)
|
||||
#else
|
||||
void mipsel_uc_init(struct uc_struct* uc)
|
||||
void mipsel_uc_init(struct uc_struct *uc)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
|
@ -5,22 +5,32 @@
|
||||
#define UC_QEMU_TARGET_MIPS_H
|
||||
|
||||
// functions to read & write registers
|
||||
int mips_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int mips_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int mips_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int mips_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
|
||||
int mips_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int mips_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int mipsel_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int mipsel_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int mips64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int mips64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int mips64el_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int mips64el_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int mips_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int mips_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int mipsel_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int mipsel_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int mips64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int mips64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int mips64el_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int mips64el_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void mips_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void mips_uc_init(struct uc_struct* uc);
|
||||
void mipsel_uc_init(struct uc_struct* uc);
|
||||
void mips64_uc_init(struct uc_struct* uc);
|
||||
void mips64el_uc_init(struct uc_struct* uc);
|
||||
void mips_uc_init(struct uc_struct *uc);
|
||||
void mipsel_uc_init(struct uc_struct *uc);
|
||||
void mips64_uc_init(struct uc_struct *uc);
|
||||
void mips64el_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
@ -18,14 +18,14 @@ typedef uint32_t ppcreg_t;
|
||||
|
||||
static uint64_t ppc_mem_redirect(uint64_t address)
|
||||
{
|
||||
/* // kseg0 range masks off high address bit
|
||||
if (address >= 0x80000000 && address <= 0x9fffffff)
|
||||
return address & 0x7fffffff;
|
||||
/* // kseg0 range masks off high address bit
|
||||
if (address >= 0x80000000 && address <= 0x9fffffff)
|
||||
return address & 0x7fffffff;
|
||||
|
||||
// kseg1 range masks off top 3 address bits
|
||||
if (address >= 0xa0000000 && address <= 0xbfffffff) {
|
||||
return address & 0x1fffffff;
|
||||
}*/
|
||||
// kseg1 range masks off top 3 address bits
|
||||
if (address >= 0xa0000000 && address <= 0xbfffffff) {
|
||||
return address & 0x1fffffff;
|
||||
}*/
|
||||
|
||||
// no redirect
|
||||
return address;
|
||||
@ -59,12 +59,12 @@ static void ppc_release(void *ctx)
|
||||
for (i = 0; i < 32; i++) {
|
||||
g_free(tcg_ctx->cpu_gpr[i]);
|
||||
}
|
||||
// g_free(tcg_ctx->cpu_PC);
|
||||
// g_free(tcg_ctx->cpu_PC);
|
||||
g_free(tcg_ctx->btarget);
|
||||
g_free(tcg_ctx->bcond);
|
||||
g_free(tcg_ctx->cpu_dspctrl);
|
||||
|
||||
// g_free(tcg_ctx->tb_ctx.tbs);
|
||||
// g_free(tcg_ctx->tb_ctx.tbs);
|
||||
|
||||
ppc_cpu_instance_finalize(tcg_ctx->uc->cpu);
|
||||
ppc_cpu_unrealize(tcg_ctx->uc->cpu);
|
||||
@ -84,17 +84,18 @@ static void reg_read(CPUPPCState *env, unsigned int regid, void *value)
|
||||
if (regid >= UC_PPC_REG_0 && regid <= UC_PPC_REG_31)
|
||||
*(ppcreg_t *)value = env->gpr[regid - UC_PPC_REG_0];
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_PPC_REG_PC:
|
||||
*(ppcreg_t *)value = env->nip;
|
||||
break;
|
||||
/* case UC_PPC_REG_CP0_CONFIG3:
|
||||
*(mipsreg_t *)value = env->CP0_Config3;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
*(mipsreg_t *)value = env->active_tc.CP0_UserLocal;
|
||||
break; */
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_PPC_REG_PC:
|
||||
*(ppcreg_t *)value = env->nip;
|
||||
break;
|
||||
/* case UC_PPC_REG_CP0_CONFIG3:
|
||||
*(mipsreg_t *)value = env->CP0_Config3;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
*(mipsreg_t *)value = env->active_tc.CP0_UserLocal;
|
||||
break; */
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,24 +107,26 @@ static void reg_write(CPUPPCState *env, unsigned int regid, const void *value)
|
||||
if (regid >= UC_PPC_REG_0 && regid <= UC_PPC_REG_31)
|
||||
env->gpr[regid - UC_PPC_REG_0] = *(ppcreg_t *)value;
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_PPC_REG_PC:
|
||||
env->nip = *(ppcreg_t *)value;
|
||||
break;
|
||||
/* case UC_MIPS_REG_CP0_CONFIG3:
|
||||
env->CP0_Config3 = *(mipsreg_t *)value;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
env->active_tc.CP0_UserLocal = *(mipsreg_t *)value;
|
||||
break; */
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_PPC_REG_PC:
|
||||
env->nip = *(ppcreg_t *)value;
|
||||
break;
|
||||
/* case UC_MIPS_REG_CP0_CONFIG3:
|
||||
env->CP0_Config3 = *(mipsreg_t *)value;
|
||||
break;
|
||||
case UC_MIPS_REG_CP0_USERLOCAL:
|
||||
env->active_tc.CP0_UserLocal = *(mipsreg_t *)value;
|
||||
break; */
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int ppc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||
int ppc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count)
|
||||
{
|
||||
CPUPPCState *env = &(POWERPC_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -137,7 +140,8 @@ int ppc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int coun
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ppc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||
int ppc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count)
|
||||
{
|
||||
CPUPPCState *env = &(POWERPC_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -158,9 +162,11 @@ int ppc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, i
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_PPC64
|
||||
int ppc64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int ppc64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#else
|
||||
int ppc_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int ppc_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#endif
|
||||
{
|
||||
CPUPPCState *env = (CPUPPCState *)ctx->data;
|
||||
@ -177,9 +183,11 @@ int ppc_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_PPC64
|
||||
int ppc64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int ppc64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#else
|
||||
int ppc_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int ppc_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#endif
|
||||
{
|
||||
CPUPPCState *env = (CPUPPCState *)ctx->data;
|
||||
@ -208,9 +216,9 @@ static int ppc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_PPC64
|
||||
void ppc64_uc_init(struct uc_struct* uc)
|
||||
void ppc64_uc_init(struct uc_struct *uc)
|
||||
#else
|
||||
void ppc_uc_init(struct uc_struct* uc)
|
||||
void ppc_uc_init(struct uc_struct *uc)
|
||||
#endif
|
||||
{
|
||||
uc->reg_read = ppc_reg_read;
|
||||
|
@ -5,16 +5,22 @@
|
||||
#define UC_QEMU_TARGET_PPC_H
|
||||
|
||||
// functions to read & write registers
|
||||
int ppc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int ppc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int ppc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int ppc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
|
||||
int ppc_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int ppc_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int ppc64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int ppc64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int ppc_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int ppc_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int ppc64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int ppc64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void ppc_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void ppc_uc_init(struct uc_struct* uc);
|
||||
void ppc64_uc_init(struct uc_struct* uc);
|
||||
void ppc_uc_init(struct uc_struct *uc);
|
||||
void ppc64_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
@ -36,99 +36,97 @@ static void riscv_release(void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
void riscv_reg_reset(struct uc_struct *uc)
|
||||
{
|
||||
}
|
||||
void riscv_reg_reset(struct uc_struct *uc) {}
|
||||
|
||||
static void reg_read(CPURISCVState *env, unsigned int regid, void *value)
|
||||
{
|
||||
switch(regid) {
|
||||
case UC_RISCV_REG_X0:
|
||||
case UC_RISCV_REG_X1:
|
||||
case UC_RISCV_REG_X2:
|
||||
case UC_RISCV_REG_X3:
|
||||
case UC_RISCV_REG_X4:
|
||||
case UC_RISCV_REG_X5:
|
||||
case UC_RISCV_REG_X6:
|
||||
case UC_RISCV_REG_X7:
|
||||
case UC_RISCV_REG_X8:
|
||||
case UC_RISCV_REG_X9:
|
||||
case UC_RISCV_REG_X10:
|
||||
case UC_RISCV_REG_X11:
|
||||
case UC_RISCV_REG_X12:
|
||||
case UC_RISCV_REG_X13:
|
||||
case UC_RISCV_REG_X14:
|
||||
case UC_RISCV_REG_X15:
|
||||
case UC_RISCV_REG_X16:
|
||||
case UC_RISCV_REG_X17:
|
||||
case UC_RISCV_REG_X18:
|
||||
case UC_RISCV_REG_X19:
|
||||
case UC_RISCV_REG_X20:
|
||||
case UC_RISCV_REG_X21:
|
||||
case UC_RISCV_REG_X22:
|
||||
case UC_RISCV_REG_X23:
|
||||
case UC_RISCV_REG_X24:
|
||||
case UC_RISCV_REG_X25:
|
||||
case UC_RISCV_REG_X26:
|
||||
case UC_RISCV_REG_X27:
|
||||
case UC_RISCV_REG_X28:
|
||||
case UC_RISCV_REG_X29:
|
||||
case UC_RISCV_REG_X30:
|
||||
case UC_RISCV_REG_X31:
|
||||
switch (regid) {
|
||||
case UC_RISCV_REG_X0:
|
||||
case UC_RISCV_REG_X1:
|
||||
case UC_RISCV_REG_X2:
|
||||
case UC_RISCV_REG_X3:
|
||||
case UC_RISCV_REG_X4:
|
||||
case UC_RISCV_REG_X5:
|
||||
case UC_RISCV_REG_X6:
|
||||
case UC_RISCV_REG_X7:
|
||||
case UC_RISCV_REG_X8:
|
||||
case UC_RISCV_REG_X9:
|
||||
case UC_RISCV_REG_X10:
|
||||
case UC_RISCV_REG_X11:
|
||||
case UC_RISCV_REG_X12:
|
||||
case UC_RISCV_REG_X13:
|
||||
case UC_RISCV_REG_X14:
|
||||
case UC_RISCV_REG_X15:
|
||||
case UC_RISCV_REG_X16:
|
||||
case UC_RISCV_REG_X17:
|
||||
case UC_RISCV_REG_X18:
|
||||
case UC_RISCV_REG_X19:
|
||||
case UC_RISCV_REG_X20:
|
||||
case UC_RISCV_REG_X21:
|
||||
case UC_RISCV_REG_X22:
|
||||
case UC_RISCV_REG_X23:
|
||||
case UC_RISCV_REG_X24:
|
||||
case UC_RISCV_REG_X25:
|
||||
case UC_RISCV_REG_X26:
|
||||
case UC_RISCV_REG_X27:
|
||||
case UC_RISCV_REG_X28:
|
||||
case UC_RISCV_REG_X29:
|
||||
case UC_RISCV_REG_X30:
|
||||
case UC_RISCV_REG_X31:
|
||||
#ifdef TARGET_RISCV64
|
||||
*(int64_t *)value = env->gpr[regid - UC_RISCV_REG_X0];
|
||||
*(int64_t *)value = env->gpr[regid - UC_RISCV_REG_X0];
|
||||
#else
|
||||
*(int32_t *)value = env->gpr[regid - UC_RISCV_REG_X0];
|
||||
*(int32_t *)value = env->gpr[regid - UC_RISCV_REG_X0];
|
||||
#endif
|
||||
break;
|
||||
case UC_RISCV_REG_PC:
|
||||
break;
|
||||
case UC_RISCV_REG_PC:
|
||||
#ifdef TARGET_RISCV64
|
||||
*(int64_t *)value = env->pc;
|
||||
*(int64_t *)value = env->pc;
|
||||
#else
|
||||
*(int32_t *)value = env->pc;
|
||||
*(int32_t *)value = env->pc;
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case UC_RISCV_REG_F0: // "ft0"
|
||||
case UC_RISCV_REG_F1: // "ft1"
|
||||
case UC_RISCV_REG_F2: // "ft2"
|
||||
case UC_RISCV_REG_F3: // "ft3"
|
||||
case UC_RISCV_REG_F4: // "ft4"
|
||||
case UC_RISCV_REG_F5: // "ft5"
|
||||
case UC_RISCV_REG_F6: // "ft6"
|
||||
case UC_RISCV_REG_F7: // "ft7"
|
||||
case UC_RISCV_REG_F8: // "fs0"
|
||||
case UC_RISCV_REG_F9: // "fs1"
|
||||
case UC_RISCV_REG_F10: // "fa0"
|
||||
case UC_RISCV_REG_F11: // "fa1"
|
||||
case UC_RISCV_REG_F12: // "fa2"
|
||||
case UC_RISCV_REG_F13: // "fa3"
|
||||
case UC_RISCV_REG_F14: // "fa4"
|
||||
case UC_RISCV_REG_F15: // "fa5"
|
||||
case UC_RISCV_REG_F16: // "fa6"
|
||||
case UC_RISCV_REG_F17: // "fa7"
|
||||
case UC_RISCV_REG_F18: // "fs2"
|
||||
case UC_RISCV_REG_F19: // "fs3"
|
||||
case UC_RISCV_REG_F20: // "fs4"
|
||||
case UC_RISCV_REG_F21: // "fs5"
|
||||
case UC_RISCV_REG_F22: // "fs6"
|
||||
case UC_RISCV_REG_F23: // "fs7"
|
||||
case UC_RISCV_REG_F24: // "fs8"
|
||||
case UC_RISCV_REG_F25: // "fs9"
|
||||
case UC_RISCV_REG_F26: // "fs10"
|
||||
case UC_RISCV_REG_F27: // "fs11"
|
||||
case UC_RISCV_REG_F28: // "ft8"
|
||||
case UC_RISCV_REG_F29: // "ft9"
|
||||
case UC_RISCV_REG_F30: // "ft10"
|
||||
case UC_RISCV_REG_F31: // "ft11"
|
||||
case UC_RISCV_REG_F0: // "ft0"
|
||||
case UC_RISCV_REG_F1: // "ft1"
|
||||
case UC_RISCV_REG_F2: // "ft2"
|
||||
case UC_RISCV_REG_F3: // "ft3"
|
||||
case UC_RISCV_REG_F4: // "ft4"
|
||||
case UC_RISCV_REG_F5: // "ft5"
|
||||
case UC_RISCV_REG_F6: // "ft6"
|
||||
case UC_RISCV_REG_F7: // "ft7"
|
||||
case UC_RISCV_REG_F8: // "fs0"
|
||||
case UC_RISCV_REG_F9: // "fs1"
|
||||
case UC_RISCV_REG_F10: // "fa0"
|
||||
case UC_RISCV_REG_F11: // "fa1"
|
||||
case UC_RISCV_REG_F12: // "fa2"
|
||||
case UC_RISCV_REG_F13: // "fa3"
|
||||
case UC_RISCV_REG_F14: // "fa4"
|
||||
case UC_RISCV_REG_F15: // "fa5"
|
||||
case UC_RISCV_REG_F16: // "fa6"
|
||||
case UC_RISCV_REG_F17: // "fa7"
|
||||
case UC_RISCV_REG_F18: // "fs2"
|
||||
case UC_RISCV_REG_F19: // "fs3"
|
||||
case UC_RISCV_REG_F20: // "fs4"
|
||||
case UC_RISCV_REG_F21: // "fs5"
|
||||
case UC_RISCV_REG_F22: // "fs6"
|
||||
case UC_RISCV_REG_F23: // "fs7"
|
||||
case UC_RISCV_REG_F24: // "fs8"
|
||||
case UC_RISCV_REG_F25: // "fs9"
|
||||
case UC_RISCV_REG_F26: // "fs10"
|
||||
case UC_RISCV_REG_F27: // "fs11"
|
||||
case UC_RISCV_REG_F28: // "ft8"
|
||||
case UC_RISCV_REG_F29: // "ft9"
|
||||
case UC_RISCV_REG_F30: // "ft10"
|
||||
case UC_RISCV_REG_F31: // "ft11"
|
||||
#ifdef TARGET_RISCV64
|
||||
*(int64_t *)value = env->fpr[regid - UC_RISCV_REG_F0];
|
||||
*(int64_t *)value = env->fpr[regid - UC_RISCV_REG_F0];
|
||||
#else
|
||||
*(int32_t *)value = env->fpr[regid - UC_RISCV_REG_F0];
|
||||
*(int32_t *)value = env->fpr[regid - UC_RISCV_REG_F0];
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
@ -136,96 +134,97 @@ static void reg_read(CPURISCVState *env, unsigned int regid, void *value)
|
||||
|
||||
static void reg_write(CPURISCVState *env, unsigned int regid, const void *value)
|
||||
{
|
||||
switch(regid) {
|
||||
case UC_RISCV_REG_X0:
|
||||
case UC_RISCV_REG_X1:
|
||||
case UC_RISCV_REG_X2:
|
||||
case UC_RISCV_REG_X3:
|
||||
case UC_RISCV_REG_X4:
|
||||
case UC_RISCV_REG_X5:
|
||||
case UC_RISCV_REG_X6:
|
||||
case UC_RISCV_REG_X7:
|
||||
case UC_RISCV_REG_X8:
|
||||
case UC_RISCV_REG_X9:
|
||||
case UC_RISCV_REG_X10:
|
||||
case UC_RISCV_REG_X11:
|
||||
case UC_RISCV_REG_X12:
|
||||
case UC_RISCV_REG_X13:
|
||||
case UC_RISCV_REG_X14:
|
||||
case UC_RISCV_REG_X15:
|
||||
case UC_RISCV_REG_X16:
|
||||
case UC_RISCV_REG_X17:
|
||||
case UC_RISCV_REG_X18:
|
||||
case UC_RISCV_REG_X19:
|
||||
case UC_RISCV_REG_X20:
|
||||
case UC_RISCV_REG_X21:
|
||||
case UC_RISCV_REG_X22:
|
||||
case UC_RISCV_REG_X23:
|
||||
case UC_RISCV_REG_X24:
|
||||
case UC_RISCV_REG_X25:
|
||||
case UC_RISCV_REG_X26:
|
||||
case UC_RISCV_REG_X27:
|
||||
case UC_RISCV_REG_X28:
|
||||
case UC_RISCV_REG_X29:
|
||||
case UC_RISCV_REG_X30:
|
||||
case UC_RISCV_REG_X31:
|
||||
switch (regid) {
|
||||
case UC_RISCV_REG_X0:
|
||||
case UC_RISCV_REG_X1:
|
||||
case UC_RISCV_REG_X2:
|
||||
case UC_RISCV_REG_X3:
|
||||
case UC_RISCV_REG_X4:
|
||||
case UC_RISCV_REG_X5:
|
||||
case UC_RISCV_REG_X6:
|
||||
case UC_RISCV_REG_X7:
|
||||
case UC_RISCV_REG_X8:
|
||||
case UC_RISCV_REG_X9:
|
||||
case UC_RISCV_REG_X10:
|
||||
case UC_RISCV_REG_X11:
|
||||
case UC_RISCV_REG_X12:
|
||||
case UC_RISCV_REG_X13:
|
||||
case UC_RISCV_REG_X14:
|
||||
case UC_RISCV_REG_X15:
|
||||
case UC_RISCV_REG_X16:
|
||||
case UC_RISCV_REG_X17:
|
||||
case UC_RISCV_REG_X18:
|
||||
case UC_RISCV_REG_X19:
|
||||
case UC_RISCV_REG_X20:
|
||||
case UC_RISCV_REG_X21:
|
||||
case UC_RISCV_REG_X22:
|
||||
case UC_RISCV_REG_X23:
|
||||
case UC_RISCV_REG_X24:
|
||||
case UC_RISCV_REG_X25:
|
||||
case UC_RISCV_REG_X26:
|
||||
case UC_RISCV_REG_X27:
|
||||
case UC_RISCV_REG_X28:
|
||||
case UC_RISCV_REG_X29:
|
||||
case UC_RISCV_REG_X30:
|
||||
case UC_RISCV_REG_X31:
|
||||
#ifdef TARGET_RISCV64
|
||||
env->gpr[regid - UC_RISCV_REG_X0] = *(uint64_t *)value;
|
||||
env->gpr[regid - UC_RISCV_REG_X0] = *(uint64_t *)value;
|
||||
#else
|
||||
env->gpr[regid - UC_RISCV_REG_X0] = *(uint32_t *)value;
|
||||
env->gpr[regid - UC_RISCV_REG_X0] = *(uint32_t *)value;
|
||||
#endif
|
||||
break;
|
||||
case UC_RISCV_REG_PC:
|
||||
break;
|
||||
case UC_RISCV_REG_PC:
|
||||
#ifdef TARGET_RISCV64
|
||||
env->pc = *(uint64_t *)value;
|
||||
env->pc = *(uint64_t *)value;
|
||||
#else
|
||||
env->pc = *(uint32_t *)value;
|
||||
env->pc = *(uint32_t *)value;
|
||||
#endif
|
||||
break;
|
||||
case UC_RISCV_REG_F0: // "ft0"
|
||||
case UC_RISCV_REG_F1: // "ft1"
|
||||
case UC_RISCV_REG_F2: // "ft2"
|
||||
case UC_RISCV_REG_F3: // "ft3"
|
||||
case UC_RISCV_REG_F4: // "ft4"
|
||||
case UC_RISCV_REG_F5: // "ft5"
|
||||
case UC_RISCV_REG_F6: // "ft6"
|
||||
case UC_RISCV_REG_F7: // "ft7"
|
||||
case UC_RISCV_REG_F8: // "fs0"
|
||||
case UC_RISCV_REG_F9: // "fs1"
|
||||
case UC_RISCV_REG_F10: // "fa0"
|
||||
case UC_RISCV_REG_F11: // "fa1"
|
||||
case UC_RISCV_REG_F12: // "fa2"
|
||||
case UC_RISCV_REG_F13: // "fa3"
|
||||
case UC_RISCV_REG_F14: // "fa4"
|
||||
case UC_RISCV_REG_F15: // "fa5"
|
||||
case UC_RISCV_REG_F16: // "fa6"
|
||||
case UC_RISCV_REG_F17: // "fa7"
|
||||
case UC_RISCV_REG_F18: // "fs2"
|
||||
case UC_RISCV_REG_F19: // "fs3"
|
||||
case UC_RISCV_REG_F20: // "fs4"
|
||||
case UC_RISCV_REG_F21: // "fs5"
|
||||
case UC_RISCV_REG_F22: // "fs6"
|
||||
case UC_RISCV_REG_F23: // "fs7"
|
||||
case UC_RISCV_REG_F24: // "fs8"
|
||||
case UC_RISCV_REG_F25: // "fs9"
|
||||
case UC_RISCV_REG_F26: // "fs10"
|
||||
case UC_RISCV_REG_F27: // "fs11"
|
||||
case UC_RISCV_REG_F28: // "ft8"
|
||||
case UC_RISCV_REG_F29: // "ft9"
|
||||
case UC_RISCV_REG_F30: // "ft10"
|
||||
case UC_RISCV_REG_F31: // "ft11"
|
||||
break;
|
||||
case UC_RISCV_REG_F0: // "ft0"
|
||||
case UC_RISCV_REG_F1: // "ft1"
|
||||
case UC_RISCV_REG_F2: // "ft2"
|
||||
case UC_RISCV_REG_F3: // "ft3"
|
||||
case UC_RISCV_REG_F4: // "ft4"
|
||||
case UC_RISCV_REG_F5: // "ft5"
|
||||
case UC_RISCV_REG_F6: // "ft6"
|
||||
case UC_RISCV_REG_F7: // "ft7"
|
||||
case UC_RISCV_REG_F8: // "fs0"
|
||||
case UC_RISCV_REG_F9: // "fs1"
|
||||
case UC_RISCV_REG_F10: // "fa0"
|
||||
case UC_RISCV_REG_F11: // "fa1"
|
||||
case UC_RISCV_REG_F12: // "fa2"
|
||||
case UC_RISCV_REG_F13: // "fa3"
|
||||
case UC_RISCV_REG_F14: // "fa4"
|
||||
case UC_RISCV_REG_F15: // "fa5"
|
||||
case UC_RISCV_REG_F16: // "fa6"
|
||||
case UC_RISCV_REG_F17: // "fa7"
|
||||
case UC_RISCV_REG_F18: // "fs2"
|
||||
case UC_RISCV_REG_F19: // "fs3"
|
||||
case UC_RISCV_REG_F20: // "fs4"
|
||||
case UC_RISCV_REG_F21: // "fs5"
|
||||
case UC_RISCV_REG_F22: // "fs6"
|
||||
case UC_RISCV_REG_F23: // "fs7"
|
||||
case UC_RISCV_REG_F24: // "fs8"
|
||||
case UC_RISCV_REG_F25: // "fs9"
|
||||
case UC_RISCV_REG_F26: // "fs10"
|
||||
case UC_RISCV_REG_F27: // "fs11"
|
||||
case UC_RISCV_REG_F28: // "ft8"
|
||||
case UC_RISCV_REG_F29: // "ft9"
|
||||
case UC_RISCV_REG_F30: // "ft10"
|
||||
case UC_RISCV_REG_F31: // "ft11"
|
||||
#ifdef TARGET_RISCV64
|
||||
env->fpr[regid - UC_RISCV_REG_F0] = *(uint64_t *)value;
|
||||
env->fpr[regid - UC_RISCV_REG_F0] = *(uint64_t *)value;
|
||||
#else
|
||||
env->fpr[regid - UC_RISCV_REG_F0] = *(uint32_t *)value;
|
||||
env->fpr[regid - UC_RISCV_REG_F0] = *(uint32_t *)value;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int riscv_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||
int riscv_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count)
|
||||
{
|
||||
CPURISCVState *env = &(RISCV_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -239,7 +238,8 @@ int riscv_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int co
|
||||
return 0;
|
||||
}
|
||||
|
||||
int riscv_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||
int riscv_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count)
|
||||
{
|
||||
CPURISCVState *env = &(RISCV_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -248,11 +248,11 @@ int riscv_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
unsigned int regid = regs[i];
|
||||
const void *value = vals[i];
|
||||
reg_write(env, regid, value);
|
||||
if(regid == UC_RISCV_REG_PC){
|
||||
if (regid == UC_RISCV_REG_PC) {
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -260,10 +260,12 @@ int riscv_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_RISCV32
|
||||
int riscv32_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int riscv32_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#else
|
||||
/* TARGET_RISCV64 */
|
||||
int riscv64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
/* TARGET_RISCV64 */
|
||||
int riscv64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
#endif
|
||||
{
|
||||
CPURISCVState *env = (CPURISCVState *)ctx->data;
|
||||
@ -280,10 +282,12 @@ int riscv64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_RISCV32
|
||||
int riscv32_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int riscv32_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#else
|
||||
/* TARGET_RISCV64 */
|
||||
int riscv64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
/* TARGET_RISCV64 */
|
||||
int riscv64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
#endif
|
||||
{
|
||||
CPURISCVState *env = (CPURISCVState *)ctx->data;
|
||||
@ -301,14 +305,14 @@ int riscv64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *
|
||||
static bool riscv_stop_interrupt(struct uc_struct *uc, int intno)
|
||||
{
|
||||
// detect stop exception
|
||||
switch(intno){
|
||||
default:
|
||||
return false;
|
||||
case RISCV_EXCP_UNICORN_END:
|
||||
return true;
|
||||
case RISCV_EXCP_BREAKPOINT:
|
||||
uc->invalid_error = UC_ERR_EXCEPTION;
|
||||
return true;
|
||||
switch (intno) {
|
||||
default:
|
||||
return false;
|
||||
case RISCV_EXCP_UNICORN_END:
|
||||
return true;
|
||||
case RISCV_EXCP_BREAKPOINT:
|
||||
uc->invalid_error = UC_ERR_EXCEPTION;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,10 +336,10 @@ static int riscv_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
#ifdef TARGET_RISCV32
|
||||
void riscv32_uc_init(struct uc_struct* uc)
|
||||
void riscv32_uc_init(struct uc_struct *uc)
|
||||
#else
|
||||
/* TARGET_RISCV64 */
|
||||
void riscv64_uc_init(struct uc_struct* uc)
|
||||
/* TARGET_RISCV64 */
|
||||
void riscv64_uc_init(struct uc_struct *uc)
|
||||
#endif
|
||||
{
|
||||
uc->reg_read = riscv_reg_read;
|
||||
|
@ -6,16 +6,22 @@
|
||||
#define UC_QEMU_TARGET_RISCV_H
|
||||
|
||||
// functions to read & write registers
|
||||
int riscv_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int riscv_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int riscv_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int riscv_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
|
||||
int riscv32_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int riscv32_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int riscv64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int riscv64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int riscv32_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int riscv32_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int riscv64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int riscv64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void riscv_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void riscv32_uc_init(struct uc_struct* uc);
|
||||
void riscv64_uc_init(struct uc_struct* uc);
|
||||
void riscv32_uc_init(struct uc_struct *uc);
|
||||
void riscv64_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
@ -10,11 +10,11 @@
|
||||
|
||||
static bool sparc_stop_interrupt(struct uc_struct *uc, int intno)
|
||||
{
|
||||
switch(intno) {
|
||||
default:
|
||||
return false;
|
||||
case TT_ILL_INSN:
|
||||
return true;
|
||||
switch (intno) {
|
||||
default:
|
||||
return false;
|
||||
case TT_ILL_INSN:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,15 +63,16 @@ static void reg_read(CPUSPARCState *env, unsigned int regid, void *value)
|
||||
else if (regid >= UC_SPARC_REG_O0 && regid <= UC_SPARC_REG_O7)
|
||||
*(int32_t *)value = env->regwptr[regid - UC_SPARC_REG_O0];
|
||||
else if (regid >= UC_SPARC_REG_L0 && regid <= UC_SPARC_REG_L7)
|
||||
*(int32_t *)value = env->regwptr[8 + regid - UC_SPARC_REG_L0];
|
||||
*(int32_t *)value = env->regwptr[8 + regid - UC_SPARC_REG_L0];
|
||||
else if (regid >= UC_SPARC_REG_I0 && regid <= UC_SPARC_REG_I7)
|
||||
*(int32_t *)value = env->regwptr[16 + regid - UC_SPARC_REG_I0];
|
||||
*(int32_t *)value = env->regwptr[16 + regid - UC_SPARC_REG_I0];
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_SPARC_REG_PC:
|
||||
*(int32_t *)value = env->pc;
|
||||
break;
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_SPARC_REG_PC:
|
||||
*(int32_t *)value = env->pc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,21 +88,23 @@ static void reg_write(CPUSPARCState *env, unsigned int regid, const void *value)
|
||||
else if (regid >= UC_SPARC_REG_L0 && regid <= UC_SPARC_REG_L7)
|
||||
env->regwptr[8 + regid - UC_SPARC_REG_L0] = *(uint32_t *)value;
|
||||
else if (regid >= UC_SPARC_REG_I0 && regid <= UC_SPARC_REG_I7)
|
||||
env->regwptr[16 + regid - UC_SPARC_REG_I0] = *(uint32_t *)value;
|
||||
env->regwptr[16 + regid - UC_SPARC_REG_I0] = *(uint32_t *)value;
|
||||
else {
|
||||
switch(regid) {
|
||||
default: break;
|
||||
case UC_SPARC_REG_PC:
|
||||
env->pc = *(uint32_t *)value;
|
||||
env->npc = *(uint32_t *)value + 4;
|
||||
break;
|
||||
switch (regid) {
|
||||
default:
|
||||
break;
|
||||
case UC_SPARC_REG_PC:
|
||||
env->pc = *(uint32_t *)value;
|
||||
env->npc = *(uint32_t *)value + 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int sparc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count)
|
||||
int sparc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count)
|
||||
{
|
||||
CPUSPARCState *env = &(SPARC_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -115,7 +118,8 @@ int sparc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int co
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sparc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count)
|
||||
int sparc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count)
|
||||
{
|
||||
CPUSPARCState *env = &(SPARC_CPU(uc->cpu)->env);
|
||||
int i;
|
||||
@ -124,7 +128,7 @@ int sparc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
unsigned int regid = regs[i];
|
||||
const void *value = vals[i];
|
||||
reg_write(env, regid, value);
|
||||
if( regid == UC_SPARC_REG_PC){
|
||||
if (regid == UC_SPARC_REG_PC) {
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
@ -136,7 +140,8 @@ int sparc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
}
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
int sparc_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count)
|
||||
int sparc_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count)
|
||||
{
|
||||
CPUSPARCState *env = (CPUSPARCState *)ctx->data;
|
||||
int i;
|
||||
@ -151,7 +156,8 @@ int sparc_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **va
|
||||
}
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
int sparc_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count)
|
||||
int sparc_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count)
|
||||
{
|
||||
CPUSPARCState *env = (CPUSPARCState *)ctx->data;
|
||||
int i;
|
||||
@ -177,7 +183,7 @@ static int sparc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
}
|
||||
|
||||
DEFAULT_VISIBILITY
|
||||
void sparc_uc_init(struct uc_struct* uc)
|
||||
void sparc_uc_init(struct uc_struct *uc)
|
||||
{
|
||||
uc->release = sparc_release;
|
||||
uc->reg_read = sparc_reg_read;
|
||||
|
@ -5,16 +5,22 @@
|
||||
#define UC_QEMU_TARGET_SPARC_H
|
||||
|
||||
// functions to read & write registers
|
||||
int sparc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int count);
|
||||
int sparc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, int count);
|
||||
int sparc_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals,
|
||||
int count);
|
||||
int sparc_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals,
|
||||
int count);
|
||||
|
||||
int sparc_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int sparc_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int sparc64_context_reg_read(struct uc_context *ctx, unsigned int *regs, void **vals, int count);
|
||||
int sparc64_context_reg_write(struct uc_context *ctx, unsigned int *regs, void *const *vals, int count);
|
||||
int sparc_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int sparc_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
int sparc64_context_reg_read(struct uc_context *ctx, unsigned int *regs,
|
||||
void **vals, int count);
|
||||
int sparc64_context_reg_write(struct uc_context *ctx, unsigned int *regs,
|
||||
void *const *vals, int count);
|
||||
|
||||
void sparc_reg_reset(struct uc_struct *uc);
|
||||
|
||||
void sparc_uc_init(struct uc_struct* uc);
|
||||
void sparc64_uc_init(struct uc_struct* uc);
|
||||
void sparc_uc_init(struct uc_struct *uc);
|
||||
void sparc64_uc_init(struct uc_struct *uc);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user