-Added support for Backup Memory. Memory type detection still needs to be added. I'm not sure what's the best way of handling that.

This commit is contained in:
cyberwarriorx 2006-10-11 21:52:43 +00:00
parent 79c3011b19
commit 0b402eee65
1 changed files with 32 additions and 10 deletions

View File

@ -263,9 +263,12 @@ void MMUInit(void) {
for(i = 0;i < 16;i++) for(i = 0;i < 16;i++)
FIFOInit(MMU.fifos + i); FIFOInit(MMU.fifos + i);
fw_init(&MMU.spi7.fw); /* init fw device */ mc_init(&MMU.spi7.fw, MC_TYPE_FLASH); /* init fw device */
fw_alloc(&MMU.spi7.fw, NDS_FW_SIZE_V1); mc_alloc(&MMU.spi7.fw, NDS_FW_SIZE_V1);
// Init Backup Memory device, this should really be done when the rom is loaded
mc_init(&MMU.spi7.bupmem, MC_TYPE_EEPROM2);
mc_alloc(&MMU.spi7.bupmem, 65536); // For now we're use 512Kbit support. Eventually this should be detected when rom is loaded
} }
void MMUDeInit(void) { void MMUDeInit(void) {
@ -276,6 +279,8 @@ void MMUDeInit(void) {
u16 SPI_CNT = 0; u16 SPI_CNT = 0;
u16 SPI_CMD = 0; u16 SPI_CMD = 0;
u16 AUX_SPI_CNT = 0;
u16 AUX_SPI_CMD = 0;
u32 rom_mask = 0; u32 rom_mask = 0;
@ -775,6 +780,24 @@ void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val)
} }
((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x304>>1] = val; ((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x304>>1] = val;
return; return;
case CARD_CR1:
MEM_16(MMU.MMU_MEM[proc], CARD_CR1) = val;
AUX_SPI_CNT = val;
if (val == 0)
mc_reset_com(&MMU.spi7.bupmem); /* reset backup memory device communication */
return;
case CARD_EEPDATA:
if(val!=0)
{
AUX_SPI_CMD = val & 0xFF;
}
MEM_16(MMU.MMU_MEM[proc], CARD_EEPDATA) = bm_transfer(&MMU.spi7.bupmem, val); /* transfer data to backup memory chip and receive back */
return;
case REG_SPICNT : case REG_SPICNT :
if(proc == ARMCPU_ARM7) if(proc == ARMCPU_ARM7)
{ {
@ -782,8 +805,7 @@ void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val)
//MMU.spi7.fw.com == 0; /* reset fw device communication */ //MMU.spi7.fw.com == 0; /* reset fw device communication */
fw_reset_com(&MMU.spi7.fw); /* reset fw device communication */ mc_reset_com(&MMU.spi7.fw); /* reset fw device communication */
} }
MEM_16(MMU.MMU_MEM[proc], REG_SPICNT) = val; MEM_16(MMU.MMU_MEM[proc], REG_SPICNT) = val;