Latest compatible version of Classicube from the original GitHub repository (https://github.com/ClassiCube/ClassiCube) that can be compiled on Classicube for PowerMac PPC running Mac OS X 10.4.

This commit is contained in:
Andrei Alexandru
2025-12-17 13:17:57 +02:00
commit c71492f846
1248 changed files with 422858 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2021 Max Thomas
* This file is part of DSiWifi and is distributed under the MIT license.
* See dsiwifi_license.txt for terms of use.
*/
#ifndef _DSIWIFI_COMMON_H
#define _DSIWIFI_COMMON_H
#include <inttypes.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define BIT(n) (1 << (n))
#define max(a, b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define min(a, b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
#endif // _DSIWIFI_COMMON_H

View File

@@ -0,0 +1,179 @@
//////////////////////////////////////////////////////////////////////////
// DSRegs.h - (c) 2005-2006 Stephen Stair
// General reference mumbo jumbo to give me easy access to the regs I like.
//////////////////////////////////////////////////////////////////////////
/******************************************************************************
DSWifi Lib and test materials are licenced under the MIT open source licence:
Copyright (c) 2005-2006 Stephen Stair
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef DSREGS_H
#define DSREGS_H
#include <nds.h>
//////////////////////////////////////////////////////////////////////////
// General registers
// general memory range defines
#define PAL ((u16 *) 0x05000000)
#define VRAM1 ((u16 *) 0x06000000)
#define VRAM2 ((u16 *) 0x06200000)
//#define OAM ((u16 *) 0x07000000)
#define CART ((u16 *) 0x08000000)
// video registers
#define DISPCNT (*((u32 volatile *) 0x04000000))
#define DISPSTAT (*((u16 volatile *) 0x04000004))
#define VCOUNT (*((u16 volatile *) 0x04000006))
#define BG0CNT (*((u16 volatile *) 0x04000008))
#define BG1CNT (*((u16 volatile *) 0x0400000A))
#define BG2CNT (*((u16 volatile *) 0x0400000C))
#define BG3CNT (*((u16 volatile *) 0x0400000E))
#define BG0HOFS (*((u16 volatile *) 0x04000010))
#define BG0VOFS (*((u16 volatile *) 0x04000012))
#define BG1HOFS (*((u16 volatile *) 0x04000014))
#define BG1VOFS (*((u16 volatile *) 0x04000016))
#define BG2HOFS (*((u16 volatile *) 0x04000018))
#define BG2VOFS (*((u16 volatile *) 0x0400001A))
#define BG3HOFS (*((u16 volatile *) 0x0400001C))
#define BG3VOFS (*((u16 volatile *) 0x0400001E))
#define BG2PA (*((u16 volatile *) 0x04000020))
#define BG2PB (*((u16 volatile *) 0x04000022))
#define BG2PC (*((u16 volatile *) 0x04000024))
#define BG2PD (*((u16 volatile *) 0x04000026))
#define BG2X (*((u32 volatile *) 0x04000028))
#define BG2Y (*((u32 volatile *) 0x0400002C))
#define BG3PA (*((u16 volatile *) 0x04000030))
#define BG3PB (*((u16 volatile *) 0x04000032))
#define BG3PC (*((u16 volatile *) 0x04000034))
#define BG3PD (*((u16 volatile *) 0x04000036))
#define BG3X (*((u32 volatile *) 0x04000038))
#define BG3Y (*((u32 volatile *) 0x0400003C))
#define WIN0H (*((u16 volatile *) 0x04000040))
#define WIN1H (*((u16 volatile *) 0x04000042))
#define WIN0V (*((u16 volatile *) 0x04000044))
#define WIN1V (*((u16 volatile *) 0x04000046))
#define WININ (*((u16 volatile *) 0x04000048))
#define WINOUT (*((u16 volatile *) 0x0400004A))
#define MOSAIC (*((u16 volatile *) 0x0400004C))
#define BLDCNT (*((u16 volatile *) 0x04000050))
#define BLDALPHA (*((u16 volatile *) 0x04000052))
#define BLDY (*((u16 volatile *) 0x04000054))
#define DISPCNT2 (*((u32 volatile *) 0x04001000))
#define DISPSTAT2 (*((u16 volatile *) 0x04001004))
#define VCOUNT2 (*((u16 volatile *) 0x04001006))
#define BG0CNT2 (*((u16 volatile *) 0x04001008))
#define BG1CNT2 (*((u16 volatile *) 0x0400100A))
#define BG2CNT2 (*((u16 volatile *) 0x0400100C))
#define BG3CNT2 (*((u16 volatile *) 0x0400100E))
#define BG0HOFS2 (*((u16 volatile *) 0x04001010))
#define BG0VOFS2 (*((u16 volatile *) 0x04001012))
#define BG1HOFS2 (*((u16 volatile *) 0x04001014))
#define BG1VOFS2 (*((u16 volatile *) 0x04001016))
#define BG2HOFS2 (*((u16 volatile *) 0x04001018))
#define BG2VOFS2 (*((u16 volatile *) 0x0400101A))
#define BG3HOFS2 (*((u16 volatile *) 0x0400101C))
#define BG3VOFS2 (*((u16 volatile *) 0x0400101E))
#define BG2PA2 (*((u16 volatile *) 0x04001020))
#define BG2PB2 (*((u16 volatile *) 0x04001022))
#define BG2PC2 (*((u16 volatile *) 0x04001024))
#define BG2PD2 (*((u16 volatile *) 0x04001026))
#define BG2X2 (*((u32 volatile *) 0x04001028))
#define BG2Y2 (*((u32 volatile *) 0x0400102C))
#define BG3PA2 (*((u16 volatile *) 0x04001030))
#define BG3PB2 (*((u16 volatile *) 0x04001032))
#define BG3PC2 (*((u16 volatile *) 0x04001034))
#define BG3PD2 (*((u16 volatile *) 0x04001036))
#define BG3X2 (*((u32 volatile *) 0x04001038))
#define BG3Y2 (*((u32 volatile *) 0x0400103C))
#define WIN0H2 (*((u16 volatile *) 0x04001040))
#define WIN1H2 (*((u16 volatile *) 0x04001042))
#define WIN0V2 (*((u16 volatile *) 0x04001044))
#define WIN1V2 (*((u16 volatile *) 0x04001046))
#define WININ2 (*((u16 volatile *) 0x04001048))
#define WINOUT2 (*((u16 volatile *) 0x0400104A))
#define MOSAIC2 (*((u16 volatile *) 0x0400104C))
#define BLDCNT2 (*((u16 volatile *) 0x04001050))
#define BLDALPHA2 (*((u16 volatile *) 0x04001052))
#define BLDY2 (*((u16 volatile *) 0x04001054))
// video memory defines
#define PAL_BG1 ((u16 *) 0x05000000)
#define PAL_FG1 ((u16 *) 0x05000200)
#define PAL_BG2 ((u16 *) 0x05000400)
#define PAL_FG2 ((u16 *) 0x05000600)
// other video defines
#define VRAMBANKCNT (((u16 volatile *) 0x04000240))
#define RGB(r,g,b) ( ((r)&31) | (((g)&31)<<5) | (((b)&31)<<10) )
#define VRAM_SETBANK(bank, set) \
if((bank)&1) { VRAMBANKCNT[(bank)>>1] = (VRAMBANKCNT[(bank)>>1]&0x00ff) | (((set)&0xff)<<8); } else \
{ VRAMBANKCNT[(bank)>>1] = (VRAMBANKCNT[(bank)>>1]&0xff00) | ((set)&0xff); }
// joypad input
#define KEYINPUT (*((u16 volatile *) 0x04000130))
#define KEYCNT (*((u16 volatile *) 0x04000132))
// System registers
#define WAITCNT (*((u16 volatile *) 0x04000204))
//#define IME (*((u16 volatile *) 0x04000208))
//#define IE (*((u32 volatile *) 0x04000210))
//#define IF (*((u32 volatile *) 0x04000214))
#define HALTCNT (*((u16 volatile *) 0x04000300))
//////////////////////////////////////////////////////////////////////////
// ARM7 specific registers
#ifdef ARM7
#define POWERCNT7 (*((u16 volatile *) 0x04000304))
#define SPI_CR (*((u16 volatile *) 0x040001C0))
#define SPI_DATA (*((u16 volatile *) 0x040001C2))
#endif
//////////////////////////////////////////////////////////////////////////
// ARM9 specific registers
#ifdef ARM9
#define POWERCNT (*((u16 volatile *) 0x04000308))
#endif
// End of file!
#endif

View File

@@ -0,0 +1,63 @@
// DS Wifi interface code
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
// spinlock.h - code for spinlocking for basic wifi structure memory protection
/******************************************************************************
DSWifi Lib and test materials are licenced under the MIT open source licence:
Copyright (c) 2005-2006 Stephen Stair
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
/*
__asm (
".GLOBL SLasm_Acquire, SLasm_Release \n"
".ARM \n"
"SLasm_Acquire: \n"
" ldr r2,[r0] \n"
" cmp r2,#0 \n"
" movne r0,#1 \n"
" bxne lr \n"
" mov r2,r1 \n"
" swp r2,r2,[r0] \n"
" cmp r2,#0 \n"
" cmpne r2,r1 \n"
" moveq r0,#0 \n"
" bxeq lr \n"
" swp r2,r2,[r0] \n"
" mov r0,#1 \n"
" bx lr \n"
"\n\n"
"SLasm_Release: \n"
" ldr r2,[r0] \n"
" cmp r2,r1 \n"
" movne r0,#2 \n"
" bxne lr \n"
" mov r2,#0 \n"
" swp r2,r2,[r0] \n"
" cmp r2,r1 \n"
" moveq r0,#0 \n"
" movne r0,#2 \n"
" bx lr \n"
);
*/

View File

@@ -0,0 +1,49 @@
#ifdef ARM7
.arch armv4t
.cpu arm7tdmi
#else
#ifdef ARM9
.arch armv5te
.cpu arm946e-s
#endif
#endif
.text
.arm
.global SLasm_Acquire
.type SLasm_Acquire STT_FUNC
@---------------------------------------------------------------------------------
SLasm_Acquire:
@---------------------------------------------------------------------------------
ldr r2,[r0]
cmp r2,#0
movne r0,#1
bxne lr
mov r2,r1
swp r2,r2,[r0]
cmp r2,#0
cmpne r2,r1
moveq r0,#0
bxeq lr
swp r2,r2,[r0]
mov r0,#1
bx lr
.global SLasm_Release
.type SLasm_Release STT_FUNC
@---------------------------------------------------------------------------------
SLasm_Release:
@---------------------------------------------------------------------------------
ldr r2,[r0]
cmp r2,r1
movne r0,#2
bxne lr
mov r2,#0
swp r2,r2,[r0]
cmp r2,r1
moveq r0,#0
movne r0,#2
bx lr
.pool
.end

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2021 Max Thomas
* This file is part of DSiWifi and is distributed under the MIT license.
* See dsiwifi_license.txt for terms of use.
*/
#ifndef _DSIWIFI_UTILS_H
#define _DSIWIFI_UTILS_H
#include "common.h"
#define round_up(x, n) ( ((x) + (n)-1) & (~((n)-1)) )
static inline void ioDelay(u32 count)
{
int i;
for (i = 0; i < count; i++)
__asm__ volatile ("");
}
static inline u32 getle32(const void *p)
{
const u8 *cp = p;
return (u32)cp[0] + ((u32)cp[1] << 8) +
((u32)cp[2] << 16) + ((u32)cp[3] << 24);
}
static inline u64 getle64(const u8* p)
{
u64 n = p[0];
n |= (u64)p[1] << 8;
n |= (u64)p[2] << 16;
n |= (u64)p[3] << 24;
n |= (u64)p[4] << 32;
n |= (u64)p[5] << 40;
n |= (u64)p[6] << 48;
n |= (u64)p[7] << 56;
return n;
}
static inline u64 getbe64(const u8* p)
{
u64 n = 0;
n |= (u64)p[0] << 56;
n |= (u64)p[1] << 48;
n |= (u64)p[2] << 40;
n |= (u64)p[3] << 32;
n |= (u64)p[4] << 24;
n |= (u64)p[5] << 16;
n |= (u64)p[6] << 8;
n |= (u64)p[7] << 0;
return n;
}
static inline u32 getbe32(const u8* p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3] << 0);
}
static inline u32 getle16(const u8* p)
{
return (p[0] << 0) | (p[1] << 8);
}
static inline u32 getbe16(const u8* p)
{
return (p[0] << 8) | (p[1] << 0);
}
static inline void putle16(u8* p, u16 n)
{
p[0] = n;
p[1] = n >> 8;
}
static inline void putbe16(u8* p, u16 n)
{
p[0] = n >> 8;
p[1] = n;
}
static inline void putle32(u8* p, u32 n)
{
p[0] = n;
p[1] = n >> 8;
p[2] = n >> 16;
p[3] = n >> 24;
}
static inline void putbe64(u8* p, u64 n)
{
p[0] = n >> 56;
p[1] = n >> 48;
p[2] = n >> 40;
p[3] = n >> 32;
p[4] = n >> 24;
p[5] = n >> 16;
p[6] = n >> 8;
p[7] = n >> 0;
}
void hexdump(const void* data, size_t size);
#endif // _DSIWIFI_UTILS_H

View File

@@ -0,0 +1,286 @@
// DS Wifi interface code
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
// wifi_shared.h - Shared structures to be used by arm9 and arm7
/******************************************************************************
DSWifi Lib and test materials are licenced under the MIT open source licence:
Copyright (c) 2005-2006 Stephen Stair
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef WIFI_SHARED_H
#define WIFI_SHARED_H
#include <nds.h>
#define WIFIINIT_OPTION_USELED 0x0002
// on spinlock contention, the side unsuccessfully attempting the lock reverts the lock.
// if the unlocking side sees the lock incorrectly set, the unlocking side will delay until it has reverted to the correct value, then continue unlocking.
// there should be a delay of at least about ~10-20 cycles between a lock and unlock, to prevent contention.
#define SPINLOCK_NOBODY 0x0000
#define SPINLOCK_ARM7 0x0001
#define SPINLOCK_ARM9 0x0002
#define SPINLOCK_OK 0x0000
#define SPINLOCK_INUSE 0x0001
#define SPINLOCK_ERROR 0x0002
#ifdef ARM7
#define SPINLOCK_VALUE SPINLOCK_ARM7
#endif
#ifdef ARM9
#define SPINLOCK_VALUE SPINLOCK_ARM9
#endif
#define Spinlock_Acquire(structtolock) SLasm_Acquire(&((structtolock).spinlock),SPINLOCK_VALUE)
#define Spinlock_Release(structtolock) SLasm_Release(&((structtolock).spinlock),SPINLOCK_VALUE)
#define Spinlock_Check(structtolock) (((structtolock).spinlock)!=SPINLOCK_NOBODY)
#ifdef __cplusplus
extern "C" {
#endif
extern u32 SLasm_Acquire(volatile u32 * lockaddr, u32 lockvalue);
extern u32 SLasm_Release(volatile u32 * lockaddr, u32 lockvalue);
#ifdef __cplusplus
};
#endif
// If for whatever reason you want to ditch SGIP and use your own stack, comment out the following line.
#define WIFI_USE_TCP_SGIP 0
#define WIFI_RXBUFFER_SIZE (1024*12)
#define WIFI_TXBUFFER_SIZE (1024*24)
#define WIFI_MAX_AP 32
#define WIFI_MAX_ASSOC_RETRY 30
#define WIFI_PS_POLL_CONST 2
#define WIFI_MAX_PROBE 4
#define WIFI_AP_TIMEOUT 40
#define WFLAG_PACKET_DATA 0x0001
#define WFLAG_PACKET_MGT 0x0002
#define WFLAG_PACKET_BEACON 0x0004
#define WFLAG_PACKET_CTRL 0x0008
#define WFLAG_PACKET_ALL 0xFFFF
#define WFLAG_ARM7_ACTIVE 0x0001
#define WFLAG_ARM7_RUNNING 0x0002
#define WFLAG_ARM9_ACTIVE 0x0001
#define WFLAG_ARM9_USELED 0x0002
#define WFLAG_ARM9_ARM7READY 0x0004
#define WFLAG_ARM9_NETUP 0x0008
#define WFLAG_ARM9_NETREADY 0x0010
#define WFLAG_ARM9_INITFLAGMASK 0x0002
#define WFLAG_IP_GOTDHCP 0x0001
// request - request flags
#define WFLAG_REQ_APCONNECT 0x0001
#define WFLAG_REQ_APCOPYVALUES 0x0002
#define WFLAG_REQ_APADHOC 0x0008
#define WFLAG_REQ_PROMISC 0x0010
#define WFLAG_REQ_USEWEP 0x0020
// request - informational flags
#define WFLAG_REQ_APCONNECTED 0x8000
#define WFLAG_APDATA_ADHOC 0x0001
#define WFLAG_APDATA_WEP 0x0002
#define WFLAG_APDATA_WPA 0x0004
#define WFLAG_APDATA_COMPATIBLE 0x0008
#define WFLAG_APDATA_EXTCOMPATIBLE 0x0010
#define WFLAG_APDATA_SHORTPREAMBLE 0x0020
#define WFLAG_APDATA_ACTIVE 0x8000
enum WIFI_RETURN {
WIFI_RETURN_OK = 0, // Everything went ok
WIFI_RETURN_LOCKFAILED = 1, // the spinlock attempt failed (it wasn't retried cause that could lock both cpus- retry again after a delay.
WIFI_RETURN_ERROR = 2, // There was an error in attempting to complete the requested task.
WIFI_RETURN_PARAMERROR = 3, // There was an error in the parameters passed to the function.
};
enum WIFI_STATS {
// software stats
WSTAT_RXQUEUEDPACKETS, // number of packets queued into the rx fifo
WSTAT_TXQUEUEDPACKETS, // number of packets queued into the tx fifo
WSTAT_RXQUEUEDBYTES, // number of bytes queued into the rx fifo
WSTAT_TXQUEUEDBYTES, // number of bytes queued into the tx fifo
WSTAT_RXQUEUEDLOST, // number of packets lost due to space limitations in queuing
WSTAT_TXQUEUEDREJECTED, // number of packets rejected due to space limitations in queuing
WSTAT_RXPACKETS,
WSTAT_RXBYTES,
WSTAT_RXDATABYTES,
WSTAT_TXPACKETS,
WSTAT_TXBYTES,
WSTAT_TXDATABYTES,
WSTAT_ARM7_UPDATES,
WSTAT_DEBUG,
// harware stats (function mostly unknown.)
WSTAT_HW_1B0,WSTAT_HW_1B1,WSTAT_HW_1B2,WSTAT_HW_1B3,WSTAT_HW_1B4,WSTAT_HW_1B5,WSTAT_HW_1B6,WSTAT_HW_1B7,
WSTAT_HW_1B8,WSTAT_HW_1B9,WSTAT_HW_1BA,WSTAT_HW_1BB,WSTAT_HW_1BC,WSTAT_HW_1BD,WSTAT_HW_1BE,WSTAT_HW_1BF,
WSTAT_HW_1C0,WSTAT_HW_1C1,WSTAT_HW_1C4,WSTAT_HW_1C5,
WSTAT_HW_1D0,WSTAT_HW_1D1,WSTAT_HW_1D2,WSTAT_HW_1D3,WSTAT_HW_1D4,WSTAT_HW_1D5,WSTAT_HW_1D6,WSTAT_HW_1D7,
WSTAT_HW_1D8,WSTAT_HW_1D9,WSTAT_HW_1DA,WSTAT_HW_1DB,WSTAT_HW_1DC,WSTAT_HW_1DD,WSTAT_HW_1DE,WSTAT_HW_1DF,
NUM_WIFI_STATS
};
enum WIFI_MODE {
WIFIMODE_DISABLED,
WIFIMODE_NORMAL,
WIFIMODE_SCAN,
WIFIMODE_ASSOCIATE,
WIFIMODE_ASSOCIATED,
WIFIMODE_DISASSOCIATE,
WIFIMODE_CANNOTASSOCIATE,
};
enum WIFI_AUTHLEVEL {
WIFI_AUTHLEVEL_DISCONNECTED,
WIFI_AUTHLEVEL_AUTHENTICATED,
WIFI_AUTHLEVEL_ASSOCIATED,
WIFI_AUTHLEVEL_DEASSOCIATED,
};
enum WEPMODES {
WEPMODE_NONE = 0,
WEPMODE_40BIT = 1,
WEPMODE_128BIT = 2
};
enum WIFI_ASSOCSTATUS {
ASSOCSTATUS_DISCONNECTED, // not *trying* to connect
ASSOCSTATUS_SEARCHING, // data given does not completely specify an AP, looking for AP that matches the data.
ASSOCSTATUS_AUTHENTICATING, // connecting...
ASSOCSTATUS_ASSOCIATING, // connecting...
ASSOCSTATUS_ACQUIRINGDHCP, // connected to AP, but getting IP data from DHCP
ASSOCSTATUS_ASSOCIATED, // Connected! (COMPLETE if Wifi_ConnectAP was called to start)
ASSOCSTATUS_CANNOTCONNECT, // error in connecting... (COMPLETE if Wifi_ConnectAP was called to start)
};
typedef struct WIFI_TXHEADER {
u16 enable_flags;
u16 unknown;
u16 countup;
u16 beaconfreq;
u16 tx_rate;
u16 tx_length;
} Wifi_TxHeader;
typedef struct WIFI_RXHEADER {
u16 a;
u16 b;
u16 c;
u16 d;
u16 byteLength;
u16 rssi_;
} Wifi_RxHeader;
typedef struct WIFI_ACCESSPOINT {
char ssid[33]; // 0-32byte data, zero
char ssid_len;
u8 bssid[6];
u8 macaddr[6];
u16 maxrate; // max rate is measured in steps of 1/2Mbit - 5.5Mbit will be represented as 11, or 0x0B
u32 timectr;
u16 rssi;
u16 flags;
u32 spinlock;
u8 channel;
u8 rssi_past[8];
u8 base_rates[16]; // terminated by a 0 entry
} Wifi_AccessPoint;
typedef struct WIFI_MAINSTRUCT {
unsigned long dummy1[8];
// wifi status
u16 curChannel, reqChannel;
u16 curMode, reqMode;
u16 authlevel,authctr;
vu32 flags9, flags7;
u32 reqPacketFlags;
u16 curReqFlags, reqReqFlags;
u32 counter7,bootcounter7;
u16 MacAddr[3];
u16 authtype;
u16 iptype,ipflags;
u32 ip,snmask,gateway;
// current AP data
char ssid7[34],ssid9[34];
u16 bssid7[3], bssid9[3];
u8 apmac7[6], apmac9[6];
char wepmode7, wepmode9;
char wepkeyid7, wepkeyid9;
u8 wepkey7[20],wepkey9[20];
u8 baserates7[16], baserates9[16];
u8 apchannel7, apchannel9;
u8 maxrate7;
u16 ap_rssi;
u16 pspoll_period;
// AP data
Wifi_AccessPoint aplist[WIFI_MAX_AP];
// probe stuff
u8 probe9_numprobe;
u8 probe9_ssidlen[WIFI_MAX_PROBE];
char probe9_ssid[WIFI_MAX_PROBE][32];
// WFC data
u8 wfc_enable[4]; // wep mode, or 0x80 for "enabled"
Wifi_AccessPoint wfc_ap[3];
unsigned long wfc_config[3][5]; // ip, gateway, snmask, primarydns, 2nddns
u8 wfc_wepkey[3][16];
// wifi data
u32 rxbufIn, rxbufOut; // bufIn/bufOut have 2-byte granularity.
u16 rxbufData[WIFI_RXBUFFER_SIZE/2]; // send raw 802.11 data through! rxbuffer is for rx'd data, arm7->arm9 transfer
u32 txbufIn, txbufOut;
u16 txbufData[WIFI_TXBUFFER_SIZE/2]; // tx buffer is for data to tx, arm9->arm7 transfer
// stats data
u32 stats[NUM_WIFI_STATS];
u16 debug[30];
u32 random; // semirandom number updated at the convenience of the arm7. use for initial seeds & such.
unsigned long dummy2[8];
} Wifi_MainStruct;
#endif