This commit is contained in:
2022-02-17 10:37:34 +01:00
parent 3ed9dbda13
commit 8d9ca1ce84

View File

@@ -143,6 +143,9 @@ void ppc_reg_reset(struct uc_struct *uc)
// http://www.csit-sun.pub.ro/~cpop/Documentatie_SMP/Motorola_PowerPC/PowerPc/GenInfo/pemch2.pdf // http://www.csit-sun.pub.ro/~cpop/Documentatie_SMP/Motorola_PowerPC/PowerPc/GenInfo/pemch2.pdf
static void reg_read(CPUPPCState *env, unsigned int regid, void *value) static void reg_read(CPUPPCState *env, unsigned int regid, void *value)
{ {
uint32_t val;
int i;
if (regid >= UC_PPC_REG_0 && regid <= UC_PPC_REG_31) if (regid >= UC_PPC_REG_0 && regid <= UC_PPC_REG_31)
*(ppcreg_t *)value = env->gpr[regid - UC_PPC_REG_0]; *(ppcreg_t *)value = env->gpr[regid - UC_PPC_REG_0];
else { else {
@@ -196,13 +199,14 @@ static void reg_read(CPUPPCState *env, unsigned int regid, void *value)
case UC_PPC_REG_CR7: case UC_PPC_REG_CR7:
*(uint32_t *)value = env->crf[regid - UC_PPC_REG_CR0]; *(uint32_t *)value = env->crf[regid - UC_PPC_REG_CR0];
break; break;
case UC_PPC_REG_CR: { case UC_PPC_REG_CR:
uint32_t cr = 0; val = 0;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
cr <<= 4; val <<= 4;
cr |= env->crf[i]; val |= env->crf[i];
} }
} break; *(uint32_t *)value = val;
break;
case UC_PPC_REG_LR: case UC_PPC_REG_LR:
*(ppcreg_t *)value = env->lr; *(ppcreg_t *)value = env->lr;
break; break;
@@ -226,6 +230,9 @@ static void reg_read(CPUPPCState *env, unsigned int regid, void *value)
static void reg_write(CPUPPCState *env, unsigned int regid, const void *value) static void reg_write(CPUPPCState *env, unsigned int regid, const void *value)
{ {
uint32_t val;
int i;
if (regid >= UC_PPC_REG_0 && regid <= UC_PPC_REG_31) if (regid >= UC_PPC_REG_0 && regid <= UC_PPC_REG_31)
env->gpr[regid - UC_PPC_REG_0] = *(ppcreg_t *)value; env->gpr[regid - UC_PPC_REG_0] = *(ppcreg_t *)value;
else { else {
@@ -279,13 +286,13 @@ static void reg_write(CPUPPCState *env, unsigned int regid, const void *value)
case UC_PPC_REG_CR7: case UC_PPC_REG_CR7:
env->crf[regid - UC_PPC_REG_CR0] = (*(uint32_t *)value) & 0b1111; env->crf[regid - UC_PPC_REG_CR0] = (*(uint32_t *)value) & 0b1111;
break; break;
case UC_PPC_REG_CR: { case UC_PPC_REG_CR:
uint32_t cr = *(uint32_t *)value; val = *(uint32_t *)value;
for (int i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
env->crf[i] = cr & 0b1111; env->crf[i] = val & 0b1111;
cr >>= 4; val >>= 4;
} }
} break; break;
case UC_PPC_REG_LR: case UC_PPC_REG_LR:
env->lr = *(ppcreg_t *)value; env->lr = *(ppcreg_t *)value;
break; break;