Search
lxdream.org :: lxdream/src/aica/armmem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 931:430048ea8b71
prev811:7ff871670e58
next934:3acd3b3ee6d1
author nkeynes
date Tue Dec 23 05:48:05 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change More refactoring and general cleanup. Most things should be working again now.
Split off cache and start real implementation, breaking save states in the process
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 Dec 23 05:48:05 2008 +0000
1.3 @@ -30,6 +30,92 @@
1.4 arm_mem_scratch = mem_get_region_by_name( MEM_REGION_AUDIO_SCRATCH );
1.5 }
1.6
1.7 +/*************** ARM memory access function blocks **************/
1.8 +
1.9 +static int32_t FASTCALL ext_audioram_read_long( sh4addr_t addr )
1.10 +{
1.11 + return *((int32_t *)(arm_mem + (addr&0x001FFFFF)));
1.12 +}
1.13 +static int32_t FASTCALL ext_audioram_read_word( sh4addr_t addr )
1.14 +{
1.15 + return SIGNEXT16(*((int16_t *)(arm_mem + (addr&0x001FFFFF))));
1.16 +}
1.17 +static int32_t FASTCALL ext_audioram_read_byte( sh4addr_t addr )
1.18 +{
1.19 + return SIGNEXT8(*((int16_t *)(arm_mem + (addr&0x001FFFFF))));
1.20 +}
1.21 +static void FASTCALL ext_audioram_write_long( sh4addr_t addr, uint32_t val )
1.22 +{
1.23 + *(uint32_t *)(arm_mem + (addr&0x001FFFFF)) = val;
1.24 + asic_g2_write_word();
1.25 +}
1.26 +static void FASTCALL ext_audioram_write_word( sh4addr_t addr, uint32_t val )
1.27 +{
1.28 + *(uint16_t *)(arm_mem + (addr&0x001FFFFF)) = (uint16_t)val;
1.29 + asic_g2_write_word();
1.30 +}
1.31 +static void FASTCALL ext_audioram_write_byte( sh4addr_t addr, uint32_t val )
1.32 +{
1.33 + *(uint8_t *)(arm_mem + (addr&0x001FFFFF)) = (uint8_t)val;
1.34 + asic_g2_write_word();
1.35 +}
1.36 +static void FASTCALL ext_audioram_read_burst( unsigned char *dest, sh4addr_t addr )
1.37 +{
1.38 + memcpy( dest, arm_mem+(addr&0x001FFFFF), 32 );
1.39 +}
1.40 +static void FASTCALL ext_audioram_write_burst( sh4addr_t addr, unsigned char *src )
1.41 +{
1.42 + memcpy( arm_mem+(addr&0x001FFFFF), src, 32 );
1.43 +}
1.44 +
1.45 +struct mem_region_fn mem_region_audioram = { ext_audioram_read_long, ext_audioram_write_long,
1.46 + ext_audioram_read_word, ext_audioram_write_word,
1.47 + ext_audioram_read_byte, ext_audioram_write_byte,
1.48 + ext_audioram_read_burst, ext_audioram_write_burst };
1.49 +
1.50 +
1.51 +static int32_t FASTCALL ext_audioscratch_read_long( sh4addr_t addr )
1.52 +{
1.53 + return *((int32_t *)(arm_mem_scratch + (addr&0x00001FFF)));
1.54 +}
1.55 +static int32_t FASTCALL ext_audioscratch_read_word( sh4addr_t addr )
1.56 +{
1.57 + return SIGNEXT16(*((int16_t *)(arm_mem_scratch + (addr&0x00001FFF))));
1.58 +}
1.59 +static int32_t FASTCALL ext_audioscratch_read_byte( sh4addr_t addr )
1.60 +{
1.61 + return SIGNEXT8(*((int16_t *)(arm_mem_scratch + (addr&0x00001FFF))));
1.62 +}
1.63 +static void FASTCALL ext_audioscratch_write_long( sh4addr_t addr, uint32_t val )
1.64 +{
1.65 + *(uint32_t *)(arm_mem_scratch + (addr&0x00001FFF)) = val;
1.66 + asic_g2_write_word();
1.67 +}
1.68 +static void FASTCALL ext_audioscratch_write_word( sh4addr_t addr, uint32_t val )
1.69 +{
1.70 + *(uint16_t *)(arm_mem_scratch + (addr&0x00001FFF)) = (uint16_t)val;
1.71 + asic_g2_write_word();
1.72 +}
1.73 +static void FASTCALL ext_audioscratch_write_byte( sh4addr_t addr, uint32_t val )
1.74 +{
1.75 + *(uint8_t *)(arm_mem_scratch + (addr&0x00001FFF)) = (uint8_t)val;
1.76 + asic_g2_write_word();
1.77 +}
1.78 +static void FASTCALL ext_audioscratch_read_burst( unsigned char *dest, sh4addr_t addr )
1.79 +{
1.80 + memcpy( dest, arm_mem_scratch+(addr&0x00001FFF), 32 );
1.81 +}
1.82 +static void FASTCALL ext_audioscratch_write_burst( sh4addr_t addr, unsigned char *src )
1.83 +{
1.84 + memcpy( arm_mem_scratch+(addr&0x00001FFF), src, 32 );
1.85 +}
1.86 +
1.87 +struct mem_region_fn mem_region_audioscratch = { ext_audioscratch_read_long, ext_audioscratch_write_long,
1.88 + ext_audioscratch_read_word, ext_audioscratch_write_word,
1.89 + ext_audioscratch_read_byte, ext_audioscratch_write_byte,
1.90 + ext_audioscratch_read_burst, ext_audioscratch_write_burst };
1.91 +
1.92 +/************************** Local ARM support **************************/
1.93 int arm_has_page( uint32_t addr ) {
1.94 return ( addr < 0x00200000 ||
1.95 (addr >= 0x00800000 && addr <= 0x00805000 ) );
.