Search
lxdream.org :: lxdream :: r591:7b9612fd2395
lxdream 0.9.1
released Jun 29
Download Now
changeset591:7b9612fd2395
parent590:4db6a084ca3c
child592:4343cbfdd21b
authornkeynes
dateThu Jan 17 10:11:37 2008 +0000 (16 years ago)
Add flag to skip breakpoints when it's the very first instruction of a run
(ie, so executing dreamcast_run() when the current pc is a breakpoint doesn't
just return immediately)
src/sh4/sh4.c
src/sh4/sh4core.h
src/sh4/sh4trans.c
src/sh4/sh4trans.h
src/sh4/sh4x86.c
src/sh4/sh4x86.in
1.1 --- a/src/sh4/sh4.c Wed Jan 16 09:39:16 2008 +0000
1.2 +++ b/src/sh4/sh4.c Thu Jan 17 10:11:37 2008 +0000
1.3 @@ -42,13 +42,14 @@
1.4 uint32_t sh4_xlat_run_slice( uint32_t );
1.5
1.6 struct dreamcast_module sh4_module = { "SH4", sh4_init, sh4_reset,
1.7 - NULL, sh4_run_slice, sh4_stop,
1.8 + sh4_start, sh4_run_slice, sh4_stop,
1.9 sh4_save_state, sh4_load_state };
1.10
1.11 struct sh4_registers sh4r;
1.12 struct breakpoint_struct sh4_breakpoints[MAX_BREAKPOINTS];
1.13 int sh4_breakpoint_count = 0;
1.14 sh4ptr_t sh4_main_ram;
1.15 +gboolean sh4_starting = FALSE;
1.16 static gboolean sh4_use_translator = FALSE;
1.17 struct sh4_icache_struct sh4_icache = { NULL, -1, -1, 0 };
1.18
1.19 @@ -80,6 +81,11 @@
1.20 sh4_reset();
1.21 }
1.22
1.23 +void sh4_start(void)
1.24 +{
1.25 + sh4_starting = TRUE;
1.26 +}
1.27 +
1.28 void sh4_reset(void)
1.29 {
1.30 if( sh4_use_translator ) {
2.1 --- a/src/sh4/sh4core.h Wed Jan 16 09:39:16 2008 +0000
2.2 +++ b/src/sh4/sh4core.h Thu Jan 17 10:11:37 2008 +0000
2.3 @@ -34,6 +34,7 @@
2.4 extern struct breakpoint_struct sh4_breakpoints[MAX_BREAKPOINTS];
2.5 extern int sh4_breakpoint_count;
2.6 extern sh4ptr_t sh4_main_ram;
2.7 +extern gboolean sh4_starting;
2.8
2.9 /**
2.10 * Cached direct pointer to the current instruction page. If AT is on, this
3.1 --- a/src/sh4/sh4trans.c Wed Jan 16 09:39:16 2008 +0000
3.2 +++ b/src/sh4/sh4trans.c Thu Jan 17 10:11:37 2008 +0000
3.3 @@ -36,7 +36,6 @@
3.4
3.5 /**
3.6 * Execute a timeslice using translated code only (ie translate/execute loop)
3.7 - * Note this version does not support breakpoints
3.8 */
3.9 uint32_t sh4_xlat_run_slice( uint32_t nanosecs )
3.10 {
3.11 @@ -95,6 +94,7 @@
3.12 }
3.13
3.14 xlat_running = FALSE;
3.15 + sh4_starting = FALSE;
3.16
3.17 if( sh4r.sh4_state != SH4_STATE_STANDBY ) {
3.18 TMU_run_slice( nanosecs );
3.19 @@ -222,6 +222,14 @@
3.20 longjmp(xlat_jmp_buf, exit_code);
3.21 }
3.22
3.23 +void sh4_translate_breakpoint_hit(uint32_t pc)
3.24 +{
3.25 + if( sh4_starting && sh4r.slice_cycle == 0 && pc == sh4r.pc ) {
3.26 + return;
3.27 + }
3.28 + sh4_translate_exit( XLAT_EXIT_BREAKPOINT );
3.29 +}
3.30 +
3.31 /**
3.32 * Exit the current block at the end of the current instruction, flush the
3.33 * translation cache (completely) and return control to sh4_xlat_run_slice.
4.1 --- a/src/sh4/sh4trans.h Wed Jan 16 09:39:16 2008 +0000
4.2 +++ b/src/sh4/sh4trans.h Thu Jan 17 10:11:37 2008 +0000
4.3 @@ -112,3 +112,10 @@
4.4 * the specified exit code (one of the XLAT_EXIT_* values).
4.5 */
4.6 void sh4_translate_exit( int exit_code );
4.7 +
4.8 +/**
4.9 + * Support function called from the translator when a breakpoint is hit.
4.10 + * Either returns immediately (to skip the breakpoint), or aborts the current
4.11 + * cycle and never returns.
4.12 + */
4.13 +void sh4_translate_breakpoint_hit( sh4vma_t pc );
5.1 --- a/src/sh4/sh4x86.c Wed Jan 16 09:39:16 2008 +0000
5.2 +++ b/src/sh4/sh4x86.c Thu Jan 17 10:11:37 2008 +0000
5.3 @@ -364,8 +364,8 @@
5.4 */
5.5 void sh4_translate_emit_breakpoint( sh4vma_t pc )
5.6 {
5.7 - load_imm32( R_EAX, XLAT_EXIT_BREAKPOINT );
5.8 - call_func1( sh4_translate_exit, R_EAX );
5.9 + load_imm32( R_EAX, pc );
5.10 + call_func1( sh4_translate_breakpoint_hit, R_EAX );
5.11 }
5.12
5.13 /**
6.1 --- a/src/sh4/sh4x86.in Wed Jan 16 09:39:16 2008 +0000
6.2 +++ b/src/sh4/sh4x86.in Thu Jan 17 10:11:37 2008 +0000
6.3 @@ -364,8 +364,8 @@
6.4 */
6.5 void sh4_translate_emit_breakpoint( sh4vma_t pc )
6.6 {
6.7 - load_imm32( R_EAX, XLAT_EXIT_BREAKPOINT );
6.8 - call_func1( sh4_translate_exit, R_EAX );
6.9 + load_imm32( R_EAX, pc );
6.10 + call_func1( sh4_translate_breakpoint_hit, R_EAX );
6.11 }
6.12
6.13 /**
.