void InitializeNetwork(bool silent) { // stop if we're already initialized, or if auto-init has failed before // in which case, manual initialization is required if(networkInit || !autoNetworkInit) return; if(!silent) ShowAction ("Initializing network..."); char ip[16]; s32 initResult = if_config(ip, NULL, NULL, true); if(initResult == 0) { networkInit = true; } else { // do not automatically attempt a reconnection autoNetworkInit = false; if(!silent) { char msg[150]; sprintf(msg, "Unable to initialize network (Error #: %i)", initResult); WaitPrompt(msg); } } }
void initializeNet (int retry) { s32 res = -EAGAIN; int retries = 0; shutdownNet(); memset(hostIP, 0, 16); while (res == -EAGAIN) { if (retries == retry) { return; } sleep(10); /* Wait 10 seconds. */ res = net_init(); retries++; } if_config(hostIP, NULL, NULL, true); netReady = 1; }
bool InitializeNetwork(bool silent) { ShowAction ((char*) "Initializing network..."); s32 result; while ((result = net_init()) == -EAGAIN); if (result >= 0) { char myIP[16]; if (if_config(myIP, NULL, NULL, true) < 0) { if(!silent) WaitPrompt((char*) "Error reading IP address."); return false; } else { return true; } } if(!silent) WaitPrompt((char*) "Unable to initialize network."); return false; }
s32 Network_Init(void) { s32 ret; /* Initialize network */ ret = if_config(hostip, NULL, NULL, true); if (ret < 0) return ret; return 0; }
static int if_up_with(int index) { (void)index; #ifdef __CELLOS_LV2__ int timeout_count = 10; int state; int ret; ret = cellNetCtlInit(); if (ret < 0) { printf("cellNetCtlInit() failed(%x)\n", ret); return -1; } for (;;) { ret = cellNetCtlGetState(&state); if (ret < 0) { printf("cellNetCtlGetState() failed(%x)\n", ret); return -1; } if (state == CELL_NET_CTL_STATE_IPObtained) break; sys_timer_usleep(500 * 1000); timeout_count--; if (index && timeout_count < 0) { printf("if_up_with(%d) timeout\n", index); return 0; } } #elif defined(GEKKO) char t[16]; if (if_config(t, NULL, NULL, TRUE) < 0) { return -1; } #endif sock=socket(AF_INET, SOCK_DGRAM, 0); target.sin_family = AF_INET; target.sin_port = htons(PC_DEVELOPMENT_UDP_PORT); #ifdef GEKKO target.sin_len = 8; #endif inet_pton(AF_INET, PC_DEVELOPMENT_IP_ADDRESS, &target.sin_addr); return 0; }
bool InitializeNetwork(bool silent) { #ifdef HW_RVL StopNetworkThread(); if(networkInit && net_gethostip() > 0) return true; networkInit = false; #else if(networkInit) return true; #endif int retry = 1; while(retry) { ShowAction("Initializing network..."); #ifdef HW_RVL u64 start = gettime(); StartNetworkThread(); while (!LWP_ThreadIsSuspended(networkthread)) { usleep(50 * 1000); if(diff_sec(start, gettime()) > 10) // wait for 10 seconds max for net init break; } #else networkInit = !(if_config(wiiIP, NULL, NULL, true) < 0); #endif CancelAction(); if(networkInit || silent) break; retry = ErrorPromptRetry("Unable to initialize network!"); #ifdef HW_RVL if(networkInit && net_gethostip() > 0) #else if(networkInit) #endif return true; } return networkInit; }
bool InitNetwork() { char myIP[16]; memset(myIP, 0, sizeof(myIP)); printf("Getting IP address via DHCP...\n\n"); if (if_config(myIP, NULL, NULL, true) < 0) { printf("No DHCP reply\n\n"); return false; } printf("Got an address: %s\n",myIP); return true; }
/**************************************************************************** * Initialize_Network ***************************************************************************/ void Initialize_Network(void) { if (networkinitialized) return; s32 result; result = if_config(IP, NULL, NULL, true); if (result < 0) { networkinitialized = false; return; } else { networkinitialized = true; return; } }
void NetworkInit() { if (networkInitialized) return; int retryCount = 0; int ret = 0; printf("\nInitializing Network..."); fflush(stdout); ret = if_config(hostip, NULL, NULL, true); if (ret < 0) { printf( "\n>> ERROR! Failed to Initialize the network: ErrorCode (%d)\n", ret); return; } //SpinnerStart(); while (1) { ret = net_init(); if (ret < 0) { if (ret != -EAGAIN) { retryCount++; printf("net_init failed trying again: %d\n", ret); sleep(3); } } if (retryCount > 4) break; if (!ret) break; sleep(1); printf("."); fflush(stdout); } // SpinnerStop(); if (ret < 0 || retryCount != 0) { printf( "\n>> ERROR! Failed to Initialize the network: ErrorCode (%d)\n", ret); return; } printf("\b.Done\n"); networkInitialized = true; }
void init_wii() { VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); // The console understands VT terminal escape codes // This positions the cursor on row 2, column 0 // we can use variables for this with format codes too // e.g. printf ("\x1b[%d;%dH", row, column ); printf("\x1b[2;0H"); printf("yellhttptest\n"); printf("Initializing FAT...\n"); if(!fatInitDefault()) { printf("FAT init failed.\n"); console_pause(); } printf("Configuring network ...\n"); memset(localip, 0, 16); memset(netmask, 0, 16); memset(gateway, 0, 16); s32 ret = if_config (localip, netmask, gateway, true); if(ret<0) { printf("Network config failed: %d\n", ret); console_pause(); } else { printf("Network config done ip: %s, gw: %s, mask %s\n", localip, gateway, netmask); } }
void InitializeNetwork(bool silent) { // stop if we're already initialized, or if auto-init has failed before // in which case, manual initialization is required if(networkInit || !autoNetworkInit) return; if(!silent) ShowAction ("Initializing network..."); while(inNetworkInit) // a network init is already in progress! usleep(50); if(networkInit) // check again if the network was inited return; inNetworkInit = true; char ip[16]; s32 initResult = if_config(ip, NULL, NULL, true); if(initResult == 0) { networkInit = true; } else { // do not automatically attempt a reconnection autoNetworkInit = false; if(!silent) { char msg[150]; sprintf(msg, "Unable to initialize network (Error #: %i)", initResult); ErrorPrompt(msg); } } if(!silent) CancelAction(); inNetworkInit = false; }
// Init the GC/Wii net interface (wifi/bba/etc) static void* init_network(void *args) { char ip[16]; int res = 0, netsleep = 1*1000*1000; while(netsleep > 0) { if(netInitHalted) { LWP_SuspendThread(initnetthread); } usleep(100); netsleep -= 100; } while(1) { if(!net_initialized) { netInitPending = 1; res = if_config(ip, NULL, NULL, true, 5); if(res >= 0) { net_initialized = 1; } else { net_initialized = 0; } netInitPending = 0; } netsleep = 1000*1000; // 1 sec while(netsleep > 0) { if(netInitHalted) { LWP_SuspendThread(initnetthread); } usleep(100); netsleep -= 100; } } return NULL; }
int InitNetwork(NET_STATE* ref) { int ret, result; ret = if_config(ref->localip, ref->netmask, ref->gateway, TRUE); if (ret < 0) { return -1; } ref->socket = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (ref->socket == INVALID_SOCKET) { return -1; } memset(&ref->sockAddr, 0, sizeof(ref->sockAddr)); ref->sockAddr.sin_family = AF_INET; ref->sockAddr.sin_port = htons(NETWORK_PORT_A); ref->sockAddr.sin_addr.s_addr = inet_addr(HOST_IP); /* getaddrinfo(HOST_NAME, STR(HOST_IP), NULL, &addrinfo); */ result = net_connect(ref->socket, (struct sockaddr *)&ref->sockAddr, sizeof(ref->sockAddr)); if (result == -1) { net_close(ref->socket); return -1; } if (LWP_CreateThread(&ref->thread_handle, NetworkThread, (void*)ref, NULL, 256*1024, 60) < 0) { ref->threadTerminated = 1; return -1; } return 0; }
int main (int argc, char **argv) { VIDEO_Init(); WPAD_Init(); PAD_Init(); sys_rmode = VIDEO_GetPreferredMode(NULL); sys_framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode)); sys_framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode)); sys_frame_count = 0; CON_Init(sys_framebuffer[sys_frame_count & 1], 20, 20, sys_rmode->fbWidth, sys_rmode->xfbHeight, sys_rmode->fbWidth * VI_DISPLAY_PIX_SZ); VIDEO_Configure(sys_rmode); VIDEO_SetNextFramebuffer(sys_framebuffer[sys_frame_count & 1]); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(sys_rmode->viTVMode & VI_NON_INTERLACE) { VIDEO_WaitVSync(); }; sys_frame_count++; GXU_Init(sys_rmode, sys_framebuffer[sys_frame_count & 1]); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_0, sys_rmode->fbWidth, sys_rmode->xfbHeight); if(!fatInitDefault()) { Sys_Error("Filesystem not enabled"); }; sys_previous_time = Sys_Milliseconds(); do { sys_netinit_error = if_config(sys_ipaddress_text, NULL, NULL, true); } while((sys_netinit_error == -EAGAIN)&&((Sys_Milliseconds() - sys_previous_time) < 3000)); if(sys_netinit_error < 0) { printf("Network not enabled\n"); }; if (KEYBOARD_Init(Sys_KeyPress) != 0) { printf("Keyboard not found\n"); }; OSK_LoadKeys(Keys_dat, Keys_dat_size); int len, i; char *cmdline; // merge the command line, this is kinda silly for (len = 1, i = 1; i < argc; i++) len += strlen(argv[i]) + 1; cmdline = malloc(len); *cmdline = 0; for (i = 1; i < argc; i++) { if (i > 1) strcat(cmdline, " "); strcat(cmdline, argv[i]); } Com_Init(cmdline); WPAD_SetPowerButtonCallback(Sys_PowerOff); while (1) { sys_previous_time = Sys_Milliseconds(); if(MOUSE_IsConnected()) { sys_mouse_valid = MOUSE_GetEvent(&sys_mouse_event); if(sys_mouse_valid) MOUSE_FlushEvents(); } else { sys_mouse_valid = 0; sys_mouse_event.button = 0; }; Com_Frame( ); if(in_osk->value) { OSK_Draw(sys_rmode, sys_framebuffer[sys_frame_count & 1]); }; sys_frame_count++; GXU_EndFrame(sys_framebuffer[sys_frame_count & 1]); KEYBOARD_FlushEvents(); VIDEO_Flush(); VIDEO_WaitVSync(); } return 0; }
/** * network_init: * * Platform specific socket library initialization. * * Returns: true (1) if successful, otherwise false (0). **/ bool network_init(void) { #ifdef _WIN32 WSADATA wsaData; #endif static bool inited = false; if (inited) return true; #if defined(_WIN32) if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { network_deinit(); return false; } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) int timeout_count = 10; cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); if (cellNetCtlInit() < 0) return false; for (;;) { int state; if (cellNetCtlGetState(&state) < 0) return false; if (state == CELL_NET_CTL_STATE_IPObtained) break; retro_sleep(500); timeout_count--; if (timeout_count < 0) return 0; } #elif defined(VITA) SceNetInitParam initparam; if (sceNetShowNetstat() == SCE_NET_ERROR_ENOTINIT) { _net_compat_net_memory = malloc(COMPAT_NET_INIT_SIZE); initparam.memory = _net_compat_net_memory; initparam.size = COMPAT_NET_INIT_SIZE; initparam.flags = 0; sceNetInit(&initparam); sceNetCtlInit(); } retro_epoll_fd = sceNetEpollCreate("epoll", 0); #elif defined(GEKKO) char t[16]; if (if_config(t, NULL, NULL, TRUE, 10) < 0) return false; #elif defined(WIIU) socket_lib_init(); #elif defined(_3DS) _net_compat_net_memory = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE); if (_net_compat_net_memory == NULL) return false; Result ret = socInit(_net_compat_net_memory, SOC_BUFFERSIZE);//WIFI init if (ret != 0) return false; #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif inited = true; return true; }
static int network_interface_up(struct sockaddr_in *target, int index, const char *ip_address, unsigned udp_port, int *s) { (void)index; #if defined(VITA) if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) { SceNetInitParam initparam; net_memory = malloc(NET_INIT_SIZE); initparam.memory = net_memory; initparam.size = NET_INIT_SIZE; initparam.flags = 0; sceNetInit(&initparam); } *s = sceNetSocket("RA_netlogger", PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, 0); target->sin_family = PSP2_NET_AF_INET; target->sin_port = sceNetHtons(udp_port); sceNetInetPton(PSP2_NET_AF_INET, ip_address, &target->sin_addr); #else #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) int ret = 0; int state, timeout_count = 10; ret = cellNetCtlInit(); if (ret < 0) return -1; for (;;) { ret = cellNetCtlGetState(&state); if (ret < 0) return -1; if (state == CELL_NET_CTL_STATE_IPObtained) break; retro_sleep(500); timeout_count--; if (index && timeout_count < 0) return 0; } #elif defined(GEKKO) char t[16]; if (if_config(t, NULL, NULL, TRUE) < 0) ret = -1; #endif if (ret < 0) return -1; *s = socket(AF_INET, SOCK_DGRAM, 0); target->sin_family = AF_INET; target->sin_port = htons(udp_port); #ifdef GEKKO target->sin_len = 8; #endif inet_pton(AF_INET, ip_address, &target->sin_addr); #endif return 0; }
static int if_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct cardstate *cs = tty->driver_data; int retval = -ENODEV; int int_arg; unsigned char buf[6]; unsigned version[4]; gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd); if (mutex_lock_interruptible(&cs->mutex)) return -ERESTARTSYS; if (!cs->connected) { gig_dbg(DEBUG_IF, "not connected"); retval = -ENODEV; } else { retval = 0; switch (cmd) { case GIGASET_REDIR: retval = get_user(int_arg, (int __user *) arg); if (retval >= 0) retval = if_lock(cs, &int_arg); if (retval >= 0) retval = put_user(int_arg, (int __user *) arg); break; case GIGASET_CONFIG: retval = get_user(int_arg, (int __user *) arg); if (retval >= 0) retval = if_config(cs, &int_arg); if (retval >= 0) retval = put_user(int_arg, (int __user *) arg); break; case GIGASET_BRKCHARS: retval = copy_from_user(&buf, (const unsigned char __user *) arg, 6) ? -EFAULT : 0; if (retval >= 0) { gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", 6, (const unsigned char *) arg); retval = cs->ops->brkchars(cs, buf); } break; case GIGASET_VERSION: retval = copy_from_user(version, (unsigned __user *) arg, sizeof version) ? -EFAULT : 0; if (retval >= 0) retval = if_version(cs, version); if (retval >= 0) retval = copy_to_user((unsigned __user *) arg, version, sizeof version) ? -EFAULT : 0; break; default: gig_dbg(DEBUG_IF, "%s: arg not supported - 0x%04x", __func__, cmd); retval = -ENOIOCTLCMD; } } mutex_unlock(&cs->mutex); return retval; }
void FlushLog() { #ifdef DEBUGPOST s32 retval; u32 cid = 0; YellHttp_Ctx *ctx = YellHttp_InitCtx(); time_t curtime; struct tm *timeconv; printf("Flushing log...\n"); memset(errstr, 0, 256); memset(creds, 0, 256); strncpy(creds, "wc24boottitle:WC24HAXX", 256); YellHttp_SetAuthCb(authentication_callback, creds); ctx->server_flags |= YELLHTTP_SRVFLAG_NOCACHE; memset(log_name, 0, 256); ES_GetDeviceID(&cid); curtime = time(NULL); timeconv = gmtime(&curtime); snprintf(log_name, 255, "%08x_%d-%d-%d_%d-%d-%d", cid, timeconv->tm_mday, timeconv->tm_mon, timeconv->tm_year - 100, timeconv->tm_hour, timeconv->tm_min, timeconv->tm_sec); formentries[0].numfields = 2; formentries[0].fields = formfields; formfields[1].value = log_name; formentries[0].path = NULL; memset(formentries[0].content_type, 0, 512); strncpy(formentries[0].content_type, "text/plain", 511); formentries[0].data = (unsigned char*)log_buffer; formentries[0].data_length = strnlen(log_buffer, 0x4000); memset(localip, 0, 16); memset(netmask, 0, 16); memset(gateway, 0, 16); printf("Initializing network...\n"); retval = if_config (localip, netmask, gateway, true); if(retval<0) { printf("Network init failed: %d\n", retval); YellHttp_FreeCtx(ctx); free(log_buffer); return; } printf("Executing ExecRequest...(GET)\n"); retval = YellHttp_ExecRequest(ctx, "http://192.168.1.33/wc24boottitle/debuglogs/upload.php"); YellHttp_GetErrorStr(retval, errstr, 256); if(retval!=0) { printf("retval = %d str: %s", retval, errstr); } retval = YellHttp_EncodePostMIME_MultipartFormData(ctx, formentries, 1); YellHttp_GetErrorStr(retval, errstr, 256); if(retval!=0)printf("Encode MIME retval = %d str: %s", retval, errstr); memset(errstr, 0, 256); printf("Executing ExecRequest...(POST)\n"); retval = YellHttp_ExecRequest(ctx, "http://192.168.1.33/wc24boottitle/debuglogs/upload.php"); YellHttp_GetErrorStr(retval, errstr, 256); if(retval!=0) { printf("retval = %d str: %s", retval, errstr); } YellHttp_FreeCtx(ctx); free(log_buffer); #endif }
void ProcessArgs(int argc, char **argv, int boothbdirect) { int i; s32 retval; u32 bootcode = launchcode & ~(0xff<<24);//Mask out the high 8-bits of launchcode, since that's used for options etc. char *path = (char*)0x900FFF00; void (*entry)() = (void*)0x80001800; u64 nandboot_titleid; YellHttp_Ctx *ctx; int use_wc24http = 0; u32 index; FILE *fdol; struct stat dolstats; if(!fatInitDefault())printf("FAT init failed.\n"); printf("Processing args...\n"); #ifndef WIILOADAPPDEBUG if(argc && !boothbdirect) { sscanf(argv[0], "%016llx", &nandboot_titleid); if(curtitleid!=nandboot_titleid) { printf("Current titleID and titleID from NANDBOOTINFO don't match: %016llx %s\n", curtitleid, argv[0]); argc = 0; } } #endif if(argc) { if(boothbdirect)launchcode = 1; if(launchcode & BIT(24))use_wc24http = 1; switch(bootcode) { case 1://Boot homebrew if(argc<2)break; if(!boothbdirect)printf("Booting homebrew from: %s\n", argv[1]); memcpy((void*)0x80001800, loader_bin, loader_bin_size); memset(path, 0, 256); if(!boothbdirect) { if(strncmp(argv[1], "http", 4)==0) { if(!use_wc24http) { printf("Using libyellhttp to download: %s\n", argv[1]); memset(localip, 0, 16); memset(netmask, 0, 16); memset(gateway, 0, 16); printf("Initializing network...\n"); retval = if_config (localip, netmask, gateway, true); if(retval<0) { printf("Network init failed: %d\n", retval); break; } ctx = YellHttp_InitCtx(); if(ctx==NULL) { printf("Failed to init/alloc http ctx.\n"); break; } printf("Downloading %s...\n", argv[1]); if(launchcode & BIT(26)) { WC24_MountWC24DlVFF(); chdir("wc24dl.vff:/"); } retval = YellHttp_ExecRequest(ctx, argv[1]); YellHttp_FreeCtx(ctx); if(retval<0) { memset(errstr, 0, 256); YellHttp_GetErrorStr(retval, errstr, 256); printf("retval = %d str: %s", retval, errstr); break; } for(i=strlen(argv[1])-1; i>0; i--) { if(argv[1][i]=='/')break; } i++; if(launchcode & BIT(26))strncpy(path, "wc24dl.vff:", 255); strncat(path, &argv[1][i], 255); } else { printf("Using WC24 to download: %s\n", argv[1]); printf("Creating record+entry...\n"); retval = WC24_CreateRecord(&myrec, &myent, 0, 0, 0x4842, WC24_TYPE_TITLEDATA, WC24_RECORD_FLAGS_DEFAULT, WC24_FLAGS_HB, 0x3c, 0x5a0, 0, argv[1], VFFPATH "boot.dol"); if(retval<0) { printf("WC24_CreateRecord returned %d\n", retval); WC24_Shutdown(); break; } index = retval; printf("Downloading...\n"); retval = KD_Download(KD_DOWNLOADFLAGS_MANUAL, (u16)index, 0x0); if(retval<0) { printf("KD_Download returned %d\n", retval); WC24_DeleteRecord(index); WC24_Shutdown(); break; } printf("Deleting record+entry...\n"); WC24_DeleteRecord(index); printf("Mounting VFF...\n"); retval = WC24_MountWC24DlVFF(); if(retval<0) { printf("WC24_MountWC24DlVFF returned %d\n", retval); WC24_Shutdown(); break; } printf("Reading wc24dl.vff:/" VFFPATH "boot.dol...\n"); fdol = fopen("wc24dl.vff:/" VFFPATH "boot.dol", "r"); if(fdol==NULL) { printf("Failed to open wc24dl.vff:/" VFFPATH "boot.dol\n"); } else { stat("wc24dl.vff:/" VFFPATH "boot.dol", &dolstats); dol_size = dolstats.st_size; fread((void*)0x90100000, 1, dolstats.st_size, fdol); fclose(fdol); unlink("wc24dl.vff:/" VFFPATH "boot.dol"); DCFlushRange((void*)0x90100000, dolstats.st_size); } printf("Unmounting VFF...\n"); VFF_Unmount("wc24dl.vff"); memset(path, 0, 256); boothbdirect = 1; WII_SetNANDBootInfoLaunchcode(0); } } else { strncpy(path, argv[1], 255); } if(!use_wc24http) { if(strncmp(path, "dvd", 3)==0) { DI_Init(); if(!ISO9660_Mount()) { printf("Failed to mount DVD ISO9660.\n"); DI_Close(); break; } } stat(path, &dolstats); dol_size = dolstats.st_size; fdol = fopen(path, "r"); if(fdol==NULL) { printf("Dol doesn't exist: %s\n", argv[1]); break; } else { fread((void*)0x90100000, 1, dol_size, fdol); DCFlushRange((void*)0x90100000, dol_size); fclose(fdol); } memset(path, 0, 256); if(strncmp(path, "dvd", 3)==0) { ISO9660_Unmount(); DI_Close(); } if(launchcode & BIT(26)) { unlink(path); VFF_Unmount("wc24dl.vff"); } } } SetDolArgv((void*)0x90100000, dol_size, argc, argv); DCFlushRange((void*)0x80001800, loader_bin_size); DCFlushRange(path, 256); if(!boothbdirect)WII_SetNANDBootInfoLaunchcode(0); if(!boothbdirect) { printf("Booting: %s\n", path); } else { printf("Booting homebrew directly from RAM buffer.\n"); } WC24_Shutdown(); WPAD_Shutdown(); FlushLog(); //IOS_ReloadIOS(36); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); entry(); break; case 2://Boot game disc memcpy((void*)0x80001800, loader_bin, loader_bin_size); memset(path, 0, 256); memcpy((void*)0x90100000, tinyload_dol, tinyload_dol_size); DCFlushRange((void*)0x80001800, loader_bin_size); DCFlushRange(path, 256); DCFlushRange((void*)0x90100000, tinyload_dol_size); WII_SetNANDBootInfoLaunchcode(0); WC24_Shutdown(); WPAD_Shutdown(); printf("Booting game disc.\n"); FlushLog(); entry(); break; default: break; } } printf("Invalid launchcode or argc: %x %x\n", launchcode, argc); #ifdef DEBUG printf("Press A to contine.\n"); while(1) { WPAD_ScanPads(); if(WPAD_ButtonsDown(0) & WPAD_BUTTON_A)break; VIDEO_WaitVSync(); } #endif printf("Shutting down...\n"); printf("Shutting down WC24...\n"); if(launchcode & BIT(26))VFF_Unmount("wc24dl.vff"); WC24_Shutdown(); FlushLog(); WPAD_Shutdown(); WII_Shutdown(); }
static int if_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct cardstate *cs; int retval = -ENODEV; int int_arg; unsigned char buf[6]; unsigned version[4]; cs = (struct cardstate *) tty->driver_data; if (!cs) { err("cs==NULL in %s", __func__); return -ENODEV; } gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd); if (mutex_lock_interruptible(&cs->mutex)) return -ERESTARTSYS; // FIXME -EINTR? if (!cs->open_count) warn("%s: device not opened", __func__); else { retval = 0; switch (cmd) { case GIGASET_REDIR: retval = get_user(int_arg, (int __user *) arg); if (retval >= 0) retval = if_lock(cs, &int_arg); if (retval >= 0) retval = put_user(int_arg, (int __user *) arg); break; case GIGASET_CONFIG: retval = get_user(int_arg, (int __user *) arg); if (retval >= 0) retval = if_config(cs, &int_arg); if (retval >= 0) retval = put_user(int_arg, (int __user *) arg); break; case GIGASET_BRKCHARS: //FIXME test if MS_LOCKED if (!cs->connected) { gig_dbg(DEBUG_ANY, "can't communicate with unplugged device"); retval = -ENODEV; break; } retval = copy_from_user(&buf, (const unsigned char __user *) arg, 6) ? -EFAULT : 0; if (retval >= 0) { gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", 6, (const unsigned char *) arg); retval = cs->ops->brkchars(cs, buf); } break; case GIGASET_VERSION: retval = copy_from_user(version, (unsigned __user *) arg, sizeof version) ? -EFAULT : 0; if (retval >= 0) retval = if_version(cs, version); if (retval >= 0) retval = copy_to_user((unsigned __user *) arg, version, sizeof version) ? -EFAULT : 0; break; default: gig_dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x", __func__, cmd); retval = -ENOIOCTLCMD; } } mutex_unlock(&cs->mutex); return retval; }
// If there was some new files obtained, return 1, else 0 void verify_download(char *mountPath) { if(dontAskAgain) { return; } int res = 0; // Ask the user if they want to update from the web if(verify_initialized) { char *line1 = "Redump.org DAT files found"; char *line2 = "Check for updated DAT files?"; res = DrawYesNoDialog(line1, line2); } else { char *line1 = "Redump.org DAT files not found"; char *line2 = "Download them now?"; res = DrawYesNoDialog(line1, line2); } // If yes, lets download an update if(res) { // Initialize the network if(!net_initialized) { char ip[16]; DrawMessageBox(D_INFO, "Checking for DAT updates\n \nInitializing Network..."); res = if_config(ip, NULL, NULL, true); if(res >= 0) { sprintf(txtbuffer, "Checking for DAT updates\nNetwork Initialized!\nIP: %s", ip); DrawMessageBox(D_INFO, txtbuffer); net_initialized = 1; print_gecko("Network Initialized!\r\n"); } else { DrawMessageBox(D_FAIL, "Checking for DAT updates\nNetwork failed to Initialize!"); sleep(5); net_initialized = 0; print_gecko("Network Failed to Initialize!\r\n"); return; } } // Download the GC DAT char datFilePath[64]; sprintf(datFilePath, "%sgc.dat",mountPath); u8 *xmlFile = (u8*)memalign(32, 1*1024*1024); if((res = http_request("www.gc-forever.com","/datfile/gc.dat", xmlFile, (1*1024*1024), 0, 0)) > 0) { remove(datFilePath); FILE *fp = fopen(datFilePath, "wb"); if(fp) { DrawMessageBox(D_INFO, "Checking for updates\nSaving GC DAT..."); fwrite(xmlFile, 1, res, fp); fclose(fp); verify_initialized = 0; print_gecko("Saved GameCube DAT! %i Bytes\r\n", res); } else { DrawMessageBox(D_FAIL, "Checking for updates\nFailed to save GC DAT..."); sleep(5); } } else { sprintf(txtbuffer, "Error: %i", res); print_gecko("Error Saving GC DAT %i\r\n", res); DrawMessageBox(D_FAIL, "Checking for updates\nCouldn't find file on gc-forever.com"); sleep(5); } // Download the Wii DAT sprintf(datFilePath, "%swii.dat",mountPath); if((res = http_request("www.gc-forever.com","/datfile/wii.dat", xmlFile, (1*1024*1024), 0, 0)) > 0) { remove(datFilePath); FILE *fp = fopen(datFilePath, "wb"); if(fp) { DrawMessageBox(D_INFO, "Checking for updates\nSaving Wii DAT..."); fwrite(xmlFile, 1, res, fp); fclose(fp); verify_initialized = 0; print_gecko("Saved Wii DAT! %i Bytes\r\n", res); } else { DrawMessageBox(D_FAIL, "Checking for updates\nFailed to save Wii DAT..."); sleep(5); } } else { sprintf(txtbuffer, "Error: %i", res); print_gecko("Error Saving Wii DAT %i\r\n", res); DrawMessageBox(D_FAIL, "Checking for updates\nCouldn't find file on gc-forever.com"); sleep(5); } free(xmlFile); dontAskAgain = 1; } else { dontAskAgain = 1; } }
void XBoxStartup() { const char *logdir = NULL; myargc = -1; myargv = NULL; #else #ifdef FORCESDLMAIN FUNCNORETURN int SDL_main(int argc, char **argv) #else FUNCNORETURN int main(int argc, char **argv) #endif { const char *logdir = NULL; myargc = argc; myargv = argv; /// \todo pull out path to exe from this string #endif #ifdef HAVE_TTF #ifdef _PS3 // apparently there is a bug in SDL_PSL1GHT which needs this to be set to work around SDL_setenv("SDL_VIDEODRIVER", "psl1ght", 1); I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE|SDL_DOUBLEBUF); #elif defined(_WIN32) I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE); #else I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE); #endif #endif #ifdef _PS3 // initialise controllers. //ioPadInit(7); #endif // init Wii-specific stuff #ifdef _WII // Start network if_config(localip, netmask, gateway, TRUE); #ifdef REMOTE_DEBUGGING #if REMOTE_DEBUGGING == 0 DEBUG_Init(GDBSTUB_DEVICE_TCP, GDBSTUB_DEF_TCPPORT); // Port 2828 #elif REMOTE_DEBUGGING > 2 DEBUG_Init(GDBSTUB_DEVICE_TCP, REMOTE_DEBUGGING); // Custom Port #elif REMOTE_DEBUGGING < 0 DEBUG_Init(GDBSTUB_DEVICE_USB, GDBSTUB_DEF_CHANNEL); // Slot 1 #else DEBUG_Init(GDBSTUB_DEVICE_USB, REMOTE_DEBUGGING-1); // Custom Slot #endif #endif // Start FAT filesystem fatInitDefault(); if (getcwd(wiicwd, PATH_MAX)) I_PutEnv(va("HOME=%ssrb2wii", wiicwd)); #endif logdir = D_Home(); #ifdef LOGMESSAGES #if defined(_WIN32_WCE) || defined(GP2X) logstream = fopen(va("%s.log",argv[0]), "wt"); #elif defined (_WII) logstream = fopen(va("%s/log.txt",logdir), "wt"); #elif defined (DEFAULTDIR) if (logdir) logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt"); else #endif logstream = fopen("./log.txt", "wt"); #endif //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); #if defined (_WIN32) && !defined (_XBOX) #ifndef _WIN32_WCE { p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) #ifdef BUGTRAP && !InitBugTrap() #endif ) { LoadLibraryA("exchndl.dll"); } } #endif prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo); #ifndef _WIN32_WCE MakeCodeWritable(); #endif #endif // startup SRB2 CONS_Printf("Setting up SRB2...\n"); D_SRB2Main(); CONS_Printf("Entering main game loop...\n"); // never return D_SRB2Loop(); #ifdef BUGTRAP // This is safe even if BT didn't start. ShutdownBugTrap(); #endif // return to OS #ifndef __GNUC__ return 0; #endif }