diff --git a/download_dependencies.sh b/download_dependencies.sh index 33262c8ddde1..3e156a040657 100755 --- a/download_dependencies.sh +++ b/download_dependencies.sh @@ -14,14 +14,14 @@ if [ "x$1" != "xlocked" ]; then fi ## Download LWIP -LWIP_REPO_URL="https://github.com/ps2dev/lwip.git" +LWIP_REPO_URL="https://github.com/lwip-tcpip/lwip.git" LWIP_REPO_FOLDER="common/external_deps/lwip" -LWIP_BRANCH_NAME="ps2-v2.0.3" +LWIP_BRANCH_NAME="STABLE-2_2_1_RELEASE" if test ! -d "$LWIP_REPO_FOLDER"; then git clone --depth 1 -b $LWIP_BRANCH_NAME $LWIP_REPO_URL "$LWIP_REPO_FOLDER"_inprogress || exit 1 mv "$LWIP_REPO_FOLDER"_inprogress "$LWIP_REPO_FOLDER" else - (cd "$LWIP_REPO_FOLDER" && git fetch origin && git reset --hard "origin/${LWIP_BRANCH_NAME}" && git checkout "$LWIP_BRANCH_NAME" && cd - )|| exit 1 + (cd "$LWIP_REPO_FOLDER" && git fetch origin --tags && git reset --hard "${LWIP_BRANCH_NAME}" && git checkout "$LWIP_BRANCH_NAME" && cd - )|| exit 1 fi ## Download libsmb2 diff --git a/ee/network/tcpip/Makefile b/ee/network/tcpip/Makefile index 4ac9ef2e9728..cae15eb6bf75 100644 --- a/ee/network/tcpip/Makefile +++ b/ee/network/tcpip/Makefile @@ -35,9 +35,42 @@ endif EE_INCS += -I$(LWIP)/src/include -I$(LWIP)/src/include/ipv4 -ps2api_OBJECTS = api_lib.o api_msg.o api_netbuf.o err.o sockets.o tcpip.o -ps2api_IPV4 = icmp.o ip.o ip4.o ip4_addr.o ip4_frag.o inet_chksum.o -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) +ps2api_OBJECTS = \ + api_lib.o \ + api_msg.o \ + api_netbuf.o \ + err.o \ + sockets.o \ + tcpip.o + +ps2api_IPV4 = \ + acd.o \ + icmp.o \ + ip.o \ + ip4.o \ + ip4_addr.o \ + ip4_frag.o \ + inet_chksum.o + +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) ifdef PS2IP_DHCP ps2ip_OBJECTS += dhcp.o @@ -82,6 +115,9 @@ $(EE_OBJS_DIR)api_msg.o: $(LWIP)/src/api/api_msg.c $(EE_OBJS_DIR)api_netbuf.o: $(LWIP)/src/api/netbuf.c $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ +$(EE_OBJS_DIR)acd.o: $(LWIP)/src/core/ipv4/acd.c + $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ + $(EE_OBJS_DIR)icmp.o: $(LWIP)/src/core/ipv4/icmp.c $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ diff --git a/ee/network/tcpip/src/include/arch/cc.h b/ee/network/tcpip/src/include/arch/cc.h index a8ef6c6abb64..c3be57d3271e 100644 --- a/ee/network/tcpip/src/include/arch/cc.h +++ b/ee/network/tcpip/src/include/arch/cc.h @@ -4,6 +4,7 @@ #include #include #include +#include #define PACK_STRUCT_FIELD(x) x __attribute((packed)) #define PACK_STRUCT_STRUCT __attribute((packed)) diff --git a/ee/network/tcpip/src/include/lwipopts.h b/ee/network/tcpip/src/include/lwipopts.h index 6b2fd7b79a56..90c45afcfd85 100644 --- a/ee/network/tcpip/src/include/lwipopts.h +++ b/ee/network/tcpip/src/include/lwipopts.h @@ -244,6 +244,8 @@ */ #define LWIP_CHECKSUM_ON_COPY 1 +/* Define LWIP_ERRNO_STDINCLUDE if you want to include here */ +#define LWIP_ERRNO_STDINCLUDE 1 /* ------------------------------------ ---------- Socket options ---------- diff --git a/ee/network/tcpip/src/ps2ip_internal.h b/ee/network/tcpip/src/ps2ip_internal.h index 59d333b7399b..bcdd1b9fb9bd 100644 --- a/ee/network/tcpip/src/ps2ip_internal.h +++ b/ee/network/tcpip/src/ps2ip_internal.h @@ -11,6 +11,7 @@ #ifndef IOP_PS2IP_INTERNAL_H #define IOP_PS2IP_INTERNAL_H +#include #include "lwip/sockets.h" typedef struct diff --git a/ee/network/tcpip/src/sys_arch.c b/ee/network/tcpip/src/sys_arch.c index 3b2371591da5..f67b80700483 100644 --- a/ee/network/tcpip/src/sys_arch.c +++ b/ee/network/tcpip/src/sys_arch.c @@ -338,6 +338,12 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *sys_msg) return result; } +err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg) +{ + // On PS2 EE, ISR and task level are the same, so just call trypost + return sys_mbox_trypost(mbox, msg); +} + void sys_mbox_post(sys_mbox_t *mbox, void *sys_msg) { SendMbx(mbox, alloc_msg(), sys_msg); diff --git a/iop/network/smap/src/imports.lst b/iop/network/smap/src/imports.lst index ac17ea7e16db..f4247410f152 100644 --- a/iop/network/smap/src/imports.lst +++ b/iop/network/smap/src/imports.lst @@ -63,7 +63,7 @@ I_inet_addr I_tcpip_input I_netif_set_link_up I_netif_set_link_down -I_tcpip_callback_with_block +I_tcpip_callback ps2ip_IMPORTS_end #endif diff --git a/iop/system/sysclib/include/ctype.h b/iop/system/sysclib/include/ctype.h index 08330f297459..d8d2df80176d 100644 --- a/iop/system/sysclib/include/ctype.h +++ b/iop/system/sysclib/include/ctype.h @@ -63,6 +63,8 @@ extern "C" { /** Blank (space) */ #define _B 0x80 +extern unsigned char look_ctype_table(char character); + #define isalpha(c) (look_ctype_table((unsigned int)(c)) & (_U|_L)) #define isupper(c) (look_ctype_table((unsigned int)(c)) & (_U)) #define islower(c) (look_ctype_table((unsigned int)(c)) & (_L)) diff --git a/iop/tcpip/tcpip-base/include/arch/cc.h b/iop/tcpip/tcpip-base/include/arch/cc.h index f3b915b0a132..a1b0d7c02e6d 100644 --- a/iop/tcpip/tcpip-base/include/arch/cc.h +++ b/iop/tcpip/tcpip-base/include/arch/cc.h @@ -1,8 +1,8 @@ #ifndef __CC_H__ #define __CC_H__ -#include #include +#include #define BYTE_ORDER LITTLE_ENDIAN @@ -47,8 +47,6 @@ typedef u32_t mem_ptr_t; #define LWIP_PLATFORM_ASSERT(args) #endif -#define atoi(x) strtol(x, NULL, 10) - #define LWIP_NO_STDINT_H 1 //stdint.h does not exist. #define LWIP_NO_INTTYPES_H 1 //inttypes.h does not exist. diff --git a/iop/tcpip/tcpip-base/include/lwipopts.h b/iop/tcpip/tcpip-base/include/lwipopts.h index f3781cc2a7fb..82a12c5e174c 100644 --- a/iop/tcpip/tcpip-base/include/lwipopts.h +++ b/iop/tcpip/tcpip-base/include/lwipopts.h @@ -167,6 +167,10 @@ #define LWIP_DHCP 1 #endif +/* ---------- ACD options ---------- */ +#define LWIP_ACD 0 +#define LWIP_DHCP_DOES_ACD_CHECK 0 + /** * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address. */ @@ -236,6 +240,8 @@ */ #define LWIP_CHECKSUM_ON_COPY 1 +/* Use PS2SDK's errno.h instead of lwIP's own errno definitions */ +#define LWIP_ERRNO_STDINCLUDE 1 /* ------------------------------------ ---------- Socket options ---------- diff --git a/iop/tcpip/tcpip-base/include/stdlib.h b/iop/tcpip/tcpip-base/include/stdlib.h new file mode 100644 index 000000000000..7f0cb3955702 --- /dev/null +++ b/iop/tcpip/tcpip-base/include/stdlib.h @@ -0,0 +1,36 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +/** + * @file + * Minimal stdlib.h for IOP tcpip + * Provides basic functions needed by lwIP on the IOP + */ + +#ifndef __IOP_TCPIP_STDLIB_H__ +#define __IOP_TCPIP_STDLIB_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* atoi - convert string to integer + * Implemented as a macro using strtol from sysclib + */ +#define atoi(x) strtol(x, NULL, 10) + +/* Required for strtol */ +long int strtol(const char *nptr, char **endptr, int base); + +#ifdef __cplusplus +} +#endif + +#endif /* __IOP_TCPIP_STDLIB_H__ */ diff --git a/iop/tcpip/tcpip-base/sys_arch.c b/iop/tcpip/tcpip-base/sys_arch.c index adf8bf3cec5c..9cca38af7824 100644 --- a/iop/tcpip/tcpip-base/sys_arch.c +++ b/iop/tcpip/tcpip-base/sys_arch.c @@ -182,6 +182,12 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg){ return result; } +err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg) +{ + // On PS2 IOP, ISR and task level are the same, so just call trypost + return sys_mbox_trypost(mbox, msg); +} + void sys_mbox_post(sys_mbox_t *mbox, void *msg) { arch_message *MsgPkt; diff --git a/iop/tcpip/tcpip-netman/src/exports.tab b/iop/tcpip/tcpip-netman/src/exports.tab index 470bc1fcd03b..f04f753ad27f 100644 --- a/iop/tcpip/tcpip-netman/src/exports.tab +++ b/iop/tcpip/tcpip-netman/src/exports.tab @@ -67,6 +67,6 @@ DECLARE_EXPORT_TABLE(ps2ip, 2, 6) #endif DECLARE_EXPORT(netif_set_link_up) DECLARE_EXPORT(netif_set_link_down) //55 - DECLARE_EXPORT(tcpip_callback_with_block) + DECLARE_EXPORT(tcpip_callback) DECLARE_EXPORT(pbuf_coalesce) END_EXPORT_TABLE diff --git a/iop/tcpip/tcpip-netman/src/imports.lst b/iop/tcpip/tcpip-netman/src/imports.lst index 5237c25a572f..20e7d2b753bf 100644 --- a/iop/tcpip/tcpip-netman/src/imports.lst +++ b/iop/tcpip/tcpip-netman/src/imports.lst @@ -50,6 +50,7 @@ I_ReceiveMbx thmsgbx_IMPORTS_end sysclib_IMPORTS_start +I_look_ctype_table I_memset I_strcpy I_strncpy @@ -59,8 +60,10 @@ I_strncmp I_strtok I_strtoul I_memcmp +I_memmove I_strtol I_strcmp +I_tolower sysclib_IMPORTS_end sysmem_IMPORTS_start diff --git a/iop/tcpip/tcpip-netman/src/ps2ip.c b/iop/tcpip/tcpip-netman/src/ps2ip.c index da3fefb3fade..547aec16713f 100644 --- a/iop/tcpip/tcpip-netman/src/ps2ip.c +++ b/iop/tcpip/tcpip-netman/src/ps2ip.c @@ -35,6 +35,9 @@ #include "ps2ip_internal.h" +/* Define errno for IOP module */ +int errno __attribute__((section("data"))); + typedef struct pbuf PBuf; typedef struct netif NetIF; typedef struct ip4_addr IPAddr; diff --git a/iop/tcpip/tcpip/Makefile b/iop/tcpip/tcpip/Makefile index fada0932d841..e79977fe4342 100644 --- a/iop/tcpip/tcpip/Makefile +++ b/iop/tcpip/tcpip/Makefile @@ -45,9 +45,41 @@ IOP_INCS += \ -I$(LWIP)/src/include/ipv4 \ -I$(PS2IP_BASE)/include -ps2api_OBJECTS = api_lib.o api_msg.o api_netbuf.o err.o sockets.o tcpip.o -ps2api_IPV4 = icmp.o ip.o ip4.o ip4_addr.o ip4_frag.o inet_chksum.o -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) +ps2api_OBJECTS = \ + api_lib.o \ + api_msg.o \ + api_netbuf.o \ + err.o \ + sockets.o \ + tcpip.o + +ps2api_IPV4 = \ + icmp.o \ + ip.o \ + ip4.o \ + ip4_addr.o \ + ip4_frag.o \ + inet_chksum.o + +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) ifdef PS2IP_DHCP ps2ip_OBJECTS += dhcp.o diff --git a/iop/tcpip/tcpip/include/ps2ip.h b/iop/tcpip/tcpip/include/ps2ip.h index 02897051ddf9..46f0ceb2bc81 100644 --- a/iop/tcpip/tcpip/include/ps2ip.h +++ b/iop/tcpip/tcpip/include/ps2ip.h @@ -61,13 +61,7 @@ extern err_t tcpip_input(struct pbuf *p, struct netif *inp); /** Function prototype for functions passed to tcpip_callback() */ typedef void (*tcpip_callback_fn)(void *ctx); -extern err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8 block); - -/** - * @ingroup lwip_os - * @see tcpip_callback_with_block - */ -#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) +extern err_t tcpip_callback(tcpip_callback_fn function, void *ctx); /* From include/lwip/netif.h: */ extern struct netif *netif_add(struct netif *netif, @@ -188,7 +182,7 @@ extern const ip_addr_t* dns_getserver(u8 numdns); #define I_lwip_fcntl DECLARE_IMPORT(47, lwip_fcntl) #define I_etharp_output DECLARE_IMPORT(23, etharp_output) #define I_tcpip_input DECLARE_IMPORT(25, tcpip_input) -#define I_tcpip_callback_with_block DECLARE_IMPORT(56, tcpip_callback_with_block) +#define I_tcpip_callback DECLARE_IMPORT(56, tcpip_callback) #define I_netif_add DECLARE_IMPORT(26, netif_add) #define I_netif_find DECLARE_IMPORT(27, netif_find) #define I_netif_set_default DECLARE_IMPORT(28, netif_set_default) diff --git a/iop/tcpip/tcpip/src/exports.tab b/iop/tcpip/tcpip/src/exports.tab index 470bc1fcd03b..f04f753ad27f 100644 --- a/iop/tcpip/tcpip/src/exports.tab +++ b/iop/tcpip/tcpip/src/exports.tab @@ -67,6 +67,6 @@ DECLARE_EXPORT_TABLE(ps2ip, 2, 6) #endif DECLARE_EXPORT(netif_set_link_up) DECLARE_EXPORT(netif_set_link_down) //55 - DECLARE_EXPORT(tcpip_callback_with_block) + DECLARE_EXPORT(tcpip_callback) DECLARE_EXPORT(pbuf_coalesce) END_EXPORT_TABLE diff --git a/iop/tcpip/tcpip/src/imports.lst b/iop/tcpip/tcpip/src/imports.lst index 8a09318f5a69..a20a3b47af01 100644 --- a/iop/tcpip/tcpip/src/imports.lst +++ b/iop/tcpip/tcpip/src/imports.lst @@ -43,6 +43,7 @@ I_ReceiveMbx thmsgbx_IMPORTS_end sysclib_IMPORTS_start +I_look_ctype_table I_memset I_strcpy I_strncpy @@ -52,8 +53,10 @@ I_strncmp I_strtok I_strtoul I_memcmp +I_memmove I_strtol I_strcmp +I_tolower sysclib_IMPORTS_end sysmem_IMPORTS_start diff --git a/iop/tcpip/tcpip/src/ps2ip.c b/iop/tcpip/tcpip/src/ps2ip.c index 141de1903e5d..1dc8f9ca493d 100644 --- a/iop/tcpip/tcpip/src/ps2ip.c +++ b/iop/tcpip/tcpip/src/ps2ip.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,9 @@ #include "ps2ip_internal.h" +/* Define errno for IOP module */ +int errno __attribute__((section("data"))); + typedef struct pbuf PBuf; typedef struct netif NetIF; typedef struct ip4_addr IPAddr;