filename | src/sdram.c |
changeset | 991:60c7fab9c880 |
prev | 962:54a657069b81 |
next | 1067:d3c00ffccfcd |
author | nkeynes |
date | Sun Apr 12 07:24:45 2009 +0000 (14 years ago) |
branch | xlat-refactor |
permissions | -rw-r--r-- |
last change | Restructure operand types - rename to forms to avoid conflict for actual data types temporary operands are now a first class form remove explicit types for immediates - now implied by opcode Initial work on promote-source-reg pass |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * Dreamcast main SDRAM - access methods and timing controls. This is fairly
5 * directly coupled to the SH4
6 *
7 * Copyright (c) 2005 Nathan Keynes.
8 *
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.
13 *
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.
18 */
20 #include "lxdream.h"
21 #include "mem.h"
22 #include "dreamcast.h"
23 #include "xlat/xltcache.h"
24 #include <string.h>
27 static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
28 {
29 return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
30 }
31 static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
32 {
33 return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
34 }
35 static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
36 {
37 return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
38 }
39 static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
40 {
41 *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
42 xlat_invalidate_long(addr);
43 }
44 static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
45 {
46 *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
47 xlat_invalidate_word(addr);
48 }
49 static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
50 {
51 *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
52 xlat_invalidate_word(addr);
53 }
54 static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
55 {
56 memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
57 }
58 static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
59 {
60 memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
61 }
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 };
.