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"
23 #include "xlat/xltcache.h"
27 static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
29 return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
31 static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
33 return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
35 static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
37 return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
39 static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
41 *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
42 xlat_invalidate_long(addr);
44 static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
46 *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
47 xlat_invalidate_word(addr);
49 static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
51 *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
52 xlat_invalidate_word(addr);
54 static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
56 memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
58 static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
60 memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
63 struct mem_region_fn mem_region_sdram = { ext_sdram_read_long, ext_sdram_write_long,
64 ext_sdram_read_word, ext_sdram_write_word,
65 ext_sdram_read_byte, ext_sdram_write_byte,
66 ext_sdram_read_burst, ext_sdram_write_burst };
.