Search
lxdream.org :: lxdream/src/sdram.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/sdram.c
changeset 940:81e0d3051d5f
prev939:6f2302afeb89
next1067:d3c00ffccfcd
author nkeynes
date Mon Jan 05 04:17:20 2009 +0000 (15 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Actually use sh4_user_address_space for user code
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Dreamcast main SDRAM - access methods and timing controls. This is fairly
     5  * directly coupled to the SH4
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #include "lxdream.h"
    21 #include "mem.h"
    22 #include "dreamcast.h"
    23 #include <string.h>
    26 static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
    27 {
    28     return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
    29 }
    30 static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
    31 {
    32     return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
    33 }
    34 static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
    35 {
    36     return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
    37 }
    38 static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
    39 {
    40     *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
    41     xlat_invalidate_long(addr);
    42 }
    43 static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
    44 {
    45     *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
    46     xlat_invalidate_word(addr);
    47 }
    48 static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
    49 {
    50     *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
    51     xlat_invalidate_word(addr);
    52 }
    53 static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
    54 {
    55     memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
    56 }
    57 static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
    58 {
    59     memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
    60 }
    62 struct mem_region_fn mem_region_sdram = { ext_sdram_read_long, ext_sdram_write_long, 
    63         ext_sdram_read_word, ext_sdram_write_word, 
    64         ext_sdram_read_byte, ext_sdram_write_byte, 
    65         ext_sdram_read_burst, ext_sdram_write_burst }; 
.