Search
lxdream.org :: lxdream/src/mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.c
changeset 502:c4ecae2b1b5e
prev490:1e0f9940e064
next510:41ce7a074f4e
author nkeynes
date Thu Nov 08 11:54:16 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Add sh4ptr_t type, start converting bare pointer refs to it
file annotate diff log raw
1.1 --- a/src/mem.c Sun Nov 04 08:49:18 2007 +0000
1.2 +++ b/src/mem.c Thu Nov 08 11:54:16 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: mem.c,v 1.21 2007-11-04 08:49:18 nkeynes Exp $
1.6 + * $Id: mem.c,v 1.22 2007-11-08 11:54:16 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,7 +34,7 @@
1.11 #include "mmio.h"
1.12 #include "dreamcast.h"
1.13
1.14 -char **page_map = NULL;
1.15 +sh4ptr_t *page_map = NULL;
1.16
1.17 int mem_load(FILE *f);
1.18 void mem_save(FILE *f);
1.19 @@ -163,7 +163,7 @@
1.20
1.21 int mem_save_block( const gchar *file, uint32_t start, uint32_t length )
1.22 {
1.23 - char *region;
1.24 + sh4ptr_t region;
1.25 int len = 4096, total = 0;
1.26 uint32_t addr = start;
1.27 FILE *f = fopen(file,"w");
1.28 @@ -191,7 +191,7 @@
1.29
1.30 int mem_load_block( const gchar *file, uint32_t start, uint32_t length )
1.31 {
1.32 - char *region;
1.33 + sh4ptr_t region;
1.34 int len = 4096, total = 0;
1.35 uint32_t addr = start;
1.36 struct stat st;
1.37 @@ -269,7 +269,7 @@
1.38 void *mem_load_rom( const gchar *file, uint32_t base, uint32_t size, uint32_t crc,
1.39 const gchar *region_name )
1.40 {
1.41 - char *mem;
1.42 + sh4ptr_t mem;
1.43 uint32_t calc_crc;
1.44 int status;
1.45
1.46 @@ -290,7 +290,7 @@
1.47
1.48 if( status == 0 ) {
1.49 /* CRC check only if we loaded something */
1.50 - calc_crc = crc32(0L, (unsigned char *)mem, size);
1.51 + calc_crc = crc32(0L, (sh4ptr_t)mem, size);
1.52 if( calc_crc != crc ) {
1.53 WARN( "Bios CRC Mismatch in %s: %08X (expected %08X)",
1.54 file, calc_crc, crc);
1.55 @@ -300,7 +300,7 @@
1.56 return mem;
1.57 }
1.58
1.59 -char *mem_get_region_by_name( const char *name )
1.60 +sh4ptr_t mem_get_region_by_name( const char *name )
1.61 {
1.62 int i;
1.63 for( i=0; i<num_mem_rgns; i++ ) {
1.64 @@ -330,7 +330,7 @@
1.65 /* P4 area (on-chip I/O channels */
1.66 P4_io[(io->base&0x1FFFFFFF)>>19] = io;
1.67 } else {
1.68 - page_map[io->base>>12] = (char *)num_io_rgns;
1.69 + page_map[io->base>>12] = (sh4ptr_t )num_io_rgns;
1.70 }
1.71 io_rgn[num_io_rgns] = io;
1.72 num_io_rgns++;
1.73 @@ -343,19 +343,19 @@
1.74
1.75 int mem_has_page( uint32_t addr )
1.76 {
1.77 - char *page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.78 + sh4ptr_t page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.79 return page != NULL;
1.80 }
1.81
1.82 -char *mem_get_page( uint32_t addr )
1.83 +sh4ptr_t mem_get_page( uint32_t addr )
1.84 {
1.85 - char *page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.86 + sh4ptr_t page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.87 return page;
1.88 }
1.89
1.90 -char *mem_get_region( uint32_t addr )
1.91 +sh4ptr_t mem_get_region( uint32_t addr )
1.92 {
1.93 - char *page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.94 + sh4ptr_t page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.95 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */
1.96 return NULL;
1.97 } else {
1.98 @@ -368,7 +368,7 @@
1.99 if( addr > 0xFF000000 ) {
1.100 return P4_io[(addr&0x00FFFFFF)>>12];
1.101 }
1.102 - char *page = page_map[(addr&0x1FFFFFFF)>>12];
1.103 + sh4ptr_t page = page_map[(addr&0x1FFFFFFF)>>12];
1.104 if( ((uintptr_t)page) < MAX_IO_REGIONS ) {
1.105 return io_rgn[(uintptr_t)page];
1.106 } else {
.