maybe fixed some sort of wifi shutdown crash

This commit is contained in:
nitsuja 2009-11-08 20:44:49 +00:00
parent 00ef096082
commit 0771dd39cb
2 changed files with 22 additions and 15 deletions

View File

@ -681,7 +681,7 @@ bool WIFI_Init()
WIFI_resetRF(&wifiMac.RF) ; WIFI_resetRF(&wifiMac.RF) ;
wifi_netEnabled = false; wifi_netEnabled = false;
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI_COMM
if(driver->WIFI_Host_InitSystem()) if(driver->WIFI_Host_InitSystem())
{ {
wifi_netEnabled = true; wifi_netEnabled = true;
@ -693,16 +693,18 @@ bool WIFI_Init()
wifiMac.rfStatus = 0x0000; wifiMac.rfStatus = 0x0000;
wifiMac.rfPins = 0x0004; wifiMac.rfPins = 0x0004;
if((u32)CommonSettings.wifi.mode >= ARRAY_SIZE(wifiComs))
CommonSettings.wifi.mode = 0;
wifiCom = wifiComs[CommonSettings.wifi.mode]; wifiCom = wifiComs[CommonSettings.wifi.mode];
#ifdef EXPERIMENTAL_WIFI if(wifiCom)
wifiCom->Init(); wifiCom->Init();
#endif
return true; return true;
} }
void WIFI_DeInit() void WIFI_DeInit()
{ {
if(wifiCom)
wifiCom->DeInit(); wifiCom->DeInit();
} }
@ -712,7 +714,7 @@ void WIFI_Reset()
WIFI_resetRF(&wifiMac.RF) ; WIFI_resetRF(&wifiMac.RF) ;
wifi_netEnabled = false; wifi_netEnabled = false;
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI_COMM
if(driver->WIFI_Host_InitSystem()) if(driver->WIFI_Host_InitSystem())
{ {
wifi_netEnabled = true; wifi_netEnabled = true;
@ -724,10 +726,11 @@ void WIFI_Reset()
wifiMac.rfStatus = 0x0000; wifiMac.rfStatus = 0x0000;
wifiMac.rfPins = 0x0004; wifiMac.rfPins = 0x0004;
if((u32)CommonSettings.wifi.mode >= ARRAY_SIZE(wifiComs))
CommonSettings.wifi.mode = 0;
wifiCom = wifiComs[CommonSettings.wifi.mode]; wifiCom = wifiComs[CommonSettings.wifi.mode];
#ifdef EXPERIMENTAL_WIFI if(wifiCom)
wifiCom->Reset(); wifiCom->Reset();
#endif
} }
@ -948,6 +951,7 @@ static void WIFI_ExtraTXStart()
// Note: Extra transfers trigger two TX start interrupts according to GBATek // Note: Extra transfers trigger two TX start interrupts according to GBATek
WIFI_triggerIRQ(WIFI_IRQ_TXSTART); WIFI_triggerIRQ(WIFI_IRQ_TXSTART);
if(wifiCom)
wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[address+6], txLen); wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[address+6], txLen);
WIFI_triggerIRQ(WIFI_IRQ_UNK); WIFI_triggerIRQ(WIFI_IRQ_UNK);
@ -1015,6 +1019,7 @@ static void WIFI_BeaconTXStart()
*(u32*)&wifiMac.circularBuffer[address + 6 + ((txLen-4) >> 1)] = crc32; *(u32*)&wifiMac.circularBuffer[address + 6 + ((txLen-4) >> 1)] = crc32;
WIFI_triggerIRQ(WIFI_IRQ_TXSTART); WIFI_triggerIRQ(WIFI_IRQ_TXSTART);
if(wifiCom)
wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[address+6], txLen); wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[address+6], txLen);
if (BIT15(wifiMac.TXStatCnt)) if (BIT15(wifiMac.TXStatCnt))
@ -1672,6 +1677,7 @@ void WIFI_usTrigger()
wifiMac.txSlotBusy[slot] = 0; wifiMac.txSlotBusy[slot] = 0;
wifiMac.TXSlot[slot] &= 0x7FFF; wifiMac.TXSlot[slot] &= 0x7FFF;
if(wifiCom)
wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[wifiMac.txSlotAddr[slot]+6], wifiMac.txSlotLen[slot]); wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[wifiMac.txSlotAddr[slot]+6], wifiMac.txSlotLen[slot]);
while((wifiMac.txSlotBusy[wifiMac.txCurSlot] == 0) && (wifiMac.txCurSlot > 0)) while((wifiMac.txSlotBusy[wifiMac.txCurSlot] == 0) && (wifiMac.txCurSlot > 0))
@ -1695,6 +1701,7 @@ void WIFI_usTrigger()
} }
} }
if(wifiCom)
wifiCom->usTrigger(); wifiCom->usTrigger();
} }

View File

@ -23,7 +23,7 @@
#include <stdio.h> #include <stdio.h>
#include "types.h" #include "types.h"
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI_COMM
#define HAVE_REMOTE #define HAVE_REMOTE
#define WPCAP #define WPCAP
@ -509,7 +509,7 @@ typedef struct
} wifimac_t ; } wifimac_t ;
// desmume host communication // desmume host communication
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI_COMM
typedef struct pcap pcap_t; typedef struct pcap pcap_t;
extern pcap_t *wifi_bridge; extern pcap_t *wifi_bridge;
#endif #endif