-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
bba.c
86 lines (77 loc) · 2.37 KB
/
bba.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <network.h>
#include <ogcsys.h>
#include "exi.h"
#include "swiss.h"
#include "deviceHandler.h"
/* Network Globals */
int net_initialized = 0;
struct in_addr bba_localip;
struct in_addr bba_netmask;
struct in_addr bba_gateway;
// Init the GC net interface (bba)
void init_network(void *args) {
int res = 0;
if(!net_initialized) {
inet_aton(swissSettings.bbaLocalIp, &bba_localip);
bba_netmask.s_addr = INADDR_BROADCAST << (32 - swissSettings.bbaNetmask);
inet_aton(swissSettings.bbaGateway, &bba_gateway);
res = if_configex(&bba_localip, &bba_netmask, &bba_gateway, swissSettings.bbaUseDhcp);
if(res >= 0) {
strcpy(swissSettings.bbaLocalIp, inet_ntoa(bba_localip));
swissSettings.bbaNetmask = (32 - __builtin_ctz(bba_netmask.s_addr));
strcpy(swissSettings.bbaGateway, inet_ntoa(bba_gateway));
net_initialized = 1;
}
else {
net_initialized = 0;
}
if(if_nametoindex("E20") == 1
|| if_nametoindex("EA0") == 1
|| if_nametoindex("EB0") == 1) {
if(__device_gcloader.features & FEAT_PATCHES)
__device_gcloader.emulable |= EMU_ETHERNET;
__device_ata_c.emulable |= EMU_ETHERNET;
__device_sd_c.emulable |= EMU_ETHERNET;
__device_sd_a.emulable |= EMU_ETHERNET;
__device_sd_b.emulable |= EMU_ETHERNET;
__device_ata_a.emulable |= EMU_ETHERNET;
__device_ata_b.emulable |= EMU_ETHERNET;
}
deviceHandler_setDeviceAvailable(&__device_smb, deviceHandler_SMB_test());
deviceHandler_setDeviceAvailable(&__device_ftp, deviceHandler_FTP_test());
deviceHandler_setDeviceAvailable(&__device_fsp, deviceHandler_FSP_test());
}
}
bool bba_exists(u32 location)
{
u32 id;
if ((location & LOC_MEMCARD_SLOT_A) && EXI_GetID(EXI_CHANNEL_0, EXI_DEVICE_0, &id)) {
switch (id) {
case EXI_ENC28J60_ID:
return true;
}
}
if ((location & LOC_MEMCARD_SLOT_B) && EXI_GetID(EXI_CHANNEL_1, EXI_DEVICE_0, &id)) {
switch (id) {
case EXI_ENC28J60_ID:
return true;
}
}
if ((location & LOC_SERIAL_PORT_1) && EXI_GetID(EXI_CHANNEL_0, EXI_DEVICE_2, &id)) {
switch (id) {
case EXI_MX98730EC_ID:
case EXI_ENC28J60_ID:
return true;
}
}
if ((location & LOC_SERIAL_PORT_2) && EXI_GetID(EXI_CHANNEL_2, EXI_DEVICE_0, &id)) {
switch (id) {
case EXI_ENC28J60_ID:
return true;
}
}
return false;
}