Search
lxdream.org :: lxdream/src/mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.c
changeset 932:2602c5603ce2
prev931:430048ea8b71
next934:3acd3b3ee6d1
author nkeynes
date Wed Dec 24 06:05:42 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Fix save-states (don't attempt to load/save non-existent regions)
file annotate diff log raw
1.1 --- a/src/mem.c Tue Dec 23 05:48:05 2008 +0000
1.2 +++ b/src/mem.c Wed Dec 24 06:05:42 2008 +0000
1.3 @@ -137,12 +137,14 @@
1.4 /* All memory regions */
1.5 fwrite( &num_mem_rgns, sizeof(num_mem_rgns), 1, f );
1.6 for( i=0; i<num_mem_rgns; i++ ) {
1.7 - fwrite_string( mem_rgn[i].name, f );
1.8 - fwrite( &mem_rgn[i].base, sizeof(uint32_t), 1, f );
1.9 - fwrite( &mem_rgn[i].flags, sizeof(uint32_t), 1, f );
1.10 - fwrite( &mem_rgn[i].size, sizeof(uint32_t), 1, f );
1.11 - if( mem_rgn[i].flags != MEM_FLAG_ROM )
1.12 - fwrite_gzip( mem_rgn[i].mem, mem_rgn[i].size, 1, f );
1.13 + if( mem_rgn[i].mem != NULL ) {
1.14 + fwrite_string( mem_rgn[i].name, f );
1.15 + fwrite( &mem_rgn[i].base, sizeof(uint32_t), 1, f );
1.16 + fwrite( &mem_rgn[i].flags, sizeof(uint32_t), 1, f );
1.17 + fwrite( &mem_rgn[i].size, sizeof(uint32_t), 1, f );
1.18 + if( mem_rgn[i].flags != MEM_FLAG_ROM )
1.19 + fwrite_gzip( mem_rgn[i].mem, mem_rgn[i].size, 1, f );
1.20 + }
1.21 }
1.22
1.23 /* All MMIO regions */
1.24 @@ -169,19 +171,21 @@
1.25 if( len != num_mem_rgns )
1.26 return -1;
1.27 for( i=0; i<len; i++ ) {
1.28 - fread_string( tmp, sizeof(tmp), f );
1.29 - fread( &base, sizeof(base), 1, f );
1.30 - fread( &flags, sizeof(flags), 1, f );
1.31 - fread( &size, sizeof(size), 1, f );
1.32 - if( strcmp( mem_rgn[i].name, tmp ) != 0 ||
1.33 - base != mem_rgn[i].base ||
1.34 - flags != mem_rgn[i].flags ||
1.35 - size != mem_rgn[i].size ) {
1.36 - ERROR( "Bad memory region %d %s", i, tmp );
1.37 - return -1;
1.38 + if( mem_rgn[i].mem != NULL ) {
1.39 + fread_string( tmp, sizeof(tmp), f );
1.40 + fread( &base, sizeof(base), 1, f );
1.41 + fread( &flags, sizeof(flags), 1, f );
1.42 + fread( &size, sizeof(size), 1, f );
1.43 + if( strcmp( mem_rgn[i].name, tmp ) != 0 ||
1.44 + base != mem_rgn[i].base ||
1.45 + flags != mem_rgn[i].flags ||
1.46 + size != mem_rgn[i].size ) {
1.47 + ERROR( "Bad memory region %d %s", i, tmp );
1.48 + return -1;
1.49 + }
1.50 + if( flags != MEM_FLAG_ROM )
1.51 + fread_gzip( mem_rgn[i].mem, size, 1, f );
1.52 }
1.53 - if( flags != MEM_FLAG_ROM )
1.54 - fread_gzip( mem_rgn[i].mem, size, 1, f );
1.55 }
1.56
1.57 /* All MMIO regions */
.