Commit 14e51cc7a42870f9e64084ee4f1a579ffea5788b

Authored by ths
1 parent 85016c98

De-cruft exception definitions, and implement nicer debug output.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3861 c046a42c-6fe2-441c-8c8c-71466251a162
target-mips/cpu.h
@@ -523,40 +523,37 @@ enum { @@ -523,40 +523,37 @@ enum {
523 EXCP_SRESET, 523 EXCP_SRESET,
524 EXCP_DSS, 524 EXCP_DSS,
525 EXCP_DINT, 525 EXCP_DINT,
  526 + EXCP_DDBL,
  527 + EXCP_DDBS,
526 EXCP_NMI, 528 EXCP_NMI,
527 EXCP_MCHECK, 529 EXCP_MCHECK,
528 - EXCP_EXT_INTERRUPT, 530 + EXCP_EXT_INTERRUPT, /* 8 */
529 EXCP_DFWATCH, 531 EXCP_DFWATCH,
530 - EXCP_DIB, /* 8 */ 532 + EXCP_DIB,
531 EXCP_IWATCH, 533 EXCP_IWATCH,
532 EXCP_AdEL, 534 EXCP_AdEL,
533 EXCP_AdES, 535 EXCP_AdES,
534 EXCP_TLBF, 536 EXCP_TLBF,
535 EXCP_IBE, 537 EXCP_IBE,
536 - EXCP_DBp, 538 + EXCP_DBp, /* 16 */
537 EXCP_SYSCALL, 539 EXCP_SYSCALL,
538 - EXCP_BREAK, /* 16 */ 540 + EXCP_BREAK,
539 EXCP_CpU, 541 EXCP_CpU,
540 EXCP_RI, 542 EXCP_RI,
541 EXCP_OVERFLOW, 543 EXCP_OVERFLOW,
542 EXCP_TRAP, 544 EXCP_TRAP,
543 EXCP_FPE, 545 EXCP_FPE,
544 - EXCP_DDBS,  
545 - EXCP_DWATCH,  
546 - EXCP_LAE, /* 24 */  
547 - EXCP_SAE, 546 + EXCP_DWATCH, /* 24 */
548 EXCP_LTLBL, 547 EXCP_LTLBL,
549 EXCP_TLBL, 548 EXCP_TLBL,
550 EXCP_TLBS, 549 EXCP_TLBS,
551 EXCP_DBE, 550 EXCP_DBE,
552 - EXCP_DDBL,  
553 EXCP_THREAD, 551 EXCP_THREAD,
554 - EXCP_MTCP0 = 0x104, /* mtmsr instruction: */  
555 - /* may change privilege level */  
556 - EXCP_BRANCH = 0x108, /* branch instruction */  
557 - EXCP_ERET = 0x10C, /* return from interrupt */  
558 - EXCP_SYSCALL_USER = 0x110, /* System call in user mode only */  
559 - EXCP_FLUSH = 0x109, 552 + EXCP_MDMX,
  553 + EXCP_C2E,
  554 + EXCP_CACHE, /* 32 */
  555 +
  556 + EXCP_LAST = EXCP_CACHE,
560 }; 557 };
561 558
562 int cpu_mips_exec(CPUMIPSState *s); 559 int cpu_mips_exec(CPUMIPSState *s);
target-mips/helper.c
@@ -318,20 +318,62 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw, @@ -318,20 +318,62 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
318 return ret; 318 return ret;
319 } 319 }
320 320
321 -#if defined(CONFIG_USER_ONLY)  
322 -void do_interrupt (CPUState *env)  
323 -{  
324 - env->exception_index = EXCP_NONE;  
325 -}  
326 -#else 321 +#if !defined(CONFIG_USER_ONLY)
  322 +static struct _excp_names {
  323 + int excp;
  324 + char *name;
  325 +} excp_names[EXCP_LAST + 1] = {
  326 + { EXCP_RESET, "reset" },
  327 + { EXCP_SRESET, "soft reset" },
  328 + { EXCP_DSS, "debug single step" },
  329 + { EXCP_DINT, "debug interrupt" },
  330 + { EXCP_NMI, "non-maskable interrupt" },
  331 + { EXCP_MCHECK, "machine check" },
  332 + { EXCP_EXT_INTERRUPT, "interrupt" },
  333 + { EXCP_DFWATCH, "deferred watchpoint" },
  334 + { EXCP_DIB, "debug instruction breakpoint" },
  335 + { EXCP_IWATCH, "instruction fetch watchpoint" },
  336 + { EXCP_AdEL, "address error load" },
  337 + { EXCP_AdES, "address error store" },
  338 + { EXCP_TLBF, "TLB refill" },
  339 + { EXCP_IBE, "instruction bus error" },
  340 + { EXCP_DBp, "debug breakpoint" },
  341 + { EXCP_SYSCALL, "syscall" },
  342 + { EXCP_BREAK, "break" },
  343 + { EXCP_CpU, "coprocessor unusable" },
  344 + { EXCP_RI, "reserved instruction" },
  345 + { EXCP_OVERFLOW, "arithmetic overflow" },
  346 + { EXCP_TRAP, "trap" },
  347 + { EXCP_FPE, "floating point" },
  348 + { EXCP_DDBS, "debug data break store" },
  349 + { EXCP_DWATCH, "data watchpoint" },
  350 + { EXCP_LTLBL, "TLB modify" },
  351 + { EXCP_TLBL, "TLB load" },
  352 + { EXCP_TLBS, "TLB store" },
  353 + { EXCP_DBE, "data bus error" },
  354 + { EXCP_DDBL, "debug data break load" },
  355 + { EXCP_THREAD, "thread" },
  356 + { EXCP_MDMX, "MDMX" },
  357 + { EXCP_C2E, "precise coprocessor 2" },
  358 + { EXCP_CACHE, "cache error" },
  359 +};
  360 +#endif
  361 +
327 void do_interrupt (CPUState *env) 362 void do_interrupt (CPUState *env)
328 { 363 {
  364 +#if !defined(CONFIG_USER_ONLY)
329 target_ulong offset; 365 target_ulong offset;
330 int cause = -1; 366 int cause = -1;
  367 + char *name;
331 368
332 if (logfile && env->exception_index != EXCP_EXT_INTERRUPT) { 369 if (logfile && env->exception_index != EXCP_EXT_INTERRUPT) {
333 - fprintf(logfile, "%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d excp %d\n",  
334 - __func__, env->PC[env->current_tc], env->CP0_EPC, cause, env->exception_index); 370 + if (env->exception_index < 0 || env->exception_index > EXCP_LAST)
  371 + name = "unknown";
  372 + else
  373 + name = excp_names[env->exception_index].name;
  374 +
  375 + fprintf(logfile, "%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
  376 + __func__, env->PC[env->current_tc], env->CP0_EPC, name);
335 } 377 }
336 if (env->exception_index == EXCP_EXT_INTERRUPT && 378 if (env->exception_index == EXCP_EXT_INTERRUPT &&
337 (env->hflags & MIPS_HFLAG_DM)) 379 (env->hflags & MIPS_HFLAG_DM))
@@ -520,15 +562,15 @@ void do_interrupt (CPUState *env) @@ -520,15 +562,15 @@ void do_interrupt (CPUState *env)
520 exit(1); 562 exit(1);
521 } 563 }
522 if (logfile && env->exception_index != EXCP_EXT_INTERRUPT) { 564 if (logfile && env->exception_index != EXCP_EXT_INTERRUPT) {
523 - fprintf(logfile, "%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d excp %d\n" 565 + fprintf(logfile, "%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n"
524 " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", 566 " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n",
525 - __func__, env->PC[env->current_tc], env->CP0_EPC, cause, env->exception_index, 567 + __func__, env->PC[env->current_tc], env->CP0_EPC, cause,
526 env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr, 568 env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,
527 env->CP0_DEPC); 569 env->CP0_DEPC);
528 } 570 }
  571 +#endif /* !defined(CONFIG_USER_ONLY) */
529 env->exception_index = EXCP_NONE; 572 env->exception_index = EXCP_NONE;
530 } 573 }
531 -#endif /* !defined(CONFIG_USER_ONLY) */  
532 574
533 void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra) 575 void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra)
534 { 576 {