Search
lxdream.org :: lxdream/src/sh4/sh4mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mem.c
changeset 934:3acd3b3ee6d1
prev933:880c37bb1909
next939:6f2302afeb89
author nkeynes
date Fri Dec 26 14:25:23 2008 +0000 (12 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Change RAM regions to use static arrays rather than mmap regions, for a 2-3% performance gain.
General mem cleanups, including some save state fixes that break states again.
file annotate diff log raw
1.1 --- a/src/sh4/sh4mem.c Wed Dec 24 06:06:23 2008 +0000
1.2 +++ b/src/sh4/sh4mem.c Fri Dec 26 14:25:23 2008 +0000
1.3 @@ -51,38 +51,38 @@
1.4 /********************* The main ram address space **********************/
1.5 static int32_t FASTCALL ext_sdram_read_long( sh4addr_t addr )
1.6 {
1.7 - return *((int32_t *)(sh4_main_ram + (addr&0x00FFFFFF)));
1.8 + return *((int32_t *)(dc_main_ram + (addr&0x00FFFFFF)));
1.9 }
1.10 static int32_t FASTCALL ext_sdram_read_word( sh4addr_t addr )
1.11 {
1.12 - return SIGNEXT16(*((int16_t *)(sh4_main_ram + (addr&0x00FFFFFF))));
1.13 + return SIGNEXT16(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
1.14 }
1.15 static int32_t FASTCALL ext_sdram_read_byte( sh4addr_t addr )
1.16 {
1.17 - return SIGNEXT8(*((int16_t *)(sh4_main_ram + (addr&0x00FFFFFF))));
1.18 + return SIGNEXT8(*((int16_t *)(dc_main_ram + (addr&0x00FFFFFF))));
1.19 }
1.20 static void FASTCALL ext_sdram_write_long( sh4addr_t addr, uint32_t val )
1.21 {
1.22 - *(uint32_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.23 + *(uint32_t *)(dc_main_ram + (addr&0x00FFFFFF)) = val;
1.24 xlat_invalidate_long(addr);
1.25 }
1.26 static void FASTCALL ext_sdram_write_word( sh4addr_t addr, uint32_t val )
1.27 {
1.28 - *(uint16_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
1.29 + *(uint16_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint16_t)val;
1.30 xlat_invalidate_word(addr);
1.31 }
1.32 static void FASTCALL ext_sdram_write_byte( sh4addr_t addr, uint32_t val )
1.33 {
1.34 - *(uint8_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
1.35 + *(uint8_t *)(dc_main_ram + (addr&0x00FFFFFF)) = (uint8_t)val;
1.36 xlat_invalidate_word(addr);
1.37 }
1.38 static void FASTCALL ext_sdram_read_burst( unsigned char *dest, sh4addr_t addr )
1.39 {
1.40 - memcpy( dest, sh4_main_ram+(addr&0x00FFFFFF), 32 );
1.41 + memcpy( dest, dc_main_ram+(addr&0x00FFFFFF), 32 );
1.42 }
1.43 static void FASTCALL ext_sdram_write_burst( sh4addr_t addr, unsigned char *src )
1.44 {
1.45 - memcpy( sh4_main_ram+(addr&0x00FFFFFF), src, 32 );
1.46 + memcpy( dc_main_ram+(addr&0x00FFFFFF), src, 32 );
1.47 }
1.48
1.49 struct mem_region_fn mem_region_sdram = { ext_sdram_read_long, ext_sdram_write_long,
1.50 @@ -91,75 +91,6 @@
1.51 ext_sdram_read_burst, ext_sdram_write_burst };
1.52
1.53
1.54 -/********************* The Boot ROM address space **********************/
1.55 -extern sh4ptr_t dc_boot_rom;
1.56 -extern sh4ptr_t dc_flash_ram;
1.57 -extern sh4ptr_t dc_audio_ram;
1.58 -static int32_t FASTCALL ext_bootrom_read_long( sh4addr_t addr )
1.59 -{
1.60 - return *((int32_t *)(dc_boot_rom + (addr&0x001FFFFF)));
1.61 -}
1.62 -static int32_t FASTCALL ext_bootrom_read_word( sh4addr_t addr )
1.63 -{
1.64 - return SIGNEXT16(*((int16_t *)(dc_boot_rom + (addr&0x001FFFFF))));
1.65 -}
1.66 -static int32_t FASTCALL ext_bootrom_read_byte( sh4addr_t addr )
1.67 -{
1.68 - return SIGNEXT8(*((int16_t *)(dc_boot_rom + (addr&0x001FFFFF))));
1.69 -}
1.70 -static void FASTCALL ext_bootrom_read_burst( unsigned char *dest, sh4addr_t addr )
1.71 -{
1.72 - memcpy( dest, sh4_main_ram+(addr&0x001FFFFF), 32 );
1.73 -}
1.74 -
1.75 -struct mem_region_fn mem_region_bootrom = {
1.76 - ext_bootrom_read_long, unmapped_write_long,
1.77 - ext_bootrom_read_word, unmapped_write_long,
1.78 - ext_bootrom_read_byte, unmapped_write_long,
1.79 - ext_bootrom_read_burst, unmapped_write_burst };
1.80 -
1.81 -/********************* The Flash RAM address space **********************/
1.82 -static int32_t FASTCALL ext_flashram_read_long( sh4addr_t addr )
1.83 -{
1.84 - return *((int32_t *)(dc_flash_ram + (addr&0x0001FFFF)));
1.85 -}
1.86 -static int32_t FASTCALL ext_flashram_read_word( sh4addr_t addr )
1.87 -{
1.88 - return SIGNEXT16(*((int16_t *)(dc_flash_ram + (addr&0x0001FFFF))));
1.89 -}
1.90 -static int32_t FASTCALL ext_flashram_read_byte( sh4addr_t addr )
1.91 -{
1.92 - return SIGNEXT8(*((int16_t *)(dc_flash_ram + (addr&0x0001FFFF))));
1.93 -}
1.94 -static void FASTCALL ext_flashram_write_long( sh4addr_t addr, uint32_t val )
1.95 -{
1.96 - *(uint32_t *)(dc_flash_ram + (addr&0x0001FFFF)) = val;
1.97 - asic_g2_write_word();
1.98 -}
1.99 -static void FASTCALL ext_flashram_write_word( sh4addr_t addr, uint32_t val )
1.100 -{
1.101 - *(uint16_t *)(dc_flash_ram + (addr&0x0001FFFF)) = (uint16_t)val;
1.102 - asic_g2_write_word();
1.103 -}
1.104 -static void FASTCALL ext_flashram_write_byte( sh4addr_t addr, uint32_t val )
1.105 -{
1.106 - *(uint8_t *)(dc_flash_ram + (addr&0x0001FFFF)) = (uint8_t)val;
1.107 - asic_g2_write_word();
1.108 -}
1.109 -static void FASTCALL ext_flashram_read_burst( unsigned char *dest, sh4addr_t addr )
1.110 -{
1.111 - memcpy( dest, dc_flash_ram+(addr&0x0001FFFF), 32 );
1.112 -}
1.113 -static void FASTCALL ext_flashram_write_burst( sh4addr_t addr, unsigned char *src )
1.114 -{
1.115 - memcpy( dc_flash_ram+(addr&0x0001FFFF), src, 32 );
1.116 -}
1.117 -
1.118 -struct mem_region_fn mem_region_flashram = { ext_flashram_read_long, ext_flashram_write_long,
1.119 - ext_flashram_read_word, ext_flashram_write_word,
1.120 - ext_flashram_read_byte, ext_flashram_write_byte,
1.121 - ext_flashram_read_burst, ext_flashram_write_burst };
1.122 -
1.123 /***************************** P4 Regions ************************************/
1.124
1.125 /* Store-queue (long-write only?) */
.