//#define DEBUG_BATS
//#define DEBUG_EXCEPTIONS
-extern FILE *logfile, *stdout, *stderr;
-void exit (int);
-void abort (void);
-
-void cpu_loop_exit(void)
-{
- longjmp(env->jmp_env, 1);
-}
-
-void do_process_exceptions (void)
-{
- cpu_loop_exit();
-}
-
-int check_exception_state (CPUState *env)
-{
- int i;
-
- /* Process PPC exceptions */
- for (i = 1; i < EXCP_PPC_MAX; i++) {
- if (env->exceptions & (1 << i)) {
- switch (i) {
- case EXCP_EXTERNAL:
- case EXCP_DECR:
- if (msr_ee == 0)
- return 0;
- break;
- case EXCP_PROGRAM:
- if (env->errors[EXCP_PROGRAM] == EXCP_FP &&
- msr_fe0 == 0 && msr_fe1 == 0)
- return 0;
- break;
- default:
- break;
- }
- env->exception_index = i;
- env->error_code = env->errors[i];
- return 1;
- }
- }
-
- return 0;
-}
-
/*****************************************************************************/
/* PPC MMU emulation */
int cpu_ppc_handle_mmu_fault (CPUState *env, uint32_t address, int rw,
uint32_t address, int rw, int access_type)
{
int ret;
-
+#if 0
if (loglevel > 0) {
fprintf(logfile, "%s\n", __func__);
}
-
- if ((access_type == ACCESS_CODE && msr_ir == 0) || msr_dr == 0) {
+#endif
+ if ((access_type == ACCESS_CODE && msr_ir == 0) ||
+ (access_type != ACCESS_CODE && msr_dr == 0)) {
/* No address translation */
*physical = address & ~0xFFF;
*prot = PAGE_READ | PAGE_WRITE;
ret = get_segment(env, physical, prot, address, rw, access_type);
}
}
+#if 0
if (loglevel > 0) {
fprintf(logfile, "%s address %08x => %08x\n",
__func__, address, *physical);
}
-
+#endif
return ret;
}
tlb_addrr = env->tlb_read[is_user][index].address;
tlb_addrw = env->tlb_write[is_user][index].address;
#if 0
- printf("%s 1 %p %p idx=%d addr=0x%08lx tbl_addr=0x%08lx 0x%08lx "
+ if (loglevel) {
+ fprintf(logfile,
+ "%s 1 %p %p idx=%d addr=0x%08lx tbl_addr=0x%08lx 0x%08lx "
"(0x%08lx 0x%08lx)\n", __func__, env,
&env->tlb_read[is_user][index], index, addr,
tlb_addrr, tlb_addrw, addr & TARGET_PAGE_MASK,
tlb_addrr & (TARGET_PAGE_MASK | TLB_INVALID_MASK));
+ }
#endif
}
ret = cpu_ppc_handle_mmu_fault(env, addr, is_write, is_user, 1);
cpu_restore_state(tb, env, pc, NULL);
}
}
- do_queue_exception_err(env->exception_index, env->error_code);
- do_process_exceptions();
+ do_raise_exception_err(env->exception_index, env->error_code);
}
{
unsigned long tlb_addrr, tlb_addrw;
void _store_msr (CPUState *env, uint32_t value)
{
+#if 0 // TRY
if (((value >> MSR_IR) & 0x01) != msr_ir ||
- ((value >> MSR_DR) & 0x01) != msr_dr) {
+ ((value >> MSR_DR) & 0x01) != msr_dr)
+ {
/* Flush all tlb when changing translation mode or privilege level */
tlb_flush(env, 1);
}
+#endif
msr_pow = (value >> MSR_POW) & 0x03;
msr_ile = (value >> MSR_ILE) & 0x01;
msr_ee = (value >> MSR_EE) & 0x01;
uint32_t msr;
int excp = env->exception_index;
- /* Dequeue PPC exceptions */
- if (excp < EXCP_PPC_MAX)
- env->exceptions &= ~(1 << excp);
msr = _load_msr(env);
#if defined (DEBUG_EXCEPTIONS)
if ((excp == EXCP_PROGRAM || excp == EXCP_DSI) && msr_pr == 1)
goto store_next;
case EXCP_MACHINE_CHECK:
if (msr_me == 0) {
- printf("Machine check exception while not allowed !\n");
- if (loglevel) {
- fprintf(logfile,
- "Machine check exception while not allowed !\n");
+ cpu_abort(env, "Machine check exception while not allowed\n");
}
- abort();
- }
msr_me = 0;
break;
case EXCP_DSI:
}
#endif
/* Requeue it */
- do_queue_exception(EXCP_EXTERNAL);
+ do_raise_exception(EXCP_EXTERNAL);
return;
}
goto store_next;
env->fpscr[7] |= 0x4;
break;
case EXCP_INVAL:
- printf("Invalid instruction at 0x%08x\n", env->nip);
+ // printf("Invalid instruction at 0x%08x\n", env->nip);
msr |= 0x00080000;
break;
case EXCP_PRIV:
case EXCP_DECR:
if (msr_ee == 0) {
/* Requeue it */
- do_queue_exception(EXCP_DECR);
+ do_raise_exception(EXCP_DECR);
return;
}
goto store_next;
T0 = 0;
#endif
#endif
+ env->exception_index = -1;
}