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