Revision 93fcfe39 target-ppc/helper.c
b/target-ppc/helper.c | ||
---|---|---|
40 | 40 |
//#define FLUSH_ALL_TLBS |
41 | 41 |
|
42 | 42 |
#ifdef DEBUG_MMU |
43 |
# define LOG_MMU(...) do { \ |
|
44 |
if (loglevel) \ |
|
45 |
fprintf(logfile, ## __VA_ARGS__); \ |
|
46 |
} while (0) |
|
47 |
# define LOG_MMU_STATE(env) do { \ |
|
48 |
if (loglevel) \ |
|
49 |
cpu_dump_state(env, logfile, fprintf, 0); \ |
|
50 |
} while (0) |
|
43 |
# define LOG_MMU(...) qemu_log(__VA_ARGS__) |
|
44 |
# define LOG_MMU_STATE(env) log_cpu_state((env), 0) |
|
51 | 45 |
#else |
52 | 46 |
# define LOG_MMU(...) do { } while (0) |
53 | 47 |
# define LOG_MMU_STATE(...) do { } while (0) |
... | ... | |
55 | 49 |
|
56 | 50 |
|
57 | 51 |
#ifdef DEBUG_SOFTWARE_TLB |
58 |
# define LOG_SWTLB(...) do { \ |
|
59 |
if (loglevel) \ |
|
60 |
fprintf(logfile, ## __VA_ARGS__); \ |
|
61 |
} while (0) |
|
52 |
# define LOG_SWTLB(...) qemu_log(__VA_ARGS__) |
|
62 | 53 |
#else |
63 | 54 |
# define LOG_SWTLB(...) do { } while (0) |
64 | 55 |
#endif |
65 | 56 |
|
66 | 57 |
#ifdef DEBUG_BATS |
67 |
# define LOG_BATS(...) do { \ |
|
68 |
if (loglevel) \ |
|
69 |
fprintf(logfile, ## __VA_ARGS__); \ |
|
70 |
} while (0) |
|
58 |
# define LOG_BATS(...) qemu_log(__VA_ARGS__) |
|
71 | 59 |
#else |
72 | 60 |
# define LOG_BATS(...) do { } while (0) |
73 | 61 |
#endif |
74 | 62 |
|
75 | 63 |
#ifdef DEBUG_SLB |
76 |
# define LOG_SLB(...) do { \ |
|
77 |
if (loglevel) \ |
|
78 |
fprintf(logfile, ## __VA_ARGS__); \ |
|
79 |
} while (0) |
|
64 |
# define LOG_SLB(...) qemu_log(__VA_ARGS__) |
|
80 | 65 |
#else |
81 | 66 |
# define LOG_SLB(...) do { } while (0) |
82 | 67 |
#endif |
83 | 68 |
|
84 | 69 |
#ifdef DEBUG_EXCEPTIONS |
85 |
# define LOG_EXCP(...) do { \ |
|
86 |
if (loglevel) \ |
|
87 |
fprintf(logfile, ## __VA_ARGS__); \ |
|
88 |
} while (0) |
|
70 |
# define LOG_EXCP(...) qemu_log(__VA_ARGS__) |
|
89 | 71 |
#else |
90 | 72 |
# define LOG_EXCP(...) do { } while (0) |
91 | 73 |
#endif |
... | ... | |
257 | 239 |
if (ctx->raddr != (target_phys_addr_t)-1ULL) { |
258 | 240 |
/* all matches should have equal RPN, WIMG & PP */ |
259 | 241 |
if ((ctx->raddr & mmask) != (pte1 & mmask)) { |
260 |
if (loglevel != 0) |
|
261 |
fprintf(logfile, "Bad RPN/WIMG/PP\n"); |
|
242 |
qemu_log("Bad RPN/WIMG/PP\n"); |
|
262 | 243 |
return -3; |
263 | 244 |
} |
264 | 245 |
} |
... | ... | |
988 | 969 |
} |
989 | 970 |
} |
990 | 971 |
#if defined (DUMP_PAGE_TABLES) |
991 |
if (loglevel != 0) {
|
|
972 |
if (qemu_log_enabled()) {
|
|
992 | 973 |
target_phys_addr_t curaddr; |
993 | 974 |
uint32_t a0, a1, a2, a3; |
994 |
fprintf(logfile, "Page table: " PADDRX " len " PADDRX "\n",
|
|
995 |
sdr, mask + 0x80); |
|
975 |
qemu_log("Page table: " PADDRX " len " PADDRX "\n",
|
|
976 |
sdr, mask + 0x80);
|
|
996 | 977 |
for (curaddr = sdr; curaddr < (sdr + mask + 0x80); |
997 | 978 |
curaddr += 16) { |
998 | 979 |
a0 = ldl_phys(curaddr); |
... | ... | |
1000 | 981 |
a2 = ldl_phys(curaddr + 8); |
1001 | 982 |
a3 = ldl_phys(curaddr + 12); |
1002 | 983 |
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) { |
1003 |
fprintf(logfile, PADDRX ": %08x %08x %08x %08x\n",
|
|
1004 |
curaddr, a0, a1, a2, a3); |
|
984 |
qemu_log(PADDRX ": %08x %08x %08x %08x\n",
|
|
985 |
curaddr, a0, a1, a2, a3);
|
|
1005 | 986 |
} |
1006 | 987 |
} |
1007 | 988 |
} |
... | ... | |
1037 | 1018 |
/* eciwx or ecowx */ |
1038 | 1019 |
return -4; |
1039 | 1020 |
default: |
1040 |
if (logfile) { |
|
1041 |
fprintf(logfile, "ERROR: instruction should not need " |
|
1021 |
qemu_log("ERROR: instruction should not need " |
|
1042 | 1022 |
"address translation\n"); |
1043 |
} |
|
1044 | 1023 |
return -4; |
1045 | 1024 |
} |
1046 | 1025 |
if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) { |
... | ... | |
1064 | 1043 |
|
1065 | 1044 |
/* Check valid flag */ |
1066 | 1045 |
if (!(tlb->prot & PAGE_VALID)) { |
1067 |
if (loglevel != 0) |
|
1068 |
fprintf(logfile, "%s: TLB %d not valid\n", __func__, i); |
|
1046 |
qemu_log("%s: TLB %d not valid\n", __func__, i); |
|
1069 | 1047 |
return -1; |
1070 | 1048 |
} |
1071 | 1049 |
mask = ~(tlb->size - 1); |
... | ... | |
1335 | 1313 |
int ret; |
1336 | 1314 |
|
1337 | 1315 |
#if 0 |
1338 |
if (loglevel != 0) { |
|
1339 |
fprintf(logfile, "%s\n", __func__); |
|
1340 |
} |
|
1316 |
qemu_log("%s\n", __func__); |
|
1341 | 1317 |
#endif |
1342 | 1318 |
if ((access_type == ACCESS_CODE && msr_ir == 0) || |
1343 | 1319 |
(access_type != ACCESS_CODE && msr_dr == 0)) { |
... | ... | |
1388 | 1364 |
} |
1389 | 1365 |
} |
1390 | 1366 |
#if 0 |
1391 |
if (loglevel != 0) { |
|
1392 |
fprintf(logfile, "%s address " ADDRX " => %d " PADDRX "\n", |
|
1367 |
qemu_log("%s address " ADDRX " => %d " PADDRX "\n", |
|
1393 | 1368 |
__func__, eaddr, ret, ctx->raddr); |
1394 |
} |
|
1395 | 1369 |
#endif |
1396 | 1370 |
|
1397 | 1371 |
return ret; |
... | ... | |
2016 | 1990 |
#else /* defined (CONFIG_USER_ONLY) */ |
2017 | 1991 |
static always_inline void dump_syscall (CPUState *env) |
2018 | 1992 |
{ |
2019 |
fprintf(logfile, "syscall r0=" REGX " r3=" REGX " r4=" REGX
|
|
1993 |
qemu_log_mask(CPU_LOG_INT, "syscall r0=" REGX " r3=" REGX " r4=" REGX
|
|
2020 | 1994 |
" r5=" REGX " r6=" REGX " nip=" ADDRX "\n", |
2021 | 1995 |
ppc_dump_gpr(env, 0), ppc_dump_gpr(env, 3), ppc_dump_gpr(env, 4), |
2022 | 1996 |
ppc_dump_gpr(env, 5), ppc_dump_gpr(env, 6), env->nip); |
... | ... | |
2042 | 2016 |
lpes1 = 1; |
2043 | 2017 |
} |
2044 | 2018 |
|
2045 |
if (loglevel & CPU_LOG_INT) { |
|
2046 |
fprintf(logfile, "Raise exception at " ADDRX " => %08x (%02x)\n", |
|
2047 |
env->nip, excp, env->error_code); |
|
2048 |
} |
|
2019 |
qemu_log_mask(CPU_LOG_INT, "Raise exception at " ADDRX " => %08x (%02x)\n", |
|
2020 |
env->nip, excp, env->error_code); |
|
2049 | 2021 |
msr = env->msr; |
2050 | 2022 |
new_msr = msr; |
2051 | 2023 |
srr0 = SPR_SRR0; |
... | ... | |
2079 | 2051 |
/* Machine check exception is not enabled. |
2080 | 2052 |
* Enter checkstop state. |
2081 | 2053 |
*/ |
2082 |
if (loglevel != 0) {
|
|
2083 |
fprintf(logfile, "Machine check while not allowed. "
|
|
2054 |
if (qemu_log_enabled()) {
|
|
2055 |
qemu_log("Machine check while not allowed. "
|
|
2084 | 2056 |
"Entering checkstop state\n"); |
2085 | 2057 |
} else { |
2086 | 2058 |
fprintf(stderr, "Machine check while not allowed. " |
... | ... | |
2200 | 2172 |
return; |
2201 | 2173 |
} |
2202 | 2174 |
} |
2203 |
if (loglevel & CPU_LOG_INT) { |
|
2204 |
dump_syscall(env); |
|
2205 |
} |
|
2175 |
dump_syscall(env); |
|
2206 | 2176 |
new_msr &= ~((target_ulong)1 << MSR_RI); |
2207 | 2177 |
lev = env->error_code; |
2208 | 2178 |
if (lev == 1 || (lpes0 == 0 && lpes1 == 0)) |
... | ... | |
2416 | 2386 |
case POWERPC_EXCP_7x5: |
2417 | 2387 |
tlb_miss: |
2418 | 2388 |
#if defined (DEBUG_SOFTWARE_TLB) |
2419 |
if (loglevel != 0) {
|
|
2389 |
if (qemu_log_enabled()) {
|
|
2420 | 2390 |
const unsigned char *es; |
2421 | 2391 |
target_ulong *miss, *cmp; |
2422 | 2392 |
int en; |
... | ... | |
2434 | 2404 |
miss = &env->spr[SPR_DMISS]; |
2435 | 2405 |
cmp = &env->spr[SPR_DCMP]; |
2436 | 2406 |
} |
2437 |
fprintf(logfile, "6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
|
|
2407 |
qemu_log("6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
|
|
2438 | 2408 |
" H1 " ADDRX " H2 " ADDRX " %08x\n", |
2439 | 2409 |
es, en, *miss, en, *cmp, |
2440 | 2410 |
env->spr[SPR_HASH1], env->spr[SPR_HASH2], |
... | ... | |
2449 | 2419 |
case POWERPC_EXCP_74xx: |
2450 | 2420 |
tlb_miss_74xx: |
2451 | 2421 |
#if defined (DEBUG_SOFTWARE_TLB) |
2452 |
if (loglevel != 0) {
|
|
2422 |
if (qemu_log_enabled()) {
|
|
2453 | 2423 |
const unsigned char *es; |
2454 | 2424 |
target_ulong *miss, *cmp; |
2455 | 2425 |
int en; |
... | ... | |
2467 | 2437 |
miss = &env->spr[SPR_TLBMISS]; |
2468 | 2438 |
cmp = &env->spr[SPR_PTEHI]; |
2469 | 2439 |
} |
2470 |
fprintf(logfile, "74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
|
|
2440 |
qemu_log("74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
|
|
2471 | 2441 |
" %08x\n", |
2472 | 2442 |
es, en, *miss, en, *cmp, env->error_code); |
2473 | 2443 |
} |
... | ... | |
2619 | 2589 |
int hdice; |
2620 | 2590 |
|
2621 | 2591 |
#if 0 |
2622 |
if (loglevel & CPU_LOG_INT) { |
|
2623 |
fprintf(logfile, "%s: %p pending %08x req %08x me %d ee %d\n", |
|
2592 |
qemu_log_mask(CPU_LOG_INT, "%s: %p pending %08x req %08x me %d ee %d\n", |
|
2624 | 2593 |
__func__, env, env->pending_interrupts, |
2625 | 2594 |
env->interrupt_request, (int)msr_me, (int)msr_ee); |
2626 |
} |
|
2627 | 2595 |
#endif |
2628 | 2596 |
/* External reset */ |
2629 | 2597 |
if (env->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) { |
... | ... | |
2735 | 2703 |
|
2736 | 2704 |
void cpu_dump_rfi (target_ulong RA, target_ulong msr) |
2737 | 2705 |
{ |
2738 |
FILE *f; |
|
2739 |
|
|
2740 |
if (logfile) { |
|
2741 |
f = logfile; |
|
2742 |
} else { |
|
2743 |
f = stdout; |
|
2744 |
return; |
|
2745 |
} |
|
2746 |
fprintf(f, "Return from exception at " ADDRX " with flags " ADDRX "\n", |
|
2747 |
RA, msr); |
|
2706 |
qemu_log("Return from exception at " ADDRX " with flags " ADDRX "\n", |
|
2707 |
RA, msr); |
|
2748 | 2708 |
} |
2749 | 2709 |
|
2750 | 2710 |
void cpu_ppc_reset (void *opaque) |
Also available in: Unified diff