- Timestamp:
- Sep 28, 2024, 1:15:15 AM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Platform/psp.mk
r182 r183 1 1 # $Id$ 2 3 PREFIX = ms0:/PSP/GAME/httpd 2 4 3 5 CC = psp-gcc 4 6 AR = psp-ar 5 7 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I /usr/local/pspdev/psp/sdk/include -D_PSP_FW_VERSION=600 6 LDFLAGS = - L /usr/local/pspdev/psp/sdk/lib7 LIBS = -lpspgum -lpspgu -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspnet -lpspnet_apctl 8 LDFLAGS = -Wl,-zmax-page-size=128 -L /usr/local/pspdev/psp/sdk/lib 9 LIBS = -lpspgum -lpspgu -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspnet -lpspnet_apctl -lcglue -lpspwlan 8 10 EXEC = .elf 9 11 LIB = .so -
trunk/Server/Makefile
r182 r183 17 17 18 18 tewi.pbp: tewi_strip$(EXEC) param.sfo 19 pack-pbp $@ param.sfo NULLNULL NULL NULL NULL tewi_strip$(EXEC) NULL19 pack-pbp $@ param.sfo ../Binary/psp.png NULL NULL NULL NULL tewi_strip$(EXEC) NULL 20 20 21 21 param.sfo: -
trunk/Server/main.c
r182 r183 29 29 #include <pspkernel.h> 30 30 #include <pspdebug.h> 31 #include <pspsdk.h> 32 #include <psputility.h> 33 #include <pspctrl.h> 34 #include <pspnet_apctl.h> 35 #include <pspwlan.h> 31 36 32 37 PSP_MODULE_INFO("Tewi HTTPd", PSP_MODULE_USER, 1, 1); … … 34 39 35 40 #define printf(...) pspDebugScreenPrintf(__VA_ARGS__) 41 #define STDERR_LOG(...) pspDebugScreenPrintf(__VA_ARGS__) 42 #else 43 #define STDERR_LOG(...) fprintf(stderr, __VA_ARGS__) 36 44 #endif 37 45 … … 87 95 #endif 88 96 97 int running = 1; 98 #ifdef _PSP 99 100 int psp_exit_callback(int arg1, int arg2, void* arg3) { running = 0; } 101 102 int psp_callback_thread(SceSize args, void* argp) { 103 int cid; 104 cid = sceKernelCreateCallback("Exit Call Back", psp_exit_callback, NULL); 105 sceKernelRegisterExitCallback(cid); 106 sceKernelSleepThreadCB(); 107 return 0; 108 } 109 #endif 110 89 111 int main(int argc, char** argv) { 90 112 logfile = stderr; … … 96 118 pspDebugScreenInit(); 97 119 pspDebugScreenSetXY(0, 0); 120 printf("PSP Bootstrap, Tewi/%s\n", tw_get_version()); 121 int thid = sceKernelCreateThread("update_thread", psp_callback_thread, 0x11, 0xfa0, 0, NULL); 122 if(thid >= 0) { 123 sceKernelStartThread(thid, 0, NULL); 124 } else { 125 printf("Failed to start thread\n"); 126 while(running) sceKernelDelayThread(50 * 1000); 127 sceKernelExitGame(); 128 } 129 sceCtrlSetSamplingCycle(0); 130 sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); 131 sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON); 132 sceUtilityLoadNetModule(PSP_NET_MODULE_INET); 133 if(pspSdkInetInit()) { 134 printf("Could not init the network\n"); 135 while(running) sceKernelDelayThread(50 * 1000); 136 sceKernelExitGame(); 137 } else { 138 printf("Network initialization successful\n"); 139 } 140 if(sceWlanGetSwitchState() != 1) { 141 printf("Turn the Wi-Fi switch on\n"); 142 while(sceWlanGetSwitchState() != 1) { 143 sceKernelDelayThread(1000 * 1000); 144 } 145 } else { 146 printf("Wi-Fi is turned on\n"); 147 } 148 int i; 149 int choice[100]; 150 int incr = 0; 151 int last = 0; 152 int cur = 0; 153 for(i = 1; i < 100; i++) { 154 choice[i - 1] = 0; 155 netData name; 156 netData data; 157 if(sceUtilityCheckNetParam(i) != 0) continue; 158 choice[incr++] = i; 159 pspDebugScreenSetXY(0, 1 + 3 + incr - 1); 160 if(incr == 1) printf("> "); 161 pspDebugScreenSetXY(2, 1 + 3 + incr - 1); 162 sceUtilityGetNetParam(i, 0, &name); 163 sceUtilityGetNetParam(i, 1, &data); 164 printf("SSID=%s", data.asString); 165 sceUtilityGetNetParam(i, 4, &data); 166 if(data.asString[0]) { 167 sceUtilityGetNetParam(i, 5, &data); 168 printf(" IPADDR=%s\n", data.asString); 169 } else { 170 printf(" DHCP\n"); 171 } 172 } 173 int press = 0; 174 while(1) { 175 if(!running) { 176 sceKernelExitGame(); 177 } 178 SceCtrlData c; 179 sceCtrlReadBufferPositive(&c, 1); 180 press = 0; 181 if(c.Buttons & PSP_CTRL_DOWN) { 182 if(cur < incr - 1) { 183 cur++; 184 } 185 press = 1; 186 } else if(c.Buttons & PSP_CTRL_UP) { 187 if(cur > 0) { 188 cur--; 189 } 190 press = -1; 191 } else if(c.Buttons & PSP_CTRL_START) { 192 break; 193 } 194 if(last != cur) { 195 pspDebugScreenSetXY(0, 1 + 3 + last); 196 printf(" "); 197 pspDebugScreenSetXY(0, 1 + 3 + cur); 198 printf("> "); 199 last = cur; 200 } 201 if(press != 0) { 202 while(1) { 203 SceCtrlData c; 204 sceCtrlReadBufferPositive(&c, 1); 205 if(press == 1) { 206 if(!(c.Buttons & PSP_CTRL_DOWN)) break; 207 } else if(press == -1) { 208 if(!(c.Buttons & PSP_CTRL_UP)) break; 209 } 210 } 211 } 212 } 213 pspDebugScreenSetXY(0, 1 + 3 + incr + 1); 214 int err = sceNetApctlConnect(choice[cur]); 215 if(err != 0) { 216 printf("Apctl initialization failure\n"); 217 while(running) sceKernelDelayThread(50 * 1000); 218 sceKernelExitGame(); 219 } else { 220 printf("Apctl initialization successful\n"); 221 } 222 printf("Apctl connecting\n"); 223 while(1) { 224 int state; 225 err = sceNetApctlGetState(&state); 226 if(err != 0) { 227 printf("Apctl getting status failure\n"); 228 while(running) sceKernelDelayThread(50 * 1000); 229 sceKernelExitGame(); 230 } 231 if(state == 4) { 232 break; 233 } 234 sceKernelDelayThread(50 * 1000); 235 } 236 union SceNetApctlInfo info; 237 if(sceNetApctlGetInfo(8, &info) != 0) { 238 printf("Got an unknown IP\n"); 239 while(running) sceKernelDelayThread(50 * 1000); 240 sceKernelExitGame(); 241 } 242 printf("Connected, My IP is %s\n", info.ip); 98 243 #endif 99 244 int st = startup(argc, argv); 100 if(st != -1) return st; 245 if(st != -1) { 246 #ifdef _PSP 247 printf("Error code %d\n", st); 248 while(running) sceKernelDelayThread(50 * 1000); 249 sceKernelExitGame(); 250 #else 251 return st; 252 #endif 253 } 101 254 tw_server_loop(); 255 #endif 256 #ifdef _PSP 257 sceKernelExitGame(); 102 258 #endif 103 259 return 0; … … 124 280 i++; 125 281 if(argv[i] == NULL) { 126 fprintf(stderr,"Missing argument\n");282 STDERR_LOG("Missing argument\n"); 127 283 return 1; 128 284 } … … 132 288 i++; 133 289 if(argv[i] == NULL) { 134 fprintf(stderr,"Missing argument\n");290 STDERR_LOG("Missing argument\n"); 135 291 return 1; 136 292 } … … 140 296 logfile = fopen(argv[i], "a"); 141 297 if(logfile == NULL) { 142 fprintf(stderr,"Failed to open logfile\n");298 STDERR_LOG("Failed to open logfile\n"); 143 299 return 1; 144 300 } … … 158 314 return 0; 159 315 } else { 160 fprintf(stderr,"Unknown option: %s\n", argv[i]);316 STDERR_LOG("Unknown option: %s\n", argv[i]); 161 317 return 1; 162 318 } … … 166 322 tw_config_init(); 167 323 if(tw_config_read(confpath) != 0) { 168 fprintf(stderr,"Could not read the config\n");324 STDERR_LOG("Could not read the config\n"); 169 325 return 1; 170 326 } 171 327 if(tw_server_init() != 0) { 172 fprintf(stderr,"Could not initialize the server\n");328 STDERR_LOG("Could not initialize the server\n"); 173 329 return 1; 174 330 } -
trunk/Server/server.c
r182 r183 431 431 #elif defined(__HAIKU__) 432 432 int32_t tw_server_pass(void* ptr) { 433 #endif 434 #if defined(__HAIKU__) || defined(__MINGW32__) 433 #elif defined(_PSP) 434 int tw_server_pass(void* ptr) { 435 #endif 436 #if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) 435 437 int sock = ((struct pass_entry*)ptr)->sock; 436 438 bool ssl = ((struct pass_entry*)ptr)->ssl; … … 855 857 #endif 856 858 859 extern int running; 860 857 861 void tw_server_loop(void) { 858 862 int i; … … 873 877 struct timeval tv; 874 878 #endif 875 while( 1) {879 while(running) { 876 880 #ifdef USE_POLL 877 881 int ret = poll(pollfds, sockcount, 1000); … … 915 919 int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); 916 920 cm_log("Server", "New connection accepted"); 917 #if defined(__MINGW32__) || defined(__HAIKU__) 921 #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) 918 922 struct pass_entry* e = malloc(sizeof(*e)); 919 923 e->sock = sock; … … 941 945 } 942 946 } 947 #elif defined(_PSP) 948 tw_server_pass(e); 943 949 #elif defined(__HAIKU__) 944 int j; 945 for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { 946 if(threads[j].used) { 947 thread_info info; 948 bool kill = false; 949 if(get_thread_info(threads[j].thread, &info) == B_OK) { 950 } else { 951 kill = true; 952 } 953 if(kill) { 954 threads[j].used = false; 955 } 950 int j; 951 for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { 952 if(threads[j].used) { 953 thread_info info; 954 bool kill = false; 955 if(get_thread_info(threads[j].thread, &info) == B_OK) { 956 } else { 957 kill = true; 958 } 959 if(kill) { 960 threads[j].used = false; 956 961 } 957 962 } 958 for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) {959 if(!threads[j].used) {960 threads[j].thread = spawn_thread(tw_server_pass, "Tewi HTTPd", 60, e);961 threads[j].used = true;962 resume_thread(threads[j].thread);963 break;964 }963 } 964 for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) { 965 if(!threads[j].used) { 966 threads[j].thread = spawn_thread(tw_server_pass, "Tewi HTTPd", 60, e); 967 threads[j].used = true; 968 resume_thread(threads[j].thread); 969 break; 965 970 } 971 } 966 972 #else 967 973 pid_t pid = fork(); -
trunk/Server/version.c
r163 r183 20 20 #elif defined(__CYGWIN__) 21 21 "Cygwin" 22 #elif defined(_PSP) 23 "PSP" 22 24 #else 23 25 "Unix"
Note:
See TracChangeset
for help on using the changeset viewer.