Search
lxdream.org :: lxdream/src/mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.c
changeset 146:f91fa34ab219
prev72:ceb5985fa8d8
next156:3b93648a3b07
author nkeynes
date Sat May 20 02:38:58 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Add repeating memory mode
Load flash as ram rather than rom
file annotate diff log raw
1.1 --- a/src/mem.c Tue Jan 10 14:00:00 2006 +0000
1.2 +++ b/src/mem.c Sat May 20 02:38:58 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: mem.c,v 1.11 2006-01-10 14:00:00 nkeynes Exp $
1.6 + * $Id: mem.c,v 1.12 2006-05-20 02:38:58 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 @@ -222,7 +222,8 @@
1.11 }
1.12
1.13 struct mem_region *mem_map_region( void *mem, uint32_t base, uint32_t size,
1.14 - char *name, int flags )
1.15 + char *name, int flags, uint32_t repeat_offset,
1.16 + uint32_t repeat_until )
1.17 {
1.18 int i;
1.19 mem_rgn[num_mem_rgns].base = base;
1.20 @@ -232,14 +233,23 @@
1.21 mem_rgn[num_mem_rgns].mem = mem;
1.22 num_mem_rgns++;
1.23
1.24 - for( i=0; i<size>>PAGE_BITS; i++ )
1.25 - page_map[(base>>PAGE_BITS)+i] = mem + (i<<PAGE_BITS);
1.26 + do {
1.27 + for( i=0; i<size>>PAGE_BITS; i++ )
1.28 + page_map[(base>>PAGE_BITS)+i] = mem + (i<<PAGE_BITS);
1.29 + base += repeat_offset;
1.30 + } while( base <= repeat_until );
1.31
1.32 return &mem_rgn[num_mem_rgns-1];
1.33 }
1.34
1.35 void *mem_create_ram_region( uint32_t base, uint32_t size, char *name )
1.36 {
1.37 + return mem_create_repeating_ram_region( base, size, name, size, base );
1.38 +}
1.39 +
1.40 +void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, char *name,
1.41 + uint32_t repeat_offset, uint32_t repeat_until )
1.42 +{
1.43 char *mem;
1.44
1.45 assert( (base&0xFFFFF000) == base ); /* must be page aligned */
1.46 @@ -249,7 +259,8 @@
1.47
1.48 mem = mem_alloc_pages( size>>PAGE_BITS );
1.49
1.50 - mem_map_region( mem, base, size, name, MEM_FLAG_RAM );
1.51 + mem_map_region( mem, base, size, name, MEM_FLAG_RAM, repeat_offset, repeat_until );
1.52 +
1.53 return mem;
1.54 }
1.55
1.56 @@ -270,7 +281,7 @@
1.57 close(fd);
1.58 return NULL;
1.59 }
1.60 - mem_map_region( mem, base, size, file, MEM_FLAG_ROM );
1.61 + mem_map_region( mem, base, size, file, MEM_FLAG_ROM, size, base );
1.62
1.63 /* CRC check */
1.64 calc_crc = crc32(0L, mem, size);
.