better wifi stub
This commit is contained in:
parent
96a3848d84
commit
db20d7408e
|
@ -24,14 +24,12 @@ As for the rest, the interface should be pretty straightforward. If you have a q
|
|||
TODO LIST
|
||||
|
||||
* better 3D engine
|
||||
* sound
|
||||
* wifi
|
||||
* other non-core shit (debugger, graphics viewers, cheat crapo, etc)
|
||||
|
||||
|
||||
TODO LIST FOR LATER
|
||||
|
||||
* sound
|
||||
* more 3D engine features
|
||||
* hardware renderer for 3D
|
||||
* wifi
|
||||
|
|
|
@ -1200,7 +1200,7 @@ void ARM7Write8(u32 addr, u8 val)
|
|||
return;
|
||||
}
|
||||
|
||||
printf("unknown arm7 write8 %08X %02X | %08X | %08X %08X %08X %08X\n", addr, val, ARM7->R[15], IME[1], IE[1], ARM7->R[0], ARM7->R[1]);
|
||||
printf("unknown arm7 write8 %08X %02X @ %08X\n", addr, val, ARM7->R[15]);
|
||||
}
|
||||
|
||||
void ARM7Write16(u32 addr, u16 val)
|
||||
|
@ -1235,7 +1235,7 @@ void ARM7Write16(u32 addr, u16 val)
|
|||
return;
|
||||
}
|
||||
|
||||
printf("unknown arm7 write16 %08X %04X | %08X\n", addr, val, ARM7->R[15]);
|
||||
printf("unknown arm7 write16 %08X %04X @ %08X\n", addr, val, ARM7->R[15]);
|
||||
}
|
||||
|
||||
void ARM7Write32(u32 addr, u32 val)
|
||||
|
@ -1266,7 +1266,7 @@ void ARM7Write32(u32 addr, u32 val)
|
|||
return;
|
||||
}
|
||||
|
||||
printf("unknown arm7 write32 %08X %08X | %08X %08X\n", addr, val, ARM7->R[15], ARM7->CurInstr);
|
||||
printf("unknown arm7 write32 %08X %08X @ %08X\n", addr, val, ARM7->R[15]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2141,7 +2141,7 @@ void ARM7IOWrite16(u32 addr, u16 val)
|
|||
case 0x0400010C: Timers[7].Reload = val; return;
|
||||
case 0x0400010E: TimerStart(7, val); return;
|
||||
|
||||
case 0x04000134: return;printf("set debug port %04X %08X\n", val, ARM7Read32(ARM7->R[13]+4)); return;
|
||||
case 0x04000134: /* TODO? */ return;
|
||||
|
||||
case 0x04000138: RTC::Write(val, false); return;
|
||||
|
||||
|
|
|
@ -93,6 +93,8 @@ extern u8 ROMSeed1[2*8];
|
|||
extern u8 ARM9BIOS[0x1000];
|
||||
extern u8 ARM7BIOS[0x4000];
|
||||
|
||||
extern u8 MainRAM[0x400000];
|
||||
|
||||
bool Init();
|
||||
void DeInit();
|
||||
void Reset();
|
||||
|
|
163
src/Wifi.cpp
163
src/Wifi.cpp
|
@ -52,8 +52,6 @@ void Reset()
|
|||
|
||||
Random = 1;
|
||||
|
||||
BBCnt = 0;
|
||||
BBWrite = 0;
|
||||
memset(BBRegs, 0, 0x100);
|
||||
memset(BBRegsRO, 0, 0x100);
|
||||
|
||||
|
@ -86,9 +84,6 @@ void Reset()
|
|||
#undef BBREG_FIXED
|
||||
|
||||
RFVersion = SPI_Firmware::GetRFVersion();
|
||||
RFCnt = 0;
|
||||
RFData1 = 0;
|
||||
RFData2 = 0;
|
||||
memset(RFRegs, 0, 4*0x40);
|
||||
|
||||
memset(&IOPORT(0x018), 0xFF, 6);
|
||||
|
@ -98,33 +93,33 @@ void Reset()
|
|||
|
||||
void RFTransfer_Type2()
|
||||
{
|
||||
u32 id = (RFData2 >> 2) & 0x1F;
|
||||
u32 id = (IOPORT(W_RFData2) >> 2) & 0x1F;
|
||||
|
||||
if (RFData2 & 0x0080)
|
||||
if (IOPORT(W_RFData2) & 0x0080)
|
||||
{
|
||||
u32 data = RFRegs[id];
|
||||
RFData1 = data & 0xFFFF;
|
||||
RFData2 = (RFData2 & 0xFFFC) | ((data >> 16) & 0x3);
|
||||
IOPORT(W_RFData1) = data & 0xFFFF;
|
||||
IOPORT(W_RFData2) = (IOPORT(W_RFData2) & 0xFFFC) | ((data >> 16) & 0x3);
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 data = RFData1 | ((RFData2 & 0x0003) << 16);
|
||||
u32 data = IOPORT(W_RFData1) | ((IOPORT(W_RFData2) & 0x0003) << 16);
|
||||
RFRegs[id] = data;
|
||||
}
|
||||
}
|
||||
|
||||
void RFTransfer_Type3()
|
||||
{
|
||||
u32 id = (RFData1 >> 8) & 0x3F;
|
||||
u32 id = (IOPORT(W_RFData1) >> 8) & 0x3F;
|
||||
|
||||
u32 cmd = RFData2 & 0xF;
|
||||
u32 cmd = IOPORT(W_RFData2) & 0xF;
|
||||
if (cmd == 6)
|
||||
{
|
||||
RFData1 = (RFData1 & 0xFF00) | (RFRegs[id] & 0xFF);
|
||||
IOPORT(W_RFData1) = (IOPORT(W_RFData1) & 0xFF00) | (RFRegs[id] & 0xFF);
|
||||
}
|
||||
else if (cmd == 5)
|
||||
{
|
||||
u32 data = RFData1 & 0xFF;
|
||||
u32 data = IOPORT(W_RFData1) & 0xFF;
|
||||
RFRegs[id] = data;
|
||||
}
|
||||
}
|
||||
|
@ -143,35 +138,25 @@ u16 Read(u32 addr)
|
|||
|
||||
switch (addr)
|
||||
{
|
||||
case 0x044: // random generator. not accurate
|
||||
case W_Random: // random generator. not accurate
|
||||
Random = (Random & 0x1) ^ (((Random & 0x3FF) << 1) | (Random >> 10));
|
||||
return Random;
|
||||
|
||||
case 0x0BC:
|
||||
return IOPORT(0x0BC) & 0x0003;
|
||||
case W_Preamble:
|
||||
return IOPORT(W_Preamble) & 0x0003;
|
||||
|
||||
case 0x158:
|
||||
return BBCnt;
|
||||
|
||||
case 0x15C:
|
||||
if ((BBCnt & 0xF000) != 0x6000)
|
||||
case W_BBRead:
|
||||
if ((IOPORT(W_BBCnt) & 0xF000) != 0x6000)
|
||||
{
|
||||
printf("WIFI: bad BB read, CNT=%04X\n", BBCnt);
|
||||
printf("WIFI: bad BB read, CNT=%04X\n", IOPORT(W_BBCnt));
|
||||
return 0;
|
||||
}
|
||||
return BBRegs[BBCnt & 0xFF];
|
||||
return BBRegs[IOPORT(W_BBCnt) & 0xFF];
|
||||
|
||||
case 0x15E:
|
||||
case W_BBBusy:
|
||||
return 0; // TODO eventually (BB busy flag)
|
||||
|
||||
case 0x17C:
|
||||
return RFData2;
|
||||
case 0x17E:
|
||||
return RFData1;
|
||||
case 0x180:
|
||||
case W_RFBusy:
|
||||
return 0; // TODO eventually (RF busy flag)
|
||||
case 0x184:
|
||||
return RFCnt;
|
||||
}
|
||||
|
||||
//printf("WIFI: read %08X\n", addr);
|
||||
|
@ -190,42 +175,114 @@ void Write(u32 addr, u16 val)
|
|||
|
||||
switch (addr)
|
||||
{
|
||||
case 0x006:
|
||||
case W_ModeReset:
|
||||
{
|
||||
u16 oldval = IOPORT(W_ModeReset);
|
||||
|
||||
if (!(oldval & 0x0001) && (val & 0x0001))
|
||||
{
|
||||
IOPORT(0x034) = 0x0002;
|
||||
IOPORT(W_RFPins) = 0x0046;
|
||||
IOPORT(W_RFStatus) = 9;
|
||||
IOPORT(0x27C) = 0x0005;
|
||||
// TODO: 02A2??
|
||||
}
|
||||
else if ((oldval & 0x0001) && !(val & 0x0001))
|
||||
{
|
||||
IOPORT(0x27C) = 0x000A;
|
||||
}
|
||||
|
||||
if (val & 0x2000)
|
||||
{
|
||||
IOPORT(W_RXBufWriteAddr) = 0;
|
||||
IOPORT(W_CmdTotalTime) = 0;
|
||||
IOPORT(W_CmdReplyTime) = 0;
|
||||
IOPORT(0x1A4) = 0;
|
||||
IOPORT(0x278) = 0x000F;
|
||||
// TODO: other ports??
|
||||
}
|
||||
if (val & 0x4000)
|
||||
{
|
||||
IOPORT(W_ModeWEP) = 0;
|
||||
IOPORT(W_TXStatCnt) = 0;
|
||||
IOPORT(0x00A) = 0;
|
||||
IOPORT(W_MACAddr0) = 0;
|
||||
IOPORT(W_MACAddr1) = 0;
|
||||
IOPORT(W_MACAddr2) = 0;
|
||||
IOPORT(W_BSSID0) = 0;
|
||||
IOPORT(W_BSSID1) = 0;
|
||||
IOPORT(W_BSSID2) = 0;
|
||||
IOPORT(W_AIDLow) = 0;
|
||||
IOPORT(W_AIDFull) = 0;
|
||||
IOPORT(W_TXRetryLimit) = 0x0707;
|
||||
IOPORT(0x02E) = 0;
|
||||
IOPORT(W_RXBufBegin) = 0x4000;
|
||||
IOPORT(W_RXBufEnd) = 0x4800;
|
||||
IOPORT(W_TXBeaconTIM) = 0;
|
||||
IOPORT(W_Preamble) = 0x0001;
|
||||
IOPORT(W_RXFilter) = 0x0401;
|
||||
IOPORT(0x0D4) = 0x0001;
|
||||
IOPORT(W_RXFilter2) = 0x0008;
|
||||
IOPORT(0x0EC) = 0x3F03;
|
||||
IOPORT(W_TXHeaderCnt) = 0;
|
||||
IOPORT(0x198) = 0;
|
||||
IOPORT(0x1A2) = 0x0001;
|
||||
IOPORT(0x224) = 0x0003;
|
||||
IOPORT(0x230) = 0x0047;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case W_ModeWEP:
|
||||
val &= 0x007F;
|
||||
break;
|
||||
|
||||
case 0x010:
|
||||
case W_IF:
|
||||
// IF: TODO
|
||||
return;
|
||||
case 0x012:
|
||||
case W_IE:
|
||||
printf("WIFI IE=%04X\n", val);
|
||||
break;
|
||||
|
||||
case 0x158:
|
||||
BBCnt = val;
|
||||
if ((BBCnt & 0xF000) == 0x5000)
|
||||
case W_PowerState:
|
||||
if (val & 0x0002)
|
||||
{
|
||||
u32 regid = BBCnt & 0xFF;
|
||||
// TODO: IRQ11
|
||||
IOPORT(W_PowerState) = 0x0000;
|
||||
}
|
||||
return;
|
||||
case W_PowerForce:
|
||||
printf("WIFI: forcing power %04X\n", val);
|
||||
val &= 0x8001;
|
||||
if (val == 0x8001)
|
||||
{
|
||||
IOPORT(0x034) = 0x0002;
|
||||
IOPORT(W_PowerState) = 0x0200;
|
||||
IOPORT(W_TXReqRead) = 0;
|
||||
IOPORT(W_RFPins) = 00046;
|
||||
IOPORT(W_RFStatus) = 9;
|
||||
}
|
||||
break;
|
||||
|
||||
case W_BBCnt:
|
||||
IOPORT(W_BBCnt) = val;
|
||||
if ((IOPORT(W_BBCnt) & 0xF000) == 0x5000)
|
||||
{
|
||||
u32 regid = IOPORT(W_BBCnt) & 0xFF;
|
||||
if (!BBRegsRO[regid])
|
||||
BBRegs[regid] = val & 0xFF;
|
||||
BBRegs[regid] = IOPORT(W_BBWrite) & 0xFF;
|
||||
}
|
||||
return;
|
||||
|
||||
case 0x15A:
|
||||
BBWrite = val;
|
||||
return;
|
||||
|
||||
case 0x17C:
|
||||
RFData2 = val;
|
||||
case W_RFData2:
|
||||
IOPORT(W_RFData2) = val;
|
||||
if (RFVersion == 3) RFTransfer_Type3();
|
||||
else RFTransfer_Type2();
|
||||
return;
|
||||
case 0x17E:
|
||||
RFData1 = val;
|
||||
return;
|
||||
case 0x184:
|
||||
RFCnt = val & 0x413F;
|
||||
return;
|
||||
case W_RFCnt:
|
||||
val &= 0x413F;
|
||||
break;
|
||||
|
||||
// read-only ports
|
||||
case 0x000:
|
||||
|
|
108
src/Wifi.h
108
src/Wifi.h
|
@ -22,7 +22,113 @@
|
|||
namespace Wifi
|
||||
{
|
||||
|
||||
//
|
||||
enum
|
||||
{
|
||||
W_ID = 0x000,
|
||||
|
||||
W_ModeReset = 0x004,
|
||||
W_ModeWEP = 0x006,
|
||||
W_TXStatCnt = 0x008,
|
||||
W_IF = 0x010,
|
||||
W_IE = 0x012,
|
||||
|
||||
W_MACAddr0 = 0x018,
|
||||
W_MACAddr1 = 0x01A,
|
||||
W_MACAddr2 = 0x01C,
|
||||
W_BSSID0 = 0x020,
|
||||
W_BSSID1 = 0x022,
|
||||
W_BSSID2 = 0x024,
|
||||
W_AIDLow = 0x028,
|
||||
W_AIDFull = 0x02A,
|
||||
|
||||
W_TXRetryLimit = 0x02C,
|
||||
W_RXCnt = 0x030,
|
||||
W_WEPCnt = 0x032,
|
||||
|
||||
W_PowerUS = 0x036,
|
||||
W_PowerTX = 0x038,
|
||||
W_PowerState = 0x03C,
|
||||
W_PowerForce = 0x040,
|
||||
|
||||
W_Random = 0x044,
|
||||
|
||||
W_RXBufBegin = 0x050,
|
||||
W_RXBufEnd = 0x052,
|
||||
W_RXBufWriteCursor = 0x054,
|
||||
W_RXBufWriteAddr = 0x056,
|
||||
W_RXBufReadAddr = 0x058,
|
||||
W_RXBufReadCursor = 0x05A,
|
||||
W_RXBufCount = 0x05C,
|
||||
W_RXBufDataRead = 0x060,
|
||||
W_RXBufGapAddr = 0x062,
|
||||
W_RXBufGapSize = 0x064,
|
||||
|
||||
W_TXBufWriteAddr = 0x068,
|
||||
W_TXBufCount = 0x06C,
|
||||
W_TXBufDataWrite = 0x070,
|
||||
W_TXBufGapAddr = 0x074,
|
||||
W_TXBufGapSize = 0x076,
|
||||
|
||||
W_TXSlotBeacon = 0x080,
|
||||
W_TXBeaconTIM = 0x084,
|
||||
W_ListenCount = 0x088,
|
||||
W_BeaconInterval = 0x08C,
|
||||
W_ListenInterval = 0x08E,
|
||||
W_TXSlotCmd = 0x090,
|
||||
W_TXSlotReply1 = 0x094,
|
||||
W_TXSlotReply2 = 0x098,
|
||||
W_TXSlotLoc1 = 0x0A0,
|
||||
W_TXSlotLoc2 = 0x0A4,
|
||||
W_TXSlotLoc3 = 0x0A8,
|
||||
W_TXReqReset = 0x0AC,
|
||||
W_TXReqSet = 0x0AE,
|
||||
W_TXReqRead = 0x0B0,
|
||||
W_TXSlotReset = 0x0B4,
|
||||
W_TXBusy = 0x0B6,
|
||||
W_TXStat = 0x0B8,
|
||||
W_Preamble = 0x0BC,
|
||||
W_CmdTotalTime = 0x0C0,
|
||||
W_CmdReplyTime = 0x0C4,
|
||||
W_RXFilter = 0x0D0,
|
||||
W_RXFilter2 = 0x0E0,
|
||||
|
||||
W_USCountCnt = 0x0E8,
|
||||
W_USCompareCnt = 0x0EA,
|
||||
W_CmdCountCnt = 0x0EE,
|
||||
|
||||
W_ContentFree = 0x10C,
|
||||
W_PreBeacon = 0x110,
|
||||
W_CmdCount = 0x118,
|
||||
W_BeaconCount1 = 0x11C,
|
||||
W_BeaconCount2 = 0x134,
|
||||
|
||||
W_BBCnt = 0x158,
|
||||
W_BBWrite = 0x15A,
|
||||
W_BBRead = 0x15C,
|
||||
W_BBBusy = 0x15E,
|
||||
W_BBMode = 0x160,
|
||||
W_BBPower = 0x168,
|
||||
|
||||
W_RFData2 = 0x17C,
|
||||
W_RFData1 = 0x17E,
|
||||
W_RFBusy = 0x180,
|
||||
W_RFCnt = 0x184,
|
||||
|
||||
W_TXHeaderCnt = 0x194,
|
||||
W_RFPins = 0x19C,
|
||||
|
||||
W_RXStatIncIF = 0x1A8,
|
||||
W_RXStatIncIE = 0x1AA,
|
||||
W_RXStatHalfIF = 0x1AC,
|
||||
W_RXStatHalfIE = 0x1AE,
|
||||
W_TXErrorCount = 0x1C0,
|
||||
W_RXCount = 0x1C4,
|
||||
|
||||
W_TXSeqNo = 0x210,
|
||||
W_RFStatus = 0x214,
|
||||
W_IFSet = 0x21C,
|
||||
W_RXTXAddr = 0x268,
|
||||
};
|
||||
|
||||
|
||||
void Reset();
|
||||
|
|
Loading…
Reference in New Issue