Some fixes to the wifi core, mostly to the BB writes, but also a very inaccurate random generator (uses rand() atm), and saving all the I/O values to a buffer, for unsupported I/O ports, and support for 32-bit reads/writes to wifi I/O ports.
Games still freeze on wifi transmission but now they send stuff to the wifi core.
This commit is contained in:
parent
f0e0d21227
commit
33ec203f93
|
@ -3636,6 +3636,8 @@ static void FASTCALL _MMU_ARM7_write32(u32 adr, u32 val)
|
|||
{
|
||||
// access to non regular hw registers
|
||||
// return to not overwrite valid data
|
||||
WIFI_write16(&wifiMac, adr, val & 0xFFFF);
|
||||
WIFI_write16(&wifiMac, adr+2, val >> 16);
|
||||
return ;
|
||||
}
|
||||
#endif
|
||||
|
@ -3878,7 +3880,7 @@ static u8 FASTCALL _MMU_ARM7_read08(u32 adr)
|
|||
if ((adr>=0x04800000)&&(adr<0x05000000))
|
||||
{
|
||||
if (adr & 1)
|
||||
return (WIFI_read16(&wifiMac,adr) >> 8) & 0xFF;
|
||||
return (WIFI_read16(&wifiMac,adr-1) >> 8) & 0xFF;
|
||||
else
|
||||
return WIFI_read16(&wifiMac,adr) & 0xFF;
|
||||
}
|
||||
|
@ -3965,6 +3967,12 @@ static u16 FASTCALL _MMU_ARM7_read16(u32 adr)
|
|||
//================================================= MMU ARM7 read 32
|
||||
static u32 FASTCALL _MMU_ARM7_read32(u32 adr)
|
||||
{
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
/* wifi mac access */
|
||||
if ((adr>=0x04800000)&&(adr<0x05000000))
|
||||
return (WIFI_read16(&wifiMac,adr) | (WIFI_read16(&wifiMac,adr+2) << 16));
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_GBASLOT
|
||||
if ( (adr >= 0x08000000) && (adr < 0x0A000000) )
|
||||
return addon.read32(adr);
|
||||
|
|
|
@ -1,197 +1,197 @@
|
|||
/*
|
||||
Copyright (C) 2007 Tim Seidel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "wifi.h"
|
||||
#include "armcpu.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
|
||||
wifimac_t wifiMac ;
|
||||
|
||||
socket_t WIFI_Host_OpenChannel(u8 num) ;
|
||||
void WIFI_Host_CloseChannel(socket_t sock) ;
|
||||
void WIFI_Host_SendData(socket_t sock, u8 channel, u8 *data, u16 length) ;
|
||||
u16 WIFI_Host_RecvData(socket_t sock, u8 *data, u16 maxLength) ;
|
||||
BOOL WIFI_Host_InitSystem(void) ;
|
||||
void WIFI_Host_ShutdownSystem(void) ;
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Firmware info needed for wifi, if no firmware image is available
|
||||
see: http://www.akkit.org/info/dswifi.htm#WifiInit
|
||||
|
||||
written in bytes, to avoid endianess issues
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
const u8 FW_Mac[6] = { 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56 } ;
|
||||
const u8 FW_WIFIInit[32] = { 0x02,0x00, 0x17,0x00, 0x26,0x00, 0x18,0x18,
|
||||
0x48,0x00, 0x40,0x48, 0x58,0x00, 0x42,0x00,
|
||||
0x40,0x01, 0x64,0x80, 0xE0,0xE0, 0x43,0x24,
|
||||
0x0E,0x00, 0x32,0x00, 0xF4,0x01, 0x01,0x01 } ;
|
||||
const u8 FW_BBInit[105] = { 0x6D, 0x9E, 0x40, 0x05,
|
||||
0x1B, 0x6C, 0x48, 0x80,
|
||||
0x38, 0x00, 0x35, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xb0, 0x00, 0x04, 0x01,
|
||||
0xd8, 0xff, 0xff, 0xc7,
|
||||
0xbb, 0x01, 0xb6, 0x7f,
|
||||
0x5a, 0x01, 0x3f, 0x01,
|
||||
0x3f, 0x36, 0x36, 0x00,
|
||||
0x78, 0x28, 0x55, 0x08,
|
||||
0x28, 0x16, 0x00, 0x01,
|
||||
0x0e, 0x20, 0x02, 0x98,
|
||||
0x98, 0x1f, 0x0a, 0x08,
|
||||
0x04, 0x01, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0xfe,
|
||||
0xfe, 0xfe, 0xfe, 0xfc,
|
||||
0xfa, 0xfa, 0xf8, 0xf8,
|
||||
0xf6, 0xa5, 0x12, 0x14,
|
||||
0x12, 0x41, 0x23, 0x03,
|
||||
0x04, 0x70, 0x35, 0x0E,
|
||||
0x16, 0x16, 0x00, 0x00,
|
||||
0x06, 0x01, 0xff, 0xfe,
|
||||
0xff, 0xff, 0x00, 0x0e,
|
||||
0x13, 0x00, 0x00, 0x28,
|
||||
0x1c
|
||||
} ;
|
||||
const u8 FW_RFInit[36] = { 0x07, 0xC0, 0x00,
|
||||
0x03, 0x9C, 0x12,
|
||||
0x28, 0x17, 0x14,
|
||||
0xba, 0xe8, 0x1a,
|
||||
0x6f, 0x45, 0x1d,
|
||||
0xfa, 0xff, 0x23,
|
||||
0x30, 0x1d, 0x24,
|
||||
0x01, 0x00, 0x28,
|
||||
0x00, 0x00, 0x2c,
|
||||
0x03, 0x9c, 0x06,
|
||||
0x22, 0x00, 0x08,
|
||||
0x6f, 0xff, 0x0d
|
||||
} ;
|
||||
const u8 FW_RFChannel[6*14] = { 0x28, 0x17, 0x14, /* Channel 1 */
|
||||
0xba, 0xe8, 0x1a,
|
||||
0x37, 0x17, 0x14, /* Channel 2 */
|
||||
0x46, 0x17, 0x19,
|
||||
0x45, 0x17, 0x14, /* Channel 3 */
|
||||
0xd1, 0x45, 0x1b,
|
||||
0x54, 0x17, 0x14, /* Channel 4 */
|
||||
0x5d, 0x74, 0x19,
|
||||
0x62, 0x17, 0x14, /* Channel 5 */
|
||||
0xe9, 0xa2, 0x1b,
|
||||
0x71, 0x17, 0x14, /* Channel 6 */
|
||||
0x74, 0xd1, 0x19,
|
||||
0x80, 0x17, 0x14, /* Channel 7 */
|
||||
0x00, 0x00, 0x18,
|
||||
0x8e, 0x17, 0x14, /* Channel 8 */
|
||||
0x8c, 0x2e, 0x1a,
|
||||
0x9d, 0x17, 0x14, /* Channel 9 */
|
||||
0x17, 0x5d, 0x18,
|
||||
0xab, 0x17, 0x14, /* Channel 10 */
|
||||
0xa3, 0x8b, 0x1a,
|
||||
0xba, 0x17, 0x14, /* Channel 11 */
|
||||
0x2f, 0xba, 0x18,
|
||||
0xc8, 0x17, 0x14, /* Channel 12 */
|
||||
0xba, 0xe8, 0x1a,
|
||||
0xd7, 0x17, 0x14, /* Channel 13 */
|
||||
0x46, 0x17, 0x19,
|
||||
0xfa, 0x17, 0x14, /* Channel 14 */
|
||||
0x2f, 0xba, 0x18
|
||||
} ;
|
||||
const u8 FW_BBChannel[14] = { 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, /* channel 1- 6 */
|
||||
0xb4, 0xb4, 0xb4, 0xb4, 0xb4, /* channel 7-10 */
|
||||
0xb5, 0xb5, /* channel 11-12 */
|
||||
0xb6, 0xb6 /* channel 13-14 */
|
||||
} ;
|
||||
|
||||
/* Note : the values are inspired from what I found in a firmware image from my DS */
|
||||
|
||||
FW_WFCProfile FW_WFCProfile1 = {"DeSmuME Soft AP",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0, 0},
|
||||
0,
|
||||
{0xBA, 0xA0, 0x35, 0xE7, 0x01, 0xD0, 0x05, 0xAD, 0x39, 0x0F, 0x40, 0x1C, 0x2B, 0x2C},
|
||||
{0, 0}
|
||||
} ;
|
||||
|
||||
FW_WFCProfile FW_WFCProfile2 = {"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0xFF,
|
||||
{0, 0, 0, 0, 0, 0, 0},
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0}
|
||||
} ;
|
||||
|
||||
FW_WFCProfile FW_WFCProfile3 = {"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0xFF,
|
||||
{0, 0, 0, 0, 0, 0, 0},
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0}
|
||||
} ;
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
|
||||
/*
|
||||
Copyright (C) 2007 Tim Seidel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "wifi.h"
|
||||
#include "armcpu.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
|
||||
wifimac_t wifiMac ;
|
||||
|
||||
socket_t WIFI_Host_OpenChannel(u8 num) ;
|
||||
void WIFI_Host_CloseChannel(socket_t sock) ;
|
||||
void WIFI_Host_SendData(socket_t sock, u8 channel, u8 *data, u16 length) ;
|
||||
u16 WIFI_Host_RecvData(socket_t sock, u8 *data, u16 maxLength) ;
|
||||
BOOL WIFI_Host_InitSystem(void) ;
|
||||
void WIFI_Host_ShutdownSystem(void) ;
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Firmware info needed for wifi, if no firmware image is available
|
||||
see: http://www.akkit.org/info/dswifi.htm#WifiInit
|
||||
|
||||
written in bytes, to avoid endianess issues
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
const u8 FW_Mac[6] = { 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56 } ;
|
||||
const u8 FW_WIFIInit[32] = { 0x02,0x00, 0x17,0x00, 0x26,0x00, 0x18,0x18,
|
||||
0x48,0x00, 0x40,0x48, 0x58,0x00, 0x42,0x00,
|
||||
0x40,0x01, 0x64,0x80, 0xE0,0xE0, 0x43,0x24,
|
||||
0x0E,0x00, 0x32,0x00, 0xF4,0x01, 0x01,0x01 } ;
|
||||
const u8 FW_BBInit[105] = { 0x6D, 0x9E, 0x40, 0x05,
|
||||
0x1B, 0x6C, 0x48, 0x80,
|
||||
0x38, 0x00, 0x35, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xb0, 0x00, 0x04, 0x01,
|
||||
0xd8, 0xff, 0xff, 0xc7,
|
||||
0xbb, 0x01, 0xb6, 0x7f,
|
||||
0x5a, 0x01, 0x3f, 0x01,
|
||||
0x3f, 0x36, 0x36, 0x00,
|
||||
0x78, 0x28, 0x55, 0x08,
|
||||
0x28, 0x16, 0x00, 0x01,
|
||||
0x0e, 0x20, 0x02, 0x98,
|
||||
0x98, 0x1f, 0x0a, 0x08,
|
||||
0x04, 0x01, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0xfe,
|
||||
0xfe, 0xfe, 0xfe, 0xfc,
|
||||
0xfa, 0xfa, 0xf8, 0xf8,
|
||||
0xf6, 0xa5, 0x12, 0x14,
|
||||
0x12, 0x41, 0x23, 0x03,
|
||||
0x04, 0x70, 0x35, 0x0E,
|
||||
0x16, 0x16, 0x00, 0x00,
|
||||
0x06, 0x01, 0xff, 0xfe,
|
||||
0xff, 0xff, 0x00, 0x0e,
|
||||
0x13, 0x00, 0x00, 0x28,
|
||||
0x1c
|
||||
} ;
|
||||
const u8 FW_RFInit[36] = { 0x07, 0xC0, 0x00,
|
||||
0x03, 0x9C, 0x12,
|
||||
0x28, 0x17, 0x14,
|
||||
0xba, 0xe8, 0x1a,
|
||||
0x6f, 0x45, 0x1d,
|
||||
0xfa, 0xff, 0x23,
|
||||
0x30, 0x1d, 0x24,
|
||||
0x01, 0x00, 0x28,
|
||||
0x00, 0x00, 0x2c,
|
||||
0x03, 0x9c, 0x06,
|
||||
0x22, 0x00, 0x08,
|
||||
0x6f, 0xff, 0x0d
|
||||
} ;
|
||||
const u8 FW_RFChannel[6*14] = { 0x28, 0x17, 0x14, /* Channel 1 */
|
||||
0xba, 0xe8, 0x1a,
|
||||
0x37, 0x17, 0x14, /* Channel 2 */
|
||||
0x46, 0x17, 0x19,
|
||||
0x45, 0x17, 0x14, /* Channel 3 */
|
||||
0xd1, 0x45, 0x1b,
|
||||
0x54, 0x17, 0x14, /* Channel 4 */
|
||||
0x5d, 0x74, 0x19,
|
||||
0x62, 0x17, 0x14, /* Channel 5 */
|
||||
0xe9, 0xa2, 0x1b,
|
||||
0x71, 0x17, 0x14, /* Channel 6 */
|
||||
0x74, 0xd1, 0x19,
|
||||
0x80, 0x17, 0x14, /* Channel 7 */
|
||||
0x00, 0x00, 0x18,
|
||||
0x8e, 0x17, 0x14, /* Channel 8 */
|
||||
0x8c, 0x2e, 0x1a,
|
||||
0x9d, 0x17, 0x14, /* Channel 9 */
|
||||
0x17, 0x5d, 0x18,
|
||||
0xab, 0x17, 0x14, /* Channel 10 */
|
||||
0xa3, 0x8b, 0x1a,
|
||||
0xba, 0x17, 0x14, /* Channel 11 */
|
||||
0x2f, 0xba, 0x18,
|
||||
0xc8, 0x17, 0x14, /* Channel 12 */
|
||||
0xba, 0xe8, 0x1a,
|
||||
0xd7, 0x17, 0x14, /* Channel 13 */
|
||||
0x46, 0x17, 0x19,
|
||||
0xfa, 0x17, 0x14, /* Channel 14 */
|
||||
0x2f, 0xba, 0x18
|
||||
} ;
|
||||
const u8 FW_BBChannel[14] = { 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, /* channel 1- 6 */
|
||||
0xb4, 0xb4, 0xb4, 0xb4, 0xb4, /* channel 7-10 */
|
||||
0xb5, 0xb5, /* channel 11-12 */
|
||||
0xb6, 0xb6 /* channel 13-14 */
|
||||
} ;
|
||||
|
||||
/* Note : the values are inspired from what I found in a firmware image from my DS */
|
||||
|
||||
FW_WFCProfile FW_WFCProfile1 = {"DeSmuME Soft AP",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0, 0},
|
||||
0,
|
||||
{0xBA, 0xA0, 0x35, 0xE7, 0x01, 0xD0, 0x05, 0xAD, 0x39, 0x0F, 0x40, 0x1C, 0x2B, 0x2C},
|
||||
{0, 0}
|
||||
} ;
|
||||
|
||||
FW_WFCProfile FW_WFCProfile2 = {"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0xFF,
|
||||
{0, 0, 0, 0, 0, 0, 0},
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0}
|
||||
} ;
|
||||
|
||||
FW_WFCProfile FW_WFCProfile3 = {"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
0,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
0xFF,
|
||||
{0, 0, 0, 0, 0, 0, 0},
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0}
|
||||
} ;
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
RF-Chip
|
||||
|
@ -359,19 +359,27 @@ u16 WIFI_getRF_STATUS(wifimac_t *wifi)
|
|||
|
||||
void WIFI_setBB_CNT(wifimac_t *wifi,u16 val)
|
||||
{
|
||||
wifi->bbIOCnt.val = val ;
|
||||
wifi->bbIOCnt.val = val;
|
||||
|
||||
if(wifi->bbIOCnt.bits.mode == 1)
|
||||
wifi->BB.data[wifi->bbIOCnt.bits.address] = wifi->bbDataToWrite;
|
||||
}
|
||||
|
||||
u8 WIFI_getBB_DATA(wifimac_t *wifi)
|
||||
{
|
||||
if ((wifi->bbIOCnt.bits.mode != 2) || !(wifi->bbIOCnt.bits.enable)) return 0 ; /* not for read or disabled */
|
||||
return wifi->BB.data[wifi->bbIOCnt.bits.address] ;
|
||||
if((!wifi->bbIOCnt.bits.enable) || (wifi->bbIOCnt.bits.mode != 2))
|
||||
return 0;
|
||||
|
||||
return wifi->BB.data[wifi->bbIOCnt.bits.address];
|
||||
// if ((wifi->bbIOCnt.bits.mode != 2) || !(wifi->bbIOCnt.bits.enable)) return 0 ; /* not for read or disabled */
|
||||
// return wifi->BB.data[wifi->bbIOCnt.bits.address] ;
|
||||
}
|
||||
|
||||
void WIFI_setBB_DATA(wifimac_t *wifi, u8 val)
|
||||
{
|
||||
if ((wifi->bbIOCnt.bits.mode != 1) || !(wifi->bbIOCnt.bits.enable)) return ; /* not for write or disabled */
|
||||
wifi->BB.data[wifi->bbIOCnt.bits.address] = val ;
|
||||
wifi->bbDataToWrite = (val & 0xFF);
|
||||
// if ((wifi->bbIOCnt.bits.mode != 1) || !(wifi->bbIOCnt.bits.enable)) return ; /* not for write or disabled */
|
||||
// wifi->BB.data[wifi->bbIOCnt.bits.address] = val ;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -473,6 +481,7 @@ void WIFI_write16(wifimac_t *wifi,u32 address, u16 val)
|
|||
return ;
|
||||
}
|
||||
if (!(address & 0x00007000)) action = TRUE ;
|
||||
|
||||
/* mirrors => register address */
|
||||
address &= 0x00000FFF ;
|
||||
switch (address)
|
||||
|
@ -632,9 +641,11 @@ void WIFI_write16(wifimac_t *wifi,u32 address, u16 val)
|
|||
wifi->aid = val & 0x07FF ;
|
||||
break ;
|
||||
default:
|
||||
val = 0 ; /* not handled yet */
|
||||
// val = 0 ; /* not handled yet */
|
||||
break ;
|
||||
}
|
||||
|
||||
wifi->ioMem[address >> 1] = val;
|
||||
}
|
||||
|
||||
u16 WIFI_read16(wifimac_t *wifi,u32 address)
|
||||
|
@ -655,6 +666,7 @@ u16 WIFI_read16(wifimac_t *wifi,u32 address)
|
|||
return wifi->circularBuffer[(address & 0x1FFF) >> 1] ;
|
||||
}
|
||||
if (!(address & 0x00007000)) action = TRUE ;
|
||||
|
||||
/* mirrors => register address */
|
||||
address &= 0x00000FFF ;
|
||||
switch (address)
|
||||
|
@ -680,6 +692,7 @@ u16 WIFI_read16(wifimac_t *wifi,u32 address)
|
|||
return WIFI_getBB_DATA(wifi) ;
|
||||
case REG_WIFI_RANDOM:
|
||||
/* FIXME: random generator */
|
||||
return (rand() & 0x7FF);
|
||||
return 0 ;
|
||||
case REG_WIFI_MAC0:
|
||||
case REG_WIFI_MAC1:
|
||||
|
@ -739,7 +752,7 @@ u16 WIFI_read16(wifimac_t *wifi,u32 address)
|
|||
case REG_WIFI_AID_HIGH:
|
||||
return wifi->aid ;
|
||||
default:
|
||||
return 0 ;
|
||||
return wifi->ioMem[address >> 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,118 +777,118 @@ void WIFI_usTrigger(wifimac_t *wifi)
|
|||
if ((wifi->ucmpEnable) && (wifi->ucmp == wifi->usec))
|
||||
{
|
||||
WIFI_triggerIRQ(wifi,WIFI_IRQ_TIMEBEACON) ;
|
||||
}
|
||||
/* receive check, given a 2 mbit connection, 2 bits per usec can be transfered. */
|
||||
/* for a packet of 32 Bytes, at least 128 usec passed, we will use the 32 byte accuracy to reduce load */
|
||||
if (!(wifi->RXCheckCounter++ & 0x7F))
|
||||
{
|
||||
/* check if data arrived in the meantime */
|
||||
rcvSize = WIFI_Host_RecvData(wifi->udpSocket,dataBuffer,0x2000) ;
|
||||
if (rcvSize)
|
||||
{
|
||||
u16 i ;
|
||||
/* process data, put it into mac memory */
|
||||
WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVSTART) ;
|
||||
for (i=0;i<(rcvSize+1) << 1;i++)
|
||||
{
|
||||
WIFI_RXPutWord(wifi,((u16 *)dataBuffer)[i]) ;
|
||||
}
|
||||
WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVCOMPLETE) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Host system operations
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
socket_t WIFI_Host_OpenChannel(u8 num)
|
||||
{
|
||||
sockaddr_t address ;
|
||||
/* create a new socket */
|
||||
socket_t channelSocket = socket(AF_INET,SOCK_DGRAM,0) ;
|
||||
/* set the sockets address */
|
||||
memset(&address,0,sizeof(sockaddr_t)) ;
|
||||
address.sa_family = AF_INET ;
|
||||
*(u32 *)&address.sa_data[2] = htonl(0) ; /* IP: any */
|
||||
*(u16 *)&address.sa_data[0] = htons(BASEPORT + num-1) ; /* Port */
|
||||
bind(channelSocket,&address,sizeof(sockaddr_t)) ;
|
||||
return channelSocket ;
|
||||
}
|
||||
|
||||
void WIFI_Host_CloseChannel(socket_t sock)
|
||||
{
|
||||
if (sock!=INVALID_SOCKET)
|
||||
{
|
||||
#ifdef WIN32
|
||||
closesocket(sock) ;
|
||||
#else
|
||||
close(sock) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void WIFI_Host_SendData(socket_t sock, u8 channel, u8 *data, u16 length)
|
||||
{
|
||||
sockaddr_t address ;
|
||||
/* create the frame to validate data: "DSWIFI" string and a u16 constant of the payload length */
|
||||
u8 *frame = (u8 *)malloc(length + 8) ;
|
||||
sprintf((char *)frame,"DSWIFI") ;
|
||||
*(u16 *)(frame+6) = htons(length) ;
|
||||
memcpy(frame+8,data,length) ;
|
||||
/* target address */
|
||||
memset(&address,0,sizeof(sockaddr_t)) ;
|
||||
address.sa_family = AF_INET ;
|
||||
*(u32 *)&address.sa_data[2] = htonl(0xFFFFFFFF) ; /* IP: broadcast */
|
||||
*(u16 *)&address.sa_data[0] = htons(BASEPORT + channel-1) ; /* Port */
|
||||
/* send the data now */
|
||||
sendto(sock,(const char *)frame,length+8,0,&address,sizeof(sockaddr_t)) ;
|
||||
/* clean up frame buffer */
|
||||
free(frame) ;
|
||||
}
|
||||
|
||||
u16 WIFI_Host_RecvData(socket_t sock, u8 *data, u16 maxLength)
|
||||
{
|
||||
fd_set dataCheck ;
|
||||
struct timeval tv ;
|
||||
FD_ZERO(&dataCheck) ;
|
||||
FD_SET(sock,&dataCheck) ;
|
||||
tv.tv_sec = 0 ;
|
||||
tv.tv_usec = 0 ;
|
||||
/* check if there is data, without blocking */
|
||||
if (select(1,&dataCheck,0,0,&tv))
|
||||
{
|
||||
/* there is data available */
|
||||
u32 receivedBytes = recv(sock,(char*)data,maxLength,0) ;
|
||||
if (receivedBytes < 8) return 0 ; /* this cant be data for us, the header alone is 8 bytes */
|
||||
if (memcmp(data,"DSWIFI",6)!=0) return 0 ; /* this isnt data for us, as the tag is not our */
|
||||
if (ntohs(*(u16 *)(data+6))+8 != receivedBytes) return 0 ; /* the datalen+headerlen is not what we received */
|
||||
memmove(data,data+8,receivedBytes-8) ;
|
||||
return receivedBytes-8 ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
BOOL WIFI_Host_InitSystem(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData ;
|
||||
WORD version = MAKEWORD(1,1) ;
|
||||
if (WSAStartup(version,&wsaData))
|
||||
{
|
||||
return FALSE ;
|
||||
}
|
||||
#endif
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
void WIFI_Host_ShutdownSystem(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSACleanup() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
/* receive check, given a 2 mbit connection, 2 bits per usec can be transfered. */
|
||||
/* for a packet of 32 Bytes, at least 128 usec passed, we will use the 32 byte accuracy to reduce load */
|
||||
if (!(wifi->RXCheckCounter++ & 0x7F))
|
||||
{
|
||||
/* check if data arrived in the meantime */
|
||||
rcvSize = WIFI_Host_RecvData(wifi->udpSocket,dataBuffer,0x2000) ;
|
||||
if (rcvSize)
|
||||
{
|
||||
u16 i ;
|
||||
/* process data, put it into mac memory */
|
||||
WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVSTART) ;
|
||||
for (i=0;i<(rcvSize+1) << 1;i++)
|
||||
{
|
||||
WIFI_RXPutWord(wifi,((u16 *)dataBuffer)[i]) ;
|
||||
}
|
||||
WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVCOMPLETE) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Host system operations
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
socket_t WIFI_Host_OpenChannel(u8 num)
|
||||
{
|
||||
sockaddr_t address ;
|
||||
/* create a new socket */
|
||||
socket_t channelSocket = socket(AF_INET,SOCK_DGRAM,0) ;
|
||||
/* set the sockets address */
|
||||
memset(&address,0,sizeof(sockaddr_t)) ;
|
||||
address.sa_family = AF_INET ;
|
||||
*(u32 *)&address.sa_data[2] = htonl(0) ; /* IP: any */
|
||||
*(u16 *)&address.sa_data[0] = htons(BASEPORT + num-1) ; /* Port */
|
||||
bind(channelSocket,&address,sizeof(sockaddr_t)) ;
|
||||
return channelSocket ;
|
||||
}
|
||||
|
||||
void WIFI_Host_CloseChannel(socket_t sock)
|
||||
{
|
||||
if (sock!=INVALID_SOCKET)
|
||||
{
|
||||
#ifdef WIN32
|
||||
closesocket(sock) ;
|
||||
#else
|
||||
close(sock) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void WIFI_Host_SendData(socket_t sock, u8 channel, u8 *data, u16 length)
|
||||
{
|
||||
sockaddr_t address ;
|
||||
/* create the frame to validate data: "DSWIFI" string and a u16 constant of the payload length */
|
||||
u8 *frame = (u8 *)malloc(length + 8) ;
|
||||
sprintf((char *)frame,"DSWIFI") ;
|
||||
*(u16 *)(frame+6) = htons(length) ;
|
||||
memcpy(frame+8,data,length) ;
|
||||
/* target address */
|
||||
memset(&address,0,sizeof(sockaddr_t)) ;
|
||||
address.sa_family = AF_INET ;
|
||||
*(u32 *)&address.sa_data[2] = htonl(0xFFFFFFFF) ; /* IP: broadcast */
|
||||
*(u16 *)&address.sa_data[0] = htons(BASEPORT + channel-1) ; /* Port */
|
||||
/* send the data now */
|
||||
sendto(sock,(const char *)frame,length+8,0,&address,sizeof(sockaddr_t)) ;
|
||||
/* clean up frame buffer */
|
||||
free(frame) ;
|
||||
}
|
||||
|
||||
u16 WIFI_Host_RecvData(socket_t sock, u8 *data, u16 maxLength)
|
||||
{
|
||||
fd_set dataCheck ;
|
||||
struct timeval tv ;
|
||||
FD_ZERO(&dataCheck) ;
|
||||
FD_SET(sock,&dataCheck) ;
|
||||
tv.tv_sec = 0 ;
|
||||
tv.tv_usec = 0 ;
|
||||
/* check if there is data, without blocking */
|
||||
if (select(1,&dataCheck,0,0,&tv))
|
||||
{
|
||||
/* there is data available */
|
||||
u32 receivedBytes = recv(sock,(char*)data,maxLength,0) ;
|
||||
if (receivedBytes < 8) return 0 ; /* this cant be data for us, the header alone is 8 bytes */
|
||||
if (memcmp(data,"DSWIFI",6)!=0) return 0 ; /* this isnt data for us, as the tag is not our */
|
||||
if (ntohs(*(u16 *)(data+6))+8 != receivedBytes) return 0 ; /* the datalen+headerlen is not what we received */
|
||||
memmove(data,data+8,receivedBytes-8) ;
|
||||
return receivedBytes-8 ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
BOOL WIFI_Host_InitSystem(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData ;
|
||||
WORD version = MAKEWORD(1,1) ;
|
||||
if (WSAStartup(version,&wsaData))
|
||||
{
|
||||
return FALSE ;
|
||||
}
|
||||
#endif
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
void WIFI_Host_ShutdownSystem(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSACleanup() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
/*
|
||||
Copyright (C) 2007 Tim Seidel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef WIFI_H
|
||||
#define WIFI_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
|
||||
/* standardize socket interface for linux and windows */
|
||||
#ifdef WIN32
|
||||
/*
|
||||
Copyright (C) 2007 Tim Seidel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef WIFI_H
|
||||
#define WIFI_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI
|
||||
|
||||
/* standardize socket interface for linux and windows */
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#define socket_t SOCKET
|
||||
#define sockaddr_t SOCKADDR
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#define socket_t int
|
||||
#define sockaddr_t struct sockaddr
|
||||
#endif
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET (socket_t)-1
|
||||
#endif
|
||||
#define BASEPORT 7000 /* channel 1: 7000 ... channel 13: 7012 */
|
||||
/* FIXME: make it configureable */
|
||||
|
||||
#define socket_t SOCKET
|
||||
#define sockaddr_t SOCKADDR
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#define socket_t int
|
||||
#define sockaddr_t struct sockaddr
|
||||
#endif
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET (socket_t)-1
|
||||
#endif
|
||||
#define BASEPORT 7000 /* channel 1: 7000 ... channel 13: 7012 */
|
||||
/* FIXME: make it configureable */
|
||||
|
||||
#define REG_WIFI_ID 0x000
|
||||
#define REG_WIFI_MODE 0x004
|
||||
#define REG_WIFI_WEP 0x006
|
||||
|
@ -424,6 +424,8 @@ typedef struct
|
|||
rfIOData_t rfIOData ;
|
||||
bbIOCnt_t bbIOCnt ;
|
||||
|
||||
u8 bbDataToWrite;
|
||||
|
||||
/* buffers */
|
||||
u16 circularBuffer[0x1000] ;
|
||||
u16 RXRangeBegin ;
|
||||
|
@ -439,6 +441,9 @@ typedef struct
|
|||
u16 CircBufWrEnd ;
|
||||
u16 CircBufWrSkip ;
|
||||
|
||||
/* i/o mem */
|
||||
u16 ioMem[0x800];
|
||||
|
||||
/* others */
|
||||
u16 randomSeed ;
|
||||
|
||||
|
@ -447,66 +452,66 @@ typedef struct
|
|||
u8 channel ;
|
||||
|
||||
} wifimac_t ;
|
||||
|
||||
extern wifimac_t wifiMac ;
|
||||
|
||||
void WIFI_Init(wifimac_t *wifi);
|
||||
|
||||
/* subchip communication IO functions */
|
||||
void WIFI_setRF_CNT(wifimac_t *wifi, u16 val) ;
|
||||
void WIFI_setRF_DATA(wifimac_t *wifi, u16 val, u8 part) ;
|
||||
u16 WIFI_getRF_DATA(wifimac_t *wifi, u8 part) ;
|
||||
u16 WIFI_getRF_STATUS(wifimac_t *wifi) ;
|
||||
|
||||
void WIFI_setBB_CNT(wifimac_t *wifi,u16 val) ;
|
||||
u8 WIFI_getBB_DATA(wifimac_t *wifi) ;
|
||||
void WIFI_setBB_DATA(wifimac_t *wifi, u8 val) ;
|
||||
|
||||
/* wifimac io */
|
||||
void WIFI_write16(wifimac_t *wifi,u32 address, u16 val) ;
|
||||
u16 WIFI_read16(wifimac_t *wifi,u32 address) ;
|
||||
|
||||
/* wifimac timing */
|
||||
void WIFI_usTrigger(wifimac_t *wifi) ;
|
||||
|
||||
#endif
|
||||
|
||||
/* DS WFC profile data documented here : */
|
||||
/* http://dsdev.bigredpimp.com/2006/07/31/aoss-wfc-profile-data/ */
|
||||
/* Note : we use bytes to avoid endianness issues */
|
||||
typedef struct _FW_WFCProfile
|
||||
{
|
||||
char SSID[32];
|
||||
char SSID_WEP64[32];
|
||||
char WEPKEY_PART1[16];
|
||||
char WEPKEY_PART2[16];
|
||||
char WEPKEY_PART3[16];
|
||||
char WEPKEY_PART4[16];
|
||||
u8 IP_ADDRESS[4];
|
||||
u8 GATEWAY[4];
|
||||
u8 PRIM_DNS[4];
|
||||
u8 SEC_DNS[4];
|
||||
u8 SUBNET_MASK;
|
||||
u8 WEP64_KEY_AOSS[20];
|
||||
u8 UNK1;
|
||||
u8 WEP_MODE;
|
||||
u8 STATUS;
|
||||
u8 UNK2[7];
|
||||
u8 UNK3;
|
||||
u8 UNK4[14];
|
||||
u8 CRC16[2];
|
||||
|
||||
} FW_WFCProfile;
|
||||
|
||||
/* wifi data to be stored in firmware, when no firmware image was loaded */
|
||||
extern const u8 FW_Mac[6];
|
||||
extern const u8 FW_WIFIInit[32] ;
|
||||
extern const u8 FW_BBInit[105] ;
|
||||
extern const u8 FW_RFInit[36] ;
|
||||
extern const u8 FW_RFChannel[6*14] ;
|
||||
extern const u8 FW_BBChannel[14] ;
|
||||
extern FW_WFCProfile FW_WFCProfile1;
|
||||
extern FW_WFCProfile FW_WFCProfile2;
|
||||
extern FW_WFCProfile FW_WFCProfile3;
|
||||
|
||||
#endif
|
||||
|
||||
extern wifimac_t wifiMac ;
|
||||
|
||||
void WIFI_Init(wifimac_t *wifi);
|
||||
|
||||
/* subchip communication IO functions */
|
||||
void WIFI_setRF_CNT(wifimac_t *wifi, u16 val) ;
|
||||
void WIFI_setRF_DATA(wifimac_t *wifi, u16 val, u8 part) ;
|
||||
u16 WIFI_getRF_DATA(wifimac_t *wifi, u8 part) ;
|
||||
u16 WIFI_getRF_STATUS(wifimac_t *wifi) ;
|
||||
|
||||
void WIFI_setBB_CNT(wifimac_t *wifi,u16 val) ;
|
||||
u8 WIFI_getBB_DATA(wifimac_t *wifi) ;
|
||||
void WIFI_setBB_DATA(wifimac_t *wifi, u8 val) ;
|
||||
|
||||
/* wifimac io */
|
||||
void WIFI_write16(wifimac_t *wifi,u32 address, u16 val) ;
|
||||
u16 WIFI_read16(wifimac_t *wifi,u32 address) ;
|
||||
|
||||
/* wifimac timing */
|
||||
void WIFI_usTrigger(wifimac_t *wifi) ;
|
||||
|
||||
#endif
|
||||
|
||||
/* DS WFC profile data documented here : */
|
||||
/* http://dsdev.bigredpimp.com/2006/07/31/aoss-wfc-profile-data/ */
|
||||
/* Note : we use bytes to avoid endianness issues */
|
||||
typedef struct _FW_WFCProfile
|
||||
{
|
||||
char SSID[32];
|
||||
char SSID_WEP64[32];
|
||||
char WEPKEY_PART1[16];
|
||||
char WEPKEY_PART2[16];
|
||||
char WEPKEY_PART3[16];
|
||||
char WEPKEY_PART4[16];
|
||||
u8 IP_ADDRESS[4];
|
||||
u8 GATEWAY[4];
|
||||
u8 PRIM_DNS[4];
|
||||
u8 SEC_DNS[4];
|
||||
u8 SUBNET_MASK;
|
||||
u8 WEP64_KEY_AOSS[20];
|
||||
u8 UNK1;
|
||||
u8 WEP_MODE;
|
||||
u8 STATUS;
|
||||
u8 UNK2[7];
|
||||
u8 UNK3;
|
||||
u8 UNK4[14];
|
||||
u8 CRC16[2];
|
||||
|
||||
} FW_WFCProfile;
|
||||
|
||||
/* wifi data to be stored in firmware, when no firmware image was loaded */
|
||||
extern const u8 FW_Mac[6];
|
||||
extern const u8 FW_WIFIInit[32] ;
|
||||
extern const u8 FW_BBInit[105] ;
|
||||
extern const u8 FW_RFInit[36] ;
|
||||
extern const u8 FW_RFChannel[6*14] ;
|
||||
extern const u8 FW_BBChannel[14] ;
|
||||
extern FW_WFCProfile FW_WFCProfile1;
|
||||
extern FW_WFCProfile FW_WFCProfile2;
|
||||
extern FW_WFCProfile FW_WFCProfile3;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue