4 * Dreamcast main SDRAM - access methods and timing controls. This is fairly
5 * directly coupled to the SH4
7 * Copyright (c) 2005 Nathan Keynes.
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.
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.
22 #include "dreamcast.h"
26 static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
28 return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
30 static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
32 return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
34 static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
36 return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
38 static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
40 *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
41 xlat_invalidate_long(addr);
43 static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
45 *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
46 xlat_invalidate_word(addr);
48 static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
50 *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
51 xlat_invalidate_word(addr);
53 static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
55 memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
57 static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
59 memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
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 };
.