Search
lxdream.org :: lxdream/src/aica/armmem.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armmem.c
changeset 37:1d84f4c18816
prev31:495e480360d7
next40:852ee31ace0d
author nkeynes
date Mon Dec 26 06:38:51 2005 +0000 (16 years ago)
permissions -rw-r--r--
last change More ARM work-in-progress - idle loop works now :)
view annotate diff log raw
     1 /**
     2  * $Id: armmem.c,v 1.5 2005-12-26 06:38:51 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 uint32_t arm_read_long( uint32_t addr ) {
    36     if( addr < 0x00200000 ) {
    37 	return *(int32_t *)(arm_mem + addr);
    38 	/* Main sound ram */
    39     } else {
    40 	switch( addr & 0xFFFFF000 ) {
    41 	case 0x00800000:
    42 	    return mmio_region_AICA0_read(addr);
    43 	    break;
    44 	case 0x00801000:
    45 	    return mmio_region_AICA1_read(addr);
    46 	    break;
    47 	case 0x00802000:
    48 	    return mmio_region_AICA2_read(addr);
    49 	    break;
    50 	case 0x00803000:
    51 	    break;
    52 	case 0x00804000:
    53 	    break;
    54 	}
    55     }
    56     ERROR( "Attempted long read to undefined page: %08X",
    57 	   addr );
    58     /* Undefined memory */
    59     return 0;
    60 }
    62 uint32_t arm_read_word( uint32_t addr ) {
    63     if( addr < 0x00200000 ) {
    64 	return *(int16_t *)(arm_mem + addr);
    65 	/* Main sound ram */
    66     } else {
    67 	/* Undefined memory */
    68 	ERROR( "Attempted word read to undefined page: %08X",
    69 	       addr );
    70 	return 0;
    71     }
    73 }
    75 uint32_t arm_read_byte( uint32_t addr ) {
    76     if( addr < 0x00200000 ) {
    77 	return (uint32_t)(*(uint8_t *)(arm_mem + addr));
    78 	/* Main sound ram */
    79     } else {
    80 	/* Undefined memory */
    81 	ERROR( "Attempted byte read to undefined page: %08X",
    82 	       addr );
    83 	return 0;
    84     }
    85 }
    87 void arm_write_long( uint32_t addr, uint32_t value )
    88 {
    89     if( addr < 0x00200000 ) {
    90 	*(uint32_t *)(arm_mem + addr) = value;
    91     } else {
    92     }
    93 }
    95 void arm_write_byte( uint32_t addr, uint32_t value )
    96 {
    97     if( addr < 0x00200000 ) {
    98 	*(uint8_t *)(arm_mem+addr) = (uint8_t)value;
    99     } else {
   100     }
   101 }
   103 /* User translations - TODO */
   105 uint32_t arm_read_long_user( uint32_t addr ) {
   106     return arm_read_long( addr );
   107 }
   109 uint32_t arm_read_byte_user( uint32_t addr ) {
   110     return arm_read_byte( addr );
   111 }
   113 void arm_write_long_user( uint32_t addr, uint32_t val ) {
   114     arm_write_long( addr, val );
   115 }
   117 void arm_write_byte_user( uint32_t addr, uint32_t val )
   118 {
   119     arm_write_byte( addr, val );
   120 }
.