mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-04 18:45:05 +01:00
* Fixed routine for slow USB devices.
* Minor refactoring of Ios loading algorithm.
This commit is contained in:
parent
4eab0cb29f
commit
05825a3231
@ -2,8 +2,8 @@
|
||||
<app version="1">
|
||||
<name> USB Loader GX</name>
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>1.0 r960</version>
|
||||
<release_date>201009211724</release_date>
|
||||
<version>1.0 r961</version>
|
||||
<release_date>201009222057</release_date>
|
||||
<short_description>Loads games from USB-devices</short_description>
|
||||
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
|
||||
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.
|
||||
|
1
Makefile
1
Makefile
@ -21,6 +21,7 @@ SOURCES := source \
|
||||
source/images \
|
||||
source/fonts \
|
||||
source/sounds \
|
||||
source/system \
|
||||
source/libwbfs \
|
||||
source/unzip \
|
||||
source/language \
|
||||
|
@ -19,10 +19,9 @@
|
||||
//#include <debug.h>
|
||||
extern "C"
|
||||
{
|
||||
extern void __exception_setreload( int t );
|
||||
extern void __exception_setreload(int t);
|
||||
}
|
||||
|
||||
|
||||
#include <di/di.h>
|
||||
#include <sys/iosupport.h>
|
||||
|
||||
@ -53,6 +52,7 @@ extern "C"
|
||||
#include "lstub.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "wad/nandtitle.h"
|
||||
#include "system/IosLoader.h"
|
||||
|
||||
extern bool geckoinit;
|
||||
extern char headlessID[8];
|
||||
@ -61,101 +61,98 @@ char bootDevice[10];
|
||||
NandTitle titles;
|
||||
PartList partitions;
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MEM2_init( 48 );
|
||||
setlocale( LC_ALL, "en.UTF-8" );
|
||||
MEM2_init(48);
|
||||
setlocale(LC_ALL, "en.UTF-8");
|
||||
geckoinit = InitGecko();
|
||||
InitVideo();
|
||||
__exception_setreload( 20 );
|
||||
__exception_setreload(20);
|
||||
|
||||
printf( "\tStarting up\n" );
|
||||
printf("\tStarting up\n");
|
||||
titles.Get();
|
||||
|
||||
bool bootDevice_found = false;
|
||||
if ( argc >= 1 )
|
||||
if (argc >= 1)
|
||||
{
|
||||
if ( !strncasecmp( argv[0], "usb:/", 5 ) )
|
||||
if (!strncasecmp(argv[0], "usb:/", 5))
|
||||
{
|
||||
strcpy( bootDevice, "USB:" );
|
||||
strcpy(bootDevice, "USB:");
|
||||
bootDevice_found = true;
|
||||
}
|
||||
else if ( !strncasecmp( argv[0], "sd:/", 4 ) )
|
||||
bootDevice_found = true;
|
||||
else if (!strncasecmp(argv[0], "sd:/", 4)) bootDevice_found = true;
|
||||
}
|
||||
|
||||
//Let's use libogc sd/usb for config loading
|
||||
printf( "\tInitialize sd card\n" );
|
||||
printf("\tInitialize sd card\n");
|
||||
SDCard_Init();
|
||||
printf( "\tInitialize usb device\n" );
|
||||
printf("\tInitialize usb device\n");
|
||||
USBDevice_Init();
|
||||
|
||||
if ( !bootDevice_found )
|
||||
if (!bootDevice_found)
|
||||
{
|
||||
printf( "\tSearch for configuration file\n" );
|
||||
printf("\tSearch for configuration file\n");
|
||||
//try USB
|
||||
//left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config
|
||||
if ( checkfile( ( char* ) "USB:/config/GXglobal.cfg" ) || ( checkfile( ( char* ) "USB:/apps/usbloader_gx/boot.elf" ) )
|
||||
|| checkfile( ( char* ) "USB:/apps/usbloadergx/boot.dol" ) || ( checkfile( ( char* ) "USB:/apps/usbloadergx/boot.elf" ) )
|
||||
|| checkfile( ( char* ) "USB:/apps/usbloader_gx/boot.dol" ) )
|
||||
strcpy( bootDevice, "USB:" );
|
||||
if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf"))
|
||||
|| checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile(
|
||||
(char*) "USB:/apps/usbloadergx/boot.elf")) || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol")) strcpy(
|
||||
bootDevice, "USB:");
|
||||
|
||||
printf( "\tConfiguration file is on %s\n", bootDevice );
|
||||
printf("\tConfiguration file is on %s\n", bootDevice);
|
||||
}
|
||||
|
||||
gettextCleanUp();
|
||||
printf( "\tLoading configuration..." );
|
||||
printf("\tLoading configuration...");
|
||||
Settings.Load();
|
||||
VIDEO_SetWidescreen(Settings.widescreen);
|
||||
printf( "done\n" );
|
||||
|
||||
SDCard_deInit();// unmount SD for reloading IOS
|
||||
USBDevice_deInit();// unmount USB for reloading IOS
|
||||
USBStorage2_Deinit();
|
||||
|
||||
printf( "\tCheck for an existing cIOS\n" );
|
||||
CheckForCIOS();
|
||||
printf("done\n");
|
||||
|
||||
// Let's load the cIOS now
|
||||
if ( LoadAppCIOS() < 0 )
|
||||
IosLoader loader(titles);
|
||||
if (loader.LoadAppCios() < 0)
|
||||
{
|
||||
printf( "\tERROR: No cIOS could be loaded. Exiting....\n" );
|
||||
sleep( 5 );
|
||||
printf("\n\tWARNING!\n");
|
||||
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+\n\n");
|
||||
|
||||
printf(
|
||||
"\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n");
|
||||
printf("\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,\n");
|
||||
printf("\tand you should go figure out how to get some cios action going on\n\tin your Wii.\n");
|
||||
|
||||
printf("\tERROR: No cIOS could be loaded. Exiting....\n");
|
||||
sleep(10);
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
|
||||
|
||||
printf( "\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision() );
|
||||
|
||||
printf( "\tWaiting for USB:\n" );
|
||||
if ( MountWBFS() < 0 )
|
||||
printf("\tWaiting for USB:\n");
|
||||
if (MountWBFS() < 0)
|
||||
{
|
||||
printf( "ERROR: No WBFS drive mounted.\n" );
|
||||
sleep( 5 );
|
||||
exit( 0 );
|
||||
printf("ERROR: No WBFS drive mounted.\n");
|
||||
sleep(5);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//if a ID was passed via args copy it and try to boot it after the partition is mounted
|
||||
//its not really a headless mode. more like hairless.
|
||||
if ( argc > 1 && argv[1] )
|
||||
if (argc > 1 && argv[1])
|
||||
{
|
||||
if ( strlen( argv[1] ) == 6 )
|
||||
strncpy( headlessID, argv[1], sizeof( headlessID ) );
|
||||
if (strlen(argv[1]) == 6) strncpy(headlessID, argv[1], sizeof(headlessID));
|
||||
}
|
||||
|
||||
//! Init the rest of the System
|
||||
|
||||
Sys_Init();
|
||||
SetupPads();
|
||||
InitAudio();
|
||||
|
||||
char *fontPath = NULL;
|
||||
asprintf( &fontPath, "%sfont.ttf", Settings.theme_path );
|
||||
SetupDefaultFont( fontPath );
|
||||
free( fontPath );
|
||||
asprintf(&fontPath, "%sfont.ttf", Settings.theme_path);
|
||||
SetupDefaultFont(fontPath);
|
||||
free(fontPath);
|
||||
|
||||
gprintf( "\n\tEnd of Main()" );
|
||||
gprintf("\n\tEnd of Main()");
|
||||
InitGUIThreads();
|
||||
MainMenu( MENU_CHECK );
|
||||
MainMenu(MENU_CHECK);
|
||||
return 0;
|
||||
}
|
||||
|
@ -456,26 +456,9 @@ int MainMenu( int menu )
|
||||
alternatedoloffset = 0;
|
||||
}
|
||||
reloadblock = off;
|
||||
returnToLoaderGV = 1;
|
||||
returnToLoaderGV = 1;
|
||||
}
|
||||
int ios2;
|
||||
|
||||
// When the selected ios is 249, and you're loading from FAT, reset ios to 222
|
||||
if ( load_from_fs != PART_FS_WBFS && ios2 == 249 )
|
||||
{
|
||||
ios2 = 222;
|
||||
}
|
||||
bool onlinefix = ShutdownWC24();
|
||||
|
||||
// You cannot reload ios when loading from fat
|
||||
if ( IOS_GetVersion() != ios2 || onlinefix )
|
||||
{
|
||||
ret = Sys_ChangeIos( ios2 );
|
||||
if ( ret < 0 )
|
||||
{
|
||||
Sys_ChangeIos( 249 );
|
||||
}
|
||||
}
|
||||
if ( !mountMethod )
|
||||
{
|
||||
gprintf( "Loading fragment list..." );
|
||||
|
268
source/sys.cpp
268
source/sys.cpp
@ -1,22 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <ogcsys.h>
|
||||
#include <unistd.h>
|
||||
#include <gctypes.h>
|
||||
#include <ogc/system.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "usbloader/wdvd.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "usbloader/disc.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "usbloader/partition_usbloader.h"
|
||||
#include "mload/mload_modules.h"
|
||||
#include "video.h"
|
||||
#include "mload/mload.h"
|
||||
#include "settings/CSettings.h"
|
||||
#include "audio.h"
|
||||
#include "menu.h"
|
||||
#include "fatmounter.h"
|
||||
#include "gecko.h"
|
||||
#include "sys.h"
|
||||
#include "wpad.h"
|
||||
#include "lstub.h"
|
||||
#include "wad/nandtitle.h"
|
||||
#include "menu.h"
|
||||
#include "video.h"
|
||||
|
||||
extern char game_partition[6];
|
||||
extern u8 load_from_fs;
|
||||
@ -76,105 +68,6 @@ void Sys_Reboot( void )
|
||||
STM_RebootSystem();
|
||||
}
|
||||
|
||||
int Sys_ChangeIos( int ios )
|
||||
{
|
||||
s32 prevIos = IOS_GetVersion();
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush( 0 );
|
||||
WPAD_Disconnect( 0 );
|
||||
WPAD_Shutdown();
|
||||
|
||||
WDVD_Close();
|
||||
|
||||
USBStorage2_Deinit();
|
||||
|
||||
s32 ret = IOS_ReloadIOSsafe( ios );
|
||||
if ( ret < 0 )
|
||||
{
|
||||
ios = prevIos;
|
||||
}
|
||||
|
||||
SDCard_Init();
|
||||
|
||||
if ( ios == 222 || ios == 223 )
|
||||
{
|
||||
load_ehc_module();
|
||||
}
|
||||
USBDevice_Init();
|
||||
|
||||
PAD_Init();
|
||||
Wpad_Init();
|
||||
WPAD_SetDataFormat( WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR );
|
||||
WPAD_SetVRes( WPAD_CHAN_ALL, screenwidth, screenheight );
|
||||
|
||||
WBFS_Init( WBFS_DEVICE_USB );
|
||||
Disc_Init();
|
||||
|
||||
if ( Sys_IsHermes() )
|
||||
{
|
||||
WBFS_OpenNamed( ( char * ) &game_partition );
|
||||
}
|
||||
else
|
||||
{
|
||||
WBFS_Open();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Sys_IosReload( int IOS )
|
||||
{
|
||||
s32 ret = -1;
|
||||
|
||||
//shutdown SD and USB before IOS Reload in DiscWait
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush( 0 );
|
||||
WPAD_Disconnect( 0 );
|
||||
WPAD_Shutdown();
|
||||
|
||||
WDVD_Close();
|
||||
|
||||
USBStorage2_Deinit();
|
||||
|
||||
if ( IOS == 249 || IOS == 222 || IOS == 223 )
|
||||
{
|
||||
for ( int i = 0; i < 10; i++ )
|
||||
{
|
||||
ret = IOS_ReloadIOSsafe( IOS );
|
||||
if ( ret < 0 ) return ret;
|
||||
if ( IOS == 222 || IOS == 223 ) load_ehc_module();
|
||||
ret = WBFS_Init( WBFS_DEVICE_USB );
|
||||
if ( !( ret < 0 ) ) break;
|
||||
sleep( 1 );
|
||||
USBStorage2_Deinit();
|
||||
}
|
||||
if ( ret >= 0 )
|
||||
{
|
||||
ret = Disc_Init();
|
||||
if ( ret >= 0 )
|
||||
{
|
||||
ret = WBFS_Open();
|
||||
}
|
||||
}
|
||||
else Sys_BackToLoader();
|
||||
}
|
||||
|
||||
PAD_Init();
|
||||
Wpad_Init();
|
||||
WPAD_SetDataFormat( WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR );
|
||||
WPAD_SetVRes( WPAD_CHAN_ALL, screenwidth, screenheight );
|
||||
//reinitialize SD and USB
|
||||
SDCard_Init();
|
||||
USBDevice_Init();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define ShutdownToDefault 0
|
||||
#define ShutdownToIdle 1
|
||||
#define ShutdownToStandby 2
|
||||
@ -205,10 +98,12 @@ static void _Sys_Shutdown( int SHUTDOWN_MODE )
|
||||
STM_ShutdownToStandby();
|
||||
}
|
||||
}
|
||||
|
||||
void Sys_Shutdown( void )
|
||||
{
|
||||
_Sys_Shutdown( ShutdownToDefault );
|
||||
}
|
||||
|
||||
void Sys_ShutdownToIdel( void )
|
||||
{
|
||||
_Sys_Shutdown( ShutdownToIdle );
|
||||
@ -242,151 +137,6 @@ bool Sys_IsHermes()
|
||||
return IOS_GetVersion() == 222 || IOS_GetVersion() == 223;
|
||||
}
|
||||
|
||||
#include "prompts/PromptWindows.h"
|
||||
|
||||
void ShowMemInfo()
|
||||
{
|
||||
char buf[255];
|
||||
struct mallinfo mymallinfo = mallinfo();
|
||||
sprintf( ( char * ) &buf, "Total: %d, Used: %d, Can be freed: %d", mymallinfo.arena / 1024, mymallinfo.uordblks / 1024, mymallinfo.keepcost / 1024 );
|
||||
WindowPrompt( "Mem info", ( char * ) &buf, "OK" );
|
||||
}
|
||||
|
||||
s32 IOS_ReloadIOSsafe( int ios )
|
||||
{
|
||||
if ( ios == 222 )
|
||||
{
|
||||
s32 ios222rev = titles.VersionOf( 0x1000000deULL );
|
||||
if ( !ios222rev )
|
||||
return -2;
|
||||
if ( ios222rev != 4 && ios222rev != 5 && ios222rev != 65535 )
|
||||
return -2;
|
||||
}
|
||||
else if ( ios == 223 )
|
||||
{
|
||||
s32 ios223rev = titles.VersionOf( 0x1000000dfULL );
|
||||
if ( !ios223rev )
|
||||
return -2;
|
||||
if ( ios223rev != 4 && ios223rev != 5 && ios223rev != 65535 )
|
||||
return -2;
|
||||
}
|
||||
else if ( ios == 249 )
|
||||
{
|
||||
s32 ios249rev = titles.VersionOf( 0x1000000f9ULL );
|
||||
if ( !ios249rev )
|
||||
return -2;
|
||||
if ( ios249rev < 9 || ios249rev == 65280 )
|
||||
return -2;
|
||||
}
|
||||
else if ( ios == 250 )
|
||||
{
|
||||
s32 ios250rev = titles.VersionOf( 0x1000000faULL );
|
||||
if ( !ios250rev )
|
||||
return -2;
|
||||
if ( ios250rev < 9 || ios250rev == 65280 )
|
||||
return -2;
|
||||
}
|
||||
|
||||
s32 r = IOS_ReloadIOS( ios );
|
||||
if ( r >= 0 )
|
||||
{
|
||||
WII_Initialize();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
s32 CheckForCIOS()
|
||||
{
|
||||
gprintf( "\tChecking for stub IOS\n" );
|
||||
s32 ret = 1;
|
||||
s32 ios222rev = titles.VersionOf( 0x00000001000000deULL );
|
||||
s32 ios249rev = titles.VersionOf( 0x00000001000000f9ULL );
|
||||
|
||||
u8 ios222OK = !( ios222rev < 4 || ios222rev == 65280 );
|
||||
u8 ios249OK = !( ios249rev < 9 || ios249rev == 65280 );
|
||||
|
||||
gprintf( "222ok: %u\t 249ok: %u\n", ios222OK, ios249OK );
|
||||
return 1;
|
||||
|
||||
//if we don't like either of the cIOS then scram
|
||||
//if( !((ios222rev >= 4 && ios222rev < 65280) || (ios249rev >=9 && ios249rev < 65280)))
|
||||
if ( ios222rev < 4 || ios222rev == 65280 || ios249rev < 9 || ios249rev == 65280 )
|
||||
{
|
||||
printf( "\x1b[2J" );
|
||||
if ( ( ios222rev < 0 && ios222rev != WII_EINSTALL ) && ( ios249rev < 0 && ios249rev != WII_EINSTALL ) )
|
||||
{
|
||||
printf( "\n\n\n\tWARNING!" );
|
||||
printf( "\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+" );
|
||||
printf( "\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed." );
|
||||
printf( "\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update," );
|
||||
printf( "\n\tand you should go figure out how to get some cios action going on\n\tin your Wii." );
|
||||
printf( "\n\n\tThis message will show every time." );
|
||||
sleep( 5 );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "\n\n\n\tERROR!" );
|
||||
printf( "\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+" );
|
||||
printf( "\n\n\tI found \n\t\t222 = %d%s", ios222rev, ios222rev == 65280 ? " (Stubbed by 4.2 update)" : "" );
|
||||
printf( "\n\t\t249 = %d%s", ios249rev, ios249rev == 65280 ? " (Stubbed by 4.2 update)" : "" );
|
||||
printf( "\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me." );
|
||||
|
||||
sleep( 15 );
|
||||
printf( "\n\n\tBye" );
|
||||
|
||||
USBDevice_deInit();
|
||||
exit( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LoadAppCIOS()
|
||||
{
|
||||
s32 ret = 1;
|
||||
/* Load Custom IOS */
|
||||
SDCard_deInit();// unmount SD for reloading IOS
|
||||
USBDevice_deInit();// unmount USB for reloading IOS
|
||||
USBStorage2_Deinit();
|
||||
|
||||
if ( Settings.cios == 222 && IOS_GetVersion() != 222 )
|
||||
{
|
||||
printf( "\n\tReloading IOS to config setting (222)..." );
|
||||
ret = IOS_ReloadIOSsafe( 222 );
|
||||
printf( "%d", ret );
|
||||
if ( ret < 0 )
|
||||
{
|
||||
Settings.cios = 249;
|
||||
IOS_ReloadIOSsafe( Settings.cios );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( Settings.cios == 249 && IOS_GetVersion() != 249 )
|
||||
|| ( Settings.cios == 250 && IOS_GetVersion() != 250 ) )
|
||||
{
|
||||
printf( "\n\tReloading IOS to config setting (%d)...", ( Settings.cios == 249 ) ? 249 : 250 );
|
||||
ret = IOS_ReloadIOSsafe( ( Settings.cios == 249 ) ? 249 : 250 );
|
||||
printf( "%d", ret );
|
||||
if ( ret < 0 )
|
||||
{
|
||||
Settings.cios = 222;
|
||||
ret = IOS_ReloadIOSsafe( Settings.cios );
|
||||
}
|
||||
}
|
||||
|
||||
SDCard_Init();
|
||||
if ( IOS_GetVersion() == 222 )
|
||||
load_ehc_module();
|
||||
|
||||
USBDevice_Init();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#include <time.h>
|
||||
|
||||
void ScreenShot()
|
||||
{
|
||||
time_t rawtime;
|
||||
|
12
source/sys.h
12
source/sys.h
@ -11,19 +11,7 @@ void Sys_ShutdownToIdel( void );
|
||||
void Sys_ShutdownToStandby( void );
|
||||
void Sys_LoadMenu( void );
|
||||
void Sys_BackToLoader( void );
|
||||
int Sys_ChangeIos( int ios );
|
||||
int Sys_IosReload( int IOS );
|
||||
bool Sys_IsHermes();
|
||||
s32 IOS_ReloadIOSsafe( int ios );
|
||||
void ScreenShot();
|
||||
s32 CheckForCIOS();
|
||||
int LoadAppCIOS();
|
||||
void ShowMemInfo();
|
||||
extern s32 ios222rev;
|
||||
extern s32 ios223rev;
|
||||
extern s32 ios249rev;
|
||||
extern s32 ios250rev;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
115
source/system/IosLoader.cpp
Normal file
115
source/system/IosLoader.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "IosLoader.h"
|
||||
#include "../fatmounter.h"
|
||||
#include "../usbloader/usbstorage2.h"
|
||||
#include "../wad/nandtitle.h"
|
||||
#include "../mload/mload_modules.h"
|
||||
#include "../settings/CSettings.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Construction/Destruction:
|
||||
******************************************************************************/
|
||||
|
||||
/* Initializes a new instance of the IosLoader class. */
|
||||
IosLoader::IosLoader(NandTitle titles)
|
||||
{
|
||||
nandTitles = titles;
|
||||
}
|
||||
|
||||
/* Finalizes an instance of the IosLoader class. */
|
||||
IosLoader::~IosLoader()
|
||||
{
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Public Methods:
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Loads CIOS (If possible the one from the settings file).
|
||||
* @return 0 if a cios has been successfully loaded. Else a value below 0 is returned.
|
||||
*/
|
||||
s32 IosLoader::LoadAppCios()
|
||||
{
|
||||
s32 ret = -1;
|
||||
|
||||
// Unmount devices before reloading IOS.
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
USBStorage2_Deinit();
|
||||
|
||||
u32 ciosLoadPriority[] = { 250, 249, 222, Settings.cios }; // Descending.
|
||||
u32 activeCios = IOS_GetVersion();
|
||||
|
||||
|
||||
for (u8 i=(sizeof(ciosLoadPriority)/sizeof(ciosLoadPriority[0])); i>=0; i--)
|
||||
{
|
||||
u32 cios = ciosLoadPriority[i];
|
||||
|
||||
if (activeCios == cios)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ret = ReloadIosSafe(cios)) > -1)
|
||||
{
|
||||
// Remember working cios.
|
||||
Settings.cios = cios;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remount devices after reloading IOS.
|
||||
SDCard_Init();
|
||||
if (IOS_GetVersion() == 222) load_ehc_module();
|
||||
USBDevice_Init();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Private/Protected Methods:
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Reloads a certain IOS under the condition, that an appropriate version of the IOS is installed.
|
||||
* @return a negative value if a safe reload of the ios was not possible.
|
||||
*/
|
||||
s32 IosLoader::ReloadIosSafe(s32 ios)
|
||||
{
|
||||
switch (ios)
|
||||
{
|
||||
case 222:
|
||||
{
|
||||
s32 ios222rev = nandTitles.VersionOf(0x1000000deULL);
|
||||
if (ios222rev == 4 || ios222rev == 5 || ios222rev == 65535) break;
|
||||
return -2;
|
||||
}
|
||||
case 223:
|
||||
{
|
||||
s32 ios223rev = nandTitles.VersionOf(0x1000000dfULL);
|
||||
if (ios223rev == 4 || ios223rev == 5 || ios223rev == 65535) break;
|
||||
return -2;
|
||||
}
|
||||
case 249:
|
||||
{
|
||||
s32 ios249rev = nandTitles.VersionOf(0x1000000f9ULL);
|
||||
if (ios249rev < 9 || ios249rev == 65280) return -2;
|
||||
break;
|
||||
}
|
||||
case 250:
|
||||
{
|
||||
s32 ios250rev = nandTitles.VersionOf(0x1000000faULL);
|
||||
if (ios250rev < 9 || ios250rev == 65280) return -2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return -3;
|
||||
}
|
||||
|
||||
s32 r = IOS_ReloadIOS(ios);
|
||||
if (r >= 0) WII_Initialize();
|
||||
return r;
|
||||
}
|
19
source/system/IosLoader.h
Normal file
19
source/system/IosLoader.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _IOSLOADER_H_
|
||||
#define _IOSLOADER_H_
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "../wad/nandtitle.h"
|
||||
|
||||
class IosLoader
|
||||
{
|
||||
public:
|
||||
IosLoader(NandTitle titles);
|
||||
~IosLoader();
|
||||
s32 CheckForCios();
|
||||
s32 LoadAppCios();
|
||||
private:
|
||||
NandTitle nandTitles;
|
||||
s32 ReloadIosSafe(s32 ios);
|
||||
};
|
||||
|
||||
#endif
|
@ -311,8 +311,9 @@ int MountWBFS()
|
||||
int ret = -1;
|
||||
time_t currTime = time( 0 );
|
||||
|
||||
while ( time( 0 ) - currTime < 15 )
|
||||
while ( time( 0 ) - currTime < 30 )
|
||||
{
|
||||
|
||||
USBDevice_deInit();
|
||||
USBStorage2_Deinit();
|
||||
USBDevice_Init();
|
||||
|
@ -34,8 +34,6 @@ using namespace std;
|
||||
#define RF_NEWS_CHANNEL 0x48414741
|
||||
#define RF_FORECAST_CHANNEL 0x48414641
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 zeroes1[0x40];
|
||||
@ -58,7 +56,6 @@ typedef struct
|
||||
u8 md5[0x10];
|
||||
} IMET;
|
||||
|
||||
|
||||
class NandTitle
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user