Search
lxdream.org :: lxdream :: r137:41907543d890
lxdream 0.9.1
released Jun 29
Download Now
changeset137:41907543d890
parent136:f07efd59604f
child138:afabd7e6d26d
authornkeynes
dateSun Apr 30 01:50:15 2006 +0000 (14 years ago)
Commit semi-correct G2-bus event register handling
src/asic.c
src/asic.h
src/sh4/sh4mem.c
1.1 --- a/src/asic.c Sun Apr 30 01:49:45 2006 +0000
1.2 +++ b/src/asic.c Sun Apr 30 01:50:15 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: asic.c,v 1.13 2006-03-22 14:29:00 nkeynes Exp $
1.6 + * $Id: asic.c,v 1.14 2006-04-30 01:50:13 nkeynes Exp $
1.7 *
1.8 * Support for the miscellaneous ASIC functions (Primarily event multiplexing,
1.9 * and DMA).
1.10 @@ -20,6 +20,7 @@
1.11 #define MODULE asic_module
1.12
1.13 #include <assert.h>
1.14 +#include <stdlib.h>
1.15 #include "dream.h"
1.16 #include "mem.h"
1.17 #include "sh4/intc.h"
1.18 @@ -43,6 +44,51 @@
1.19 struct dreamcast_module asic_module = { "ASIC", asic_init, NULL, NULL, NULL,
1.20 NULL, NULL, NULL };
1.21
1.22 +#define G2_BIT5_TICKS 8
1.23 +#define G2_BIT4_TICKS 16
1.24 +#define G2_BIT0_ON_TICKS 24
1.25 +#define G2_BIT0_OFF_TICKS 24
1.26 +
1.27 +struct asic_g2_state {
1.28 + unsigned int bit5_off_timer;
1.29 + unsigned int bit4_on_timer;
1.30 + unsigned int bit4_off_timer;
1.31 + unsigned int bit0_on_timer;
1.32 + unsigned int bit0_off_timer;
1.33 +} g2_state;
1.34 +
1.35 +/* FIXME: Handle rollover */
1.36 +void asic_g2_write_word()
1.37 +{
1.38 + g2_state.bit5_off_timer = sh4r.icount + G2_BIT5_TICKS;
1.39 + if( g2_state.bit4_off_timer < sh4r.icount )
1.40 + g2_state.bit4_on_timer = sh4r.icount + G2_BIT5_TICKS;
1.41 + g2_state.bit4_off_timer = max(sh4r.icount,g2_state.bit4_off_timer) + G2_BIT4_TICKS;
1.42 + if( g2_state.bit0_off_timer < sh4r.icount ) {
1.43 + g2_state.bit0_on_timer = sh4r.icount + G2_BIT0_ON_TICKS;
1.44 + g2_state.bit0_off_timer = g2_state.bit0_on_timer + G2_BIT0_OFF_TICKS;
1.45 + } else {
1.46 + g2_state.bit0_off_timer += G2_BIT0_OFF_TICKS;
1.47 + }
1.48 + MMIO_WRITE( ASIC, G2STATUS, MMIO_READ(ASIC, G2STATUS) | 0x20 );
1.49 +}
1.50 +
1.51 +static uint32_t g2_read_status()
1.52 +{
1.53 + uint32_t val = MMIO_READ( ASIC, G2STATUS );
1.54 + if( g2_state.bit5_off_timer <= sh4r.icount )
1.55 + val = val & (~0x20);
1.56 + if( g2_state.bit4_off_timer <= sh4r.icount )
1.57 + val = val & (~0x10);
1.58 + else if( g2_state.bit4_on_timer <= sh4r.icount )
1.59 + val = val | 0x10;
1.60 + if( g2_state.bit0_off_timer <= sh4r.icount )
1.61 + val = val & (~0x01);
1.62 + else if( g2_state.bit0_on_timer <= sh4r.icount )
1.63 + val = val | 0x01;
1.64 + return val | 0x0E;
1.65 +}
1.66 +
1.67 void asic_check_cleared_events( void );
1.68
1.69 void asic_init( void )
1.70 @@ -121,7 +167,7 @@
1.71 // reg, val, MMIO_REGID(ASIC,reg), MMIO_REGDESC(ASIC,reg) );
1.72 return val;
1.73 case G2STATUS:
1.74 - return 0; /* find out later if there's any cases we actually need to care about */
1.75 + return g2_read_status();
1.76 default:
1.77 val = MMIO_READ(ASIC, reg);
1.78 WARN( "Read from ASIC (%03X => %08X) [%s: %s]",
2.1 --- a/src/asic.h Sun Apr 30 01:49:45 2006 +0000
2.2 +++ b/src/asic.h Sun Apr 30 01:50:15 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: asic.h,v 1.6 2006-03-22 14:29:00 nkeynes Exp $
2.6 + * $Id: asic.h,v 1.7 2006-04-30 01:50:13 nkeynes Exp $
2.7 *
2.8 * Support for the miscellaneous ASIC functions (Primarily event multiplexing,
2.9 * and DMA). Includes MMIO definitions for the 5f6000 and 5f7000 regions,
2.10 @@ -199,3 +199,4 @@
2.11 void asic_clear_event( int event );
2.12
2.13 void asic_init( void );
2.14 +void asic_g2_write_word( );
3.1 --- a/src/sh4/sh4mem.c Sun Apr 30 01:49:45 2006 +0000
3.2 +++ b/src/sh4/sh4mem.c Sun Apr 30 01:50:15 2006 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: sh4mem.c,v 1.9 2006-03-30 11:26:45 nkeynes Exp $
3.6 + * $Id: sh4mem.c,v 1.10 2006-04-30 01:50:15 nkeynes Exp $
3.7 * sh4mem.c is responsible for the SH4's access to memory (including memory
3.8 * mapped I/O), using the page maps created in mem.c
3.9 *
3.10 @@ -234,9 +234,15 @@
3.11 sh4_stop();
3.12 return;
3.13 }
3.14 + if( (addr&0x1F800000) == 0x00800000 )
3.15 + asic_g2_write_word();
3.16 +
3.17 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
3.18 if( ((uint32_t)page) < MAX_IO_REGIONS ) { /* IO Region */
3.19 if( page == NULL ) {
3.20 + if( (addr & 0x1F000000) >= 0x04000000 &&
3.21 + (addr & 0x1F000000) < 0x07000000 )
3.22 + return;
3.23 ERROR( "Long write to missing page: %08X => %08X", val, addr );
3.24 return;
3.25 }
.