Search
lxdream.org :: lxdream/src/aica/armcore.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armcore.c
changeset 43:0cf3e339cc59
prev37:1d84f4c18816
next44:8da2cbcffe24
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/aica/armcore.c Mon Dec 26 06:38:51 2005 +0000
1.2 +++ b/src/aica/armcore.c Mon Dec 26 11:47:15 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: armcore.c,v 1.7 2005-12-26 06:38:51 nkeynes Exp $
1.6 + * $Id: armcore.c,v 1.8 2005-12-26 11:47:15 nkeynes Exp $
1.7 *
1.8 * ARM7TDMI CPU emulation core.
1.9 *
1.10 @@ -19,6 +19,7 @@
1.11 #define MODULE aica_module
1.12 #include "dream.h"
1.13 #include "aica/armcore.h"
1.14 +#include "mem.h"
1.15
1.16 struct arm_registers armr;
1.17
1.18 @@ -43,14 +44,67 @@
1.19 uint32_t arm_cpu_freq = ARM_BASE_RATE;
1.20 uint32_t arm_cpu_period = 1000 / ARM_BASE_RATE;
1.21
1.22 +
1.23 +static struct breakpoint_struct arm_breakpoints[MAX_BREAKPOINTS];
1.24 +static int arm_breakpoint_count = 0;
1.25 +
1.26 +void arm_set_breakpoint( uint32_t pc, int type )
1.27 +{
1.28 + arm_breakpoints[arm_breakpoint_count].address = pc;
1.29 + arm_breakpoints[arm_breakpoint_count].type = type;
1.30 + arm_breakpoint_count++;
1.31 +}
1.32 +
1.33 +gboolean arm_clear_breakpoint( uint32_t pc, int type )
1.34 +{
1.35 + int i;
1.36 +
1.37 + for( i=0; i<arm_breakpoint_count; i++ ) {
1.38 + if( arm_breakpoints[i].address == pc &&
1.39 + arm_breakpoints[i].type == type ) {
1.40 + while( ++i < arm_breakpoint_count ) {
1.41 + arm_breakpoints[i-1].address = arm_breakpoints[i].address;
1.42 + arm_breakpoints[i-1].type = arm_breakpoints[i].type;
1.43 + }
1.44 + arm_breakpoint_count--;
1.45 + return TRUE;
1.46 + }
1.47 + }
1.48 + return FALSE;
1.49 +}
1.50 +
1.51 +int arm_get_breakpoint( uint32_t pc )
1.52 +{
1.53 + int i;
1.54 + for( i=0; i<arm_breakpoint_count; i++ ) {
1.55 + if( arm_breakpoints[i].address == pc )
1.56 + return arm_breakpoints[i].type;
1.57 + }
1.58 + return 0;
1.59 +}
1.60 +
1.61 uint32_t arm_run_slice( uint32_t nanosecs )
1.62 {
1.63 + int i;
1.64 uint32_t target = armr.icount + nanosecs / arm_cpu_period;
1.65 uint32_t start = armr.icount;
1.66 while( armr.icount < target ) {
1.67 armr.icount++;
1.68 if( !arm_execute_instruction() )
1.69 break;
1.70 +#ifdef ENABLE_DEBUG_MODE
1.71 + for( i=0; i<arm_breakpoint_count; i++ ) {
1.72 + if( arm_breakpoints[i].address == armr.r[15] ) {
1.73 + break;
1.74 + }
1.75 + }
1.76 + if( i != arm_breakpoint_count ) {
1.77 + dreamcast_stop();
1.78 + if( arm_breakpoints[i].type == BREAK_ONESHOT )
1.79 + arm_clear_breakpoint( armr.r[15], BREAK_ONESHOT );
1.80 + break;
1.81 + }
1.82 +#endif
1.83 }
1.84
1.85 if( target != armr.icount ) {
.