diff options
Diffstat (limited to 'target-ppc')
-rw-r--r-- | target-ppc/helper.c | 53 | ||||
-rw-r--r-- | target-ppc/op.c | 33 | ||||
-rw-r--r-- | target-ppc/op_helper.c | 41 | ||||
-rw-r--r-- | target-ppc/op_helper.h | 4 | ||||
-rw-r--r-- | target-ppc/translate.c | 10 | ||||
-rw-r--r-- | target-ppc/translate_init.c | 18 |
6 files changed, 137 insertions, 22 deletions
diff --git a/target-ppc/helper.c b/target-ppc/helper.c index a7d0391..aac7907 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -649,10 +649,10 @@ int mmu4xx_get_physical_address (CPUState *env, mmu_ctx_t *ctx, } mask = ~(tlb->size - 1); if (loglevel) { - fprintf(logfile, "%s: TLB %d address " ADDRX " PID " ADDRX " <=> " - ADDRX " " ADDRX " " ADDRX "\n", - __func__, i, address, env->spr[SPR_40x_PID], - tlb->EPN, mask, tlb->PID); + fprintf(logfile, "%s: TLB %d address " ADDRX " PID %d <=> " + ADDRX " " ADDRX " %d\n", + __func__, i, address, (int)env->spr[SPR_40x_PID], + tlb->EPN, mask, (int)tlb->PID); } /* Check PID */ if (tlb->PID != 0 && tlb->PID != env->spr[SPR_40x_PID]) @@ -1450,9 +1450,6 @@ void do_interrupt (CPUState *env) if (loglevel) { fprintf(logfile, "DSI exception: DSISR=0x" ADDRX" DAR=0x" ADDRX "\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]); - } else { - printf("DSI exception: DSISR=0x" ADDRX" DAR=0x" ADDRX "\n", - env->spr[SPR_DSISR], env->spr[SPR_DAR]); } #endif goto store_next; @@ -1495,7 +1492,9 @@ void do_interrupt (CPUState *env) case EXCP_FP: if (msr_fe0 == 0 && msr_fe1 == 0) { #if defined (DEBUG_EXCEPTIONS) - printf("Ignore floating point exception\n"); + if (loglevel) { + fprintf(logfile, "Ignore floating point exception\n"); + } #endif return; } @@ -1508,7 +1507,12 @@ void do_interrupt (CPUState *env) env->fpscr[7] |= 0x4; break; case EXCP_INVAL: - // printf("Invalid instruction at 0x" ADDRX "\n", env->nip); +#if defined (DEBUG_EXCEPTIONS) + if (loglevel) { + fprintf(logfile, "Invalid instruction at 0x" ADDRX "\n", + env->nip); + } +#endif msr |= 0x00080000; break; case EXCP_PRIV: @@ -1609,8 +1613,10 @@ void do_interrupt (CPUState *env) case PPC_FLAGS_EXCP_40x: /* PIT on 4xx */ msr &= ~0xFFFF0000; +#if defined (DEBUG_EXCEPTIONS) if (loglevel != 0) fprintf(logfile, "PIT exception\n"); +#endif goto store_next; case PPC_FLAGS_EXCP_602: case PPC_FLAGS_EXCP_603: @@ -1630,8 +1636,10 @@ void do_interrupt (CPUState *env) case PPC_FLAGS_EXCP_40x: /* FIT on 4xx */ msr &= ~0xFFFF0000; +#if defined (DEBUG_EXCEPTIONS) if (loglevel != 0) fprintf(logfile, "FIT exception\n"); +#endif goto store_next; default: cpu_abort(env, "Invalid exception 0x1010 !\n"); @@ -1644,8 +1652,10 @@ void do_interrupt (CPUState *env) case PPC_FLAGS_EXCP_40x: /* Watchdog on 4xx */ msr &= ~0xFFFF0000; +#if defined (DEBUG_EXCEPTIONS) if (loglevel != 0) fprintf(logfile, "WDT exception\n"); +#endif goto store_next; case PPC_FLAGS_EXCP_BOOKE: srr_0 = &env->spr[SPR_BOOKE_CSRR0]; @@ -1929,11 +1939,12 @@ void ppc_hw_interrupt (CPUPPCState *env) { int raised = 0; -#if 0 - printf("%s: %p pending %08x req %08x %08x me %d ee %d\n", - __func__, env, env->pending_interrupts, - env->interrupt_request, interrupt_request, - msr_me, msr_ee); +#if 1 + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: %p pending %08x req %08x me %d ee %d\n", + __func__, env, env->pending_interrupts, + env->interrupt_request, msr_me, msr_ee); + } #endif /* Raise it */ if (env->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) { @@ -2007,3 +2018,17 @@ void ppc_hw_interrupt (CPUPPCState *env) } } #endif /* !CONFIG_USER_ONLY */ + +void cpu_dump_EA (target_ulong EA) +{ + FILE *f; + + if (logfile) { + f = logfile; + } else { + f = stdout; + return; + } + fprintf(f, "Memory access at address " TARGET_FMT_lx "\n", EA); +} + diff --git a/target-ppc/op.c b/target-ppc/op.c index 3a2f5f8..68828f5 100644 --- a/target-ppc/op.c +++ b/target-ppc/op.c @@ -130,6 +130,13 @@ #define REG 31 #include "op_template.h" + +void OPPROTO op_print_mem_EA (void) +{ + do_print_mem_EA(T0); + RETURN(); +} + /* PowerPC state maintenance operations */ /* set_Rc0 */ PPC_OP(set_Rc0) @@ -360,15 +367,33 @@ void OPPROTO op_store_msr_32 (void) #endif /* SPR */ -PPC_OP(load_spr) +void OPPROTO op_load_spr (void) +{ + T0 = env->spr[PARAM1]; + RETURN(); +} + +void OPPROTO op_store_spr (void) +{ + env->spr[PARAM1] = T0; + RETURN(); +} + +void OPPROTO op_load_dump_spr (void) +{ + T0 = ppc_load_dump_spr(PARAM1); + RETURN(); +} + +void OPPROTO op_store_dump_spr (void) { - T0 = regs->spr[PARAM(1)]; + ppc_store_dump_spr(PARAM1, T0); RETURN(); } -PPC_OP(store_spr) +void OPPROTO op_mask_spr (void) { - regs->spr[PARAM(1)] = T0; + env->spr[PARAM1] &= ~T0; RETURN(); } diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index a65da36..140b7f5 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -68,6 +68,12 @@ void do_raise_exception (uint32_t exception) do_raise_exception_err(exception, 0); } +void cpu_dump_EA (target_ulong EA); +void do_print_mem_EA (target_ulong EA) +{ + cpu_dump_EA(EA); +} + /*****************************************************************************/ /* Registers load and stores */ void do_load_cr (void) @@ -181,6 +187,25 @@ void do_store_fpscr (uint32_t mask) set_float_rounding_mode(rnd_type, &env->fp_status); } +target_ulong ppc_load_dump_spr (int sprn) +{ + if (loglevel) { + fprintf(logfile, "Read SPR %d %03x => " ADDRX "\n", + sprn, sprn, env->spr[sprn]); + } + + return env->spr[sprn]; +} + +void ppc_store_dump_spr (int sprn, target_ulong val) +{ + if (loglevel) { + fprintf(logfile, "Write SPR %d %03x => " ADDRX " <= " ADDRX "\n", + sprn, sprn, env->spr[sprn], val); + } + env->spr[sprn] = val; +} + /*****************************************************************************/ /* Fixed point operations helpers */ #if defined(TARGET_PPC64) @@ -1250,10 +1275,14 @@ void do_load_dcr (void) target_ulong val; if (unlikely(env->dcr_env == NULL)) { - printf("No DCR environment\n"); + if (loglevel) { + fprintf(logfile, "No DCR environment\n"); + } do_raise_exception_err(EXCP_PROGRAM, EXCP_INVAL | EXCP_INVAL_INVAL); } else if (unlikely(ppc_dcr_read(env->dcr_env, T0, &val) != 0)) { - printf("DCR read error\n"); + if (loglevel) { + fprintf(logfile, "DCR read error %d %03x\n", (int)T0, (int)T0); + } do_raise_exception_err(EXCP_PROGRAM, EXCP_INVAL | EXCP_PRIV_REG); } else { T0 = val; @@ -1263,10 +1292,14 @@ void do_load_dcr (void) void do_store_dcr (void) { if (unlikely(env->dcr_env == NULL)) { - printf("No DCR environment\n"); + if (loglevel) { + fprintf(logfile, "No DCR environment\n"); + } do_raise_exception_err(EXCP_PROGRAM, EXCP_INVAL | EXCP_INVAL_INVAL); } else if (unlikely(ppc_dcr_write(env->dcr_env, T0, T1) != 0)) { - printf("DCR write error\n"); + if (loglevel) { + fprintf(logfile, "DCR write error %d %03x\n", (int)T0, (int)T0); + } do_raise_exception_err(EXCP_PROGRAM, EXCP_INVAL | EXCP_PRIV_REG); } } diff --git a/target-ppc/op_helper.h b/target-ppc/op_helper.h index abc295a..2930310 100644 --- a/target-ppc/op_helper.h +++ b/target-ppc/op_helper.h @@ -50,6 +50,8 @@ void glue(do_icbi_64, MEMSUFFIX) (void); #else +void do_print_mem_EA (target_ulong EA); + /* Registers load and stores */ void do_load_cr (void); void do_store_cr (uint32_t mask); @@ -57,6 +59,8 @@ void do_load_xer (void); void do_store_xer (void); void do_load_fpscr (void); void do_store_fpscr (uint32_t mask); +target_ulong ppc_load_dump_spr (int sprn); +void ppc_store_dump_spr (int sprn, target_ulong val); /* Integer arithmetic helpers */ void do_adde (void); diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 6145701..fa533fe 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -29,6 +29,7 @@ //#define DO_SINGLE_STEP //#define PPC_DEBUG_DISAS +//#define DEBUG_MEMORY_ACCESSES //#define DO_PPC_STATISTICS #if defined(USE_DIRECT_JUMP) @@ -1745,6 +1746,9 @@ static inline void gen_addr_imm_index (DisasContext *ctx, int maskl) if (likely(simm != 0)) gen_op_addi(simm); } +#ifdef DEBUG_MEMORY_ACCESSES + gen_op_print_mem_EA(); +#endif } static inline void gen_addr_reg_index (DisasContext *ctx) @@ -1756,6 +1760,9 @@ static inline void gen_addr_reg_index (DisasContext *ctx) gen_op_load_gpr_T1(rB(ctx->opcode)); gen_op_add(); } +#ifdef DEBUG_MEMORY_ACCESSES + gen_op_print_mem_EA(); +#endif } static inline void gen_addr_register (DisasContext *ctx) @@ -1765,6 +1772,9 @@ static inline void gen_addr_register (DisasContext *ctx) } else { gen_op_load_gpr_T0(rA(ctx->opcode)); } +#ifdef DEBUG_MEMORY_ACCESSES + gen_op_print_mem_EA(); +#endif } /*** Integer load ***/ diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 72e577d..c7a7324 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -25,6 +25,7 @@ //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR +//#define PPC_DEBUG_IRQ struct ppc_def_t { const unsigned char *name; @@ -61,6 +62,23 @@ static void spr_write_generic (void *opaque, int sprn) gen_op_store_spr(sprn); } +static void spr_read_dump (void *opaque, int sprn) +{ + gen_op_load_dump_spr(sprn); +} + +static void spr_write_dump (void *opaque, int sprn) +{ + gen_op_store_dump_spr(sprn); +} + +#if !defined(CONFIG_USER_ONLY) +static void spr_write_clear (void *opaque, int sprn) +{ + gen_op_mask_spr(sprn); +} +#endif + /* SPR common to all PowerPC */ /* XER */ static void spr_read_xer (void *opaque, int sprn) |