Search
lxdream.org :: lxdream/src/sdram.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sdram.c
changeset 953:f4a156508ad1
next962:54a657069b81
author nkeynes
date Tue Jan 13 11:56:28 2009 +0000 (14 years ago)
permissions -rw-r--r--
last change Merge lxdream-mem branch back to trunk
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/sdram.c Tue Jan 13 11:56:28 2009 +0000
1.3 @@ -0,0 +1,65 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Dreamcast main SDRAM - access methods and timing controls. This is fairly
1.8 + * directly coupled to the SH4
1.9 + *
1.10 + * Copyright (c) 2005 Nathan Keynes.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.21 + */
1.22 +
1.23 +#include "lxdream.h"
1.24 +#include "mem.h"
1.25 +#include "dreamcast.h"
1.26 +#include <string.h>
1.27 +
1.28 +
1.29 +static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
1.30 +{
1.31 + return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
1.32 +}
1.33 +static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
1.34 +{
1.35 + return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
1.36 +}
1.37 +static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
1.38 +{
1.39 + return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
1.40 +}
1.41 +static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
1.42 +{
1.43 + *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
1.44 + xlat_invalidate_long(addr);
1.45 +}
1.46 +static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
1.47 +{
1.48 + *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
1.49 + xlat_invalidate_word(addr);
1.50 +}
1.51 +static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
1.52 +{
1.53 + *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
1.54 + xlat_invalidate_word(addr);
1.55 +}
1.56 +static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
1.57 +{
1.58 + memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
1.59 +}
1.60 +static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
1.61 +{
1.62 + memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
1.63 +}
1.64 +
1.65 +struct mem_region_fn mem_region_sdram = { ext_sdram_read_long, ext_sdram_write_long,
1.66 + ext_sdram_read_word, ext_sdram_write_word,
1.67 + ext_sdram_read_byte, ext_sdram_write_byte,
1.68 + ext_sdram_read_burst, ext_sdram_write_burst };
.