filename | src/sdram.c |
changeset | 939:6f2302afeb89 |
next | 940:81e0d3051d5f |
author | nkeynes |
date | Sat Jan 03 03:30:26 2009 +0000 (14 years ago) |
branch | lxdream-mem |
permissions | -rw-r--r-- |
last change | MMU work-in-progress * Move SDRAM out into separate sdram.c * Move all page-table management into mmu.c * Convert UTLB management to use the new page-tables * Rip out all calls to mmu_vma_to_phys_* and replace with direct access |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/sdram.c Sat Jan 03 03:30:26 2009 +00001.3 @@ -0,0 +1,65 @@1.4 +/**1.5 + * $Id: sdram.c 954 2008-12-26 14:25:23Z nkeynes $1.6 + *1.7 + * Dreamcast main SDRAM - access methods and timing controls. This is fairly1.8 + * directly coupled to the SH41.9 + *1.10 + * Copyright (c) 2005 Nathan Keynes.1.11 + *1.12 + * This program is free software; you can redistribute it and/or modify1.13 + * it under the terms of the GNU General Public License as published by1.14 + * the Free Software Foundation; either version 2 of the License, or1.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 of1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.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 };
.