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.7 + * Dreamcast main SDRAM - access methods and timing controls. This is fairly
1.8 + * directly coupled to the SH4
1.10 + * Copyright (c) 2005 Nathan Keynes.
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.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.23 +#include "lxdream.h"
1.25 +#include "dreamcast.h"
1.26 +#include <string.h>
1.29 +static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
1.31 + return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
1.33 +static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
1.35 + return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
1.37 +static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
1.39 + return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
1.41 +static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
1.43 + *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
1.44 + xlat_invalidate_long(addr);
1.46 +static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
1.48 + *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
1.49 + xlat_invalidate_word(addr);
1.51 +static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
1.53 + *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
1.54 + xlat_invalidate_word(addr);
1.56 +static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
1.58 + memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
1.60 +static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
1.62 + memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
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 };