Search
lxdream.org :: lxdream/src/aica/armmem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 40:852ee31ace0d
prev37:1d84f4c18816
next66:2ec5b6eb75e5
author nkeynes
date Mon Dec 26 10:48:20 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Fixup ARM memory to be a little more functional
file annotate diff log raw
1.1 --- a/src/aica/armmem.c Mon Dec 26 06:38:51 2005 +0000
1.2 +++ b/src/aica/armmem.c Mon Dec 26 10:48:20 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: armmem.c,v 1.5 2005-12-26 06:38:51 nkeynes Exp $
1.6 + * $Id: armmem.c,v 1.6 2005-12-26 10:48:20 nkeynes Exp $
1.7 *
1.8 * Implements the ARM's memory map.
1.9 *
1.10 @@ -21,10 +21,11 @@
1.11 #include "mem.h"
1.12
1.13 char *arm_mem = NULL;
1.14 +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 -
1.19 + arm_mem_scratch = mem_get_region_by_name( MEM_REGION_AUDIO_SCRATCH );
1.20 }
1.21
1.22 int arm_has_page( uint32_t addr ) {
1.23 @@ -40,17 +41,13 @@
1.24 switch( addr & 0xFFFFF000 ) {
1.25 case 0x00800000:
1.26 return mmio_region_AICA0_read(addr);
1.27 - break;
1.28 case 0x00801000:
1.29 return mmio_region_AICA1_read(addr);
1.30 - break;
1.31 case 0x00802000:
1.32 return mmio_region_AICA2_read(addr);
1.33 - break;
1.34 case 0x00803000:
1.35 - break;
1.36 case 0x00804000:
1.37 - break;
1.38 + return *(int32_t *)(arm_mem_scratch + addr - 0x00803000);
1.39 }
1.40 }
1.41 ERROR( "Attempted long read to undefined page: %08X",
1.42 @@ -60,44 +57,69 @@
1.43 }
1.44
1.45 uint32_t arm_read_word( uint32_t addr ) {
1.46 - if( addr < 0x00200000 ) {
1.47 - return *(int16_t *)(arm_mem + addr);
1.48 - /* Main sound ram */
1.49 - } else {
1.50 - /* Undefined memory */
1.51 - ERROR( "Attempted word read to undefined page: %08X",
1.52 - addr );
1.53 - return 0;
1.54 - }
1.55 -
1.56 + return (uint32_t)(uint16_t)arm_read_long( addr );
1.57 }
1.58
1.59 uint32_t arm_read_byte( uint32_t addr ) {
1.60 - if( addr < 0x00200000 ) {
1.61 - return (uint32_t)(*(uint8_t *)(arm_mem + addr));
1.62 - /* Main sound ram */
1.63 - } else {
1.64 - /* Undefined memory */
1.65 - ERROR( "Attempted byte read to undefined page: %08X",
1.66 - addr );
1.67 - return 0;
1.68 - }
1.69 + return (uint32_t)(uint8_t)arm_read_long( addr );
1.70 }
1.71
1.72 void arm_write_long( uint32_t addr, uint32_t value )
1.73 {
1.74 if( addr < 0x00200000 ) {
1.75 + /* Main sound ram */
1.76 *(uint32_t *)(arm_mem + addr) = value;
1.77 } else {
1.78 + switch( addr & 0xFFFFF000 ) {
1.79 + case 0x00800000:
1.80 + mmio_region_AICA0_write(addr, value);
1.81 + break;
1.82 + case 0x00801000:
1.83 + mmio_region_AICA1_write(addr, value);
1.84 + break;
1.85 + case 0x00802000:
1.86 + mmio_region_AICA2_write(addr, value);
1.87 + break;
1.88 + case 0x00803000:
1.89 + case 0x00804000:
1.90 + *(uint32_t *)(arm_mem_scratch + addr - 0x00803000) = value;
1.91 + break;
1.92 + default:
1.93 + ERROR( "Attempted long write to undefined address: %08X",
1.94 + addr );
1.95 + /* Undefined memory */
1.96 + }
1.97 }
1.98 + return 0;
1.99 }
1.100
1.101 void arm_write_byte( uint32_t addr, uint32_t value )
1.102 {
1.103 if( addr < 0x00200000 ) {
1.104 - *(uint8_t *)(arm_mem+addr) = (uint8_t)value;
1.105 + /* Main sound ram */
1.106 + *(uint8_t *)(arm_mem + addr) = (uint8_t)value;
1.107 } else {
1.108 + switch( addr & 0xFFFFF000 ) {
1.109 + case 0x00800000:
1.110 + mmio_region_AICA0_write(addr, value);
1.111 + break;
1.112 + case 0x00801000:
1.113 + mmio_region_AICA1_write(addr, value);
1.114 + break;
1.115 + case 0x00802000:
1.116 + mmio_region_AICA2_write(addr, value);
1.117 + break;
1.118 + case 0x00803000:
1.119 + case 0x00804000:
1.120 + *(uint8_t *)(arm_mem_scratch + addr - 0x00803000) = (uint8_t)value;
1.121 + break;
1.122 + default:
1.123 + ERROR( "Attempted byte write to undefined address: %08X",
1.124 + addr );
1.125 + /* Undefined memory */
1.126 + }
1.127 }
1.128 + return 0;
1.129 }
1.130
1.131 /* User translations - TODO */
.