From a020847776f636806b222acef5ad28163699412e Mon Sep 17 00:00:00 2001 From: Nishi Date: Sat, 28 Sep 2024 00:07:34 +0000 Subject: [PATCH] kinda works git-svn-id: file:///raid/svn-personal/tewi/trunk@187 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Platform/ps3.mk | 14 ++++++++++++++ Server/Makefile | 15 ++++++++++++++- Server/config.c | 4 +++- Server/http.c | 4 ++++ Server/main.c | 3 +++ Server/module.c | 2 +- Server/server.c | 18 +++++++++++++----- Server/tw_config.h | 3 +++ Server/version.c | 2 ++ config.h.tmpl | 14 +++++++------- psp.sh | 1 + 11 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 Platform/ps3.mk diff --git a/Platform/ps3.mk b/Platform/ps3.mk new file mode 100644 index 0000000..345fa99 --- /dev/null +++ b/Platform/ps3.mk @@ -0,0 +1,14 @@ +# $Id$ + +PREFIX = /dev_hdd0/httpd + +CC = ppu-gcc +AR = ppu-ar +CFLAGS = -g -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I /usr/local/ps3dev/ppu/include +LDFLAGS = -L /usr/local/ps3dev/ppu/lib +LIBS = -lnet -lsysmodule -lsysutil -lrt -llv2 +EXEC = .elf +LIB = .so +MODULE = +SERVADD = ppu-strip tewi.elf -o tewi_strip.elf +TARGET = tewi.pkg diff --git a/Server/Makefile b/Server/Makefile index 59c05b6..306be72 100644 --- a/Server/Makefile +++ b/Server/Makefile @@ -21,6 +21,19 @@ tewi.pbp: tewi_strip$(EXEC) param.sfo param.sfo: mksfoex -d MEMSIZE=1 'Tewi HTTPd' $@ +tewi.self: tewi_strip$(EXEC) + sprxlinker tewi_strip$(EXEC) + make_self_npdrm tewi_strip$(EXEC) $@ UP0001-TEWI_00-0000000000000000 + fself tewi_strip$(EXEC) tewi.fake.self + +tewi.pkg: tewi.self + mkdir -p pkg/USRDIR + cp /usr/local/ps3dev/bin/ICON0.PNG pkg/ICON0.PNG + make_self_npdrm tewi.elf pkg/USRDIR/EBOOT.BIN UP0001-TEWI_00-0000000000000000 + sfo.py --title "Tewi HTTPd" --appid "TEWI" -f /usr/local/ps3dev/bin/sfo.xml pkg/PARAM.SFO + pkg.py --contentid UP0001-TEWI_00-0000000000000000 pkg/ $@ + rm -rf pkg + .c.o: $(CC) $(CFLAGS) $(EXTCFLAGS) -c -o $@ $< @@ -28,4 +41,4 @@ tewi.res: tewi.rc ../Binary/tewi.ico $(WINDRES) tewi.rc -O coff -o $@ clean: - rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp + rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg diff --git a/Server/config.c b/Server/config.c index 6c3f0c0..a76cd1a 100644 --- a/Server/config.c +++ b/Server/config.c @@ -101,8 +101,10 @@ void tw_config_init(void) { config.server_root = cm_strdup(PREFIX); config.server_admin = cm_strdup(SERVER_ADMIN); config.defined[0] = NULL; -#ifdef _PSP +#if defined(_PSP) strcpy(config.hostname, "psp"); +#elif defined(__PPU__) + strcpy(config.hostname, "ps3"); #else gethostname(config.hostname, 1024); #endif diff --git a/Server/http.c b/Server/http.c index 6029264..c6d83c0 100644 --- a/Server/http.c +++ b/Server/http.c @@ -19,7 +19,11 @@ #include #else #ifdef USE_POLL +#ifdef __PPU__ +#include +#else #include +#endif #else #include #endif diff --git a/Server/main.c b/Server/main.c index cc827b2..9e902e8 100644 --- a/Server/main.c +++ b/Server/main.c @@ -240,6 +240,9 @@ int main(int argc, char** argv) { sceKernelExitGame(); } printf("Connected, My IP is %s\n", info.ip); +#elif defined(__PPU__) + printf("PS3 Bootstrap, Tewi/%s\n", tw_get_version()); + netInitialize(); #endif int st = startup(argc, argv); if(st != -1) { diff --git a/Server/module.c b/Server/module.c index 0fc9057..f5eb5e6 100644 --- a/Server/module.c +++ b/Server/module.c @@ -15,7 +15,7 @@ extern struct tw_config config; -#ifdef _PSP +#if defined(_PSP) || defined(__PPU__) void* tw_module_load(const char* path) { return NULL; } void* tw_module_symbol(void* mod, const char* sym) { return NULL; } diff --git a/Server/server.c b/Server/server.c index 5e295c1..193bf42 100644 --- a/Server/server.c +++ b/Server/server.c @@ -42,14 +42,20 @@ #include "strptime.h" #else #ifdef USE_POLL +#ifdef __PPU__ +#include +#else #include +#endif #else #include #endif #include #include #include +#ifndef __PPU__ #include +#endif #ifndef NO_GETADDRINFO #include #endif @@ -135,11 +141,13 @@ int tw_server_init(void) { cm_log("Server", "setsockopt failure (reuseaddr)"); return 1; } +#ifndef __PPU__ if(setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&yes, sizeof(yes)) < 0) { close_socket(sock); cm_log("Server", "setsockopt failure (nodelay)"); return 1; } +#endif #ifndef NO_IPV6 int no = 0; if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&no, sizeof(no)) < 0) { @@ -430,10 +438,10 @@ struct pass_entry { unsigned int WINAPI tw_server_pass(void* ptr) { #elif defined(__HAIKU__) int32_t tw_server_pass(void* ptr) { -#elif defined(_PSP) +#elif defined(_PSP) || defined(__PPU__) int tw_server_pass(void* ptr) { #endif -#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) +#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) int sock = ((struct pass_entry*)ptr)->sock; bool ssl = ((struct pass_entry*)ptr)->ssl; int port = ((struct pass_entry*)ptr)->port; @@ -513,7 +521,7 @@ int tw_server_pass(void* ptr) { } else if(cm_strcaseequ(req.headers[i], "If-Modified-Since")) { struct tm tm; strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm); -#if defined(__MINGW32__) || defined(_PSP) +#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) time_t t = 0; struct tm* btm = localtime(&t); cmtime = mktime(&tm); @@ -918,7 +926,7 @@ void tw_server_loop(void) { socklen_t clen = sizeof(claddr); int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); cm_log("Server", "New connection accepted"); -#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) +#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) struct pass_entry* e = malloc(sizeof(*e)); e->sock = sock; e->ssl = config.ports[i] & (1ULL << 32); @@ -944,7 +952,7 @@ void tw_server_loop(void) { break; } } -#elif defined(_PSP) +#elif defined(_PSP) || defined(__PPU__) tw_server_pass(e); #elif defined(__HAIKU__) int j; diff --git a/Server/tw_config.h b/Server/tw_config.h index e5485e6..3e66276 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -18,6 +18,9 @@ extern "C" { #include #define NO_IPV6 #else +#ifdef __PPU__ +#include +#endif #include #ifdef __HAIKU__ #define NO_IPV6 diff --git a/Server/version.c b/Server/version.c index 3d49ce3..93568a0 100644 --- a/Server/version.c +++ b/Server/version.c @@ -21,6 +21,8 @@ const char* tw_platform = "Cygwin" #elif defined(_PSP) "PSP" +#elif defined(__PPU__) + "PS3" #else "Unix" #endif diff --git a/config.h.tmpl b/config.h.tmpl index 4b73646..ac30b97 100644 --- a/config.h.tmpl +++ b/config.h.tmpl @@ -27,24 +27,24 @@ /* Windows should not have chroot */ #endif -#if defined(_PSP) && !defined(NO_IPV6) +#if (defined(_PSP) || defined(__PPU__)) && !defined(NO_IPV6) #define NO_IPV6 -/* PSP does not have IPv6 */ +/* PSP/PS3 does not have IPv6 */ #endif -#if defined(_PSP) && defined(USE_POLL) +#if (defined(_PSP)) && defined(USE_POLL) #undef USE_POLL /* Force select(2) for PSP */ #endif -#if defined(_PSP) && defined(HAS_CHROOT) +#if (defined(_PSP) || defined(__PPU__)) && defined(HAS_CHROOT) #undef HAS_CHROOT -/* PSP should not have chroot */ +/* PSP/PS3 should not have chroot */ #endif -#if defined(_PSP) && !defined(NO_GETADDRINFO) +#if (defined(_PSP) || defined(__PPU__)) && !defined(NO_GETADDRINFO) #define NO_GETADDRINFO -/* PSP should not have getaddrinfo */ +/* PSP/PS3 should not have getaddrinfo */ #endif #endif diff --git a/psp.sh b/psp.sh index ad7f58d..fe455ab 100755 --- a/psp.sh +++ b/psp.sh @@ -2,6 +2,7 @@ # $Id$ export PSPDEV=/usr/local/pspdev export PATH=$PATH:/usr/local/pspdev/bin +cat config.h.tmpl | sed -E 's/#undef (NO_SSL)/#define \1/g' > config.h rm -rf httpd make PLATFORM=psp DESTDIR=httpd/ install mv httpd/ms0:/PSP/GAME/httpd/* httpd/ -- 2.45.2