PS2SDK
PS2 Homebrew Libraries
main.h
1 
2 #ifndef MAIN_H
3 #define MAIN_H
4 
5 #include <thbase.h>
6 
7 #ifdef BUILDING_SMAP_NETMAN
8 #include <netman.h>
9 #endif
10 #ifdef BUILDING_SMAP_PS2IP
11 #include <ps2ip.h>
12 #endif
13 #ifdef BUILDING_SMAP_NETDEV
14 #include <netdev.h>
15 #endif
16 #ifdef BUILDING_SMAP_MODULAR
17 #include <smap_modular.h>
18 #endif
19 
20 #ifndef BUILDING_SMAP_NETDEV
21 #define sceInetPrintf(...) printf(__VA_ARGS__)
22 #endif
23 
24 #define DEBUG_PRINTF(args...) sceInetPrintf("SMAP: "args)
25 
26 #ifdef BUILDING_SMAP_NETDEV
27 struct RuntimeStats_NetDev
28 {
29  u32 m_RxErrorVarious[16];
30  u32 m_TxErrorVarious[16];
31  u32 m_Rx_Packets;
32  u32 m_Tx_Packets;
33  u32 m_Rx_Bytes;
34  u32 m_Tx_Bytes;
35  u32 m_Rx_Errors;
36  u32 m_Tx_Errors;
37  u32 m_Rx_Dropped;
38  u32 m_Tx_Dropped;
39  u32 m_Rx_Broadcast_Packets;
40  u32 m_Tx_Broadcast_Packets;
41  u32 m_Rx_Broadcast_Bytes;
42  u32 m_Tx_Broadcast_Bytes;
43  u32 m_Rx_Multicast_Packets;
44  u32 m_Tx_Multicast_Packets;
45  u32 m_Rx_Multicast_Bytes;
46  u32 m_Tx_Multicast_Bytes;
47  u32 m_Multicast;
48  u32 m_Collisions;
49  u32 m_Rx_Length_Er;
50  u32 m_Rx_Over_Er;
51  u32 m_Rx_Crc_Er;
52  u32 m_Rx_Frame_Er;
53  u32 m_Rx_Fifo_Er;
54  u32 m_Rx_Missed_Er;
55  u32 m_Tx_Aborted_Er;
56  u32 m_Tx_Carrier_Er;
57  u32 m_Tx_Fifo_Er;
58  u32 m_Tx_Heartbeat_Er;
59  u32 m_Tx_Window_Er;
60 };
61 #endif
62 
63 // This struct needs to be the exact same layout as struct NetManEthRuntimeStats!
65 {
66  u32 RxDroppedFrameCount;
67  u32 RxErrorCount;
68  u16 RxFrameOverrunCount;
69  u16 RxFrameBadLengthCount;
70  u16 RxFrameBadFCSCount;
71  u16 RxFrameBadAlignmentCount;
72  u32 TxDroppedFrameCount;
73  u32 TxErrorCount;
74  u16 TxFrameLOSSCRCount;
75  u16 TxFrameEDEFERCount;
76  u16 TxFrameCollisionCount;
77  u16 TxFrameUnderrunCount;
78  u16 RxAllocFail;
79 };
80 
82 {
83  volatile u8 *smap_regbase;
84  volatile u8 *emac3_regbase;
85  unsigned int TxBufferSpaceAvailable;
86  unsigned char NumPacketsInTx;
87  unsigned char TxBDIndex;
88  unsigned char TxDNVBDIndex;
89  unsigned char RxBDIndex;
90  void *packetToSend;
91  int Dev9IntrEventFlag;
92  int IntrHandlerThreadID;
93  unsigned char SmapDriverStarting; // SMAP driver is starting.
94  unsigned char SmapIsInitialized; // SMAP driver is initialized (software)
95  unsigned char NetDevStopFlag;
96  unsigned char EnableLinkCheckTimer;
97  unsigned char LinkStatus; // Ethernet link is initialized (hardware)
98  unsigned char LinkMode;
99  iop_sys_clock_t LinkCheckTimer;
100 #ifdef SMAP_RX_PACKETS_POLLING_MODE
101  iop_sys_clock_t RxIntrPollingTimer;
102 #endif
103  struct RuntimeStats RuntimeStats;
104 #ifdef BUILDING_SMAP_NETDEV
105  struct RuntimeStats_NetDev RuntimeStats_NetDev;
106 #endif
107 #ifdef BUILDING_SMAP_NETMAN
108  int NetIFID;
109 #endif
110 #ifdef BUILDING_SMAP_NETDEV
111  sceInetDevOps_t m_devops;
112 #endif
113 #ifdef BUILDING_SMAP_MODULAR
114  const SmapModularHookTable_t *HookTable[1];
115 #endif
116 };
117 
118 /* Event flag bits */
119 #define SMAP_EVENT_START 0x01
120 #define SMAP_EVENT_STOP 0x02
121 #define SMAP_EVENT_INTR 0x04
122 #define SMAP_EVENT_XMIT 0x08
123 #define SMAP_EVENT_LINK_CHECK 0x10
124 
125 /* Function prototypes */
126 extern int DisplayBanner(void);
127 extern int smap_init(int argc, char *argv[]);
128 #ifdef BUILDING_SMAP_NETDEV
129 extern int smap_deinit(void);
130 #endif
131 #ifdef BUILDING_SMAP_PS2IP
132 extern int SMAPInitStart(void);
133 #endif
134 extern void SMAPXmit(void);
135 extern int SMAPGetMACAddress(u8 *buffer);
136 #ifdef BUILDING_SMAP_PS2IP
137 extern void PS2IPLinkStateUp(void);
138 extern void PS2IPLinkStateDown(void);
139 
140 extern void SMapLowLevelInput(struct pbuf *pBuf);
141 extern int SMapTxPacketNext(void **payload);
142 extern void SMapTxPacketDeQ(void);
143 #endif
144 
145 /* Data prototypes */
146 extern struct SmapDriverData SmapDriverData;
147 
148 #endif
thbase.h
SmapDriverData
Definition: main.h:81
netman.h
SmapModularHookTable
Definition: smap_modular.h:25
RuntimeStats
Definition: main.h:64
sceInetDevOps
Definition: netdev.h:115
pbuf
Definition: tcpip.h:229
_iop_sys_clock
Definition: thbase.h:87