Search
lxdream.org :: lxdream/src/aica/armmem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 934:3acd3b3ee6d1
prev931:430048ea8b71
next1067:d3c00ffccfcd
author nkeynes
date Fri Dec 26 14:25:23 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Change RAM regions to use static arrays rather than mmap regions, for a 2-3% performance gain.
General mem cleanups, including some save state fixes that break states again.
file annotate diff log raw
1.1 --- a/src/aica/armmem.c Tue Dec 23 05:48:05 2008 +0000
1.2 +++ b/src/aica/armmem.c Fri Dec 26 14:25:23 2008 +0000
1.3 @@ -1,4 +1,4 @@
1.4 -/**
1.5 +/*`*
1.6 * $Id$
1.7 *
1.8 * Implements the ARM's memory map.
1.9 @@ -22,50 +22,45 @@
1.10 #include "aica.h"
1.11 #include "armcore.h"
1.12
1.13 -unsigned char *arm_mem = NULL;
1.14 -unsigned char *arm_mem_scratch = NULL;
1.15 -
1.16 -void arm_mem_init() {
1.17 - arm_mem = mem_get_region_by_name( MEM_REGION_AUDIO );
1.18 - arm_mem_scratch = mem_get_region_by_name( MEM_REGION_AUDIO_SCRATCH );
1.19 -}
1.20 +unsigned char aica_main_ram[2 MB];
1.21 +unsigned char aica_scratch_ram[8 KB];
1.22
1.23 /*************** ARM memory access function blocks **************/
1.24
1.25 static int32_t FASTCALL ext_audioram_read_long( sh4addr_t addr )
1.26 {
1.27 - return *((int32_t *)(arm_mem + (addr&0x001FFFFF)));
1.28 + return *((int32_t *)(aica_main_ram + (addr&0x001FFFFF)));
1.29 }
1.30 static int32_t FASTCALL ext_audioram_read_word( sh4addr_t addr )
1.31 {
1.32 - return SIGNEXT16(*((int16_t *)(arm_mem + (addr&0x001FFFFF))));
1.33 + return SIGNEXT16(*((int16_t *)(aica_main_ram + (addr&0x001FFFFF))));
1.34 }
1.35 static int32_t FASTCALL ext_audioram_read_byte( sh4addr_t addr )
1.36 {
1.37 - return SIGNEXT8(*((int16_t *)(arm_mem + (addr&0x001FFFFF))));
1.38 + return SIGNEXT8(*((int16_t *)(aica_main_ram + (addr&0x001FFFFF))));
1.39 }
1.40 static void FASTCALL ext_audioram_write_long( sh4addr_t addr, uint32_t val )
1.41 {
1.42 - *(uint32_t *)(arm_mem + (addr&0x001FFFFF)) = val;
1.43 + *(uint32_t *)(aica_main_ram + (addr&0x001FFFFF)) = val;
1.44 asic_g2_write_word();
1.45 }
1.46 static void FASTCALL ext_audioram_write_word( sh4addr_t addr, uint32_t val )
1.47 {
1.48 - *(uint16_t *)(arm_mem + (addr&0x001FFFFF)) = (uint16_t)val;
1.49 + *(uint16_t *)(aica_main_ram + (addr&0x001FFFFF)) = (uint16_t)val;
1.50 asic_g2_write_word();
1.51 }
1.52 static void FASTCALL ext_audioram_write_byte( sh4addr_t addr, uint32_t val )
1.53 {
1.54 - *(uint8_t *)(arm_mem + (addr&0x001FFFFF)) = (uint8_t)val;
1.55 + *(uint8_t *)(aica_main_ram + (addr&0x001FFFFF)) = (uint8_t)val;
1.56 asic_g2_write_word();
1.57 }
1.58 static void FASTCALL ext_audioram_read_burst( unsigned char *dest, sh4addr_t addr )
1.59 {
1.60 - memcpy( dest, arm_mem+(addr&0x001FFFFF), 32 );
1.61 + memcpy( dest, aica_main_ram+(addr&0x001FFFFF), 32 );
1.62 }
1.63 static void FASTCALL ext_audioram_write_burst( sh4addr_t addr, unsigned char *src )
1.64 {
1.65 - memcpy( arm_mem+(addr&0x001FFFFF), src, 32 );
1.66 + memcpy( aica_main_ram+(addr&0x001FFFFF), src, 32 );
1.67 }
1.68
1.69 struct mem_region_fn mem_region_audioram = { ext_audioram_read_long, ext_audioram_write_long,
1.70 @@ -76,38 +71,38 @@
1.71
1.72 static int32_t FASTCALL ext_audioscratch_read_long( sh4addr_t addr )
1.73 {
1.74 - return *((int32_t *)(arm_mem_scratch + (addr&0x00001FFF)));
1.75 + return *((int32_t *)(aica_scratch_ram + (addr&0x00001FFF)));
1.76 }
1.77 static int32_t FASTCALL ext_audioscratch_read_word( sh4addr_t addr )
1.78 {
1.79 - return SIGNEXT16(*((int16_t *)(arm_mem_scratch + (addr&0x00001FFF))));
1.80 + return SIGNEXT16(*((int16_t *)(aica_scratch_ram + (addr&0x00001FFF))));
1.81 }
1.82 static int32_t FASTCALL ext_audioscratch_read_byte( sh4addr_t addr )
1.83 {
1.84 - return SIGNEXT8(*((int16_t *)(arm_mem_scratch + (addr&0x00001FFF))));
1.85 + return SIGNEXT8(*((int16_t *)(aica_scratch_ram + (addr&0x00001FFF))));
1.86 }
1.87 static void FASTCALL ext_audioscratch_write_long( sh4addr_t addr, uint32_t val )
1.88 {
1.89 - *(uint32_t *)(arm_mem_scratch + (addr&0x00001FFF)) = val;
1.90 + *(uint32_t *)(aica_scratch_ram + (addr&0x00001FFF)) = val;
1.91 asic_g2_write_word();
1.92 }
1.93 static void FASTCALL ext_audioscratch_write_word( sh4addr_t addr, uint32_t val )
1.94 {
1.95 - *(uint16_t *)(arm_mem_scratch + (addr&0x00001FFF)) = (uint16_t)val;
1.96 + *(uint16_t *)(aica_scratch_ram + (addr&0x00001FFF)) = (uint16_t)val;
1.97 asic_g2_write_word();
1.98 }
1.99 static void FASTCALL ext_audioscratch_write_byte( sh4addr_t addr, uint32_t val )
1.100 {
1.101 - *(uint8_t *)(arm_mem_scratch + (addr&0x00001FFF)) = (uint8_t)val;
1.102 + *(uint8_t *)(aica_scratch_ram + (addr&0x00001FFF)) = (uint8_t)val;
1.103 asic_g2_write_word();
1.104 }
1.105 static void FASTCALL ext_audioscratch_read_burst( unsigned char *dest, sh4addr_t addr )
1.106 {
1.107 - memcpy( dest, arm_mem_scratch+(addr&0x00001FFF), 32 );
1.108 + memcpy( dest, aica_scratch_ram+(addr&0x00001FFF), 32 );
1.109 }
1.110 static void FASTCALL ext_audioscratch_write_burst( sh4addr_t addr, unsigned char *src )
1.111 {
1.112 - memcpy( arm_mem_scratch+(addr&0x00001FFF), src, 32 );
1.113 + memcpy( aica_scratch_ram+(addr&0x00001FFF), src, 32 );
1.114 }
1.115
1.116 struct mem_region_fn mem_region_audioscratch = { ext_audioscratch_read_long, ext_audioscratch_write_long,
1.117 @@ -123,7 +118,7 @@
1.118
1.119 uint32_t arm_read_long( uint32_t addr ) {
1.120 if( addr < 0x00200000 ) {
1.121 - return *(int32_t *)(arm_mem + addr);
1.122 + return *(int32_t *)(aica_main_ram + addr);
1.123 /* Main sound ram */
1.124 } else {
1.125 uint32_t val;
1.126 @@ -142,7 +137,7 @@
1.127 return val;
1.128 case 0x00803000:
1.129 case 0x00804000:
1.130 - return *(int32_t *)(arm_mem_scratch + addr - 0x00803000);
1.131 + return *(int32_t *)(aica_scratch_ram + addr - 0x00803000);
1.132 }
1.133 }
1.134 ERROR( "Attempted long read to undefined page: %08X at %08X",
1.135 @@ -163,7 +158,7 @@
1.136 {
1.137 if( addr < 0x00200000 ) {
1.138 /* Main sound ram */
1.139 - *(uint32_t *)(arm_mem + addr) = value;
1.140 + *(uint32_t *)(aica_main_ram + addr) = value;
1.141 } else {
1.142 switch( addr & 0xFFFFF000 ) {
1.143 case 0x00800000:
1.144 @@ -180,7 +175,7 @@
1.145 break;
1.146 case 0x00803000:
1.147 case 0x00804000:
1.148 - *(uint32_t *)(arm_mem_scratch + addr - 0x00803000) = value;
1.149 + *(uint32_t *)(aica_scratch_ram + addr - 0x00803000) = value;
1.150 break;
1.151 default:
1.152 ERROR( "Attempted long write to undefined address: %08X",
1.153 @@ -209,7 +204,7 @@
1.154 void arm_write_word( uint32_t addr, uint32_t value )
1.155 {
1.156 if( addr < 0x00200000 ) {
1.157 - *(uint16_t *)(arm_mem + addr) = (uint16_t)value;
1.158 + *(uint16_t *)(aica_main_ram + addr) = (uint16_t)value;
1.159 } else {
1.160
1.161 }
1.162 @@ -218,7 +213,7 @@
1.163 {
1.164 if( addr < 0x00200000 ) {
1.165 /* Main sound ram */
1.166 - *(uint8_t *)(arm_mem + addr) = (uint8_t)value;
1.167 + *(uint8_t *)(aica_main_ram + addr) = (uint8_t)value;
1.168 } else {
1.169 uint32_t tmp;
1.170 switch( addr & 0xFFFFF000 ) {
1.171 @@ -239,7 +234,7 @@
1.172 break;
1.173 case 0x00803000:
1.174 case 0x00804000:
1.175 - *(uint8_t *)(arm_mem_scratch + addr - 0x00803000) = (uint8_t)value;
1.176 + *(uint8_t *)(aica_scratch_ram + addr - 0x00803000) = (uint8_t)value;
1.177 break;
1.178 default:
1.179 ERROR( "Attempted byte write to undefined address: %08X",
.