*First attempt to fix the weird startup problems and wiitdb issue (Testversion 3)

This commit is contained in:
dimok321 2010-01-17 09:49:26 +00:00
parent bc68840faf
commit ca9455aa53
3 changed files with 79 additions and 58 deletions

View File

@ -166,12 +166,12 @@ int main(int argc, char *argv[])
} }
gettextCleanUp(); gettextCleanUp();
printf("\n\tLoading configuration..."); printf("\n\tLoading configuration...");
CFG_Load(); CFG_Load();
printf("done"); printf("done");
LoadAppCIOS(); LoadAppCIOS();
printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision()); printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());
//if a ID was passed via args copy it and try to boot it after the partition is mounted //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. //its not really a headless mode. more like hairless.

View File

@ -39,6 +39,37 @@ void HaltCheck()
usleep(50); usleep(50);
} }
void ReloadHDD_Settings()
{
if(strstr(bootDevice, "USB:") != 0)
{
CFG_Load();
int ios = 249;
switch(Settings.cios)
{
case ios249:
ios = 249;
break;
case ios222:
ios = 222;
break;
case ios250:
ios = 250;
break;
}
if(ios != IOS_GetVersion())
Sys_ChangeIos(ios);
}
if(strstr(Settings.ogg_path, "USB:/") != 0)
{
bgMusic->Load(Settings.ogg_path);
bgMusic->Play();
}
// open database if available, load titles if needed
OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride == 1 ? true: false, true);
}
int CheckPartition() int CheckPartition()
{ {
s32 ret2 = -1; s32 ret2 = -1;
@ -157,19 +188,11 @@ static void * CheckDevices (void *arg)
{ {
if(CheckHDD() >= 0) if(CheckHDD() >= 0)
{ {
// open database if needed, load titles if needed
if(isInserted(bootDevice))
OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride == 1 ? true: false, true);
checkthreadState = 1;
LWP_SetThreadPriority(LWP_GetSelf(), 0); LWP_SetThreadPriority(LWP_GetSelf(), 0);
if(strstr(Settings.ogg_path, "USB:/") != 0) ReloadHDD_Settings();
{
bgMusic->Load(Settings.ogg_path); checkthreadState = 1;
bgMusic->Play();
}
} }
} }

View File

@ -248,28 +248,28 @@ s32 IOS_ReloadIOSsafe(int ios)
if (ios222rev == -69) if (ios222rev == -69)
ios222rev = getIOSrev(0x00000001000000dell); ios222rev = getIOSrev(0x00000001000000dell);
if (ios222rev >= 0 && (ios222rev != 4 && ios222rev != 5))return -2; if (ios222rev >= 0 && !(ios222rev >= 4 && ios222rev < 65280)) return -2;
} }
else if (ios==223) else if (ios==223)
{ {
if (ios223rev == -69) if (ios223rev == -69)
ios223rev = getIOSrev(0x00000001000000dfll); ios223rev = getIOSrev(0x00000001000000dfll);
if (ios223rev >= 0 && (ios223rev != 4 && ios223rev != 5))return -2; if (ios223rev >= 0 && !(ios223rev >= 4 && ios223rev < 65280)) return -2;
} }
else if (ios==249) else if (ios==249)
{ {
if (ios249rev == -69) if (ios249rev == -69)
ios249rev = getIOSrev(0x00000001000000f9ll); ios249rev = getIOSrev(0x00000001000000f9ll);
if (ios249rev >= 0 && !(ios249rev>=9 && ios249rev<65280))return -2; if (ios249rev >= 0 && !(ios249rev >= 9 && ios249rev < 65280))return -2;
} }
else if (ios==250) else if (ios==250)
{ {
if (ios250rev == -69) if (ios250rev == -69)
ios250rev = getIOSrev(0x00000001000000fall); ios250rev = getIOSrev(0x00000001000000fall);
if (ios250rev >= 0 && !(ios250rev>=9 && ios250rev<65280))return -2; if (ios250rev >= 0 && !(ios250rev >= 9 && ios250rev < 65280))return -2;
} }
s32 r = IOS_ReloadIOS(ios); s32 r = IOS_ReloadIOS(ios);
@ -284,12 +284,12 @@ s32 IOS_ReloadIOSsafe(int ios)
s32 CheckForCIOS() s32 CheckForCIOS()
{ {
gprintf("\n\tChecking for stub IOS"); gprintf("\n\tChecking for stub IOS");
s32 ret = -1; s32 ret = 1;
s32 ios222rev = getIOSrev(0x00000001000000dell); ios222rev = getIOSrev(0x00000001000000dell);
s32 ios249rev = getIOSrev(0x00000001000000f9ll); ios249rev = getIOSrev(0x00000001000000f9ll);
//if we don't like either of the cIOS then scram //if we don't like either of the cIOS then scram
if (!(ios222rev==4 || ios222rev==5 || (ios249rev>=9 && ios249rev<65280))) if (!((ios222rev >= 4 && ios222rev < 65280) || (ios249rev >=9 && ios249rev < 65280)))
{ {
InitTextVideo(); InitTextVideo();
printf("\x1b[2J"); printf("\x1b[2J");
@ -316,15 +316,15 @@ s32 CheckForCIOS()
} }
} }
printf("\n\tReloading ios 249..."); //Needed for Settings load of HDD
ret = IOS_ReloadIOSsafe(249); printf("\n\tReloading ios 222...");
ret = IOS_ReloadIOSsafe(222);
printf("%d", ret); printf("%d", ret);
if (ret < 0) if (ret < 0)
{ {
printf("\n\tIOS 249 failed, reloading ios 222..."); printf("\n\tIOS 222 failed, reloading ios 249...");
ret = IOS_ReloadIOSsafe(222); ret = IOS_ReloadIOSsafe(249);
printf("%d", ret); printf("%d", ret);
if (ret < 0) { if (ret < 0) {
printf("\n\tIOS 222 failed, reloading ios 250..."); printf("\n\tIOS 222 failed, reloading ios 250...");
@ -336,14 +336,14 @@ s32 CheckForCIOS()
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
} }
else }
{ else
SDCard_Init(); {
//only for 222 loading ehc modules SDCard_Init();
printf("\n\tLoad ehc module"); //only for 222 loading ehc modules
load_ehc_module(); printf("\n\tLoad ehc module");
SDCard_deInit(); load_ehc_module();
} SDCard_deInit();
} }
return ret; return ret;
@ -352,46 +352,44 @@ s32 CheckForCIOS()
int LoadAppCIOS() int LoadAppCIOS()
{ {
s32 ret = 1; s32 ret = 1;
bool IOS_Reloaded = false;
/* Load Custom IOS */ /* Load Custom IOS */
SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit();
if (Settings.cios == ios222 && IOS_GetVersion() != 222) if (Settings.cios == ios222 && IOS_GetVersion() != 222)
{ {
printf("\n\tReloading IOS to config setting (%d)...", ios222 ? 222 : 223); printf("\n\tReloading IOS to config setting (222)...");
SDCard_deInit();// unmount SD for reloading IOS ret = IOS_ReloadIOSsafe(222);
USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit();
ret = IOS_ReloadIOSsafe(ios222 ? 222 : 223);
printf("%d", ret); printf("%d", ret);
if (ret < 0) if (ret < 0)
{ {
Settings.cios = ios249; Settings.cios = ios249;
IOS_ReloadIOSsafe(249); IOS_ReloadIOSsafe(249);
} }
IOS_Reloaded = true;
SDCard_Init();
USBDevice_Init(); // and mount USB:/
if(ret >= 0)
load_ehc_module();
} }
else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) ||
(Settings.cios == ios250 && IOS_GetVersion() != 250)) if ((Settings.cios == ios249 && IOS_GetVersion() != 249)
|| (Settings.cios == ios250 && IOS_GetVersion() != 250))
{ {
printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250); printf("\n\tReloading IOS to config setting (%d)...", (Settings.cios == ios249) ? 249 : 250);
SDCard_deInit();// unmount SD for reloading IOS ret = IOS_ReloadIOSsafe((Settings.cios == ios249) ? 249 : 250);
USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit();
ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250);
printf("%d", ret); printf("%d", ret);
if (ret < 0) { if (ret < 0) {
Settings.cios = ios222; Settings.cios = ios222;
ret = IOS_ReloadIOSsafe(222); ret = IOS_ReloadIOSsafe(222);
SDCard_Init();
load_ehc_module();
} }
IOS_Reloaded = true;
else SDCard_Init(); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card
USBDevice_Init(); // and mount USB:/
} }
SDCard_Init();
if(IOS_GetVersion() == 222 && IOS_Reloaded)
load_ehc_module();
USBDevice_Init();
return ret; return ret;
} }