Search
lxdream.org :: lxdream :: r1171:d644413208a3
lxdream 0.9.1
released Jun 29
Download Now
changeset1171:d644413208a3
parent1170:9ffc8295b414
child1172:43eef98ff265
authorNathan Keynes <nkeynes@lxdream.org>
dateTue May 10 20:31:14 2011 +1000 (8 years ago)
Fix SLEEP issue on timeslice border
- Don't update slice_cycle if we're already past it in sh4_sleep_run_slice
- Make sure we don't re-enter the main run_slice if we're sleeping
src/sh4/sh4.c
1.1 --- a/src/sh4/sh4.c Fri Apr 08 08:11:20 2011 +1000
1.2 +++ b/src/sh4/sh4.c Tue May 10 20:31:14 2011 +1000
1.3 @@ -246,10 +246,6 @@
1.4 {
1.5 sh4r.slice_cycle = 0;
1.6
1.7 - if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
1.8 - sh4_sleep_run_slice(nanosecs);
1.9 - }
1.10 -
1.11 /* Setup for sudden vm exits */
1.12 switch( setjmp(sh4_exit_jmp_buf) ) {
1.13 case CORE_EXIT_BREAKPOINT:
1.14 @@ -267,25 +263,28 @@
1.15 dreamcast_reset();
1.16 break;
1.17 case CORE_EXIT_SLEEP:
1.18 - sh4_sleep_run_slice(nanosecs);
1.19 break;
1.20 case CORE_EXIT_FLUSH_ICACHE:
1.21 xlat_flush_cache();
1.22 break;
1.23 }
1.24
1.25 - sh4_running = TRUE;
1.26 -
1.27 - /* Execute the core's real slice */
1.28 + if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
1.29 + sh4_sleep_run_slice(nanosecs);
1.30 + } else {
1.31 + sh4_running = TRUE;
1.32 +
1.33 + /* Execute the core's real slice */
1.34 #ifdef SH4_TRANSLATOR
1.35 - if( sh4_use_translator ) {
1.36 - sh4_translate_run_slice(nanosecs);
1.37 - } else {
1.38 + if( sh4_use_translator ) {
1.39 + sh4_translate_run_slice(nanosecs);
1.40 + } else {
1.41 + sh4_emulate_run_slice(nanosecs);
1.42 + }
1.43 +#else
1.44 sh4_emulate_run_slice(nanosecs);
1.45 +#endif
1.46 }
1.47 -#else
1.48 - sh4_emulate_run_slice(nanosecs);
1.49 -#endif
1.50
1.51 /* And finish off the peripherals afterwards */
1.52
1.53 @@ -621,8 +620,7 @@
1.54 */
1.55 uint32_t sh4_sleep_run_slice( uint32_t nanosecs )
1.56 {
1.57 - int sleep_state = sh4r.sh4_state;
1.58 - assert( sleep_state != SH4_STATE_RUNNING );
1.59 + assert( sh4r.sh4_state != SH4_STATE_RUNNING );
1.60
1.61 while( sh4r.event_pending < nanosecs ) {
1.62 sh4r.slice_cycle = sh4r.event_pending;
1.63 @@ -634,7 +632,8 @@
1.64 return sh4r.slice_cycle;
1.65 }
1.66 }
1.67 - sh4r.slice_cycle = nanosecs;
1.68 + if( sh4r.slice_cycle < nanosecs )
1.69 + sh4r.slice_cycle = nanosecs;
1.70 return sh4r.slice_cycle;
1.71 }
1.72
.