Search
lxdream.org :: lxdream/src/aica/armmem.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 14:fc481a638848
prev11:0a82ef380c45
next31:495e480360d7
author nkeynes
date Mon Dec 12 10:37:41 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Use cpu-specific is_valid_page function
file annotate diff log raw
nkeynes@11
     1
#include <stdlib.h>
nkeynes@11
     2
#include "dream.h"
nkeynes@7
     3
#include "mem.h"
nkeynes@7
     4
nkeynes@11
     5
char *arm_mem = NULL;
nkeynes@11
     6
nkeynes@7
     7
void arm_mem_init() {
nkeynes@11
     8
    arm_mem = mem_get_region_by_name( MEM_REGION_AUDIO );
nkeynes@11
     9
    
nkeynes@7
    10
}
nkeynes@7
    11
nkeynes@14
    12
int arm_has_page( uint32_t addr ) {
nkeynes@14
    13
    return ( addr < 0x00200000 ||
nkeynes@14
    14
	     (addr >= 0x00800000 && addr <= 0x00805000 ) );
nkeynes@14
    15
}
nkeynes@14
    16
nkeynes@11
    17
int32_t arm_read_long( uint32_t addr ) {
nkeynes@11
    18
    if( addr < 0x00200000 ) {
nkeynes@11
    19
	return *(int32_t *)(arm_mem + addr);
nkeynes@11
    20
	/* Main sound ram */
nkeynes@11
    21
    } else if( addr >= 0x00800000 && addr <= 0x00803000 ) {
nkeynes@11
    22
	/* Sound registers / scratch ram */
nkeynes@11
    23
    } else {
nkeynes@11
    24
	/* Undefined memory */
nkeynes@11
    25
	ERROR( "Attempted long read to undefined page: %08X",
nkeynes@11
    26
	       addr );
nkeynes@11
    27
	return 0;
nkeynes@11
    28
    }
nkeynes@7
    29
}
nkeynes@7
    30
nkeynes@11
    31
int16_t arm_read_word( uint32_t addr ) {
nkeynes@11
    32
    if( addr < 0x00200000 ) {
nkeynes@11
    33
	return *(int16_t *)(arm_mem + addr);
nkeynes@11
    34
	/* Main sound ram */
nkeynes@11
    35
    } else {
nkeynes@11
    36
	/* Undefined memory */
nkeynes@11
    37
	ERROR( "Attempted word read to undefined page: %08X",
nkeynes@11
    38
	       addr );
nkeynes@11
    39
	return 0;
nkeynes@11
    40
    }
nkeynes@11
    41
nkeynes@7
    42
}
nkeynes@7
    43
nkeynes@11
    44
int8_t arm_read_byte( uint32_t addr ) {
nkeynes@11
    45
    if( addr < 0x00200000 ) {
nkeynes@11
    46
	return *(int8_t *)(arm_mem + addr);
nkeynes@11
    47
	/* Main sound ram */
nkeynes@11
    48
    } else {
nkeynes@11
    49
	/* Undefined memory */
nkeynes@11
    50
	ERROR( "Attempted byte read to undefined page: %08X",
nkeynes@11
    51
	       addr );
nkeynes@11
    52
	return 0;
nkeynes@11
    53
    }
nkeynes@7
    54
}
nkeynes@7
    55
nkeynes@11
    56
uint32_t arm_read_long_user( uint32_t addr ) {
nkeynes@11
    57
nkeynes@11
    58
}
nkeynes@11
    59
nkeynes@11
    60
uint32_t arm_read_byte_user( uint32_t addr ) {
nkeynes@11
    61
nkeynes@11
    62
}
.