Search
lxdream.org :: lxdream/src/aica/armmem.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 31:495e480360d7
prev14:fc481a638848
next37:1d84f4c18816
author nkeynes
date Sun Dec 25 08:24:11 2005 +0000 (16 years ago)
permissions -rw-r--r--
last change Finish adding header blocks to all files
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@31
     2
 * $Id: armmem.c,v 1.4 2005-12-25 08:24:11 nkeynes Exp $
nkeynes@31
     3
 *
nkeynes@31
     4
 * Implements the ARM's memory map.
nkeynes@31
     5
 *
nkeynes@31
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@31
     7
 *
nkeynes@31
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@31
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@31
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@31
    11
 * (at your option) any later version.
nkeynes@31
    12
 *
nkeynes@31
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@31
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@31
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@31
    16
 * GNU General Public License for more details.
nkeynes@31
    17
 */
nkeynes@31
    18
nkeynes@11
    19
#include <stdlib.h>
nkeynes@11
    20
#include "dream.h"
nkeynes@7
    21
#include "mem.h"
nkeynes@7
    22
nkeynes@11
    23
char *arm_mem = NULL;
nkeynes@11
    24
nkeynes@7
    25
void arm_mem_init() {
nkeynes@11
    26
    arm_mem = mem_get_region_by_name( MEM_REGION_AUDIO );
nkeynes@11
    27
    
nkeynes@7
    28
}
nkeynes@7
    29
nkeynes@14
    30
int arm_has_page( uint32_t addr ) {
nkeynes@14
    31
    return ( addr < 0x00200000 ||
nkeynes@14
    32
	     (addr >= 0x00800000 && addr <= 0x00805000 ) );
nkeynes@14
    33
}
nkeynes@14
    34
nkeynes@11
    35
int32_t arm_read_long( uint32_t addr ) {
nkeynes@11
    36
    if( addr < 0x00200000 ) {
nkeynes@11
    37
	return *(int32_t *)(arm_mem + addr);
nkeynes@11
    38
	/* Main sound ram */
nkeynes@11
    39
    } else if( addr >= 0x00800000 && addr <= 0x00803000 ) {
nkeynes@11
    40
	/* Sound registers / scratch ram */
nkeynes@11
    41
    } else {
nkeynes@11
    42
	/* Undefined memory */
nkeynes@11
    43
	ERROR( "Attempted long read to undefined page: %08X",
nkeynes@11
    44
	       addr );
nkeynes@11
    45
	return 0;
nkeynes@11
    46
    }
nkeynes@7
    47
}
nkeynes@7
    48
nkeynes@11
    49
int16_t arm_read_word( uint32_t addr ) {
nkeynes@11
    50
    if( addr < 0x00200000 ) {
nkeynes@11
    51
	return *(int16_t *)(arm_mem + addr);
nkeynes@11
    52
	/* Main sound ram */
nkeynes@11
    53
    } else {
nkeynes@11
    54
	/* Undefined memory */
nkeynes@11
    55
	ERROR( "Attempted word read to undefined page: %08X",
nkeynes@11
    56
	       addr );
nkeynes@11
    57
	return 0;
nkeynes@11
    58
    }
nkeynes@11
    59
nkeynes@7
    60
}
nkeynes@7
    61
nkeynes@11
    62
int8_t arm_read_byte( uint32_t addr ) {
nkeynes@11
    63
    if( addr < 0x00200000 ) {
nkeynes@11
    64
	return *(int8_t *)(arm_mem + addr);
nkeynes@11
    65
	/* Main sound ram */
nkeynes@11
    66
    } else {
nkeynes@11
    67
	/* Undefined memory */
nkeynes@11
    68
	ERROR( "Attempted byte read to undefined page: %08X",
nkeynes@11
    69
	       addr );
nkeynes@11
    70
	return 0;
nkeynes@11
    71
    }
nkeynes@7
    72
}
nkeynes@7
    73
nkeynes@11
    74
uint32_t arm_read_long_user( uint32_t addr ) {
nkeynes@11
    75
nkeynes@11
    76
}
nkeynes@11
    77
nkeynes@11
    78
uint32_t arm_read_byte_user( uint32_t addr ) {
nkeynes@11
    79
nkeynes@11
    80
}
.