void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, int aspectRatio, u32 returnTo, u8 BootType, bool use_led) { normalCFG.vidMode = vidMode; normalCFG.vipatch = vipatch; normalCFG.countryString = countryString; normalCFG.patchVidMode = patchVidMode; normalCFG.aspectRatio = aspectRatio; normalCFG.returnTo = returnTo; normalCFG.configbytes[0] = configbytes[0]; normalCFG.configbytes[1] = configbytes[1]; normalCFG.IOS = CurrentIOS; normalCFG.codelist = codelist; normalCFG.codelistend = codelistend; normalCFG.cheats = code_buf; normalCFG.cheatSize = code_size; normalCFG.hooktype = hooktype; normalCFG.debugger = debuggerselect; normalCFG.gameconf = gameconf; normalCFG.gameconfsize = gameconfsize; normalCFG.BootType = BootType; normalCFG.use_led = use_led; normalCFG.wip_list = get_wip_list(); normalCFG.wip_count = get_wip_count(); /* Copy CFG Into lower MEM1 so it doesnt get destroyed */ DCFlushRange(&normalCFG, sizeof(the_CFG)); the_CFG *lowCFG = (the_CFG*)MEM1_lo_alloc(sizeof(the_CFG)); memcpy(lowCFG, &normalCFG, sizeof(the_CFG)); DCFlushRange(&lowCFG, sizeof(the_CFG)); *EXT_ADDR_CFG = ((u32)lowCFG); /* Unmount devices etc */ ShutdownBeforeExit(); /* Wii Games will need it */ net_wc24cleanup(); /* Set proper time */ settime(secs_to_ticks(time(NULL) - 946684800)); /* Copy in booter */ memcpy(EXT_ADDR, booter_ptr, booter_size); DCFlushRange(EXT_ADDR, booter_size); /* Loader just for the booter */ memcpy(LDR_ADDR, extldr_ptr, extldr_size); DCFlushRange(LDR_ADDR, extldr_size); /* Boot it */ JumpToEntry(LDR_ENTRY); }
/**************************************************************************** * DeinitNetwork ***************************************************************************/ void DeinitNetwork(void) { net_wc24cleanup(); net_deinit(); networkinitialized = false; }
static void * WiiloadThread(void *arg) { int netInit = 0; int netReady = 0; int wc24cleared = 0; stopNetworkThread = 0; errors = 0; strcpy(wiiload.ip, "<unknown>"); printopt("Net thread running, ready !"); while (!stopNetworkThread) { if (!netInit) { s32 res; res = net_init_async(NULL, NULL); Debug ("net_init_async %d", res); if (res != 0) { errors ++; continue; } netInit = 1; } if (netInit) { if (errors > 5 && !wc24cleared) { Debug ("Cleareing net_wc24cleanup"); net_deinit (); net_wc24cleanup(); errors = 0; netInit = 0; wc24cleared = 1; } s32 res; res = net_get_status(); Debug ("net_get_status %d", res); if (res == 0) { struct in_addr hostip; hostip.s_addr = net_gethostip(); if (hostip.s_addr) { strcpy(wiiload.ip, inet_ntoa(hostip)); netReady = 1; } } else errors ++; } if (netReady) { if (!StartWiiLoadServer ()) errors ++; } sleep (1); if (errors > 10) { Debug ("too many errors"); stopNetworkThread = 1; } } stopNetworkThread = 2; wiiload.status = WIILOAD_STOPPED; net_deinit(); return NULL; }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { VIDEO_Init(); VIDEO_SetBlack(true); // Disable video output during initialisation net_wc24cleanup(); if (fatMountSimple("sd", &__io_wiisd)) DebugStart (true, "sd://ploader.log"); else DebugStart (true, NULL); configbytes[0] = 0xCD; //configbytes[0] = 0; Debug ("---------------------------------------------------------------------------"); Debug (" di "VER" by stfour"); Debug (" (part of postLoader project)"); Debug ("---------------------------------------------------------------------------"); struct discHdr *header; header = (struct discHdr *)memalign(32, sizeof(struct discHdr)); s32 rr = Disc_Init(); Debug("Disc_Init() returned: %d", rr); rr = Disc_Open(); Debug("Disc_Open() returned: %d", rr); // Check disc rr = Disc_IsGC(); Debug("Disc_IsGC() returned: %d", rr); if (rr == 0) { rr = WDVD_ReadDiskId ((void*)0x80000000); Debug("WDVD_ReadDiskId() returned: %d", rr); rr = WDVD_EnableAudio(*(u8*)0x80000008); Debug("WDVD_EnableAudio() returned: %d", rr); *(volatile unsigned int *)0xCC003024 |= 7; int retval = ES_GetTicketViews(BC, &view, 1); if (retval != 0) { Debug("ES_GetTicketViews fail %d", retval); exit (0); } retval = ES_LaunchTitle(BC, &view); exit (0); } // Check disc rr = Disc_IsWii(); Debug("Disc_IsWii() returned: %d", rr); if (rr == 0) { // Read header rr = Disc_ReadHeader(header); Debug("Disc_ReadHeader() returned: %d", rr); Disc_WiiBoot (0, FALSE, TRUE, 0); } exit (0); }
static void * netcb (void *arg) { s32 res=-1; int retry; int wait; static bool prevInit = false; while(netHalt != 2) { retry = 5; while (retry>0 && (netHalt != 2)) { if(prevInit) { int i; net_deinit(); for(i=0; i < 400 && (netHalt != 2); i++) // 10 seconds to try to reset { res = net_get_status(); if(res != -EBUSY) // trying to init net so we can't kill the net { usleep(2000); net_wc24cleanup(); //kill the net prevInit=false; // net_wc24cleanup is called only once usleep(20000); break; } usleep(20000); } } usleep(2000); res = net_init_async(NULL, NULL); if(res != 0) { sleep(1); retry--; continue; } res = net_get_status(); wait = 400; // only wait 8 sec while (res == -EBUSY && wait > 0 && (netHalt != 2)) { usleep(20000); res = net_get_status(); wait--; } if(res==0) break; retry--; usleep(2000); } if (res == 0) { struct in_addr hostip; hostip.s_addr = net_gethostip(); if (hostip.s_addr) { strcpy(wiiIP, inet_ntoa(hostip)); networkInit = true; prevInit = true; } } if(netHalt != 2) LWP_SuspendThread(networkthread); } return NULL; }