Skip to content

Commit 8a71c53

Browse files
authored
Merge pull request #822 from uyjulian/smap_related_changes
Implement netdev API
2 parents 88485de + 66e4824 commit 8a71c53

File tree

17 files changed

+1272
-103
lines changed

17 files changed

+1272
-103
lines changed

iop/network/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SUBDIRS = \
1313
smap \
1414
smap-modular-netman \
1515
smap-modular-none \
16+
smap-netdev \
1617
smap-none \
1718
smap-ps2ip \
1819
smbman \

iop/network/netman/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ IOP_IMPORT_INCS += \
1818
system/sysmem \
1919
system/threadman
2020

21-
IOP_OBJS = netman.o rpc_server.o rpc_client.o imports.o exports.o
21+
IOP_OBJS = \
22+
netman.o \
23+
rpc_server.o \
24+
rpc_client.o \
25+
netdev.o \
26+
imports.o \
27+
exports.o
2228

2329
include $(PS2SDKSRC)/Defs.make
2430
include $(PS2SDKSRC)/iop/Rules.bin.make
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
#ifndef _NETDEV_H
12+
#define _NETDEV_H
13+
14+
#include <tamtypes.h>
15+
16+
#define sceInetBus_Unknown 0
17+
#define sceInetBus_USB 1
18+
#define sceInetBus_1394 2
19+
#define sceInetBus_PCMCIA 3
20+
#define sceInetBus_PSEUDO 4
21+
#define sceInetBus_NIC 5
22+
23+
#define sceInetDevProtVer 2
24+
25+
#define sceInetDevF_Up 0x0001
26+
#define sceInetDevF_Running 0x0002
27+
#define sceInetDevF_Broadcast 0x0004
28+
#define sceInetDevF_ARP 0x0010
29+
#define sceInetDevF_DHCP 0x0020
30+
#define sceInetDevF_PPP 0x0040
31+
#define sceInetDevF_NIC 0x0080
32+
#define sceInetDevF_Error 0x0100
33+
#define sceInetDevF_PPPoE 0x0200
34+
#define sceInetDevF_Multicast 0x0400
35+
36+
#define sceInetDevEFP_StartDone 0x00000001
37+
#define sceInetDevEFP_PlugOut 0x00000002
38+
#define sceInetDevEFP_Recv 0x00000004
39+
#define sceInetDevEFP_Error 0x00000010
40+
#define sceInetDevEFP_TimeOut 0x00000020
41+
#define sceInetDevEFP_InetUse 0xffff0000
42+
43+
#define sceInetDevDHCP_RelOnStop 0x00000001
44+
45+
#define sceInetNDCC_GET_THPRI 0x80000000
46+
#define sceInetNDCC_SET_THPRI 0x81000000
47+
#define sceInetNDCC_GET_IF_TYPE 0x80000100
48+
#define sceInetNDCC_GET_RX_PACKETS 0x80010000
49+
#define sceInetNDCC_GET_TX_PACKETS 0x80010001
50+
#define sceInetNDCC_GET_RX_BYTES 0x80010002
51+
#define sceInetNDCC_GET_TX_BYTES 0x80010003
52+
#define sceInetNDCC_GET_RX_ERRORS 0x80010004
53+
#define sceInetNDCC_GET_TX_ERRORS 0x80010005
54+
#define sceInetNDCC_GET_RX_DROPPED 0x80010006
55+
#define sceInetNDCC_GET_TX_DROPPED 0x80010007
56+
#define sceInetNDCC_GET_RX_BROADCAST_PACKETS 0x80010008
57+
#define sceInetNDCC_GET_TX_BROADCAST_PACKETS 0x80010009
58+
#define sceInetNDCC_GET_RX_BROADCAST_BYTES 0x8001000a
59+
#define sceInetNDCC_GET_TX_BROADCAST_BYTES 0x8001000b
60+
#define sceInetNDCC_GET_RX_MULTICAST_PACKETS 0x8001000c
61+
#define sceInetNDCC_GET_TX_MULTICAST_PACKETS 0x8001000d
62+
#define sceInetNDCC_GET_RX_MULTICAST_BYTES 0x8001000e
63+
#define sceInetNDCC_GET_TX_MULTICAST_BYTES 0x8001000f
64+
65+
#define sceInetNDIFT_GENERIC 0x00000000
66+
#define sceInetNDIFT_ETHERNET 0x00000001
67+
#define sceInetNDIFT_PPP 0x00000002
68+
69+
#define sceInetNDCC_GET_MULTICAST 0x80011000
70+
#define sceInetNDCC_GET_COLLISIONS 0x80011001
71+
#define sceInetNDCC_GET_RX_LENGTH_ER 0x80011002
72+
#define sceInetNDCC_GET_RX_OVER_ER 0x80011003
73+
#define sceInetNDCC_GET_RX_CRC_ER 0x80011004
74+
#define sceInetNDCC_GET_RX_FRAME_ER 0x80011005
75+
#define sceInetNDCC_GET_RX_FIFO_ER 0x80011006
76+
#define sceInetNDCC_GET_RX_MISSED_ER 0x80011007
77+
#define sceInetNDCC_GET_TX_ABORTED_ER 0x80011008
78+
#define sceInetNDCC_GET_TX_CARRIER_ER 0x80011009
79+
#define sceInetNDCC_GET_TX_FIFO_ER 0x8001100a
80+
#define sceInetNDCC_GET_TX_HEARTBEAT_ER 0x8001100b
81+
#define sceInetNDCC_GET_TX_WINDOW_ER 0x8001100c
82+
#define sceInetNDCC_GET_NEGO_MODE 0x80020000
83+
#define sceInetNDCC_SET_NEGO_MODE 0x81020000
84+
#define sceInetNDCC_GET_NEGO_STATUS 0x80020001
85+
#define sceInetNDCC_GET_LINK_STATUS 0x80030000
86+
#define sceInetNDCC_SET_MULTICAST_LIST 0x81040000
87+
88+
#define sceInetNDNEGO_10 0x0001
89+
#define sceInetNDNEGO_10_FD 0x0002
90+
#define sceInetNDNEGO_TX 0x0004
91+
#define sceInetNDNEGO_TX_FD 0x0008
92+
#define sceInetNDNEGO_PAUSE 0x0040
93+
#define sceInetNDNEGO_AUTO 0x0080
94+
95+
typedef struct sceInetPkt
96+
{
97+
struct sceInetPkt *forw;
98+
struct sceInetPkt *back;
99+
#ifdef NETDEV_OPAQUE
100+
int reserved[2];
101+
#else
102+
void *m_reserved1;
103+
void *m_reserved2;
104+
#endif
105+
u8 *rp;
106+
u8 *wp;
107+
} sceInetPkt_t;
108+
109+
typedef struct sceInetPktQ
110+
{
111+
struct sceInetPkt *head;
112+
struct sceInetPkt *tail;
113+
} sceInetPktQ_t;
114+
115+
typedef struct sceInetDevOps
116+
{
117+
struct sceInetDevOps *forw;
118+
struct sceInetDevOps *back;
119+
char interface[9];
120+
char *module_name;
121+
char *vendor_name;
122+
char *device_name;
123+
u8 bus_type;
124+
u8 bus_loc[31];
125+
u16 prot_ver;
126+
u16 impl_ver;
127+
void *priv;
128+
int flags;
129+
int evfid;
130+
struct sceInetPktQ rcvq;
131+
struct sceInetPktQ sndq;
132+
int (*start)(void *priv, int flags);
133+
int (*stop)(void *priv, int flags);
134+
int (*xmit)(void *priv, int flags);
135+
int (*control)(void *priv, int code, void *ptr, int len);
136+
unsigned int ip_addr;
137+
unsigned int ip_mask;
138+
unsigned int broad_addr;
139+
unsigned int gw_addr;
140+
unsigned int ns_addr1;
141+
int mtu;
142+
u8 hw_addr[16];
143+
u8 dhcp_hostname[256];
144+
int dhcp_hostname_len;
145+
int dhcp_flags;
146+
void *reserved[4];
147+
unsigned int ns_addr2;
148+
void *pppoe_priv;
149+
} sceInetDevOps_t;
150+
151+
extern int sceInetRegisterNetDevice(sceInetDevOps_t *ops);
152+
extern int sceInetUnregisterNetDevice(sceInetDevOps_t *ops);
153+
extern void *sceInetAllocMem(sceInetDevOps_t *ops, int siz);
154+
extern void sceInetFreeMem(sceInetDevOps_t *ops, void *ptr);
155+
extern void sceInetPktEnQ(sceInetPktQ_t *que, sceInetPkt_t *pkt);
156+
extern sceInetPkt_t *sceInetPktDeQ(sceInetPktQ_t *que);
157+
extern unsigned int sceInetRand(void);
158+
extern int sceInetPrintf(const char *fmt, ...);
159+
extern sceInetPkt_t *sceInetAllocPkt(sceInetDevOps_t *ops, int siz);
160+
extern void sceInetFreePkt(sceInetDevOps_t *ops, sceInetPkt_t *pkt);
161+
// TODO: sceInetRegisterPPPoE
162+
// TODO: sceInetUnregisterPPPoE
163+
164+
#define netdev_IMPORTS_start DECLARE_IMPORT_TABLE(netdev, 1, 1)
165+
#define netdev_IMPORTS_end END_IMPORT_TABLE
166+
167+
#define I_sceInetRegisterNetDevice DECLARE_IMPORT(4, sceInetRegisterNetDevice)
168+
#define I_sceInetUnregisterNetDevice DECLARE_IMPORT(5, sceInetUnregisterNetDevice)
169+
#define I_sceInetAllocMem DECLARE_IMPORT(6, sceInetAllocMem)
170+
#define I_sceInetFreeMem DECLARE_IMPORT(7, sceInetFreeMem)
171+
#define I_sceInetPktEnQ DECLARE_IMPORT(8, sceInetPktEnQ)
172+
#define I_sceInetPktDeQ DECLARE_IMPORT(9, sceInetPktDeQ)
173+
#define I_sceInetRand DECLARE_IMPORT(10, sceInetRand)
174+
#define I_sceInetPrintf DECLARE_IMPORT(11, sceInetPrintf)
175+
#define I_sceInetAllocPkt DECLARE_IMPORT(12, sceInetAllocPkt)
176+
#define I_sceInetFreePkt DECLARE_IMPORT(13, sceInetFreePkt)
177+
#define I_sceInetRegisterPPPoE DECLARE_IMPORT(14, sceInetRegisterPPPoE)
178+
#define I_sceInetUnregisterPPPoE DECLARE_IMPORT(15, sceInetUnregisterPPPoE)
179+
180+
#endif

iop/network/netman/src/exports.tab

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
DECLARE_EXPORT_TABLE(netman, 3, 1)
23
DECLARE_EXPORT(_start)
34
DECLARE_EXPORT(_retonly)
@@ -22,4 +23,31 @@ DECLARE_EXPORT_TABLE(netman, 3, 1)
2223
DECLARE_EXPORT(NetManTxPacketDeQ)
2324
END_EXPORT_TABLE
2425

26+
DECLARE_EXPORT_TABLE(netdev, 1, 1)
27+
DECLARE_EXPORT(_retonly)
28+
DECLARE_EXPORT(_retonly)
29+
DECLARE_EXPORT(_retonly)
30+
DECLARE_EXPORT(_retonly)
31+
DECLARE_EXPORT(sceInetRegisterNetDevice)
32+
DECLARE_EXPORT(sceInetUnregisterNetDevice)
33+
DECLARE_EXPORT(sceInetAllocMem)
34+
DECLARE_EXPORT(sceInetFreeMem)
35+
DECLARE_EXPORT(sceInetPktEnQ)
36+
DECLARE_EXPORT(sceInetPktDeQ)
37+
DECLARE_EXPORT(sceInetRand)
38+
DECLARE_EXPORT(sceInetPrintf)
39+
DECLARE_EXPORT(sceInetAllocPkt)
40+
DECLARE_EXPORT(sceInetFreePkt)
41+
DECLARE_EXPORT(_retonly) // TODO sceInetRegisterPPPoE
42+
DECLARE_EXPORT(_retonly) // TODO sceInetUnregisterPPPoE
43+
DECLARE_EXPORT(_retonly)
44+
DECLARE_EXPORT(_retonly)
45+
DECLARE_EXPORT(_retonly)
46+
DECLARE_EXPORT(_retonly)
47+
DECLARE_EXPORT(_retonly)
48+
DECLARE_EXPORT(_retonly)
49+
DECLARE_EXPORT(_retonly)
50+
DECLARE_EXPORT(_retonly)
51+
END_EXPORT_TABLE
52+
2553
void _retonly(){};

0 commit comments

Comments
 (0)