Search
lxdream.org :: lxdream/src/mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.c
changeset 929:fd8cb0c82f5f
prev825:2ac7ceccd775
next930:07e5b11419db
author nkeynes
date Sat Dec 20 03:01:40 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change First pass experiment using cached decoding.
file annotate diff log raw
1.1 --- a/src/mem.c Sun Aug 24 01:58:09 2008 +0000
1.2 +++ b/src/mem.c Sat Dec 20 03:01:40 2008 +0000
1.3 @@ -81,7 +81,7 @@
1.4 for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
1.5 if( io_rgn[i]->ports[j].def_val != UNDEFINED &&
1.6 io_rgn[i]->ports[j].def_val != *io_rgn[i]->ports[j].val ) {
1.7 - io_rgn[i]->io_write( io_rgn[i]->ports[j].offset,
1.8 + io_rgn[i]->fn.write_long( io_rgn[i]->ports[j].offset,
1.9 io_rgn[i]->ports[j].def_val );
1.10 }
1.11 }
1.12 @@ -225,7 +225,7 @@
1.13 }
1.14
1.15 struct mem_region *mem_map_region( void *mem, uint32_t base, uint32_t size,
1.16 - const char *name, int flags, uint32_t repeat_offset,
1.17 + const char *name, mem_region_fn_t fn, int flags, uint32_t repeat_offset,
1.18 uint32_t repeat_until )
1.19 {
1.20 int i;
1.21 @@ -234,6 +234,7 @@
1.22 mem_rgn[num_mem_rgns].flags = flags;
1.23 mem_rgn[num_mem_rgns].name = name;
1.24 mem_rgn[num_mem_rgns].mem = mem;
1.25 + mem_rgn[num_mem_rgns].fn = fn;
1.26 num_mem_rgns++;
1.27
1.28 do {
1.29 @@ -245,12 +246,13 @@
1.30 return &mem_rgn[num_mem_rgns-1];
1.31 }
1.32
1.33 -void *mem_create_ram_region( uint32_t base, uint32_t size, const char *name )
1.34 +void *mem_create_ram_region( uint32_t base, uint32_t size, const char *name, mem_region_fn_t fn )
1.35 {
1.36 - return mem_create_repeating_ram_region( base, size, name, size, base );
1.37 + return mem_create_repeating_ram_region( base, size, name, fn, size, base );
1.38 }
1.39
1.40 void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, const char *name,
1.41 + mem_region_fn_t fn,
1.42 uint32_t repeat_offset, uint32_t repeat_until )
1.43 {
1.44 char *mem;
1.45 @@ -262,13 +264,13 @@
1.46
1.47 mem = mem_alloc_pages( size>>LXDREAM_PAGE_BITS );
1.48
1.49 - mem_map_region( mem, base, size, name, MEM_FLAG_RAM, repeat_offset, repeat_until );
1.50 + mem_map_region( mem, base, size, name, fn, MEM_FLAG_RAM, repeat_offset, repeat_until );
1.51
1.52 return mem;
1.53 }
1.54
1.55 gboolean mem_load_rom( const gchar *file, uint32_t base, uint32_t size, uint32_t crc,
1.56 - const gchar *region_name )
1.57 + const gchar *region_name, mem_region_fn_t fn )
1.58 {
1.59 sh4ptr_t mem;
1.60 uint32_t calc_crc;
1.61 @@ -281,7 +283,7 @@
1.62 ERROR( "Unable to allocate ROM memory: %s (%s)", file, strerror(errno) );
1.63 return FALSE;
1.64 }
1.65 - mem_map_region( mem, base, size, region_name, MEM_FLAG_ROM, size, base );
1.66 + mem_map_region( mem, base, size, region_name, fn, MEM_FLAG_ROM, size, base );
1.67 } else {
1.68 mprotect( mem, size, PROT_READ|PROT_WRITE );
1.69 }
.