Search
lxdream.org :: lxdream/src/sh4/sh4core.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4core.c
changeset 43:0cf3e339cc59
prev38:9ccc7ac66a9d
next53:f2981805b929
author nkeynes
date Mon Dec 26 11:47:15 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Add sh4 + arm breakpoints
Hook up break button in GUI
Enable ARM slice in main loop
file annotate diff log raw
1.1 --- a/src/sh4/sh4core.c Mon Dec 26 10:47:10 2005 +0000
1.2 +++ b/src/sh4/sh4core.c Mon Dec 26 11:47:15 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: sh4core.c,v 1.15 2005-12-26 10:47:10 nkeynes Exp $
1.6 + * $Id: sh4core.c,v 1.16 2005-12-26 11:47:15 nkeynes Exp $
1.7 *
1.8 * SH4 emulation core, and parent module for all the SH4 peripheral
1.9 * modules.
1.10 @@ -90,6 +90,44 @@
1.11 SCIF_reset();
1.12 }
1.13
1.14 +static struct breakpoint_struct sh4_breakpoints[MAX_BREAKPOINTS];
1.15 +static int sh4_breakpoint_count = 0;
1.16 +
1.17 +void sh4_set_breakpoint( uint32_t pc, int type )
1.18 +{
1.19 + sh4_breakpoints[sh4_breakpoint_count].address = pc;
1.20 + sh4_breakpoints[sh4_breakpoint_count].type = type;
1.21 + sh4_breakpoint_count++;
1.22 +}
1.23 +
1.24 +gboolean sh4_clear_breakpoint( uint32_t pc, int type )
1.25 +{
1.26 + int i;
1.27 +
1.28 + for( i=0; i<sh4_breakpoint_count; i++ ) {
1.29 + if( sh4_breakpoints[i].address == pc &&
1.30 + sh4_breakpoints[i].type == type ) {
1.31 + while( ++i < sh4_breakpoint_count ) {
1.32 + sh4_breakpoints[i-1].address = sh4_breakpoints[i].address;
1.33 + sh4_breakpoints[i-1].type = sh4_breakpoints[i].type;
1.34 + }
1.35 + sh4_breakpoint_count--;
1.36 + return TRUE;
1.37 + }
1.38 + }
1.39 + return FALSE;
1.40 +}
1.41 +
1.42 +int sh4_get_breakpoint( uint32_t pc )
1.43 +{
1.44 + int i;
1.45 + for( i=0; i<sh4_breakpoint_count; i++ ) {
1.46 + if( sh4_breakpoints[i].address == pc )
1.47 + return sh4_breakpoints[i].type;
1.48 + }
1.49 + return 0;
1.50 +}
1.51 +
1.52 uint32_t sh4_run_slice( uint32_t nanosecs )
1.53 {
1.54 int target = sh4r.icount + nanosecs / sh4_cpu_period;
1.55 @@ -105,6 +143,19 @@
1.56 sh4r.icount++;
1.57 if( !sh4_execute_instruction() )
1.58 break;
1.59 +#ifdef ENABLE_DEBUG_MODE
1.60 + for( i=0; i<sh4_breakpoint_count; i++ ) {
1.61 + if( sh4_breakpoints[i].address == sh4r.pc ) {
1.62 + break;
1.63 + }
1.64 + }
1.65 + if( i != sh4_breakpoint_count ) {
1.66 + dreamcast_stop();
1.67 + if( sh4_breakpoints[i].type == BREAK_ONESHOT )
1.68 + sh4_clear_breakpoint( sh4r.pc, BREAK_ONESHOT );
1.69 + break;
1.70 + }
1.71 +#endif
1.72 }
1.73
1.74 /* If we aborted early, but the cpu is still technically running,
1.75 @@ -147,11 +198,6 @@
1.76 sh4r.new_pc = pc+2;
1.77 }
1.78
1.79 -void sh4_set_breakpoint( uint32_t pc, int type )
1.80 -{
1.81 -
1.82 -}
1.83 -
1.84 #define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", sh4r.pc, ir ); RAISE( EXC_ILLEGAL, EXV_ILLEGAL ); }while(0)
1.85 #define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", sh4r.pc, ir ); dreamcast_stop(); return FALSE; }while(0)
1.86
.