Misc fixes for dsiwifi BMI stage (#1216)

This commit is contained in:
Max Thomas 2021-09-06 04:52:33 -06:00 committed by GitHub
parent 8d8a46ad67
commit a54b076b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 1 deletions

View File

@ -572,6 +572,18 @@ void DSi_NWifi::SendCMD(u8 cmd, u32 param)
{ {
switch (cmd) switch (cmd)
{ {
case 3: // SEND_RELATIVE_ADDR
Host->SendResponse(0, true);
return;
case 5: // IO_SEND_OP_COND, dummy response
Host->SendResponse(0x80000000, true);
return;
case 7: // SELECT_CARD
Host->SendResponse(0, true);
return;
case 12: case 12:
// stop command // stop command
// CHECKME: does the SDIO controller actually send those?? // CHECKME: does the SDIO controller actually send those??
@ -727,12 +739,16 @@ void DSi_NWifi::HandleCommand()
void DSi_NWifi::BMI_Command() void DSi_NWifi::BMI_Command()
{ {
u32 cmd = MB_Read32(0); // Need a full command written
if (Mailbox[0].Level() < 0x4) return;
u32 cmd = MB_Peek32(0);
switch (cmd) switch (cmd)
{ {
case 0x01: // BMI_DONE case 0x01: // BMI_DONE
{ {
MB_Read32(0); // cmd pop
printf("BMI_DONE\n"); printf("BMI_DONE\n");
EEPROMReady = 1; // GROSS FUCKING HACK EEPROMReady = 1; // GROSS FUCKING HACK
u8 ready_msg[6] = {0x0A, 0x00, 0x08, 0x06, 0x16, 0x00}; u8 ready_msg[6] = {0x0A, 0x00, 0x08, 0x06, 0x16, 0x00};
@ -743,6 +759,12 @@ void DSi_NWifi::BMI_Command()
case 0x03: // BMI_WRITE_MEMORY case 0x03: // BMI_WRITE_MEMORY
{ {
if (Mailbox[0].Level() < 0xC)
{
printf("BMI_WRITE_MEMORY wait for data...\n");
return;
}
MB_Read32(0); // cmd pop
u32 addr = MB_Read32(0); u32 addr = MB_Read32(0);
u32 len = MB_Read32(0); u32 len = MB_Read32(0);
printf("BMI mem write %08X %08X\n", addr, len); printf("BMI mem write %08X %08X\n", addr, len);
@ -758,6 +780,12 @@ void DSi_NWifi::BMI_Command()
case 0x04: // BMI_EXECUTE case 0x04: // BMI_EXECUTE
{ {
if (Mailbox[0].Level() < 0xC)
{
printf("BMI_EXECUTE wait for data...\n");
return;
}
u32 entry = MB_Read32(0); u32 entry = MB_Read32(0);
u32 arg = MB_Read32(0); u32 arg = MB_Read32(0);
@ -767,6 +795,12 @@ void DSi_NWifi::BMI_Command()
case 0x06: // BMI_READ_SOC_REGISTER case 0x06: // BMI_READ_SOC_REGISTER
{ {
if (Mailbox[0].Level() < 0x8)
{
printf("BMI_READ_SOC_REGISTER wait for data...\n");
return;
}
MB_Read32(0); // cmd pop
u32 addr = MB_Read32(0); u32 addr = MB_Read32(0);
u32 val = WindowRead(addr); u32 val = WindowRead(addr);
MB_Write32(4, val); MB_Write32(4, val);
@ -775,6 +809,12 @@ void DSi_NWifi::BMI_Command()
case 0x07: // BMI_WRITE_SOC_REGISTER case 0x07: // BMI_WRITE_SOC_REGISTER
{ {
if (Mailbox[0].Level() < 0xC)
{
printf("BMI_WRITE_SOC_REGISTER wait for data...\n");
return;
}
MB_Read32(0); // cmd pop
u32 addr = MB_Read32(0); u32 addr = MB_Read32(0);
u32 val = MB_Read32(0); u32 val = MB_Read32(0);
WindowWrite(addr, val); WindowWrite(addr, val);
@ -782,6 +822,7 @@ void DSi_NWifi::BMI_Command()
return; return;
case 0x08: // BMI_GET_TARGET_ID case 0x08: // BMI_GET_TARGET_ID
MB_Read32(0); // cmd pop
MB_Write32(4, 0xFFFFFFFF); MB_Write32(4, 0xFFFFFFFF);
MB_Write32(4, 0x0000000C); MB_Write32(4, 0x0000000C);
MB_Write32(4, ROMID); MB_Write32(4, ROMID);
@ -790,6 +831,12 @@ void DSi_NWifi::BMI_Command()
case 0x0D: // BMI_LZ_STREAM_START case 0x0D: // BMI_LZ_STREAM_START
{ {
if (Mailbox[0].Level() < 0x8)
{
printf("BMI_LZ_STREAM_START wait for data...\n");
return;
}
MB_Read32(0); // cmd pop
u32 addr = MB_Read32(0); u32 addr = MB_Read32(0);
printf("BMI_LZ_STREAM_START %08X\n", addr); printf("BMI_LZ_STREAM_START %08X\n", addr);
} }
@ -797,6 +844,13 @@ void DSi_NWifi::BMI_Command()
case 0x0E: // BMI_LZ_DATA case 0x0E: // BMI_LZ_DATA
{ {
if (Mailbox[0].Level() < 0x8)
{
printf("BMI_LZ_DATA wait for data...\n");
return;
}
MB_Read32(0); // cmd pop
u32 len = MB_Read32(0); u32 len = MB_Read32(0);
printf("BMI LZ write %08X\n", len); printf("BMI LZ write %08X\n", len);
//FILE* f = fopen("debug/wififirm.bin", "ab"); //FILE* f = fopen("debug/wififirm.bin", "ab");

View File

@ -95,6 +95,20 @@ private:
Mailbox[n].Write(val & 0xFF); Mailbox[n].Write(val & 0xFF);
} }
u32 MB_Peek32(int n)
{
return MB_Peek32(n, 0);
}
u32 MB_Peek32(int n, int offs)
{
u32 ret = Mailbox[n].Peek(offs+0);
ret |= (Mailbox[n].Peek(offs+1) << 8);
ret |= (Mailbox[n].Peek(offs+2) << 16);
ret |= (Mailbox[n].Peek(offs+3) << 24);
return ret;
}
u32 MB_Read32(int n) u32 MB_Read32(int n)
{ {
u32 ret = Mailbox[n].Read(); u32 ret = Mailbox[n].Read();

View File

@ -447,6 +447,7 @@ u16 DSi_SDHost::Read(u32 addr)
case 0x028: return SDOption; case 0x028: return SDOption;
case 0x02C: return 0; // TODO case 0x02C: return 0; // TODO
case 0x02E: return 0; // TODO
case 0x034: return CardIRQCtl; case 0x034: return CardIRQCtl;
case 0x036: return CardIRQStatus; case 0x036: return CardIRQStatus;