Search
lxdream.org :: lxdream/src/sh4/sh4trans.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4trans.c
changeset 585:371342a39c09
prev577:a181aeacd6e8
next1065:bc1cc0c54917
author nkeynes
date Tue Jan 15 11:07:32 2008 +0000 (13 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Handle sh4 aborts/reset within the translator
file annotate diff log raw
1.1 --- a/src/sh4/sh4trans.c Mon Jan 14 10:23:49 2008 +0000
1.2 +++ b/src/sh4/sh4trans.c Tue Jan 15 11:07:32 2008 +0000
1.3 @@ -27,6 +27,13 @@
1.4
1.5
1.6 static jmp_buf xlat_jmp_buf;
1.7 +static gboolean xlat_running = FALSE;
1.8 +
1.9 +gboolean sh4_xlat_is_running()
1.10 +{
1.11 + return xlat_running;
1.12 +}
1.13 +
1.14 /**
1.15 * Execute a timeslice using translated code only (ie translate/execute loop)
1.16 * Note this version does not support breakpoints
1.17 @@ -53,9 +60,12 @@
1.18 dreamcast_stop();
1.19 return sh4r.slice_cycle;
1.20 }
1.21 + case XLAT_EXIT_SYSRESET:
1.22 + dreamcast_reset();
1.23 break;
1.24 }
1.25 -
1.26 +
1.27 + xlat_running = TRUE;
1.28 void * (*code)() = NULL;
1.29 while( sh4r.slice_cycle < nanosecs ) {
1.30 if( sh4r.event_pending <= sh4r.slice_cycle ) {
1.31 @@ -84,6 +94,8 @@
1.32 code = code();
1.33 }
1.34
1.35 + xlat_running = FALSE;
1.36 +
1.37 if( sh4r.sh4_state != SH4_STATE_STANDBY ) {
1.38 TMU_run_slice( nanosecs );
1.39 SCIF_run_slice( nanosecs );
1.40 @@ -184,21 +196,24 @@
1.41 thunk();
1.42 }
1.43 // finally longjmp back into sh4_xlat_run_slice
1.44 + xlat_running = FALSE;
1.45 longjmp(xlat_jmp_buf, XLAT_EXIT_CONTINUE);
1.46 }
1.47
1.48 void sh4_translate_exit( int exit_code )
1.49 {
1.50 void *pc = xlat_get_native_pc();
1.51 - assert(pc != NULL);
1.52 -
1.53 - void *code = xlat_get_code( sh4r.pc );
1.54 - xlat_recovery_record_t recover = xlat_get_recovery(code, pc, TRUE);
1.55 - if( recover != NULL ) {
1.56 - // Can be null if there is no recovery necessary
1.57 - sh4_translate_run_recovery(recover);
1.58 + if( pc != NULL ) {
1.59 + // could be null if we're not actually running inside the translator
1.60 + void *code = xlat_get_code( sh4r.pc );
1.61 + xlat_recovery_record_t recover = xlat_get_recovery(code, pc, TRUE);
1.62 + if( recover != NULL ) {
1.63 + // Can be null if there is no recovery necessary
1.64 + sh4_translate_run_recovery(recover);
1.65 + }
1.66 }
1.67 // finally longjmp back into sh4_xlat_run_slice
1.68 + xlat_running = FALSE;
1.69 longjmp(xlat_jmp_buf, exit_code);
1.70 }
1.71
1.72 @@ -224,6 +239,7 @@
1.73 // Can be null if there is no recovery necessary
1.74 sh4_translate_run_recovery(recover);
1.75 xlat_flush_cache();
1.76 + xlat_running = FALSE;
1.77 longjmp(xlat_jmp_buf, XLAT_EXIT_CONTINUE);
1.78 } else {
1.79 xlat_flush_cache();
1.80 @@ -244,8 +260,8 @@
1.81 // fault - off to the fault handler
1.82 if( !mmu_update_icache(sh4r.pc) ) {
1.83 // double fault - halt
1.84 + ERROR( "Double fault - halting" );
1.85 dreamcast_stop();
1.86 - ERROR( "Double fault - halting" );
1.87 return NULL;
1.88 }
1.89 }
.