Search
lxdream.org :: lxdream/src/sh4/sh4core.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4core.c
changeset 378:f10fbdd4e24b
prev374:8f80a795513e
next384:c9d5c194984b
author nkeynes
date Wed Sep 12 11:31:16 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Fix load_spreg/store_spreg
Fix PREF
Add jump target debug checking
file annotate diff log raw
1.1 --- a/src/sh4/sh4core.c Tue Sep 11 02:14:46 2007 +0000
1.2 +++ b/src/sh4/sh4core.c Wed Sep 12 11:31:16 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: sh4core.c,v 1.44 2007-09-11 02:14:46 nkeynes Exp $
1.6 + * $Id: sh4core.c,v 1.45 2007-09-12 09:20:38 nkeynes Exp $
1.7 *
1.8 * SH4 emulation core, and parent module for all the SH4 peripheral
1.9 * modules.
1.10 @@ -40,94 +40,11 @@
1.11
1.12 /********************** SH4 Module Definition ****************************/
1.13
1.14 -void sh4_init( void );
1.15 -void sh4_reset( void );
1.16 uint32_t sh4_run_slice( uint32_t );
1.17 -void sh4_start( void );
1.18 -void sh4_stop( void );
1.19 -void sh4_save_state( FILE *f );
1.20 -int sh4_load_state( FILE *f );
1.21 -void sh4_accept_interrupt( void );
1.22
1.23 -struct dreamcast_module sh4_module = { "SH4", sh4_init, sh4_reset,
1.24 - NULL, sh4_run_slice, sh4_stop,
1.25 - sh4_save_state, sh4_load_state };
1.26 -
1.27 -struct sh4_registers sh4r;
1.28 -
1.29 -void sh4_init(void)
1.30 -{
1.31 - register_io_regions( mmio_list_sh4mmio );
1.32 - MMU_init();
1.33 - sh4_reset();
1.34 -}
1.35 -
1.36 -void sh4_reset(void)
1.37 -{
1.38 - /* zero everything out, for the sake of having a consistent state. */
1.39 - memset( &sh4r, 0, sizeof(sh4r) );
1.40 -
1.41 - /* Resume running if we were halted */
1.42 - sh4r.sh4_state = SH4_STATE_RUNNING;
1.43 -
1.44 - sh4r.pc = 0xA0000000;
1.45 - sh4r.new_pc= 0xA0000002;
1.46 - sh4r.vbr = 0x00000000;
1.47 - sh4r.fpscr = 0x00040001;
1.48 - sh4r.sr = 0x700000F0;
1.49 - sh4r.fr_bank = &sh4r.fr[0][0];
1.50 -
1.51 - /* Mem reset will do this, but if we want to reset _just_ the SH4... */
1.52 - MMIO_WRITE( MMU, EXPEVT, EXC_POWER_RESET );
1.53 -
1.54 - /* Peripheral modules */
1.55 - CPG_reset();
1.56 - INTC_reset();
1.57 - MMU_reset();
1.58 - TMU_reset();
1.59 - SCIF_reset();
1.60 -}
1.61 -
1.62 -static struct breakpoint_struct sh4_breakpoints[MAX_BREAKPOINTS];
1.63 -static int sh4_breakpoint_count = 0;
1.64 static uint16_t *sh4_icache = NULL;
1.65 static uint32_t sh4_icache_addr = 0;
1.66
1.67 -void sh4_set_breakpoint( uint32_t pc, int type )
1.68 -{
1.69 - sh4_breakpoints[sh4_breakpoint_count].address = pc;
1.70 - sh4_breakpoints[sh4_breakpoint_count].type = type;
1.71 - sh4_breakpoint_count++;
1.72 -}
1.73 -
1.74 -gboolean sh4_clear_breakpoint( uint32_t pc, int type )
1.75 -{
1.76 - int i;
1.77 -
1.78 - for( i=0; i<sh4_breakpoint_count; i++ ) {
1.79 - if( sh4_breakpoints[i].address == pc &&
1.80 - sh4_breakpoints[i].type == type ) {
1.81 - while( ++i < sh4_breakpoint_count ) {
1.82 - sh4_breakpoints[i-1].address = sh4_breakpoints[i].address;
1.83 - sh4_breakpoints[i-1].type = sh4_breakpoints[i].type;
1.84 - }
1.85 - sh4_breakpoint_count--;
1.86 - return TRUE;
1.87 - }
1.88 - }
1.89 - return FALSE;
1.90 -}
1.91 -
1.92 -int sh4_get_breakpoint( uint32_t pc )
1.93 -{
1.94 - int i;
1.95 - for( i=0; i<sh4_breakpoint_count; i++ ) {
1.96 - if( sh4_breakpoints[i].address == pc )
1.97 - return sh4_breakpoints[i].type;
1.98 - }
1.99 - return 0;
1.100 -}
1.101 -
1.102 uint32_t sh4_run_slice( uint32_t nanosecs )
1.103 {
1.104 int i;
1.105 @@ -199,29 +116,6 @@
1.106 return nanosecs;
1.107 }
1.108
1.109 -void sh4_stop(void)
1.110 -{
1.111 -
1.112 -}
1.113 -
1.114 -void sh4_save_state( FILE *f )
1.115 -{
1.116 - fwrite( &sh4r, sizeof(sh4r), 1, f );
1.117 - MMU_save_state( f );
1.118 - INTC_save_state( f );
1.119 - TMU_save_state( f );
1.120 - SCIF_save_state( f );
1.121 -}
1.122 -
1.123 -int sh4_load_state( FILE * f )
1.124 -{
1.125 - fread( &sh4r, sizeof(sh4r), 1, f );
1.126 - MMU_load_state( f );
1.127 - INTC_load_state( f );
1.128 - TMU_load_state( f );
1.129 - return SCIF_load_state( f );
1.130 -}
1.131 -
1.132 /********************** SH4 emulation core ****************************/
1.133
1.134 void sh4_set_pc( int pc )
.