Search
lxdream.org :: lxdream/src/aica/armmem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 953:f4a156508ad1
prev811:7ff871670e58
next968:6fb1481859a4
author nkeynes
date Tue Jan 13 11:56:28 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Merge lxdream-mem branch back to trunk
file annotate diff log raw
1.1 --- a/src/aica/armmem.c Wed Aug 13 10:27:49 2008 +0000
1.2 +++ b/src/aica/armmem.c Tue Jan 13 11:56:28 2009 +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,14 +22,95 @@
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 +unsigned char aica_main_ram[2 MB];
1.16 +unsigned char aica_scratch_ram[8 KB];
1.17
1.18 -void arm_mem_init() {
1.19 - arm_mem = mem_get_region_by_name( MEM_REGION_AUDIO );
1.20 - arm_mem_scratch = mem_get_region_by_name( MEM_REGION_AUDIO_SCRATCH );
1.21 +/*************** ARM memory access function blocks **************/
1.22 +
1.23 +static int32_t FASTCALL ext_audioram_read_long( sh4addr_t addr )
1.24 +{
1.25 + return *((int32_t *)(aica_main_ram + (addr&0x001FFFFF)));
1.26 +}
1.27 +static int32_t FASTCALL ext_audioram_read_word( sh4addr_t addr )
1.28 +{
1.29 + return SIGNEXT16(*((int16_t *)(aica_main_ram + (addr&0x001FFFFF))));
1.30 +}
1.31 +static int32_t FASTCALL ext_audioram_read_byte( sh4addr_t addr )
1.32 +{
1.33 + return SIGNEXT8(*((int16_t *)(aica_main_ram + (addr&0x001FFFFF))));
1.34 +}
1.35 +static void FASTCALL ext_audioram_write_long( sh4addr_t addr, uint32_t val )
1.36 +{
1.37 + *(uint32_t *)(aica_main_ram + (addr&0x001FFFFF)) = val;
1.38 + asic_g2_write_word();
1.39 +}
1.40 +static void FASTCALL ext_audioram_write_word( sh4addr_t addr, uint32_t val )
1.41 +{
1.42 + *(uint16_t *)(aica_main_ram + (addr&0x001FFFFF)) = (uint16_t)val;
1.43 + asic_g2_write_word();
1.44 +}
1.45 +static void FASTCALL ext_audioram_write_byte( sh4addr_t addr, uint32_t val )
1.46 +{
1.47 + *(uint8_t *)(aica_main_ram + (addr&0x001FFFFF)) = (uint8_t)val;
1.48 + asic_g2_write_word();
1.49 +}
1.50 +static void FASTCALL ext_audioram_read_burst( unsigned char *dest, sh4addr_t addr )
1.51 +{
1.52 + memcpy( dest, aica_main_ram+(addr&0x001FFFFF), 32 );
1.53 +}
1.54 +static void FASTCALL ext_audioram_write_burst( sh4addr_t addr, unsigned char *src )
1.55 +{
1.56 + memcpy( aica_main_ram+(addr&0x001FFFFF), src, 32 );
1.57 }
1.58
1.59 +struct mem_region_fn mem_region_audioram = { ext_audioram_read_long, ext_audioram_write_long,
1.60 + ext_audioram_read_word, ext_audioram_write_word,
1.61 + ext_audioram_read_byte, ext_audioram_write_byte,
1.62 + ext_audioram_read_burst, ext_audioram_write_burst };
1.63 +
1.64 +
1.65 +static int32_t FASTCALL ext_audioscratch_read_long( sh4addr_t addr )
1.66 +{
1.67 + return *((int32_t *)(aica_scratch_ram + (addr&0x00001FFF)));
1.68 +}
1.69 +static int32_t FASTCALL ext_audioscratch_read_word( sh4addr_t addr )
1.70 +{
1.71 + return SIGNEXT16(*((int16_t *)(aica_scratch_ram + (addr&0x00001FFF))));
1.72 +}
1.73 +static int32_t FASTCALL ext_audioscratch_read_byte( sh4addr_t addr )
1.74 +{
1.75 + return SIGNEXT8(*((int16_t *)(aica_scratch_ram + (addr&0x00001FFF))));
1.76 +}
1.77 +static void FASTCALL ext_audioscratch_write_long( sh4addr_t addr, uint32_t val )
1.78 +{
1.79 + *(uint32_t *)(aica_scratch_ram + (addr&0x00001FFF)) = val;
1.80 + asic_g2_write_word();
1.81 +}
1.82 +static void FASTCALL ext_audioscratch_write_word( sh4addr_t addr, uint32_t val )
1.83 +{
1.84 + *(uint16_t *)(aica_scratch_ram + (addr&0x00001FFF)) = (uint16_t)val;
1.85 + asic_g2_write_word();
1.86 +}
1.87 +static void FASTCALL ext_audioscratch_write_byte( sh4addr_t addr, uint32_t val )
1.88 +{
1.89 + *(uint8_t *)(aica_scratch_ram + (addr&0x00001FFF)) = (uint8_t)val;
1.90 + asic_g2_write_word();
1.91 +}
1.92 +static void FASTCALL ext_audioscratch_read_burst( unsigned char *dest, sh4addr_t addr )
1.93 +{
1.94 + memcpy( dest, aica_scratch_ram+(addr&0x00001FFF), 32 );
1.95 +}
1.96 +static void FASTCALL ext_audioscratch_write_burst( sh4addr_t addr, unsigned char *src )
1.97 +{
1.98 + memcpy( aica_scratch_ram+(addr&0x00001FFF), src, 32 );
1.99 +}
1.100 +
1.101 +struct mem_region_fn mem_region_audioscratch = { ext_audioscratch_read_long, ext_audioscratch_write_long,
1.102 + ext_audioscratch_read_word, ext_audioscratch_write_word,
1.103 + ext_audioscratch_read_byte, ext_audioscratch_write_byte,
1.104 + ext_audioscratch_read_burst, ext_audioscratch_write_burst };
1.105 +
1.106 +/************************** Local ARM support **************************/
1.107 int arm_has_page( uint32_t addr ) {
1.108 return ( addr < 0x00200000 ||
1.109 (addr >= 0x00800000 && addr <= 0x00805000 ) );
1.110 @@ -37,7 +118,7 @@
1.111
1.112 uint32_t arm_read_long( uint32_t addr ) {
1.113 if( addr < 0x00200000 ) {
1.114 - return *(int32_t *)(arm_mem + addr);
1.115 + return *(int32_t *)(aica_main_ram + addr);
1.116 /* Main sound ram */
1.117 } else {
1.118 uint32_t val;
1.119 @@ -56,7 +137,7 @@
1.120 return val;
1.121 case 0x00803000:
1.122 case 0x00804000:
1.123 - return *(int32_t *)(arm_mem_scratch + addr - 0x00803000);
1.124 + return *(int32_t *)(aica_scratch_ram + addr - 0x00803000);
1.125 }
1.126 }
1.127 ERROR( "Attempted long read to undefined page: %08X at %08X",
1.128 @@ -77,7 +158,7 @@
1.129 {
1.130 if( addr < 0x00200000 ) {
1.131 /* Main sound ram */
1.132 - *(uint32_t *)(arm_mem + addr) = value;
1.133 + *(uint32_t *)(aica_main_ram + addr) = value;
1.134 } else {
1.135 switch( addr & 0xFFFFF000 ) {
1.136 case 0x00800000:
1.137 @@ -94,7 +175,7 @@
1.138 break;
1.139 case 0x00803000:
1.140 case 0x00804000:
1.141 - *(uint32_t *)(arm_mem_scratch + addr - 0x00803000) = value;
1.142 + *(uint32_t *)(aica_scratch_ram + addr - 0x00803000) = value;
1.143 break;
1.144 default:
1.145 ERROR( "Attempted long write to undefined address: %08X",
1.146 @@ -123,7 +204,7 @@
1.147 void arm_write_word( uint32_t addr, uint32_t value )
1.148 {
1.149 if( addr < 0x00200000 ) {
1.150 - *(uint16_t *)(arm_mem + addr) = (uint16_t)value;
1.151 + *(uint16_t *)(aica_main_ram + addr) = (uint16_t)value;
1.152 } else {
1.153
1.154 }
1.155 @@ -132,7 +213,7 @@
1.156 {
1.157 if( addr < 0x00200000 ) {
1.158 /* Main sound ram */
1.159 - *(uint8_t *)(arm_mem + addr) = (uint8_t)value;
1.160 + *(uint8_t *)(aica_main_ram + addr) = (uint8_t)value;
1.161 } else {
1.162 uint32_t tmp;
1.163 switch( addr & 0xFFFFF000 ) {
1.164 @@ -153,7 +234,7 @@
1.165 break;
1.166 case 0x00803000:
1.167 case 0x00804000:
1.168 - *(uint8_t *)(arm_mem_scratch + addr - 0x00803000) = (uint8_t)value;
1.169 + *(uint8_t *)(aica_scratch_ram + addr - 0x00803000) = (uint8_t)value;
1.170 break;
1.171 default:
1.172 ERROR( "Attempted byte write to undefined address: %08X",
.