revision 146:f91fa34ab219
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 146:f91fa34ab219 |
parent | 145:8f1af16b0665 |
child | 147:82478590bfa7 |
author | nkeynes |
date | Sat May 20 02:38:58 2006 +0000 (17 years ago) |
Add repeating memory mode
Load flash as ram rather than rom
Load flash as ram rather than rom
![]() | src/dreamcast.c | view | annotate | diff | log | |
![]() | src/mem.c | view | annotate | diff | log | |
![]() | src/mem.h | view | annotate | diff | log |
1.1 --- a/src/dreamcast.c Sat May 20 02:38:08 2006 +00001.2 +++ b/src/dreamcast.c Sat May 20 02:38:58 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: dreamcast.c,v 1.15 2006-05-15 08:28:48 nkeynes Exp $1.6 + * $Id: dreamcast.c,v 1.16 2006-05-20 02:38:58 nkeynes Exp $1.7 * Central switchboard for the system. This pulls all the individual modules1.8 * together into some kind of coherent structure. This is also where you'd1.9 * add Naomi support, if I ever get a board to play with...1.10 @@ -62,12 +62,14 @@1.11 dreamcast_register_module( &mem_module );1.13 /* Setup standard memory map */1.14 - mem_create_ram_region( 0x0C000000, 16 MB, MEM_REGION_MAIN );1.15 + mem_create_repeating_ram_region( 0x0C000000, 16 MB, MEM_REGION_MAIN, 0x01000000, 0x0F000000 );1.16 mem_create_ram_region( 0x00800000, 2 MB, MEM_REGION_AUDIO );1.17 mem_create_ram_region( 0x00703000, 8 KB, MEM_REGION_AUDIO_SCRATCH );1.18 mem_create_ram_region( 0x05000000, 8 MB, MEM_REGION_VIDEO );1.19 mem_load_rom( "dcboot.rom", 0x00000000, 0x00200000, 0x89f2b1a1 );1.20 - mem_load_rom( "dcflash.rom",0x00200000, 0x00020000, 0x357c3568 );1.21 + mem_create_ram_region( 0x00200000, 0x00020000, MEM_REGION_FLASH );1.22 + mem_load_block( "../bios/dcflash.rom", 0x00200000, 0x00020000 );1.23 + // mem_load_rom( "dcflash.rom",0x00200000, 0x00020000, 0x357c3568 );1.25 /* Load in the rest of the core modules */1.26 dreamcast_register_module( &sh4_module );
2.1 --- a/src/mem.c Sat May 20 02:38:08 2006 +00002.2 +++ b/src/mem.c Sat May 20 02:38:58 2006 +00002.3 @@ -1,5 +1,5 @@2.4 /**2.5 - * $Id: mem.c,v 1.11 2006-01-10 14:00:00 nkeynes Exp $2.6 + * $Id: mem.c,v 1.12 2006-05-20 02:38:58 nkeynes Exp $2.7 * mem.c is responsible for creating and maintaining the overall system memory2.8 * map, as visible from the SH4 processor.2.9 *2.10 @@ -222,7 +222,8 @@2.11 }2.13 struct mem_region *mem_map_region( void *mem, uint32_t base, uint32_t size,2.14 - char *name, int flags )2.15 + char *name, int flags, uint32_t repeat_offset,2.16 + uint32_t repeat_until )2.17 {2.18 int i;2.19 mem_rgn[num_mem_rgns].base = base;2.20 @@ -232,14 +233,23 @@2.21 mem_rgn[num_mem_rgns].mem = mem;2.22 num_mem_rgns++;2.24 - for( i=0; i<size>>PAGE_BITS; i++ )2.25 - page_map[(base>>PAGE_BITS)+i] = mem + (i<<PAGE_BITS);2.26 + do {2.27 + for( i=0; i<size>>PAGE_BITS; i++ )2.28 + page_map[(base>>PAGE_BITS)+i] = mem + (i<<PAGE_BITS);2.29 + base += repeat_offset;2.30 + } while( base <= repeat_until );2.32 return &mem_rgn[num_mem_rgns-1];2.33 }2.35 void *mem_create_ram_region( uint32_t base, uint32_t size, char *name )2.36 {2.37 + return mem_create_repeating_ram_region( base, size, name, size, base );2.38 +}2.39 +2.40 +void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, char *name,2.41 + uint32_t repeat_offset, uint32_t repeat_until )2.42 +{2.43 char *mem;2.45 assert( (base&0xFFFFF000) == base ); /* must be page aligned */2.46 @@ -249,7 +259,8 @@2.48 mem = mem_alloc_pages( size>>PAGE_BITS );2.50 - mem_map_region( mem, base, size, name, MEM_FLAG_RAM );2.51 + mem_map_region( mem, base, size, name, MEM_FLAG_RAM, repeat_offset, repeat_until );2.52 +2.53 return mem;2.54 }2.56 @@ -270,7 +281,7 @@2.57 close(fd);2.58 return NULL;2.59 }2.60 - mem_map_region( mem, base, size, file, MEM_FLAG_ROM );2.61 + mem_map_region( mem, base, size, file, MEM_FLAG_ROM, size, base );2.63 /* CRC check */2.64 calc_crc = crc32(0L, mem, size);
3.1 --- a/src/mem.h Sat May 20 02:38:08 2006 +00003.2 +++ b/src/mem.h Sat May 20 02:38:58 2006 +00003.3 @@ -1,5 +1,5 @@3.4 /**3.5 - * $Id: mem.h,v 1.7 2006-03-13 12:37:06 nkeynes Exp $3.6 + * $Id: mem.h,v 1.8 2006-05-20 02:38:58 nkeynes Exp $3.7 *3.8 * mem is responsible for creating and maintaining the overall system memory3.9 * map, as visible from the SH4 processor. (Note the ARM has a different map)3.10 @@ -21,6 +21,7 @@3.11 #define dream_mem_H3.13 #include <stdint.h>3.14 +#include "dream.h"3.16 #ifdef __cplusplus3.17 extern "C" {3.18 @@ -41,17 +42,22 @@3.19 #define MEM_REGION_VIDEO "Video RAM"3.20 #define MEM_REGION_AUDIO "Audio RAM"3.21 #define MEM_REGION_AUDIO_SCRATCH "Audio Scratch RAM"3.22 +#define MEM_REGION_FLASH "System Flash"3.24 #define MB * (1024 * 1024)3.25 #define KB * 10243.27 void *mem_create_ram_region( uint32_t base, uint32_t size, char *name );3.28 +void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, char *name,3.29 + uint32_t repeat_offset, uint32_t last_repeat );3.30 void *mem_load_rom( char *name, uint32_t base, uint32_t size, uint32_t crc );3.31 void *mem_alloc_pages( int n );3.32 char *mem_get_region( uint32_t addr );3.33 char *mem_get_region_by_name( char *name );3.34 int mem_has_page( uint32_t addr );3.35 char *mem_get_page( uint32_t addr );3.36 +int mem_load_block( const gchar *filename, uint32_t base, uint32_t size );3.37 +int mem_save_block( const gchar *filename, uint32_t base, uint32_t size );3.39 void mem_init( void );3.40 void mem_reset( void );
.