Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions download_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 39 additions & 3 deletions ee/network/tcpip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $@

Expand Down
1 change: 1 addition & 0 deletions ee/network/tcpip/src/include/arch/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <errno.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/select.h>

#define PACK_STRUCT_FIELD(x) x __attribute((packed))
#define PACK_STRUCT_STRUCT __attribute((packed))
Expand Down
2 changes: 2 additions & 0 deletions ee/network/tcpip/src/include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
*/
#define LWIP_CHECKSUM_ON_COPY 1

/* Define LWIP_ERRNO_STDINCLUDE if you want to include <errno.h> here */
#define LWIP_ERRNO_STDINCLUDE 1
/*
------------------------------------
---------- Socket options ----------
Expand Down
1 change: 1 addition & 0 deletions ee/network/tcpip/src/ps2ip_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef IOP_PS2IP_INTERNAL_H
#define IOP_PS2IP_INTERNAL_H

#include <sys/select.h>
#include "lwip/sockets.h"

typedef struct
Expand Down
6 changes: 6 additions & 0 deletions ee/network/tcpip/src/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion iop/network/smap/src/imports.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions iop/system/sysclib/include/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions iop/tcpip/tcpip-base/include/arch/cc.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __CC_H__
#define __CC_H__

#include <errno.h>
#include <stddef.h>
#include <sys/time.h>

#define BYTE_ORDER LITTLE_ENDIAN

Expand Down Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions iop/tcpip/tcpip-base/include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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 ----------
Expand Down
36 changes: 36 additions & 0 deletions iop/tcpip/tcpip-base/include/stdlib.h
Original file line number Diff line number Diff line change
@@ -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__ */
6 changes: 6 additions & 0 deletions iop/tcpip/tcpip-base/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion iop/tcpip/tcpip-netman/src/exports.tab
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions iop/tcpip/tcpip-netman/src/imports.lst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ I_ReceiveMbx
thmsgbx_IMPORTS_end

sysclib_IMPORTS_start
I_look_ctype_table
I_memset
I_strcpy
I_strncpy
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions iop/tcpip/tcpip-netman/src/ps2ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
42 changes: 39 additions & 3 deletions iop/tcpip/tcpip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,42 @@ 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 = \
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
Expand Down Expand Up @@ -92,6 +125,9 @@ $(IOP_OBJS_DIR)api_msg.o: $(LWIP)/src/api/api_msg.c
$(IOP_OBJS_DIR)api_netbuf.o: $(LWIP)/src/api/netbuf.c
$(IOP_CC) $(IOP_CFLAGS) -c $< -o $@

$(IOP_OBJS_DIR)acd.o: $(LWIP)/src/core/ipv4/acd.c
$(IOP_CC) $(IOP_CFLAGS) -c $< -o $@

$(IOP_OBJS_DIR)icmp.o: $(LWIP)/src/core/ipv4/icmp.c
$(IOP_CC) $(IOP_CFLAGS) -c $< -o $@

Expand Down
10 changes: 2 additions & 8 deletions iop/tcpip/tcpip/include/ps2ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 10 additions & 7 deletions iop/tcpip/tcpip/src/exports.tab
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,26 @@ DECLARE_EXPORT_TABLE(ps2ip, 2, 6)
DECLARE_EXPORT(ip4addr_ntoa_r) //45
DECLARE_EXPORT(lwip_shutdown)
DECLARE_EXPORT(lwip_fcntl)
DECLARE_EXPORT(acd_netif_ip_addr_changed)
DECLARE_EXPORT(acd_network_changed_link_down)
DECLARE_EXPORT(acd_arp_reply) //50
#ifdef PS2IP_DNS
DECLARE_EXPORT(lwip_gethostbyname)
DECLARE_EXPORT(lwip_gethostbyname_r)
DECLARE_EXPORT(lwip_freeaddrinfo) //50
DECLARE_EXPORT(lwip_freeaddrinfo)
DECLARE_EXPORT(lwip_getaddrinfo)
DECLARE_EXPORT(dns_setserver)
DECLARE_EXPORT(dns_getserver)
DECLARE_EXPORT(dns_getserver) //50
#else
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly) //50
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly) //55
DECLARE_EXPORT(_retonly)
#endif
DECLARE_EXPORT(netif_set_link_up)
DECLARE_EXPORT(netif_set_link_down) //55
DECLARE_EXPORT(tcpip_callback_with_block)
DECLARE_EXPORT(pbuf_coalesce)
DECLARE_EXPORT(netif_set_link_down)
DECLARE_EXPORT(tcpip_callback)
DECLARE_EXPORT(pbuf_coalesce) //60
END_EXPORT_TABLE
3 changes: 3 additions & 0 deletions iop/tcpip/tcpip/src/imports.lst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ I_ReceiveMbx
thmsgbx_IMPORTS_end

sysclib_IMPORTS_start
I_look_ctype_table
I_memset
I_strcpy
I_strncpy
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions iop/tcpip/tcpip/src/ps2ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <types.h>
#include <stdio.h>
#include <errno.h>
#include <intrman.h>
#include <loadcore.h>
#include <thbase.h>
Expand All @@ -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;
Expand Down