From 6b990a3b904479f7b47f94ef5ed0d36910d1df87 Mon Sep 17 00:00:00 2001 From: Nishi Date: Fri, 27 Sep 2024 16:15:15 +0000 Subject: [PATCH] psp support git-svn-id: file:///raid/svn-personal/tewi/trunk@183 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Binary/psp.png | Bin 0 -> 9927 bytes Platform/psp.mk | 6 +- Server/Makefile | 2 +- Server/main.c | 170 +++++++++++++++++++++++++++++++++++++++++++++-- Server/server.c | 50 ++++++++------ Server/version.c | 2 + 6 files changed, 198 insertions(+), 32 deletions(-) create mode 100644 Binary/psp.png diff --git a/Binary/psp.png b/Binary/psp.png new file mode 100644 index 0000000000000000000000000000000000000000..2610ecb85b8505ef8dd2ec71aeb01160db458dc2 GIT binary patch literal 9927 zcmV;&COFxNP)EX>4Tx04R}tkvmAkKpe)uriu@$4t5ZA$WR@`4n7daT7@E12(?114knkrph-iL z;^HW{794ymRvlcNb#-tR1i=T0vxAeOi0Ge)_ ziC9!jrB}s{S9Ds^>t?1$8Vf-E(<&}XeJZ$#6e;)*ThN_v%IMhPZNh!O{aVz z<*~|ni?dcNv-&;x3j-N_Wtr+gyS1`YlU`CF3bemC&c_JQu?y5Hj`Mx&IJFbN{|sE|4S%T$%zlzy zX=tG%pl=(vxNd059&ot>3_KaKDZ7%NrjX47?`QN)X`ufW=w9=BtMB9V0Z39;@f+aa z5E#u-_IitVcQ*I-@0ogkKmGc0-oag7;s5{u32;bRa{vGf6951U69E94oEQKA00(qQ zO+^Rj2^$V9G2XhzJ^%n907*naRCwC8e0P{t#rgmH&dfQt-@AR;UCOfb-ix>tv15y3 z#D)zOjmDC%#%^rU*kUw>NNf>}J(h1oM53q&B1rGOF3a}4{gjz`e}CLxbnBVQ{7ng)Z2f4@Uh=VI^@Ffj{O^UZd$ctT+fq^=3&KC zpDmtOHlTFim_f()b?^M`jln%f^vv(hwApf#9nG72YIeOk_n(hEd*A;BEdcoPJ;`|V zC?7^{?yIaAFlxYYf8B-GUAkb^cR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U1A zns^2+$xce`kzhvsV#~o%$ev_L&Gr!3O@XTg(QjA3cf&0g=j7zT|A#@0+Pb}|RBFMp zxhuZfF??LlQN?39dC}njz&K_+lXje}Tup`&p`8X*|35hYY3Bye$kYG;002ovPDHLk FV1h^tNVxz2 literal 0 HcmV?d00001 diff --git a/Platform/psp.mk b/Platform/psp.mk index 385321f..9973bb5 100644 --- a/Platform/psp.mk +++ b/Platform/psp.mk @@ -1,10 +1,12 @@ # $Id$ +PREFIX = ms0:/PSP/GAME/httpd + CC = psp-gcc AR = psp-ar CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I /usr/local/pspdev/psp/sdk/include -D_PSP_FW_VERSION=600 -LDFLAGS = -L /usr/local/pspdev/psp/sdk/lib -LIBS = -lpspgum -lpspgu -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspnet -lpspnet_apctl +LDFLAGS = -Wl,-zmax-page-size=128 -L /usr/local/pspdev/psp/sdk/lib +LIBS = -lpspgum -lpspgu -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspnet -lpspnet_apctl -lcglue -lpspwlan EXEC = .elf LIB = .so MODULE = diff --git a/Server/Makefile b/Server/Makefile index 68322a9..59c05b6 100644 --- a/Server/Makefile +++ b/Server/Makefile @@ -16,7 +16,7 @@ tewi$(EXEC): $(OBJS) ../Common/common.a $(SERVADD) tewi.pbp: tewi_strip$(EXEC) param.sfo - pack-pbp $@ param.sfo NULL NULL NULL NULL NULL tewi_strip$(EXEC) NULL + pack-pbp $@ param.sfo ../Binary/psp.png NULL NULL NULL NULL tewi_strip$(EXEC) NULL param.sfo: mksfoex -d MEMSIZE=1 'Tewi HTTPd' $@ diff --git a/Server/main.c b/Server/main.c index 1fef989..cc827b2 100644 --- a/Server/main.c +++ b/Server/main.c @@ -28,11 +28,19 @@ #ifdef _PSP #include #include +#include +#include +#include +#include +#include PSP_MODULE_INFO("Tewi HTTPd", PSP_MODULE_USER, 1, 1); PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER); #define printf(...) pspDebugScreenPrintf(__VA_ARGS__) +#define STDERR_LOG(...) pspDebugScreenPrintf(__VA_ARGS__) +#else +#define STDERR_LOG(...) fprintf(stderr, __VA_ARGS__) #endif extern bool cm_do_log; @@ -86,6 +94,20 @@ void WINAPI servmain(DWORD argc, LPSTR* argv) { } #endif +int running = 1; +#ifdef _PSP + +int psp_exit_callback(int arg1, int arg2, void* arg3) { running = 0; } + +int psp_callback_thread(SceSize args, void* argp) { + int cid; + cid = sceKernelCreateCallback("Exit Call Back", psp_exit_callback, NULL); + sceKernelRegisterExitCallback(cid); + sceKernelSleepThreadCB(); + return 0; +} +#endif + int main(int argc, char** argv) { logfile = stderr; #ifdef SERVICE @@ -95,10 +117,144 @@ int main(int argc, char** argv) { #ifdef _PSP pspDebugScreenInit(); pspDebugScreenSetXY(0, 0); + printf("PSP Bootstrap, Tewi/%s\n", tw_get_version()); + int thid = sceKernelCreateThread("update_thread", psp_callback_thread, 0x11, 0xfa0, 0, NULL); + if(thid >= 0) { + sceKernelStartThread(thid, 0, NULL); + } else { + printf("Failed to start thread\n"); + while(running) sceKernelDelayThread(50 * 1000); + sceKernelExitGame(); + } + sceCtrlSetSamplingCycle(0); + sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); + sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON); + sceUtilityLoadNetModule(PSP_NET_MODULE_INET); + if(pspSdkInetInit()) { + printf("Could not init the network\n"); + while(running) sceKernelDelayThread(50 * 1000); + sceKernelExitGame(); + } else { + printf("Network initialization successful\n"); + } + if(sceWlanGetSwitchState() != 1) { + printf("Turn the Wi-Fi switch on\n"); + while(sceWlanGetSwitchState() != 1) { + sceKernelDelayThread(1000 * 1000); + } + } else { + printf("Wi-Fi is turned on\n"); + } + int i; + int choice[100]; + int incr = 0; + int last = 0; + int cur = 0; + for(i = 1; i < 100; i++) { + choice[i - 1] = 0; + netData name; + netData data; + if(sceUtilityCheckNetParam(i) != 0) continue; + choice[incr++] = i; + pspDebugScreenSetXY(0, 1 + 3 + incr - 1); + if(incr == 1) printf("> "); + pspDebugScreenSetXY(2, 1 + 3 + incr - 1); + sceUtilityGetNetParam(i, 0, &name); + sceUtilityGetNetParam(i, 1, &data); + printf("SSID=%s", data.asString); + sceUtilityGetNetParam(i, 4, &data); + if(data.asString[0]) { + sceUtilityGetNetParam(i, 5, &data); + printf(" IPADDR=%s\n", data.asString); + } else { + printf(" DHCP\n"); + } + } + int press = 0; + while(1) { + if(!running) { + sceKernelExitGame(); + } + SceCtrlData c; + sceCtrlReadBufferPositive(&c, 1); + press = 0; + if(c.Buttons & PSP_CTRL_DOWN) { + if(cur < incr - 1) { + cur++; + } + press = 1; + } else if(c.Buttons & PSP_CTRL_UP) { + if(cur > 0) { + cur--; + } + press = -1; + } else if(c.Buttons & PSP_CTRL_START) { + break; + } + if(last != cur) { + pspDebugScreenSetXY(0, 1 + 3 + last); + printf(" "); + pspDebugScreenSetXY(0, 1 + 3 + cur); + printf("> "); + last = cur; + } + if(press != 0) { + while(1) { + SceCtrlData c; + sceCtrlReadBufferPositive(&c, 1); + if(press == 1) { + if(!(c.Buttons & PSP_CTRL_DOWN)) break; + } else if(press == -1) { + if(!(c.Buttons & PSP_CTRL_UP)) break; + } + } + } + } + pspDebugScreenSetXY(0, 1 + 3 + incr + 1); + int err = sceNetApctlConnect(choice[cur]); + if(err != 0) { + printf("Apctl initialization failure\n"); + while(running) sceKernelDelayThread(50 * 1000); + sceKernelExitGame(); + } else { + printf("Apctl initialization successful\n"); + } + printf("Apctl connecting\n"); + while(1) { + int state; + err = sceNetApctlGetState(&state); + if(err != 0) { + printf("Apctl getting status failure\n"); + while(running) sceKernelDelayThread(50 * 1000); + sceKernelExitGame(); + } + if(state == 4) { + break; + } + sceKernelDelayThread(50 * 1000); + } + union SceNetApctlInfo info; + if(sceNetApctlGetInfo(8, &info) != 0) { + printf("Got an unknown IP\n"); + while(running) sceKernelDelayThread(50 * 1000); + sceKernelExitGame(); + } + printf("Connected, My IP is %s\n", info.ip); #endif int st = startup(argc, argv); - if(st != -1) return st; + if(st != -1) { +#ifdef _PSP + printf("Error code %d\n", st); + while(running) sceKernelDelayThread(50 * 1000); + sceKernelExitGame(); +#else + return st; +#endif + } tw_server_loop(); +#endif +#ifdef _PSP + sceKernelExitGame(); #endif return 0; } @@ -123,7 +279,7 @@ int startup(int argc, char** argv) { } else if(strcmp(argv[i], "--config") == 0 || strcmp(argv[i], "-C") == 0) { i++; if(argv[i] == NULL) { - fprintf(stderr, "Missing argument\n"); + STDERR_LOG("Missing argument\n"); return 1; } confpath = argv[i]; @@ -131,7 +287,7 @@ int startup(int argc, char** argv) { } else if(strcmp(argv[i], "--logfile") == 0 || strcmp(argv[i], "-l") == 0) { i++; if(argv[i] == NULL) { - fprintf(stderr, "Missing argument\n"); + STDERR_LOG("Missing argument\n"); return 1; } if(logfile != NULL && logfile != stderr) { @@ -139,7 +295,7 @@ int startup(int argc, char** argv) { } logfile = fopen(argv[i], "a"); if(logfile == NULL) { - fprintf(stderr, "Failed to open logfile\n"); + STDERR_LOG("Failed to open logfile\n"); return 1; } #endif @@ -157,7 +313,7 @@ int startup(int argc, char** argv) { printf("--version | -V : Version information\n"); return 0; } else { - fprintf(stderr, "Unknown option: %s\n", argv[i]); + STDERR_LOG("Unknown option: %s\n", argv[i]); return 1; } } @@ -165,11 +321,11 @@ int startup(int argc, char** argv) { } tw_config_init(); if(tw_config_read(confpath) != 0) { - fprintf(stderr, "Could not read the config\n"); + STDERR_LOG("Could not read the config\n"); return 1; } if(tw_server_init() != 0) { - fprintf(stderr, "Could not initialize the server\n"); + STDERR_LOG("Could not initialize the server\n"); return 1; } sprintf(tw_server, "Tewi/%s (%s)%s", tw_get_version(), tw_get_platform(), config.extension == NULL ? "" : config.extension); diff --git a/Server/server.c b/Server/server.c index 9e8374b..5e295c1 100644 --- a/Server/server.c +++ b/Server/server.c @@ -430,8 +430,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) +int tw_server_pass(void* ptr) { #endif -#if defined(__HAIKU__) || defined(__MINGW32__) +#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) int sock = ((struct pass_entry*)ptr)->sock; bool ssl = ((struct pass_entry*)ptr)->ssl; int port = ((struct pass_entry*)ptr)->port; @@ -854,6 +856,8 @@ struct thread_entry { }; #endif +extern int running; + void tw_server_loop(void) { int i; #if defined(__MINGW32__) || defined(__HAIKU__) @@ -872,7 +876,7 @@ void tw_server_loop(void) { fd_set fdset; struct timeval tv; #endif - while(1) { + while(running) { #ifdef USE_POLL int ret = poll(pollfds, sockcount, 1000); #else @@ -914,7 +918,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__) +#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) struct pass_entry* e = malloc(sizeof(*e)); e->sock = sock; e->ssl = config.ports[i] & (1ULL << 32); @@ -940,29 +944,31 @@ void tw_server_loop(void) { break; } } +#elif defined(_PSP) + tw_server_pass(e); #elif defined(__HAIKU__) - int j; - for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { - if(threads[j].used) { - thread_info info; - bool kill = false; - if(get_thread_info(threads[j].thread, &info) == B_OK) { - } else { - kill = true; - } - if(kill) { - threads[j].used = false; - } + int j; + for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { + if(threads[j].used) { + thread_info info; + bool kill = false; + if(get_thread_info(threads[j].thread, &info) == B_OK) { + } else { + kill = true; } - } - for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { - if(!threads[j].used) { - threads[j].thread = spawn_thread(tw_server_pass, "Tewi HTTPd", 60, e); - threads[j].used = true; - resume_thread(threads[j].thread); - break; + if(kill) { + threads[j].used = false; } } + } + for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { + if(!threads[j].used) { + threads[j].thread = spawn_thread(tw_server_pass, "Tewi HTTPd", 60, e); + threads[j].used = true; + resume_thread(threads[j].thread); + break; + } + } #else pid_t pid = fork(); if(pid == 0) { diff --git a/Server/version.c b/Server/version.c index c4cbb4c..3d49ce3 100644 --- a/Server/version.c +++ b/Server/version.c @@ -19,6 +19,8 @@ const char* tw_platform = "Haiku" #elif defined(__CYGWIN__) "Cygwin" +#elif defined(_PSP) + "PSP" #else "Unix" #endif -- 2.43.0