Search
lxdream.org :: lxdream/src/mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.c
changeset 17:944f75eea496
prev15:5194dd0fdb60
next18:9a1b5d75703f
author nkeynes
date Tue Dec 13 14:47:59 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change More work on load/save state - save state a little more structured now
Memory save now in
file annotate diff log raw
1.1 --- a/src/mem.c Mon Dec 12 13:11:11 2005 +0000
1.2 +++ b/src/mem.c Tue Dec 13 14:47:59 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: mem.c,v 1.3 2005-12-12 13:11:07 nkeynes Exp $
1.6 + * $Id: mem.c,v 1.4 2005-12-13 14:47:59 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 @@ -34,8 +34,10 @@
1.11
1.12 char **page_map = NULL;
1.13
1.14 +int mem_load(FILE *f);
1.15 +void mem_save(FILE *f);
1.16 struct dreamcast_module mem_module =
1.17 - { "MEM", mem_init, mem_reset, NULL, NULL, NULL, NULL };
1.18 + { "MEM", mem_init, mem_reset, NULL, NULL, mem_save, mem_load };
1.19
1.20 struct mem_region mem_rgn[MAX_MEM_REGIONS];
1.21 struct mmio_region *io_rgn[MAX_IO_REGIONS];
1.22 @@ -83,6 +85,40 @@
1.23 }
1.24 }
1.25
1.26 +void mem_save( FILE *f )
1.27 +{
1.28 + int i;
1.29 + uint32_t len;
1.30 +
1.31 + /* All memory regions */
1.32 + fwrite( &num_mem_rgns, sizeof(num_mem_rgns), 1, f );
1.33 + for( i=0; i<num_mem_rgns; i++ ) {
1.34 + fwrite_string( mem_rgn[i].name, f );
1.35 + fwrite( &mem_rgn[i].base, sizeof(uint32_t), 1, f );
1.36 + fwrite( &mem_rgn[i].flags, sizeof(int), 1, f );
1.37 + fwrite( &mem_rgn[i].size, sizeof(uint32_t), 1, f );
1.38 + fwrite( mem_rgn[i].mem, mem_rgn[i].size, 1, f );
1.39 + }
1.40 +
1.41 + /* All MMIO regions */
1.42 + fwrite( &num_io_rgns, sizeof(num_io_rgns), 1, f );
1.43 + for( i=0; i<num_io_rgns; i++ ) {
1.44 + fwrite_string( io_rgn[i]->id, f );
1.45 + fwrite( &io_rgn[i]->base, sizeof( uint32_t ), 1, f );
1.46 + fwrite( io_rgn[i]->mem, 4096, 1, f );
1.47 + }
1.48 +}
1.49 +
1.50 +int mem_load( FILE *f )
1.51 +{
1.52 + char tmp[64];
1.53 + uint32_t len;
1.54 + int i;
1.55 +
1.56 + /* All memory regions */
1.57 +
1.58 +}
1.59 +
1.60 struct mem_region *mem_map_region( void *mem, uint32_t base, uint32_t size,
1.61 char *name, int flags )
1.62 {
.