Search
lxdream.org :: lxdream :: r156:3b93648a3b07
lxdream 0.9.1
released Jun 29
Download Now
changeset156:3b93648a3b07
parent155:be61d1a20937
child157:fbe03268ad8a
authornkeynes
dateThu Jun 15 10:25:45 2006 +0000 (17 years ago)
Add P4 I/O tracing
Add ability to set I/O trace by region address
src/mem.c
src/mem.h
src/mmio.h
src/sh4/sh4mem.c
1.1 --- a/src/mem.c Wed May 24 11:50:19 2006 +0000
1.2 +++ b/src/mem.c Thu Jun 15 10:25:45 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: mem.c,v 1.12 2006-05-20 02:38:58 nkeynes Exp $
1.6 + * $Id: mem.c,v 1.13 2006-06-15 10:25:42 nkeynes Exp $
1.7 * mem.c is responsible for creating and maintaining the overall system memory
1.8 * map, as visible from the SH4 processor.
1.9 *
1.10 @@ -356,3 +356,23 @@
1.11 }
1.12 }
1.13
1.14 +struct mmio_region *mem_get_io_region( uint32_t addr )
1.15 +{
1.16 + if( addr > 0xFF000000 ) {
1.17 + return P4_io[(addr&0x00FFFFFF)>>12];
1.18 + }
1.19 + char *page = page_map[(addr&0x1FFFFFFF)>>12];
1.20 + if( ((uint32_t)page) < MAX_IO_REGIONS ) {
1.21 + return io_rgn[(uint32_t)page];
1.22 + } else {
1.23 + return NULL;
1.24 + }
1.25 +}
1.26 +
1.27 +void mem_set_trace( uint32_t addr, int flag )
1.28 +{
1.29 + struct mmio_region *region = mem_get_io_region(addr);
1.30 + if( region != NULL )
1.31 + region->trace_flag = flag;
1.32 +}
1.33 +
2.1 --- a/src/mem.h Wed May 24 11:50:19 2006 +0000
2.2 +++ b/src/mem.h Thu Jun 15 10:25:45 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: mem.h,v 1.8 2006-05-20 02:38:58 nkeynes Exp $
2.6 + * $Id: mem.h,v 1.9 2006-06-15 10:25:42 nkeynes Exp $
2.7 *
2.8 * mem is responsible for creating and maintaining the overall system memory
2.9 * map, as visible from the SH4 processor. (Note the ARM has a different map)
2.10 @@ -58,7 +58,7 @@
2.11 char *mem_get_page( uint32_t addr );
2.12 int mem_load_block( const gchar *filename, uint32_t base, uint32_t size );
2.13 int mem_save_block( const gchar *filename, uint32_t base, uint32_t size );
2.14 -
2.15 +void mem_set_trace( uint32_t addr, int flag );
2.16 void mem_init( void );
2.17 void mem_reset( void );
2.18
3.1 --- a/src/mmio.h Wed May 24 11:50:19 2006 +0000
3.2 +++ b/src/mmio.h Thu Jun 15 10:25:45 2006 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: mmio.h,v 1.4 2006-04-30 01:49:45 nkeynes Exp $
3.6 + * $Id: mmio.h,v 1.5 2006-06-15 10:25:42 nkeynes Exp $
3.7 *
3.8 * mmio.h defines a complicated batch of macros used to build up the
3.9 * memory-mapped I/O regions in a reasonably readable fashion.
3.10 @@ -83,6 +83,11 @@
3.11 io_rgn[mid]->index[(r)>>2]->desc : "Undefined register" )
3.12 #define MMIO_NAME_BYNUM( mid ) (io_rgn[mid]->id)
3.13
3.14 +#define MMIO_REGID_IOBYNUM( io, r ) (io->index[(r)>>2] != NULL ? \
3.15 + io->index[(r)>>2]->id : "<UNDEF>" )
3.16 +#define MMIO_REGDESC_IOBYNUM( io, r ) (io->index[(r)>>2] != NULL ? \
3.17 + io->index[(r)>>2]->desc : "Undefined register" )
3.18 +
3.19 #ifdef __cplusplus
3.20 }
3.21 #endif
4.1 --- a/src/sh4/sh4mem.c Wed May 24 11:50:19 2006 +0000
4.2 +++ b/src/sh4/sh4mem.c Thu Jun 15 10:25:45 2006 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: sh4mem.c,v 1.11 2006-05-23 13:10:28 nkeynes Exp $
4.6 + * $Id: sh4mem.c,v 1.12 2006-06-15 10:25:45 nkeynes Exp $
4.7 * sh4mem.c is responsible for the SH4's access to memory (including memory
4.8 * mapped I/O), using the page maps created in mem.c
4.9 *
4.10 @@ -53,6 +53,10 @@
4.11 TRACE( str " [%s.%s: %s]", __VA_ARGS__, \
4.12 MMIO_NAME_BYNUM((uint32_t)p), MMIO_REGID_BYNUM((uint32_t)p, r), \
4.13 MMIO_REGDESC_BYNUM((uint32_t)p, r) )
4.14 +#define TRACE_P4IO( str, io, r, ... ) if(io->trace_flag) \
4.15 +TRACE( str " [%s.%s: %s]", __VA_ARGS__, \
4.16 + io->id, MMIO_REGID_IOBYNUM(io, r), \
4.17 + MMIO_REGDESC_IOBYNUM(io, r) )
4.18
4.19 extern struct mem_region mem_rgn[];
4.20 extern struct mmio_region *P4_io[];
4.21 @@ -64,7 +68,9 @@
4.22 ERROR( "Attempted read from unknown P4 region: %08X", addr );
4.23 return 0;
4.24 } else {
4.25 - return io->io_read( addr&0xFFF );
4.26 + int32_t val = io->io_read( addr&0xFFF );
4.27 + TRACE_P4IO( "Long read %08X <= %08X", io, (addr&0xFFF), val, addr );
4.28 + return val;
4.29 }
4.30 }
4.31
4.32 @@ -81,6 +87,7 @@
4.33 ERROR( "Attempted write to unknown P4 region: %08X", addr );
4.34 }
4.35 } else {
4.36 + TRACE_P4IO( "Long write %08X => %08X", io, (addr&0xFFF), val, addr );
4.37 io->io_write( addr&0xFFF, val );
4.38 }
4.39 }
.