Skip to content

Commit 7de8774

Browse files
committed
Upgrade to mainstream lwip 2.2.1
1 parent a4d5418 commit 7de8774

File tree

24 files changed

+252
-29
lines changed

24 files changed

+252
-29
lines changed

download_dependencies.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ if [ "x$1" != "xlocked" ]; then
1414
fi
1515

1616
## Download LWIP
17-
LWIP_REPO_URL="https://github.com/ps2dev/lwip.git"
17+
LWIP_REPO_URL="https://github.com/lwip-tcpip/lwip.git"
1818
LWIP_REPO_FOLDER="common/external_deps/lwip"
19-
LWIP_BRANCH_NAME="ps2-v2.0.3"
19+
LWIP_BRANCH_NAME="STABLE-2_2_1_RELEASE"
2020
if test ! -d "$LWIP_REPO_FOLDER"; then
2121
git clone --depth 1 -b $LWIP_BRANCH_NAME $LWIP_REPO_URL "$LWIP_REPO_FOLDER"_inprogress || exit 1
2222
mv "$LWIP_REPO_FOLDER"_inprogress "$LWIP_REPO_FOLDER"
2323
else
24-
(cd "$LWIP_REPO_FOLDER" && git fetch origin && git reset --hard "origin/${LWIP_BRANCH_NAME}" && git checkout "$LWIP_BRANCH_NAME" && cd - )|| exit 1
24+
(cd "$LWIP_REPO_FOLDER" && git fetch origin --tags && git reset --hard "${LWIP_BRANCH_NAME}" && git checkout "$LWIP_BRANCH_NAME" && cd - )|| exit 1
2525
fi
2626

2727
## Download libsmb2

ee/network/tcpip/Makefile

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,42 @@ endif
3535

3636
EE_INCS += -I$(LWIP)/src/include -I$(LWIP)/src/include/ipv4
3737

38-
ps2api_OBJECTS = api_lib.o api_msg.o api_netbuf.o err.o sockets.o tcpip.o
39-
ps2api_IPV4 = icmp.o ip.o ip4.o ip4_addr.o ip4_frag.o inet_chksum.o
40-
ps2ip_OBJECTS = sys.o lwip_init.o mem.o netif.o pbuf.o stats.o tcp_in.o tcp_out.o udp.o memp.o tcp.o ethernet.o etharp.o raw.o def.o timeouts.o $(ps2api_IPV4) $(ps2api_OBJECTS)
38+
ps2api_OBJECTS = \
39+
api_lib.o \
40+
api_msg.o \
41+
api_netbuf.o \
42+
err.o \
43+
sockets.o \
44+
tcpip.o
45+
46+
ps2api_IPV4 = \
47+
acd.o \
48+
icmp.o \
49+
ip.o \
50+
ip4.o \
51+
ip4_addr.o \
52+
ip4_frag.o \
53+
inet_chksum.o
54+
55+
ps2ip_OBJECTS = \
56+
sys.o \
57+
lwip_init.o \
58+
mem.o \
59+
netif.o \
60+
pbuf.o \
61+
stats.o \
62+
tcp_in.o \
63+
tcp_out.o \
64+
udp.o \
65+
memp.o \
66+
tcp.o \
67+
ethernet.o \
68+
etharp.o \
69+
raw.o \
70+
def.o \
71+
timeouts.o \
72+
$(ps2api_IPV4) \
73+
$(ps2api_OBJECTS)
4174

4275
ifdef PS2IP_DHCP
4376
ps2ip_OBJECTS += dhcp.o
@@ -82,6 +115,9 @@ $(EE_OBJS_DIR)api_msg.o: $(LWIP)/src/api/api_msg.c
82115
$(EE_OBJS_DIR)api_netbuf.o: $(LWIP)/src/api/netbuf.c
83116
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
84117

118+
$(EE_OBJS_DIR)acd.o: $(LWIP)/src/core/ipv4/acd.c
119+
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
120+
85121
$(EE_OBJS_DIR)icmp.o: $(LWIP)/src/core/ipv4/icmp.c
86122
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
87123

ee/network/tcpip/src/include/arch/cc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <errno.h>
55
#include <stdlib.h>
66
#include <stddef.h>
7+
#include <sys/select.h>
78

89
#define PACK_STRUCT_FIELD(x) x __attribute((packed))
910
#define PACK_STRUCT_STRUCT __attribute((packed))

ee/network/tcpip/src/include/lwipopts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@
244244
*/
245245
#define LWIP_CHECKSUM_ON_COPY 1
246246

247+
/* Define LWIP_ERRNO_STDINCLUDE if you want to include <errno.h> here */
248+
#define LWIP_ERRNO_STDINCLUDE 1
247249
/*
248250
------------------------------------
249251
---------- Socket options ----------

ee/network/tcpip/src/ps2ip_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef IOP_PS2IP_INTERNAL_H
1212
#define IOP_PS2IP_INTERNAL_H
1313

14+
#include <sys/select.h>
1415
#include "lwip/sockets.h"
1516

1617
typedef struct

ee/network/tcpip/src/sys_arch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *sys_msg)
338338
return result;
339339
}
340340

341+
err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg)
342+
{
343+
// On PS2 EE, ISR and task level are the same, so just call trypost
344+
return sys_mbox_trypost(mbox, msg);
345+
}
346+
341347
void sys_mbox_post(sys_mbox_t *mbox, void *sys_msg)
342348
{
343349
SendMbx(mbox, alloc_msg(), sys_msg);

iop/Rules.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ $(IOP_BIN_STRIPPED_ELF): $(IOP_BIN_ELF)
146146
$(IOP_STRIP) --strip-unneeded --remove-section=.pdr --remove-section=.comment --remove-section=.mdebug.abi32 --remove-section=.gnu.attributes -o $@ $<
147147

148148
$(IOP_BIN): $(IOP_BIN_STRIPPED_ELF) $(PS2SDKSRC)/tools/srxfixup/bin/srxfixup
149-
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup --irx1 -o $@ $<
149+
$(PS2SDKSRC)/tools/srxfixup/bin/srxfixup --rb --irx1 -o $@ $<
150150

151151
$(IOP_LIB)_tmp$(MAKE_CURPID): $(IOP_OBJS)
152152
$(DIR_GUARD)

iop/network/smap/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ IOP_IMPORT_INCS += \
3535
system/sysclib \
3636
system/threadman
3737

38-
IOP_OBJS = ipstack.o main.o smap.o xfer.o imports.o exports.o
38+
# ipstack.o must NOT be first: its tiny tail-call thunks would sit at
39+
# .text+0x0000, producing "jal 0x0" call sites whose R_MIPS_26 relocation
40+
# is not applied by some IOP loaders (observed on PCSX2), crashing to
41+
# EPC=0x10 (break instruction at IOP address 0x0).
42+
IOP_OBJS = main.o smap.o xfer.o ipstack.o imports.o exports.o
3943

4044
ifneq (x$(LWIP_DHCP),x0)
4145
IOP_CFLAGS += -DLWIP_DHCP=1

iop/network/smap/src/imports.lst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ I_inet_addr
6363
I_tcpip_input
6464
I_netif_set_link_up
6565
I_netif_set_link_down
66-
I_tcpip_callback_with_block
66+
I_tcpip_callback
6767
ps2ip_IMPORTS_end
6868
#endif
6969

iop/network/smap/src/xfer.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ static inline void CopyFromFIFO(volatile u8 *smap_regbase, void *buffer, unsigne
5858
}
5959
}
6060

61+
/* Max Ethernet frame size (1514 bytes) rounded up to 4-byte boundary */
62+
#define SMAP_MAX_FRAME_SIZE_ALIGNED 1516
63+
64+
static u8 TxAlignedBuf[SMAP_MAX_FRAME_SIZE_ALIGNED] __attribute__((aligned(4)));
65+
6166
static inline void CopyToFIFO(volatile u8 *smap_regbase, const void *buffer, unsigned int length)
6267
{
6368
int i, result;
@@ -66,6 +71,14 @@ static inline void CopyToFIFO(volatile u8 *smap_regbase, const void *buffer, uns
6671
return;
6772
}
6873

74+
/* DMA and 32-bit FIFO writes require 4-byte aligned source.
75+
* Upstream lwIP PBUF_RAM payloads land at 2-byte alignment (ETH+IP+TCP headers = 54 bytes ≡ 2 mod 4).
76+
* Copy to a static aligned buffer when needed. */
77+
if ((unsigned int)buffer & 3) {
78+
memcpy(TxAlignedBuf, buffer, length);
79+
buffer = TxAlignedBuf;
80+
}
81+
6982
result = SmapDmaTransfer(smap_regbase, (void *)buffer, length, DMAC_FROM_MEM);
7083

7184
for (i = result; (unsigned int)i < length; i += 4) {

0 commit comments

Comments
 (0)