--- trunk/src/cpus/cpu_ppc.c 2007/10/08 16:22:43 43 +++ trunk/src/cpus/cpu_ppc.c 2007/10/08 16:22:56 44 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: cpu_ppc.c,v 1.70 2007/06/15 00:41:21 debug Exp $ + * $Id: cpu_ppc.c,v 1.72 2007/06/28 13:36:46 debug Exp $ * * PowerPC/POWER CPU emulation. */ @@ -49,7 +49,6 @@ #include "ppc_spr_strings.h" #include "settings.h" #include "symbol.h" -#include "timer.h" #include "useremul.h" @@ -57,8 +56,6 @@ #include "tmp_ppc_head.c" -extern int native_code_translation_enabled; - void ppc_pc_to_pointers(struct cpu *); void ppc32_pc_to_pointers(struct cpu *); @@ -238,10 +235,6 @@ interrupt_handler_register(&template); } - if (native_code_translation_enabled) - cpu->sampling_timer = timer_add(CPU_SAMPLE_TIMER_HZ, - ppc_timer_sample_tick, cpu); - return 1; } @@ -371,8 +364,8 @@ cpu->cd.ppc.spr[SPR_SRR1] = (cpu->cd.ppc.msr & 0x87c0ffff); if (!quiet_mode) - fatal("[ PPC Exception 0x%x; pc=0x%"PRIx64" ]\n", exception_nr, - (long long)cpu->pc); + fatal("[ PPC Exception 0x%x; pc=0x%"PRIx64" ]\n", + exception_nr, cpu->pc); /* Disable External Interrupts, Recoverable Interrupt Mode, and go to Supervisor mode */ @@ -446,8 +439,8 @@ for (i=0; icd.ppc.gpr[i]); + debug(" r%02i = 0x%08"PRIx32" ", i, + (uint32_t) cpu->cd.ppc.gpr[i]); if ((i % 4) == 3) debug("\n"); } @@ -457,8 +450,8 @@ int r = (i >> 1) + ((i & 1) << 4); if ((i % 2) == 0) debug("cpu%i:", x); - debug(" r%02i = 0x%016llx ", r, - (long long)cpu->cd.ppc.gpr[r]); + debug(" r%02i = 0x%016"PRIx64" ", r, + (uint64_t) cpu->cd.ppc.gpr[r]); if ((i % 2) == 1) debug("\n"); } @@ -466,31 +459,40 @@ /* Other special registers: */ if (bits32) { - debug("cpu%i: srr0 = 0x%08x srr1 = 0x%08x\n", x, - (int)cpu->cd.ppc.spr[SPR_SRR0], - (int)cpu->cd.ppc.spr[SPR_SRR1]); + debug("cpu%i: srr0 = 0x%08"PRIx32 + " srr1 = 0x%08"PRIx32"\n", x, + (uint32_t) cpu->cd.ppc.spr[SPR_SRR0], + (uint32_t) cpu->cd.ppc.spr[SPR_SRR1]); } else { - debug("cpu%i: srr0 = 0x%016llx srr1 = 0x%016llx\n", x, - (long long)cpu->cd.ppc.spr[SPR_SRR0], - (long long)cpu->cd.ppc.spr[SPR_SRR1]); + debug("cpu%i: srr0 = 0x%016"PRIx64 + " srr1 = 0x%016"PRIx64"\n", x, + (uint64_t) cpu->cd.ppc.spr[SPR_SRR0], + (uint64_t) cpu->cd.ppc.spr[SPR_SRR1]); } + debug("cpu%i: msr = ", x); reg_access_msr(cpu, &tmp, 0, 0); if (bits32) - debug("0x%08x ", (int)tmp); + debug("0x%08"PRIx32, (uint32_t) tmp); else - debug("0x%016llx ", (long long)tmp); - debug("tb = 0x%08x%08x\n", (int)cpu->cd.ppc.spr[SPR_TBU], - (int)cpu->cd.ppc.spr[SPR_TBL]); - debug("cpu%i: dec = 0x%08x", x, (int)cpu->cd.ppc.spr[SPR_DEC]); + debug("0x%016"PRIx64, (uint64_t) tmp); + + debug(" tb = 0x%08"PRIx32"%08"PRIx32"\n", + (uint32_t) cpu->cd.ppc.spr[SPR_TBU], + (uint32_t) cpu->cd.ppc.spr[SPR_TBL]); + + debug("cpu%i: dec = 0x%08"PRIx32, + x, (uint32_t) cpu->cd.ppc.spr[SPR_DEC]); if (!bits32) - debug(" hdec = 0x%08x\n", - (int)cpu->cd.ppc.spr[SPR_HDEC]); + debug(" hdec = 0x%08"PRIx32"\n", + (uint32_t) cpu->cd.ppc.spr[SPR_HDEC]); + debug("\n"); } if (coprocs & 1) { - debug("cpu%i: fpscr = 0x%08x\n", x, (int)cpu->cd.ppc.fpscr); + debug("cpu%i: fpscr = 0x%08"PRIx32"\n", + x, (uint32_t) cpu->cd.ppc.fpscr); /* TODO: show floating-point values :-) */ @@ -499,16 +501,16 @@ for (i=0; icd.ppc.fpr[i]); + debug(" f%02i = 0x%016"PRIx64" ", i, + (uint64_t) cpu->cd.ppc.fpr[i]); if ((i % 2) == 1) debug("\n"); } } if (coprocs & 2) { - debug("cpu%i: sdr1 = 0x%llx\n", x, - (long long)cpu->cd.ppc.spr[SPR_SDR1]); + debug("cpu%i: sdr1 = 0x%"PRIx64"\n", x, + (uint64_t) cpu->cd.ppc.spr[SPR_SDR1]); if (cpu->cd.ppc.cpu_type.flags & PPC_601) debug("cpu%i: PPC601-style, TODO!\n"); else { @@ -518,7 +520,8 @@ uint32_t lower = cpu->cd.ppc.spr[spr+1]; uint32_t len = (((upper & BAT_BL) << 15) | 0x1ffff) + 1; - debug("cpu%i: %sbat%i: u=0x%08x l=0x%08x ", + debug("cpu%i: %sbat%i: u=0x%08"PRIx32 + " l=0x%08"PRIx32" ", x, i<4? "i" : "d", i&3, upper, lower); if (!(upper & BAT_V)) { debug(" (not valid)\n"); @@ -553,8 +556,10 @@ if (coprocs & 4) { for (i=0; i<16; i++) { uint32_t s = cpu->cd.ppc.sr[i]; + debug("cpu%i:", x); - debug(" sr%-2i = 0x%08x", i, (int)s); + debug(" sr%-2i = 0x%08"PRIx32, i, s); + s &= (SR_TYPE | SR_SUKEY | SR_PRKEY | SR_NOEXEC); if (s != 0) { debug(" ("); @@ -651,15 +656,15 @@ debug("cpu%i: ", cpu->cpu_id); if (cpu->cd.ppc.bits == 32) - debug("%08x", (int)dumpaddr); + debug("%08"PRIx32, (uint32_t) dumpaddr); else - debug("%016llx", (long long)dumpaddr); + debug("%016"PRIx64, (uint64_t) dumpaddr); /* NOTE: Fixed to big-endian. */ iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) + instr[3]; - debug(": %08x\t", iword); + debug(": %08"PRIx32"\t", iword); /* * Decode the instruction: @@ -760,9 +765,9 @@ if (cpu->cd.ppc.bits == 32) addr &= 0xffffffff; if (cpu->cd.ppc.bits == 32) - debug("0x%x", (int)addr); + debug("0x%"PRIx32, (uint32_t) addr); else - debug("0x%llx", (long long)addr); + debug("0x%"PRIx64, (uint64_t) addr); symbol = get_symbol_name(&cpu->machine->symbol_context, addr, &offset); if (symbol != NULL) @@ -793,9 +798,9 @@ if (cpu->cd.ppc.bits == 32) addr &= 0xffffffff; if (cpu->cd.ppc.bits == 32) - debug("\t0x%x", (int)addr); + debug("\t0x%"PRIx32, (uint32_t) addr); else - debug("\t0x%llx", (long long)addr); + debug("\t0x%"PRIx64, (uint64_t) addr); symbol = get_symbol_name(&cpu->machine->symbol_context, addr, &offset); if (symbol != NULL) @@ -1084,7 +1089,7 @@ if (symbol != NULL) debug(" \t<%s", symbol); else - debug(" \t<0x%llx", (long long)addr); + debug(" \t<0x%"PRIx64, (uint64_t) addr); if (wlen > 0 && !fpreg /* && !reverse */) { /* TODO */ } @@ -1255,10 +1260,10 @@ ppc_spr_names[spr]==NULL? "?" : ppc_spr_names[spr]); if (running) { if (cpu->cd.ppc.bits == 32) - debug(": 0x%x", (int) + debug(": 0x%"PRIx32, (uint32_t) cpu->cd.ppc.spr[spr]); else - debug(": 0x%llx", (long long) + debug(": 0x%"PRIx64, (uint64_t) cpu->cd.ppc.spr[spr]); } debug(">"); @@ -1415,10 +1420,10 @@ ppc_spr_names[spr]==NULL? "?" : ppc_spr_names[spr]); if (running) { if (cpu->cd.ppc.bits == 32) - debug(": 0x%x", (int) + debug(": 0x%"PRIx32, (uint32_t) cpu->cd.ppc.gpr[rs]); else - debug(": 0x%llx", (long long) + debug(": 0x%"PRIx64, (uint64_t) cpu->cd.ppc.gpr[rs]); } debug(">"); @@ -1571,7 +1576,7 @@ if (symbol != NULL) debug(" \t<%s", symbol); else - debug(" \t<0x%llx", (long long)addr); + debug(" \t<0x%"PRIx64, (uint64_t) addr); if (wlen > 0 && load && wlen > 0) { unsigned char tw[8]; uint64_t tdata = 0; @@ -1595,12 +1600,12 @@ if (symbol != NULL) debug("%s", symbol); else - debug("0x%llx", - (long long)tdata); + debug("0x%"PRIx64, + (uint64_t) tdata); } else { /* TODO: if load==2, then this is a _signed_ load. */ - debug("0x%llx", (long long)tdata); + debug("0x%"PRIx64, (uint64_t) tdata); } } else debug(": unreadable"); @@ -1618,12 +1623,12 @@ if (symbol != NULL) debug("%s", symbol); else - debug("0x%llx", (long long)tdata); + debug("0x%"PRIx64, (uint64_t) tdata); } else { if (tdata > -256 && tdata < 256) debug("%i", (int)tdata); else - debug("0x%llx", (long long)tdata); + debug("0x%"PRIx64, (uint64_t) tdata); } } debug(">"); @@ -1815,8 +1820,8 @@ break; } else fatal("[ using UNIMPLEMENTED spr %i (%s), pc = " - "0x%llx ]\n", spr, ppc_spr_names[spr] == NULL? - "UNKNOWN" : ppc_spr_names[spr], (long long)pc); + "0x%"PRIx64" ]\n", spr, ppc_spr_names[spr] == NULL? + "UNKNOWN" : ppc_spr_names[spr], (uint64_t) pc); } spr_used[spr >> 2] |= (1 << (spr & 3));