Merge pull request #150 from retr0s4ge/master
Add WiFi fix from desmume-reloaded, tweak the wait for display thread added in commit ee8fdeb
This commit is contained in:
commit
490c7e917c
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "ROMReader.h"
|
||||
#include "wifi.h"
|
||||
|
||||
class BaseDriver;
|
||||
class CFIRMWARE;
|
||||
class EMUFILE;
|
||||
|
||||
|
@ -72,7 +72,6 @@ extern BOOL click;
|
|||
#define NDS_FW_LANG_CHI 6
|
||||
#define NDS_FW_LANG_RES 7
|
||||
|
||||
extern BaseDriver *driver;
|
||||
extern CFIRMWARE *firmware;
|
||||
|
||||
#define DSGBA_LOADER_SIZE 512
|
||||
|
|
|
@ -142,6 +142,8 @@ ENDL
|
|||
" Select basic console type; default FAT" ENDL
|
||||
" --bios-arm9 BIN_FILE Uses the ARM9 BIOS provided at the specified path" ENDL
|
||||
" --bios-arm7 BIN_FILE Uses the ARM7 BIOS provided at the specified path" ENDL
|
||||
" --firmware-path BIN_FILE Uses the firmware provided at the specified path" ENDL
|
||||
" --firmware-boot 0|1 Boot from firmware" ENDL
|
||||
" --bios-swi Uses SWI from the provided bios files (else HLE)" ENDL
|
||||
" --lang N Firmware language (can affect game translations)" ENDL
|
||||
" 0 = Japanese, 1 = English (default), 2 = French" ENDL
|
||||
|
@ -195,6 +197,8 @@ ENDL
|
|||
#define OPT_ARM9 201
|
||||
#define OPT_ARM7 202
|
||||
#define OPT_LANGUAGE 203
|
||||
#define OPT_FIRMPATH 204
|
||||
#define OPT_FIRMBOOT 205
|
||||
|
||||
#define OPT_SLOT1 300
|
||||
#define OPT_SLOT1_FAT_DIR 301
|
||||
|
@ -269,6 +273,8 @@ bool CommandLine::parse(int argc,char **argv)
|
|||
{ "bios-arm9", required_argument, NULL, OPT_ARM9},
|
||||
{ "bios-arm7", required_argument, NULL, OPT_ARM7},
|
||||
{ "bios-swi", no_argument, &_bios_swi, 1},
|
||||
{ "firmware-path", required_argument, NULL, OPT_FIRMPATH},
|
||||
{ "firmware-boot", required_argument, NULL, OPT_FIRMBOOT},
|
||||
{ "lang", required_argument, NULL, OPT_LANGUAGE},
|
||||
|
||||
//slot-1 contents
|
||||
|
@ -332,6 +338,8 @@ bool CommandLine::parse(int argc,char **argv)
|
|||
case OPT_CONSOLE_TYPE: console_type = optarg; break;
|
||||
case OPT_ARM9: _bios_arm9 = strdup(optarg); break;
|
||||
case OPT_ARM7: _bios_arm7 = strdup(optarg); break;
|
||||
case OPT_FIRMPATH: _fw_path = strdup(optarg); break;
|
||||
case OPT_FIRMBOOT: _fw_boot = atoi(optarg); break;
|
||||
|
||||
//slot-1 contents
|
||||
case OPT_SLOT1: slot1 = strtoupper(optarg); break;
|
||||
|
@ -418,6 +426,10 @@ bool CommandLine::parse(int argc,char **argv)
|
|||
//TODO NOT MAX PRIORITY! change ARM9BIOS etc to be a std::string
|
||||
if(_bios_arm9) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM9BIOS,_bios_arm9); }
|
||||
if(_bios_arm7) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM7BIOS,_bios_arm7); }
|
||||
#ifndef HOST_WINDOWS
|
||||
if(_fw_path) { CommonSettings.UseExtFirmware = true; CommonSettings.UseExtFirmwareSettings = true; strcpy(CommonSettings.Firmware,_fw_path); }
|
||||
#endif
|
||||
if(_fw_boot) CommonSettings.BootFromFirmware = true;
|
||||
if(_bios_swi) CommonSettings.SWIFromBIOS = true;
|
||||
if(_spu_sync_mode != -1) CommonSettings.SPU_sync_mode = _spu_sync_mode;
|
||||
if(_spu_sync_method != -1) CommonSettings.SPU_sync_method = _spu_sync_method;
|
||||
|
@ -490,6 +502,10 @@ bool CommandLine::validate()
|
|||
printerror("If either bios-swi is used, bios-arm9 and bios-arm7 must be specified.\n");
|
||||
}
|
||||
|
||||
if(_fw_boot && (!_fw_path)) {
|
||||
printerror("If either firmware boot is used, firmware path must be specified.\n");
|
||||
}
|
||||
|
||||
if((_cflash_image && _gbaslot_rom) || (_cflash_path && _gbaslot_rom)) {
|
||||
printerror("Cannot specify both cflash and gbaslot rom (both occupy SLOT-2)\n");
|
||||
}
|
||||
|
|
|
@ -91,6 +91,8 @@ private:
|
|||
char* _cflash_path;
|
||||
char* _gbaslot_rom;
|
||||
char* _bios_arm9, *_bios_arm7;
|
||||
char* _fw_path;
|
||||
int _fw_boot;
|
||||
int _load_to_memory;
|
||||
int _bios_swi;
|
||||
int _spu_advanced;
|
||||
|
|
|
@ -38,6 +38,10 @@ armcpu_t* TDebugEventData::cpu() { return procnum==0?&NDS_ARM9:&NDS_ARM7; }
|
|||
TDebugEventData DebugEventData;
|
||||
u32 debugFlag;
|
||||
|
||||
// PACKET HACK VARS
|
||||
FILE *log_ptr; // File to store the dumped data
|
||||
const u32 rc4_addr[2] = { 0x020986A8, 0x02098710 };
|
||||
|
||||
//DEBUG CONFIGURATION
|
||||
const bool debug_acl = false;
|
||||
const bool debug_cacheMiss = false;
|
||||
|
@ -78,9 +82,60 @@ void HandleDebugEvent_Read()
|
|||
|
||||
void HandleDebugEvent_Write()
|
||||
{
|
||||
if(!debug_acl) return;
|
||||
if(DebugEventData.procnum != ARMCPU_ARM9) return; //acl only valid on arm9
|
||||
acl_check_access(DebugEventData.addr,CP15_ACCESS_WRITE);
|
||||
// Disabled by default.
|
||||
// If you want to enable first you must know and update the address of the
|
||||
// RC4 algoritm function.
|
||||
return;
|
||||
|
||||
// This method is called twice, so ommit one call.
|
||||
extern bool nds_debug_continuing[2];
|
||||
if (nds_debug_continuing[DebugEventData.procnum]) {
|
||||
nds_debug_continuing[DebugEventData.procnum] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// RC4 encrypt / decrypt function
|
||||
// R1: Pointer to data to operate (to decrypt or encrypt)
|
||||
// R2: Size of this data
|
||||
if (DebugEventData.addr == rc4_addr[0] || DebugEventData.addr == rc4_addr[1]) {
|
||||
nds_debug_continuing[DebugEventData.procnum] = true;
|
||||
|
||||
u32 addr = DebugEventData.addr;
|
||||
printf("WIFI: Call to RC4_ALGORITM\n");
|
||||
|
||||
// Write log. Append current data
|
||||
// TODO: It needs to open the file each time, it could be slow.
|
||||
// An improvement could be opening the file at the start of the function
|
||||
// and closing at the end of the function.
|
||||
log_ptr = fopen("wifi_log.txt", "a");
|
||||
if (log_ptr != NULL)
|
||||
{
|
||||
// Create header
|
||||
time_t ti;
|
||||
time(&ti);
|
||||
tm* t = localtime(&ti);
|
||||
|
||||
fprintf(log_ptr, "\n[%02d-%02d-%02d-%02d-%02d] %s of RC4_ALGORITM -----------\n",
|
||||
t->tm_mon, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,
|
||||
(addr == rc4_addr[0]) ? "Start" : "End"
|
||||
);
|
||||
|
||||
// Dump data
|
||||
int length = DebugEventData.cpu()->R[2];
|
||||
int position = DebugEventData.cpu()->R[1] - 0x02000000; // Relative to memory array
|
||||
fwrite(MMU.MAIN_MEM + position, sizeof(char), length, log_ptr);
|
||||
|
||||
// End
|
||||
fprintf(log_ptr, "\n- THE END -----------------------------------------------\n");
|
||||
|
||||
// Flush and close by the moment
|
||||
fflush(log_ptr);
|
||||
fclose(log_ptr);
|
||||
}
|
||||
else {
|
||||
printf("Error opening log file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleDebugEvent_Execute()
|
||||
|
|
|
@ -49,11 +49,6 @@ BaseDriver::~BaseDriver()
|
|||
{
|
||||
}
|
||||
|
||||
void BaseDriver::USR_InfoMessage(const char *message)
|
||||
{
|
||||
LOG("%s\n", message);
|
||||
}
|
||||
|
||||
void BaseDriver::AddLine(const char *fmt, ...)
|
||||
{
|
||||
#if HAVE_LIBAGG
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
#include <pcap.h>
|
||||
#endif
|
||||
|
||||
class VIEW3D_Driver
|
||||
{
|
||||
|
@ -35,11 +40,57 @@ public:
|
|||
BaseDriver();
|
||||
~BaseDriver();
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
#ifdef HOST_WINDOWS
|
||||
virtual bool WIFI_SocketsAvailable() { return true; }
|
||||
virtual bool WIFI_PCapAvailable() { return false; }
|
||||
|
||||
virtual void WIFI_GetUniqueMAC(u8* mac) {}
|
||||
|
||||
virtual bool WIFI_WFCWarning() { return false; }
|
||||
|
||||
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) { return -1; }
|
||||
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {}
|
||||
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) { return NULL; }
|
||||
virtual void PCAP_close(pcap_t* dev) {}
|
||||
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) { return -1; }
|
||||
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) { return -1; }
|
||||
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) { return -1; }
|
||||
#else
|
||||
virtual bool WIFI_SocketsAvailable() { return true; }
|
||||
virtual bool WIFI_PCapAvailable() { return true; }
|
||||
|
||||
virtual void WIFI_GetUniqueMAC(u8* mac) {}
|
||||
|
||||
virtual bool WIFI_WFCWarning() { return false; }
|
||||
|
||||
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) {
|
||||
return pcap_findalldevs(alldevs, errbuf); }
|
||||
|
||||
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {
|
||||
pcap_freealldevs(alldevs); }
|
||||
|
||||
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) {
|
||||
return pcap_open_live(source, snaplen, flags, readtimeout, errbuf); }
|
||||
|
||||
virtual void PCAP_close(pcap_t* dev) {
|
||||
pcap_close(dev); }
|
||||
|
||||
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) {
|
||||
return pcap_setnonblock(dev, nonblock, errbuf); }
|
||||
|
||||
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) {
|
||||
return pcap_sendpacket(dev, data, len); }
|
||||
|
||||
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) {
|
||||
return pcap_dispatch(dev, num, callback, userdata); }
|
||||
#endif
|
||||
#endif
|
||||
virtual void AVI_SoundUpdate(void* soundData, int soundLen) {}
|
||||
virtual bool AVI_IsRecording() { return FALSE; }
|
||||
virtual bool WAV_IsRecording() { return FALSE; }
|
||||
|
||||
virtual void USR_InfoMessage(const char *message);
|
||||
virtual void USR_InfoMessage(const char *message) { LOG("%s\n", message); }
|
||||
virtual void USR_RefreshScreen() {}
|
||||
virtual void USR_SetDisplayPostpone(int milliseconds, bool drawNextFrame) {} // -1 == indefinitely, 0 == don't pospone, 500 == don't draw for 0.5 seconds
|
||||
|
||||
|
@ -56,9 +107,7 @@ public:
|
|||
virtual bool EMU_HasEmulationStarted() { return true; }
|
||||
virtual bool EMU_IsAtFrameBoundary() { return true; }
|
||||
|
||||
virtual void EMU_DebugIdleEnter() {}
|
||||
virtual void EMU_DebugIdleUpdate() {}
|
||||
virtual void EMU_DebugIdleWakeUp() {}
|
||||
|
||||
enum eDebug_IOReg
|
||||
{
|
||||
|
@ -74,5 +123,6 @@ public:
|
|||
virtual void AddLine(const char *fmt, ...);
|
||||
virtual void SetLineColor(u8 r, u8 b, u8 g);
|
||||
};
|
||||
extern BaseDriver* driver;
|
||||
|
||||
#endif //_DRIVER_H_
|
||||
|
|
|
@ -18,7 +18,11 @@
|
|||
#ifndef _AVIOUT_H_
|
||||
#define _AVIOUT_H_
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <Commdlg.h>
|
||||
#include <Shellapi.h>
|
||||
|
||||
#include <vfw.h>
|
||||
|
||||
#include <queue>
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
<!-- export other user options to preprocessor -->
|
||||
<PreprocessorDefinitions Condition="'$(DEVELOPER)' == 'true'">DEVELOPER=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(GDB_STUB)' == 'true'">GDB_STUB=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(EXPERIMENTAL_WIFI_COMM)' == 'true'">EXPERIMENTAL_WIFI_COMM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>EXPERIMENTAL_WIFI_COMM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
||||
<!-- desmume configuration: features we always have in windows -->
|
||||
<PreprocessorDefinitions>HAVE_LIBAGG=1;HAVE_JIT=1;HAVE_LUA=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <Commdlg.h>
|
||||
#include <Shellapi.h>
|
||||
|
||||
#include "hotkey.h"
|
||||
|
||||
#include "NDSSystem.h"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define INPUTDX_INCLUDED
|
||||
|
||||
#include <windows.h>
|
||||
#include <Mmsystem.h>
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include "directx/dinput.h"
|
||||
#include "directx/xinput.h"
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#include <Commdlg.h>
|
||||
#include <Shellapi.h>
|
||||
#include "driver.h"
|
||||
#include "lua-engine.h"
|
||||
|
||||
|
|
|
@ -2292,7 +2292,7 @@ static void StepRunLoop_User()
|
|||
Hud.fps3d = GPU->GetFPSRender3D();
|
||||
|
||||
// wait for the HUD to update from last frame
|
||||
WaitForSingleObject(display_done_event, display_done_timeout);
|
||||
if(frameskiprate==0) WaitForSingleObject(display_done_event, display_done_timeout);
|
||||
Display();
|
||||
|
||||
mainLoopData.fps3d = Hud.fps3d;
|
||||
|
@ -2693,7 +2693,11 @@ static void ExitRunLoop()
|
|||
emu_halt(EMUHALT_REASON_USER_REQUESTED_HALT, NDSErrorTag_None);
|
||||
}
|
||||
|
||||
class WinWifiHandler : public WifiHandler
|
||||
//-----------------------------------------------------------------------------
|
||||
// Platform driver for Win32
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WinDriver : public BaseDriver
|
||||
{
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
virtual bool WIFI_SocketsAvailable() { return bSocketsAvailable; }
|
||||
|
@ -2785,14 +2789,7 @@ class WinWifiHandler : public WifiHandler
|
|||
return _pcap_dispatch(dev, num, callback, userdata);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Platform driver for Win32
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WinDriver : public BaseDriver
|
||||
{
|
||||
virtual bool AVI_IsRecording()
|
||||
{
|
||||
return ::AVI_IsRecording();
|
||||
|
@ -2986,7 +2983,6 @@ int _main()
|
|||
#endif
|
||||
|
||||
driver = new WinDriver();
|
||||
CurrentWifiHandler = new WinWifiHandler();
|
||||
WinGPUEvent = new GPUEventHandlerWindows;
|
||||
|
||||
InitializeCriticalSection(&win_execute_sync);
|
||||
|
@ -7000,7 +6996,7 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
|
|||
|
||||
if (bWinPCapAvailable)
|
||||
{
|
||||
if(CurrentWifiHandler->PCAP_findalldevs(&alldevs, errbuf) == -1)
|
||||
if(driver->PCAP_findalldevs(&alldevs, errbuf) == -1)
|
||||
{
|
||||
// TODO: fail more gracefully!
|
||||
EndDialog(hDlg, TRUE);
|
||||
|
|
|
@ -21,7 +21,10 @@
|
|||
|
||||
#include "throttle.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <Commdlg.h>
|
||||
#include <Shellapi.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "debug.h"
|
||||
|
|
1264
desmume/src/wifi.cpp
1264
desmume/src/wifi.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +1,36 @@
|
|||
/*
|
||||
Copyright (C) 2007 Tim Seidel
|
||||
Copyright (C) 2008-2015 DeSmuME team
|
||||
/* Copyright (C) 2007 Tim Seidel
|
||||
Copyright (C) 2008-2009 DeSmuME team
|
||||
Copyright (C) 2014 pleonex
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
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 the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
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 <stdio.h>
|
||||
#include <queue>
|
||||
#include "types.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
#ifdef HOST_WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#define HAVE_REMOTE
|
||||
#define WPCAP
|
||||
#define PACKET_SIZE 65535
|
||||
#define _INC_STDIO
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -81,17 +79,17 @@
|
|||
#define REG_WIFI_CIRCBUFWR_SKIP 0x076
|
||||
|
||||
// 078 - internal
|
||||
#define REG_WIFI_TXBUF_BEACON 0x080
|
||||
#define REG_WIFI_TXLOCBEACON 0x080
|
||||
#define REG_WIFI_LISTENCOUNT 0x088
|
||||
#define REG_WIFI_BEACONPERIOD 0x08C
|
||||
#define REG_WIFI_LISTENINT 0x08E
|
||||
#define REG_WIFI_TXBUF_CMD 0x090
|
||||
#define REG_WIFI_TXBUF_REPLY1 0x094
|
||||
#define REG_WIFI_TXBUF_REPLY2 0x098
|
||||
#define REG_WIFI_TXLOCEXTRA 0x090
|
||||
// 094 - ?
|
||||
// 098 - ?
|
||||
// 09C - internal
|
||||
#define REG_WIFI_TXBUF_LOC1 0x0A0
|
||||
#define REG_WIFI_TXBUF_LOC2 0x0A4
|
||||
#define REG_WIFI_TXBUF_LOC3 0x0A8
|
||||
#define REG_WIFI_TXLOC1 0x0A0
|
||||
#define REG_WIFI_TXLOC2 0x0A4
|
||||
#define REG_WIFI_TXLOC3 0x0A8
|
||||
#define REG_WIFI_TXREQ_RESET 0x0AC
|
||||
#define REG_WIFI_TXREQ_SET 0x0AE
|
||||
#define REG_WIFI_TXREQ_READ 0x0B0
|
||||
|
@ -168,7 +166,6 @@
|
|||
#define REG_WIFI_RFSTATUS 0x214
|
||||
#define REG_WIFI_IF_SET 0x21C
|
||||
#define REG_WIFI_TXSEQNO 0x210
|
||||
#define REG_WIFI_RXTXADDR 0x268
|
||||
#define REG_WIFI_POWERACK 0x2D0
|
||||
|
||||
|
||||
|
@ -177,6 +174,11 @@
|
|||
/* WIFI misc constants */
|
||||
#define WIFI_CHIPID 0x1440 /* emulates "old" wifi chip, new is 0xC340 */
|
||||
|
||||
// SAVE PACKETS HACK FUNCTIONS
|
||||
static void create_packet();
|
||||
static void save_packet(u8* packet, u32 len, u32 seconds, u32 millis, bool isReceived);
|
||||
u32 timeval2millis(struct timeval tv);
|
||||
|
||||
/* Referenced as RF_ in dswifi: rffilter_t */
|
||||
/* based on the documentation for the RF2958 chip of RF Micro Devices */
|
||||
/* using the register names as in docs ( http://www.rfmd.com/pdfs/2958.pdf )*/
|
||||
|
@ -412,34 +414,14 @@ typedef union
|
|||
#define WIFI_IRQ_TIMEBEACON 14
|
||||
#define WIFI_IRQ_TIMEPREBEACON 15
|
||||
|
||||
struct Wifi_TXSlot
|
||||
typedef struct
|
||||
{
|
||||
u16 RegVal;
|
||||
bool enabled;
|
||||
u16 address;
|
||||
|
||||
u16 CurAddr;
|
||||
int RemPreamble; // preamble time in µs
|
||||
int RemHWords;
|
||||
u32 TimeMask; // 3 = 2mbps, 7 = 1mbps
|
||||
bool NotStarted;
|
||||
};
|
||||
|
||||
#define WIFI_TXSLOT_LOC1 0
|
||||
#define WIFI_TXSLOT_MPCMD 1
|
||||
#define WIFI_TXSLOT_LOC2 2
|
||||
#define WIFI_TXSLOT_LOC3 3
|
||||
#define WIFI_TXSLOT_BEACON 4
|
||||
#define WIFI_TXSLOT_MPREPLY 5
|
||||
#define WIFI_TXSLOT_NUM 6
|
||||
|
||||
struct Wifi_RXPacket
|
||||
{
|
||||
u8* Data;
|
||||
int CurOffset;
|
||||
int RemHWords;
|
||||
bool NotStarted;
|
||||
};
|
||||
|
||||
typedef std::queue<Wifi_RXPacket> Wifi_RXPacketQueue;
|
||||
bool sending;
|
||||
u16 remtime;
|
||||
} Wifi_TXLoc;
|
||||
|
||||
enum EAPStatus
|
||||
{
|
||||
|
@ -473,22 +455,29 @@ typedef struct
|
|||
/* sending */
|
||||
u16 TXStatCnt;
|
||||
u16 TXPower;
|
||||
u16 TXSlot[3];
|
||||
u16 TXCnt;
|
||||
u16 TXOpt;
|
||||
u16 TXStat;
|
||||
u16 BeaconAddr;
|
||||
BOOL BeaconEnable;
|
||||
u16 TXSlotExtra;
|
||||
u16 TXSeqNo;
|
||||
Wifi_TXSlot TXSlots[WIFI_TXSLOT_NUM];
|
||||
int TXCurSlot;
|
||||
u16 TXBusy;
|
||||
u8 txCurSlot;
|
||||
u8 txSlotBusy[3];
|
||||
u32 txSlotAddr[3];
|
||||
u32 txSlotLen[3];
|
||||
u32 txSlotRemainingBytes[3];
|
||||
bool ExtraSlotBusy;
|
||||
u16 ExtraSlotAddr;
|
||||
u16 ExtraSlotLen;
|
||||
u16 ExtraSlotRemBytes;
|
||||
|
||||
/* receiving */
|
||||
u16 RXCnt;
|
||||
u16 RXCheckCounter;
|
||||
u8 RXNum;
|
||||
Wifi_RXPacketQueue RXPacketQueue;
|
||||
|
||||
u16 RXStatIncIF, RXStatIncIE;
|
||||
u16 RXStatOvfIF, RXStatOvfIE;
|
||||
u8 RXStat[16];
|
||||
u16 RXTXAddr;
|
||||
|
||||
/* addressing/handshaking */
|
||||
|
@ -508,7 +497,6 @@ typedef struct
|
|||
u16 retryLimit;
|
||||
|
||||
/* timing */
|
||||
u64 GlobalUsecTimer;
|
||||
BOOL crystalEnabled;
|
||||
u64 usec;
|
||||
BOOL usecEnable;
|
||||
|
@ -547,6 +535,11 @@ typedef struct
|
|||
u16 CircBufWrEnd;
|
||||
u16 CircBufWrSkip;
|
||||
|
||||
/* tx packets */
|
||||
s32 curPacketSize[3];
|
||||
s32 curPacketPos[3];
|
||||
BOOL curPacketSending[3];
|
||||
|
||||
/* I/O ports */
|
||||
u16 IOPorts[0x800];
|
||||
|
||||
|
@ -558,6 +551,19 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
u64 usecCounter;
|
||||
|
||||
} Adhoc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u64 usecCounter;
|
||||
|
||||
u8 curPacket[4096];
|
||||
s32 curPacketSize;
|
||||
s32 curPacketPos;
|
||||
BOOL curPacketSending;
|
||||
|
||||
EAPStatus status;
|
||||
u16 seqNum;
|
||||
|
||||
|
@ -570,6 +576,7 @@ extern pcap_t *wifi_bridge;
|
|||
#endif
|
||||
|
||||
extern wifimac_t wifiMac;
|
||||
extern Adhoc_t Adhoc;
|
||||
extern SoftAP_t SoftAP;
|
||||
|
||||
bool WIFI_Init();
|
||||
|
@ -621,57 +628,6 @@ typedef struct _FW_WFCProfile
|
|||
|
||||
} FW_WFCProfile;
|
||||
|
||||
class WifiHandler
|
||||
{
|
||||
public:
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
virtual bool WIFI_SocketsAvailable() { return true; }
|
||||
virtual bool WIFI_PCapAvailable() { return false; }
|
||||
virtual void WIFI_GetUniqueMAC(u8* mac) {}
|
||||
virtual bool WIFI_WFCWarning() { return false; }
|
||||
|
||||
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) { return -1; }
|
||||
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {}
|
||||
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) { return NULL; }
|
||||
virtual void PCAP_close(pcap_t* dev) {}
|
||||
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) { return -1; }
|
||||
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) { return -1; }
|
||||
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) { return -1; }
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef HOST_WINDOWS
|
||||
class UnixWifiHandler : public WifiHandler
|
||||
{
|
||||
#ifdef EXPERIMENTAL_WIFI_COMM
|
||||
virtual bool WIFI_SocketsAvailable() { return true; }
|
||||
virtual bool WIFI_PCapAvailable() { return true; }
|
||||
virtual bool WIFI_WFCWarning() { return false; }
|
||||
|
||||
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) {
|
||||
return pcap_findalldevs(alldevs, errbuf); }
|
||||
|
||||
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {
|
||||
pcap_freealldevs(alldevs); }
|
||||
|
||||
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) {
|
||||
return pcap_open_live(source, snaplen, flags, readtimeout, errbuf); }
|
||||
|
||||
virtual void PCAP_close(pcap_t* dev) {
|
||||
pcap_close(dev); }
|
||||
|
||||
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) {
|
||||
return pcap_setnonblock(dev, nonblock, errbuf); }
|
||||
|
||||
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) {
|
||||
return pcap_sendpacket(dev, data, len); }
|
||||
|
||||
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) {
|
||||
return pcap_dispatch(dev, num, callback, userdata); }
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/* wifi data to be stored in firmware, when no firmware image was loaded */
|
||||
extern u8 FW_Mac[6];
|
||||
extern const u8 FW_WIFIInit[32];
|
||||
|
@ -682,6 +638,5 @@ extern const u8 FW_BBChannel[14];
|
|||
extern FW_WFCProfile FW_WFCProfile1;
|
||||
extern FW_WFCProfile FW_WFCProfile2;
|
||||
extern FW_WFCProfile FW_WFCProfile3;
|
||||
extern WifiHandler *CurrentWifiHandler;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue