diff --git a/out/boot.dol b/out/boot.dol index 61f46be7..aed9acdf 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/channel/identify.c b/source/channel/identify.c index 605a3359..60deeb57 100644 --- a/source/channel/identify.c +++ b/source/channel/identify.c @@ -28,7 +28,7 @@ static inline bool apply_patch(char *name, const u8 *old, const u8 *patch, u32 s } IRQ_Restore(level); - gprintf("patched %s %u times.\n", name, found); + //gprintf("patched %s %u times.\n", name, found); return (found > 0); } diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index 48f83d95..134c0265 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -1119,14 +1119,14 @@ void Nand::Init_ISFS() return; PatchIOS(IOS_GetVersion() < 222, isWiiVC); usleep(1000); - gprintf("Init ISFS\n"); + //gprintf("Init ISFS\n"); ISFS_Initialize(); isfs_inited = true; } void Nand::DeInit_ISFS() { - gprintf("Deinit ISFS\n"); + //gprintf("Deinit ISFS\n"); ISFS_Deinitialize(); isfs_inited = false; usleep(1000); diff --git a/source/main.cpp b/source/main.cpp index be1831bb..c286be52 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -145,7 +145,8 @@ int main(int argc, char **argv) gprintf("Real Wii\n"); gprintf("AHBPROT disabled = %s\n", AHBPROT_Patched() ? "yes" : "no"); - + IOS_GetCurrentIOSInfo(); + /* Init device partition handlers */ DeviceHandle.Init(); @@ -172,8 +173,9 @@ int main(int argc, char **argv) NandHandle.DeInit_ISFS(); NandHandle.Patch_AHB(); iosOK = IOS_ReloadIOS(mainIOS) == 0; - gprintf("AHBPROT disabled after IOS Reload: %s\n", AHBPROT_Patched() ? "yes" : "no"); NandHandle.Init_ISFS(); + gprintf("AHBPROT disabled after IOS Reload: %s\n", AHBPROT_Patched() ? "yes" : "no"); + gprintf("Now using "); } else gprintf("Using IOS58\n");// stay on IOS58. no reload to cIOS diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 41193217..5ae7ac69 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -72,7 +72,7 @@ CMenu::CMenu() m_lqBg = NULL; m_use_sd_logging = false; m_use_wifi_gecko = false; - m_init_network = false; + //m_init_network = false; m_use_source = true; m_sourceflow = false; m_clearCats = false; @@ -137,12 +137,17 @@ bool CMenu::init(bool usb_mounted) /* Load/Create wiiflow.ini so we can get settings to start Gecko and Network */ m_cfg.load(fmt("%s/" CFG_FILENAME, m_appDir.c_str())); show_mem = m_cfg.getBool("DEBUG", "show_mem", false); + /* Check if we want WiFi Gecko */ m_use_wifi_gecko = m_cfg.getBool("DEBUG", "wifi_gecko", false); WiFiDebugger.SetBuffer(m_use_wifi_gecko); + if(m_use_wifi_gecko) + _initAsyncNetwork(); + /* Check if we want SD Gecko */ m_use_sd_logging = m_cfg.getBool("DEBUG", "sd_write_log", false); LogToSD_SetBuffer(m_use_sd_logging); + /* Init gamer tags now in case we need to init network on boot */ m_cfg.setString("GAMERCARD", "gamercards", "wiinnertag"); m_cfg.getString("GAMERCARD", "wiinnertag_url", WIINNERTAG_URL); @@ -164,9 +169,9 @@ bool CMenu::init(bool usb_mounted) ); } } - /* Init Network if wanted */ - m_init_network = (has_enabled_providers() || m_use_wifi_gecko); - _netInit(); + /* Init Network if wanted for gamercard if it isn't already inited */ + if(has_enabled_providers()) + _initAsyncNetwork(); /* Set SD only to off if any usb device is attached and format is FAT, NTFS, WBFS, or LINUX */ m_cfg.getBool("GENERAL", "sd_only", true);// will only set it true if this doesn't already exist @@ -186,6 +191,7 @@ bool CMenu::init(bool usb_mounted) if(strncmp(wii_games_dir, "%s:/", 4) != 0) strcpy(wii_games_dir, GAMES_DIR); gprintf("Wii Games Directory: %s\n", wii_games_dir); + if(m_cfg.getBool(WII_DOMAIN, "prefer_usb", false)) { if(usb_mounted) @@ -2769,7 +2775,8 @@ void CMenu::TempLoadIOS(int IOS) Open_Inputs(); for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height()); - _netInit(); + if(has_enabled_providers() || m_use_wifi_gecko) + _initAsyncNetwork(); } } diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 630a271f..adb03673 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -118,7 +118,7 @@ private: bool m_reload; bool m_use_wifi_gecko; bool m_use_sd_logging; - bool m_init_network; + //bool m_init_network; bool m_source_autoboot; dir_discHdr m_autoboot_hdr; s16 m_showtimer; @@ -1133,7 +1133,6 @@ private: void _restoreSrcTiers(); void _getSFlowBgTex(); void _mainLoopCommon(bool withCF = false, bool adjusting = false); - void _netInit(); void _loadDefaultFont(void); bool _loadFile(u8 * &buffer, u32 &size, const char *path, const char *file); int _loadGameIOS(u8 ios, int userIOS, string id, bool RealNAND_Channels = false); @@ -1211,10 +1210,11 @@ private: int _gametdbDownloaderAsync(); int _bannerDownloader(); - static s32 _networkComplete(s32 result, void *usrData); + //void _netInit(); void _initAsyncNetwork(); + static s32 _networkComplete(s32 result, void *usrData); bool _isNetworkAvailable(); - int _initNetwork(); + s32 _initNetwork(); void LoadView(void); static void _addDiscProgress(int status, int total, void *user_data); static void _ShowProgress(int dumpstat, int dumpprog, int filestat, int fileprog, int files, int folders, const char *tmess, void *user_data); diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index e34fddcb..193f016e 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -728,22 +728,26 @@ void CMenu::_textDownload(void) } /************************************* Setup network connection *********************************************/ - +/* void CMenu::_netInit(void) { - if(networkInit || !m_init_network || m_exit) + if(networkInit || m_exit) return; _initAsyncNetwork(); while(net_get_status() == -EBUSY) usleep(100); } - +*/ void CMenu::_initAsyncNetwork() { + if(networkInit || m_exit) + return; if(!_isNetworkAvailable()) return; m_thrdNetwork = true; net_init_async(_networkComplete, this); + while(net_get_status() == -EBUSY) + usleep(100); } s32 CMenu::_networkComplete(s32 ok, void *usrData) @@ -754,14 +758,15 @@ s32 CMenu::_networkComplete(s32 ok, void *usrData) m->m_thrdNetwork = false; if(networkInit) - wolfSSL_Init(); - - if(m->m_use_wifi_gecko) { - const string &ip = m->m_cfg.getString("DEBUG", "wifi_gecko_ip"); - u16 port = m->m_cfg.getInt("DEBUG", "wifi_gecko_port", 4405); - if(ip.size() > 0 && port != 0) - WiFiDebugger.Init(ip.c_str(), port); + wolfSSL_Init(); + if(m->m_use_wifi_gecko) + { + const string &ip = m->m_cfg.getString("DEBUG", "wifi_gecko_ip"); + u16 port = m->m_cfg.getInt("DEBUG", "wifi_gecko_port", 4405); + if(ip.size() > 0 && port != 0) + WiFiDebugger.Init(ip.c_str(), port); + } } return 0; @@ -769,38 +774,41 @@ s32 CMenu::_networkComplete(s32 ok, void *usrData) bool CMenu::_isNetworkAvailable() { - bool retval = false; + bool ret = false; u32 size; char ISFS_Filepath[32] ATTRIBUTE_ALIGN(32); strcpy(ISFS_Filepath, "/shared2/sys/net/02/config.dat"); u8 *buf = ISFS_GetFile(ISFS_Filepath, &size, -1); if(buf && size > 4) { - retval = buf[4] > 0; // There is a valid connection defined. + ret = buf[4] > 0; // There is a valid connection defined. } MEM2_free(buf); - return retval; + return ret; } -int CMenu::_initNetwork() +s32 CMenu::_initNetwork() { while(net_get_status() == -EBUSY && m_thrdNetwork == true) { usleep(100); // Async initialization may be busy, wait to see if it succeeds. } + if(networkInit) return 0; + if(!_isNetworkAvailable()) return -2; char ip[16]; - int val = if_config(ip, NULL, NULL, true, 0); + s32 ret = if_config(ip, NULL, NULL, true, 0); - if (val == 0) + if(ret == 0) + { wolfSSL_Init(); - - networkInit = !val; - return val; + networkInit = true; + } + return ret; } /************************************* Cover Downloading ******************************/ diff --git a/source/menu/menu_game_boot.cpp b/source/menu/menu_game_boot.cpp index d2405a99..ee2ecd03 100644 --- a/source/menu/menu_game_boot.cpp +++ b/source/menu/menu_game_boot.cpp @@ -703,7 +703,8 @@ int CMenu::_loadGameIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channe { /* doesn't use cIOS so we don't check userIOS */ bool ret = loadIOS(gameIOS, false);//load game requested IOS and patch nothing - _netInit();// needed after IOS change + if(has_enabled_providers() || m_use_wifi_gecko) + _initAsyncNetwork();// needed after IOS change if(ret == false) { error(wfmt(_fmt("errgame4", L"Couldn't load IOS %i"), gameIOS)); @@ -737,7 +738,8 @@ int CMenu::_loadGameIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channe { gprintf("Reloading IOS into %d\n", gameIOS); bool ret = loadIOS(gameIOS, true);// cIOS patch everything - _netInit();// always seem to do netinit after changing IOS + if(has_enabled_providers() || m_use_wifi_gecko) + _initAsyncNetwork();// always seem to do netinit after changing IOS if(ret == false) { error(wfmt(_fmt("errgame4", L"Couldn't load IOS %i"), gameIOS));