cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
}
#if defined(PPC_DEBUG_IRQ)
- printf("%s: %p n_IRQ %d level %d => pending %08x req %08x\n", __func__,
- env, n_IRQ, level, env->pending_interrupts, env->interrupt_request);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: %p n_IRQ %d level %d => pending %08x req %08x\n",
+ __func__, env, n_IRQ, level,
+ env->pending_interrupts, env->interrupt_request);
+ }
#endif
}
int cur_level;
#if defined(PPC_DEBUG_IRQ)
- printf("%s: env %p pin %d level %d\n", __func__, env, pin, level);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: env %p pin %d level %d\n", __func__,
+ env, pin, level);
+ }
#endif
cur_level = (env->irq_input_state >> pin) & 1;
/* Don't generate spurious events */
case PPC6xx_INPUT_INT:
/* Level sensitive - active high */
#if defined(PPC_DEBUG_IRQ)
- printf("%s: set the external IRQ state to %d\n", __func__, level);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: set the external IRQ state to %d\n",
+ __func__, level);
+ }
#endif
ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
break;
case PPC6xx_INPUT_SMI:
/* Level sensitive - active high */
#if defined(PPC_DEBUG_IRQ)
- printf("%s: set the SMI IRQ state to %d\n", __func__, level);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: set the SMI IRQ state to %d\n",
+ __func__, level);
+ }
#endif
ppc_set_irq(env, PPC_INTERRUPT_SMI, level);
break;
*/
if (cur_level == 1 && level == 0) {
#if defined(PPC_DEBUG_IRQ)
- printf("%s: raise machine check state\n", __func__);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: raise machine check state\n",
+ __func__);
+ }
#endif
ppc_set_irq(env, PPC_INTERRUPT_MCK, 1);
}
/* XXX: TODO: relay the signal to CKSTP_OUT pin */
if (level) {
#if defined(PPC_DEBUG_IRQ)
- printf("%s: stop the CPU\n", __func__);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: stop the CPU\n", __func__);
+ }
#endif
env->halted = 1;
} else {
#if defined(PPC_DEBUG_IRQ)
- printf("%s: restart the CPU\n", __func__);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: restart the CPU\n", __func__);
+ }
#endif
env->halted = 0;
}
if (level) {
#if 0 // XXX: TOFIX
#if defined(PPC_DEBUG_IRQ)
- printf("%s: reset the CPU\n", __func__);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: reset the CPU\n", __func__);
+ }
#endif
cpu_reset(env);
#endif
break;
case PPC6xx_INPUT_SRESET:
#if defined(PPC_DEBUG_IRQ)
- printf("%s: set the RESET IRQ state to %d\n", __func__, level);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: set the RESET IRQ state to %d\n",
+ __func__, level);
+ }
#endif
ppc_set_irq(env, PPC_INTERRUPT_RESET, level);
break;
default:
/* Unknown pin - do nothing */
#if defined(PPC_DEBUG_IRQ)
- printf("%s: unknown IRQ pin %d\n", __func__, pin);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
+ }
#endif
return;
}
case PPC405_INPUT_INT:
/* Level sensitive - active high */
#if defined(PPC_DEBUG_IRQ)
- printf("%s: set the external IRQ state to %d\n", __func__, level);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: set the external IRQ state to %d\n",
+ __func__, level);
+ }
#endif
ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
break;
/* Level sensitive - active low */
if (level) {
#if defined(PPC_DEBUG_IRQ)
- printf("%s: stop the CPU\n", __func__);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: stop the CPU\n", __func__);
+ }
#endif
env->halted = 1;
} else {
#if defined(PPC_DEBUG_IRQ)
- printf("%s: restart the CPU\n", __func__);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: restart the CPU\n", __func__);
+ }
#endif
env->halted = 0;
}
case PPC405_INPUT_DEBUG:
/* Level sensitive - active high */
#if defined(PPC_DEBUG_IRQ)
- printf("%s: set the external IRQ state to %d\n", __func__, level);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: set the external IRQ state to %d\n",
+ __func__, level);
+ }
#endif
ppc_set_irq(env, EXCP_40x_DEBUG, level);
break;
default:
/* Unknown pin - do nothing */
#if defined(PPC_DEBUG_IRQ)
- printf("%s: unknown IRQ pin %d\n", __func__, pin);
+ if (loglevel & CPU_LOG_INT) {
+ fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
+ }
#endif
return;
}
void ppc405_irq_init (CPUState *env)
{
- printf("%s\n", __func__);
env->irq_inputs = (void **)qemu_allocate_irqs(&ppc405_set_irq, env, 7);
}
now = time(NULL);
if (last_time != now) {
last_time = now;
- printf("%s: tb=0x%016lx %d %08lx\n",
- __func__, tb, now, tb_env->tb_offset);
+ if (loglevel) {
+ fprintf(logfile, "%s: tb=0x%016lx %d %08lx\n",
+ __func__, tb, now, tb_env->tb_offset);
+ }
}
}
#endif
tb = cpu_ppc_get_tb(tb_env);
#ifdef DEBUG_TB
- printf("%s: tb=0x%016lx\n", __func__, tb);
+ if (loglevel) {
+ fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
+ }
#endif
return tb >> 32;
tb_env->tb_offset = muldiv64(value, ticks_per_sec, tb_env->tb_freq)
- qemu_get_clock(vm_clock);
#ifdef DEBUG_TB
- printf("%s: tb=0x%016lx offset=%08x\n", __func__, value);
+ if (loglevel) {
+ fprintf(logfile, "%s: tb=0x%016lx offset=%08x\n", __func__, value);
+ }
#endif
}
else
decr = -muldiv64(-diff, tb_env->tb_freq, ticks_per_sec);
#if defined(DEBUG_TB)
- printf("%s: 0x%08x\n", __func__, decr);
+ if (loglevel) {
+ fprintf(logfile, "%s: 0x%08x\n", __func__, decr);
+ }
#endif
return decr;
{
/* Raise it */
#ifdef DEBUG_TB
- printf("raise decrementer exception\n");
+ if (loglevel) {
+ fprintf(logfile, "raise decrementer exception\n");
+ }
#endif
ppc_set_irq(env, PPC_INTERRUPT_DECR, 1);
}
uint64_t now, next;
#ifdef DEBUG_TB
- printf("%s: 0x%08x => 0x%08x\n", __func__, decr, value);
+ if (loglevel) {
+ fprintf(logfile, "%s: 0x%08x => 0x%08x\n", __func__, decr, value);
+ }
#endif
now = qemu_get_clock(vm_clock);
next = now + muldiv64(value, ticks_per_sec, tb_env->tb_freq);
tb_env = env->tb_env;
ppcemb_timer = tb_env->opaque;
- if (loglevel)
+ if (loglevel) {
fprintf(logfile, "%s %p %p\n", __func__, tb_env, ppcemb_timer);
+ }
ppcemb_timer->pit_reload = val;
if (val == 0) {
/* Stop PIT */
- if (loglevel)
+ if (loglevel) {
fprintf(logfile, "%s: stop PIT\n", __func__);
+ }
qemu_del_timer(tb_env->decr_timer);
} else {
- if (loglevel)
+ if (loglevel) {
fprintf(logfile, "%s: start PIT 0x" ADDRX "\n", __func__, val);
+ }
now = qemu_get_clock(vm_clock);
next = now + muldiv64(val, ticks_per_sec, tb_env->tb_freq);
if (next == now)
}
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])
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;
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;
}
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:
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:
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");
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];
{
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)) {
}
}
#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);
+}
+
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)
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)
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;
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);
}
}