diff options
author | Arisotura <thetotalworm@gmail.com> | 2020-05-30 13:52:51 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2020-05-30 13:52:51 +0200 |
commit | 8f5dff17251b759651d967fe072cf4f56b9edb35 (patch) | |
tree | 0aabf83bed2cbafdc9371935ed581fc39cea9d02 /src | |
parent | 8a15adb38bf5c141e41b1a5f9984ee363d64786f (diff) |
make soft-reset work somewhat better
Diffstat (limited to 'src')
-rw-r--r-- | src/DSi.cpp | 29 | ||||
-rw-r--r-- | src/DSi_I2C.cpp | 19 |
2 files changed, 40 insertions, 8 deletions
diff --git a/src/DSi.cpp b/src/DSi.cpp index 15f06a2..fb4b37a 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -173,12 +173,41 @@ void SoftReset() NDS::ARM9->Reset(); NDS::ARM7->Reset(); + memcpy(NDS::ARM9->ITCM, ITCMInit, 0x8000); + + for (u32 i = 0; i < 0x3C00; i+=4) + ARM7Write32(0x03FFC400+i, *(u32*)&ARM7Init[i]); + DSi_AES::Reset(); LoadNAND(); NDS::ARM9->JumpTo(BootAddr[0]); NDS::ARM7->JumpTo(BootAddr[1]); + + SCFG_BIOS = 0x0101; // TODO: should be zero when booting from BIOS + SCFG_Clock9 = 0x0187; // CHECKME + SCFG_Clock7 = 0x0187; + SCFG_EXT[0] = 0x8307F100; + SCFG_EXT[1] = 0x93FFFB06; + SCFG_MC = 0x0010;//0x0011; + + // LCD init flag + GPU::DispStat[0] |= (1<<6); + GPU::DispStat[1] |= (1<<6); + + NDS::MapSharedWRAM(3); + + u32 eaddr = 0x03FFE6E4; + ARM7Write32(eaddr+0x00, *(u32*)&eMMC_CID[0]); + ARM7Write32(eaddr+0x04, *(u32*)&eMMC_CID[4]); + ARM7Write32(eaddr+0x08, *(u32*)&eMMC_CID[8]); + ARM7Write32(eaddr+0x0C, *(u32*)&eMMC_CID[12]); + ARM7Write16(eaddr+0x2C, 0x0001); + ARM7Write16(eaddr+0x2E, 0x0001); + ARM7Write16(eaddr+0x3C, 0x0100); + ARM7Write16(eaddr+0x3E, 0x40E0); + ARM7Write16(eaddr+0x42, 0x0001); } bool LoadBIOS() diff --git a/src/DSi_I2C.cpp b/src/DSi_I2C.cpp index 0ab7008..b2ca6e4 100644 --- a/src/DSi_I2C.cpp +++ b/src/DSi_I2C.cpp @@ -84,7 +84,7 @@ u8 Read(bool last) return 0; } - //printf("BPTWL: read %02X -> %02X\n", CurPos, Registers[CurPos]); + printf("BPTWL: read %02X -> %02X\n", CurPos, Registers[CurPos]); return Registers[CurPos++]; } @@ -107,7 +107,10 @@ void Write(u8 val, bool last) { printf("BPTWL: soft-reset\n"); val = 0; // checkme + // TODO: soft-reset might need to be scheduled later! DSi::SoftReset(); + CurPos = -1; + return; } if (CurPos == 0x11 || CurPos == 0x12 || @@ -121,7 +124,7 @@ void Write(u8 val, bool last) Registers[CurPos] = val; } - //printf("BPTWL: write %02X -> %02X\n", CurPos, val); + printf("BPTWL: write %02X -> %02X\n", CurPos, val); CurPos++; // CHECKME } @@ -163,7 +166,7 @@ void Reset() void WriteCnt(u8 val) { - //printf("I2C: write CNT %02X, %08X\n", val, NDS::GetPC(1)); + printf("I2C: write CNT %02X, %08X\n", val, NDS::GetPC(1)); // TODO: check ACK flag // TODO: transfer delay @@ -190,7 +193,7 @@ void WriteCnt(u8 val) break; } - //printf("I2C read, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast); + printf("I2C read, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast); } else { @@ -201,7 +204,7 @@ void WriteCnt(u8 val) if (val & (1<<1)) { Device = Data & 0xFE; - //printf("I2C: %s start, device=%02X\n", (Data&0x01)?"read":"write", Device); + printf("I2C: %s start, device=%02X\n", (Data&0x01)?"read":"write", Device); switch (Device) { @@ -216,7 +219,7 @@ void WriteCnt(u8 val) } else { - //printf("I2C write, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast); + printf("I2C write, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast); switch (Device) { @@ -240,12 +243,12 @@ void WriteCnt(u8 val) } u8 ReadData() -{ +{printf("I2C: read data: %02X\n", Data); return Data; } void WriteData(u8 val) -{ +{printf("I2C: write data: %02X\n", val); Data = val; } |