Search
lxdream.org :: lxdream/src/sh4/sh4mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mem.c
changeset 570:d2893980fbf5
prev569:a1c49e1e8776
next571:9bc09948d0f2
author nkeynes
date Sun Jan 06 12:24:18 2008 +0000 (12 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Change to generate different code for mmu on/off cases
file annotate diff log raw
1.1 --- a/src/sh4/sh4mem.c Fri Jan 04 11:54:17 2008 +0000
1.2 +++ b/src/sh4/sh4mem.c Sun Jan 06 12:24:18 2008 +0000
1.3 @@ -154,18 +154,12 @@
1.4 (((int64_t)((uint32_t)sh4_read_long(addr+4))) << 32);
1.5 }
1.6
1.7 -int64_t sh4_read_long( sh4addr_t vma )
1.8 +int32_t sh4_read_long( sh4addr_t addr )
1.9 {
1.10 sh4ptr_t page;
1.11
1.12 CHECK_READ_WATCH(addr,4);
1.13
1.14 - uint64_t ppa = mmu_vma_to_phys_read(vma);
1.15 - if( ppa>>32 ) {
1.16 - return ppa;
1.17 - }
1.18 - sh4addr_t addr = (sh4addr_t)ppa;
1.19 -
1.20 if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */
1.21 return ZEROEXT32(sh4_read_p4( addr ));
1.22 } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.23 @@ -192,18 +186,12 @@
1.24 }
1.25 }
1.26
1.27 -int64_t sh4_read_word( sh4addr_t vma )
1.28 +int32_t sh4_read_word( sh4addr_t addr )
1.29 {
1.30 sh4ptr_t page;
1.31
1.32 CHECK_READ_WATCH(addr,2);
1.33
1.34 - uint64_t ppa = mmu_vma_to_phys_read(vma);
1.35 - if( ppa>>32 ) {
1.36 - return ppa;
1.37 - }
1.38 - sh4addr_t addr = (sh4addr_t)ppa;
1.39 -
1.40 if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */
1.41 return ZEROEXT32(SIGNEXT16(sh4_read_p4( addr )));
1.42 } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.43 @@ -230,18 +218,12 @@
1.44 }
1.45 }
1.46
1.47 -int64_t sh4_read_byte( sh4addr_t vma )
1.48 +int32_t sh4_read_byte( sh4addr_t addr )
1.49 {
1.50 sh4ptr_t page;
1.51
1.52 CHECK_READ_WATCH(addr,1);
1.53
1.54 - uint64_t ppa = mmu_vma_to_phys_read(vma);
1.55 - if( ppa>>32 ) {
1.56 - return ppa;
1.57 - }
1.58 - sh4addr_t addr = (sh4addr_t)ppa;
1.59 -
1.60 if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */
1.61 return ZEROEXT32(SIGNEXT8(sh4_read_p4( addr )));
1.62 } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.63 @@ -278,25 +260,19 @@
1.64 sh4_write_long( addr+4, (uint32_t)(val>>32) );
1.65 }
1.66
1.67 -int32_t sh4_write_long( sh4addr_t vma, uint32_t val )
1.68 +void sh4_write_long( sh4addr_t addr, uint32_t val )
1.69 {
1.70 sh4ptr_t page;
1.71
1.72 - uint64_t ppa = mmu_vma_to_phys_write(vma);
1.73 - if( ppa>>32 ) {
1.74 - return ppa>>32;
1.75 - }
1.76 - sh4addr_t addr = (sh4addr_t)ppa;
1.77 -
1.78 CHECK_WRITE_WATCH(addr,4,val);
1.79
1.80 if( addr >= 0xE0000000 ) {
1.81 sh4_write_p4( addr, val );
1.82 - return 0;
1.83 + return;
1.84 } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.85 *(uint32_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.86 xlat_invalidate_long(addr);
1.87 - return 0;
1.88 + return;
1.89 } else if( (addr&0x1F800000) == 0x04000000 ||
1.90 (addr&0x1F800000) == 0x11000000 ) {
1.91 texcache_invalidate_page(addr& 0x7FFFFF);
1.92 @@ -309,7 +285,7 @@
1.93 if( (addr&0x1FFFFFFF) < 0x200000 ) {
1.94 WARN( "Attempted write to read-only memory: %08X => %08X", val, addr);
1.95 sh4_stop();
1.96 - return 0;
1.97 + return;
1.98 }
1.99 if( (addr&0x1F800000) == 0x00800000 )
1.100 asic_g2_write_word();
1.101 @@ -319,37 +295,30 @@
1.102 if( page == NULL ) {
1.103 if( (addr & 0x1F000000) >= 0x04000000 &&
1.104 (addr & 0x1F000000) < 0x07000000 )
1.105 - return 0;
1.106 + return;
1.107 WARN( "Long write to missing page: %08X => %08X", val, addr );
1.108 - return 0;
1.109 + return;
1.110 }
1.111 TRACE_IO( "Long write %08X => %08X", page, (addr&0xFFF), val, addr );
1.112 io_rgn[(uintptr_t)page]->io_write(addr&0xFFF, val);
1.113 } else {
1.114 *(uint32_t *)(page+(addr&0xFFF)) = val;
1.115 }
1.116 - return 0;
1.117 }
1.118
1.119 -int32_t sh4_write_word( sh4addr_t vma, uint32_t val )
1.120 +void sh4_write_word( sh4addr_t addr, uint32_t val )
1.121 {
1.122 sh4ptr_t page;
1.123
1.124 - uint64_t ppa = mmu_vma_to_phys_write(vma);
1.125 - if( ppa>>32 ) {
1.126 - return ppa>>32;
1.127 - }
1.128 - sh4addr_t addr = (sh4addr_t)ppa;
1.129 -
1.130 CHECK_WRITE_WATCH(addr,2,val);
1.131
1.132 if( addr >= 0xE0000000 ) {
1.133 sh4_write_p4( addr, (int16_t)val );
1.134 - return 0;
1.135 + return;
1.136 } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.137 *(uint16_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.138 xlat_invalidate_word(addr);
1.139 - return 0;
1.140 + return;
1.141 } else if( (addr&0x1F800000) == 0x04000000 ||
1.142 (addr&0x1F800000) == 0x11000000 ) {
1.143 texcache_invalidate_page(addr& 0x7FFFFF);
1.144 @@ -362,41 +331,34 @@
1.145 if( (addr&0x1FFFFFFF) < 0x200000 ) {
1.146 WARN( "Attempted write to read-only memory: %08X => %08X", val, addr);
1.147 sh4_stop();
1.148 - return 0;
1.149 + return;
1.150 }
1.151 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.152 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */
1.153 if( page == NULL ) {
1.154 WARN( "Attempted word write to missing page: %08X", addr );
1.155 - return 0;
1.156 + return;
1.157 }
1.158 TRACE_IO( "Word write %04X => %08X", page, (addr&0xFFF), val&0xFFFF, addr );
1.159 io_rgn[(uintptr_t)page]->io_write(addr&0xFFF, val);
1.160 } else {
1.161 *(uint16_t *)(page+(addr&0xFFF)) = val;
1.162 }
1.163 - return 0;
1.164 }
1.165
1.166 -int32_t sh4_write_byte( sh4addr_t vma, uint32_t val )
1.167 +void sh4_write_byte( sh4addr_t addr, uint32_t val )
1.168 {
1.169 sh4ptr_t page;
1.170
1.171 - uint64_t ppa = mmu_vma_to_phys_write(vma);
1.172 - if( ppa>>32 ) {
1.173 - return ppa>>32;
1.174 - }
1.175 - sh4addr_t addr = (sh4addr_t)ppa;
1.176 -
1.177 CHECK_WRITE_WATCH(addr,1,val);
1.178
1.179 if( addr >= 0xE0000000 ) {
1.180 sh4_write_p4( addr, (int8_t)val );
1.181 - return 0;
1.182 + return;
1.183 } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.184 *(uint8_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.185 xlat_invalidate_word(addr);
1.186 - return 0;
1.187 + return;
1.188 } else if( (addr&0x1F800000) == 0x04000000 ||
1.189 (addr&0x1F800000) == 0x11000000 ) {
1.190 texcache_invalidate_page(addr& 0x7FFFFF);
1.191 @@ -409,20 +371,19 @@
1.192 if( (addr&0x1FFFFFFF) < 0x200000 ) {
1.193 WARN( "Attempted write to read-only memory: %08X => %08X", val, addr);
1.194 sh4_stop();
1.195 - return 0;
1.196 + return;
1.197 }
1.198 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
1.199 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */
1.200 if( page == NULL ) {
1.201 WARN( "Attempted byte write to missing page: %08X", addr );
1.202 - return 0;
1.203 + return;
1.204 }
1.205 TRACE_IO( "Byte write %02X => %08X", page, (addr&0xFFF), val&0xFF, addr );
1.206 io_rgn[(uintptr_t)page]->io_write( (addr&0xFFF), val);
1.207 } else {
1.208 *(uint8_t *)(page+(addr&0xFFF)) = val;
1.209 }
1.210 - return 0;
1.211 }
1.212
1.213
.