-corrected a few wrong things from r673

-use the devolution sample loader device mount way to read the iso
(may fixes bugs in booting devolution)
This commit is contained in:
fix94.1 2012-08-24 13:50:17 +00:00
parent 6723f00181
commit 99a2f9faad
11 changed files with 61 additions and 73 deletions

View File

@ -36,14 +36,12 @@
#include <malloc.h> #include <malloc.h>
#include "nand.hpp" #include "nand.hpp"
#include "devicemounter/DeviceHandler.hpp"
#include "fileOps/fileOps.h" #include "fileOps/fileOps.h"
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "loader/alt_ios.h" #include "loader/alt_ios.h"
#include "loader/cios.h" #include "loader/cios.h"
#include "loader/sys.h" #include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
#include "music/musicplayer.h"
#include "memory/memory.h" #include "memory/memory.h"
u8 *confbuffer ATTRIBUTE_ALIGN(32); u8 *confbuffer ATTRIBUTE_ALIGN(32);
@ -160,12 +158,7 @@ s32 Nand::Enable_Emu()
if(emu_enabled) if(emu_enabled)
return 0; return 0;
if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS) if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS)
{
m_music.Stop();
loadIOS(mainIOS, false, false); loadIOS(mainIOS, false, false);
DeviceHandler::Instance()->MountAll();
m_music.Next();
}
NandDevice *Device = &NandDeviceList[EmuDevice]; NandDevice *Device = &NandDeviceList[EmuDevice];

View File

@ -115,36 +115,34 @@ void DeviceHandler::UnMount(int dev)
UnMountUSB(dev-USB1); UnMountUSB(dev-USB1);
} }
void DeviceHandler::SetModes()
{
/* Set for USB */
if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS)
usb_libogc_mode = 1;
else
usb_libogc_mode = 0;
/* Set for SD */
if(CurrentIOS.Type == IOS_TYPE_D2X)
sdhc_mode_sd = 0;
else
sdhc_mode_sd = 1;
}
bool DeviceHandler::MountSD() bool DeviceHandler::MountSD()
{ {
if(sd) if(!sd)
sd = new PartitionHandle(&__io_sdhc);
if(sd && sd->GetPartitionCount() < 1)
{ {
delete sd; delete sd;
sd = NULL; sd = NULL;
}
sd = new PartitionHandle(&__io_sdhc);
if(sd->GetPartitionCount() < 1)
{
delete sd;
sdhc_mode_sd = 1;
gprintf("Couldn't find SD Card. Trying __io_wiisd mode\n");
sd = new PartitionHandle(&__io_sdhc);
}
if(sd->GetPartitionCount() < 1)
{
delete sd;
sd = NULL;
sdhc_mode_sd = 0;
gprintf("SD Card not found.\n");
return false; return false;
} }
gprintf("SD Card found.\n");
//! Mount only one SD Partition //! Mount only one SD Partition
return sd->Mount(0, DeviceName[SD], true); return sd->Mount(0, DeviceName[SD], true);
} }
bool DeviceHandler::MountUSB(int pos) bool DeviceHandler::MountUSB(int pos)
{ {
if(!usb0 && !usb1) if(!usb0 && !usb1)
@ -165,36 +163,21 @@ bool DeviceHandler::MountUSB(int pos)
bool DeviceHandler::MountAllUSB() bool DeviceHandler::MountAllUSB()
{ {
if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS)
usb_libogc_mode = 1;
else
usb_libogc_mode = 0;
if(!usb0) if(!usb0)
usb0 = new PartitionHandle(GetUSB0Interface()); usb0 = new PartitionHandle(GetUSB0Interface());
//if(!usb1 && (Settings.USBPort == 1 || Settings.USBPort == 2))
//usb1 = new PartitionHandle(GetUSB1Interface());
if(usb0 && usb0->GetPartitionCount() < 1) if(usb0 && usb0->GetPartitionCount() < 1)
{ {
delete usb0; delete usb0;
usb0 = NULL; usb0 = NULL;
return false;
} }
if(usb1 && usb1->GetPartitionCount() < 1)
{
delete usb1;
usb1 = NULL;
}
bool result = false; bool result = false;
int partCount = GetUSBPartitionCount(); int partCount = GetUSBPartitionCount();
for(int i = 0; i < partCount; i++) for(int i = 0; i < partCount; i++)
{ {
if(MountUSB(i)) if(MountUSB(i))
result = true; result = true;
} }
return result; return result;
} }

View File

@ -69,6 +69,8 @@ class DeviceHandler
static DeviceHandler * Instance(); static DeviceHandler * Instance();
static void DestroyInstance(); static void DestroyInstance();
void SetModes();
void MountAll(); void MountAll();
void UnMountAll(); void UnMountAll();
bool Mount(int dev); bool Mount(int dev);

View File

@ -20,6 +20,7 @@
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <ogc/machine/processor.h> #include <ogc/machine/processor.h>
#include <sdcard/wiisd_io.h>
// for directory parsing and low-level file I/O // for directory parsing and low-level file I/O
#include <sys/types.h> #include <sys/types.h>
@ -28,6 +29,7 @@
#include <dirent.h> #include <dirent.h>
#include "gc/gc.hpp" #include "gc/gc.hpp"
#include "fat.h"
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "fileOps/fileOps.h" #include "fileOps/fileOps.h"
#include "loader/utils.h" #include "loader/utils.h"
@ -182,12 +184,7 @@ bool DEVO_Installed(const char* path)
return devo; return devo;
} }
void DEVO_ShowReport(void) void DEVO_GetLoader(const char *loader)
{
gprintf("%s\n", (char*)loader_bin + 4);
}
void DEVO_SetOptions(const char *isopath, const char *partition, const char *loader, const char *gameID, bool memcard_emu)
{ {
//Read in loader.bin //Read in loader.bin
char loader_path[256]; char loader_path[256];
@ -209,8 +206,13 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *loa
gprintf("Devolution loader.bin not found!\n"); gprintf("Devolution loader.bin not found!\n");
return; return;
} }
gprintf("%s\n", (char*)loader_bin + 4);
}
DEVO_ShowReport(); void DEVO_SetOptions(const char *isopath, const char *partition, const char *gameID, bool memcard_emu)
{
// re-mount device we need
fatMountSimple(partition, strncasecmp(partition, "sd", 2) ? &__io_usbstorage : &__io_wiisd);
//start writing cfg to mem //start writing cfg to mem
struct stat st; struct stat st;
@ -218,7 +220,7 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *loa
char iso2path[256]; char iso2path[256];
stat(isopath, &st); stat(isopath, &st);
f = fopen(isopath, "rb"); FILE *f = fopen(isopath, "rb");
gprintf("Read ISO File: \"%s\"\n", isopath); gprintf("Read ISO File: \"%s\"\n", isopath);
fread((u8*)0x80000000, 1, 32, f); fread((u8*)0x80000000, 1, 32, f);
fclose(f); fclose(f);
@ -296,6 +298,8 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *loa
// flush disc ID and Devolution config out to memory // flush disc ID and Devolution config out to memory
DCFlushRange((void*)0x80000000, 64); DCFlushRange((void*)0x80000000, 64);
fatUnmount(partition);
} }
void DEVO_Boot() void DEVO_Boot()

View File

@ -80,8 +80,8 @@ typedef struct global_config
} gconfig; } gconfig;
bool DEVO_Installed(const char *path); bool DEVO_Installed(const char *path);
void DEVO_ShowReport(void); void DEVO_GetLoader(const char *loader);
void DEVO_SetOptions(const char *isopath, const char *partition, const char *loader, const char *gameID, bool memcard_emum); void DEVO_SetOptions(const char *isopath, const char *partition, const char *gameID, bool memcard_emum);
void DEVO_Boot(); void DEVO_Boot();
// General // General

View File

@ -14,6 +14,7 @@
#include "gecko/gecko.h" #include "gecko/gecko.h"
#include "memory/mem2.hpp" #include "memory/mem2.hpp"
#include "memory/memory.h" #include "memory/memory.h"
#include "music/musicplayer.h"
#include "types.h" #include "types.h"
// mload from uloader by Hermes // mload from uloader by Hermes
@ -81,15 +82,16 @@ void load_dip_249()
bool loadIOS(int ios, bool launch_game, bool emu_channel) bool loadIOS(int ios, bool launch_game, bool emu_channel)
{ {
#ifndef DOLPHIN #ifndef DOLPHIN
bool iosOK = true;
if(ios != IOS_GetVersion())
{
m_music.Stop();
Close_Inputs(); Close_Inputs();
DeviceHandler::Instance()->UnMountAll(); DeviceHandler::Instance()->UnMountAll();
WDVD_Close(); WDVD_Close();
USBStorage2_Deinit(); USBStorage2_Deinit();
mload_close(); mload_close();
bool iosOK = true;
if(ios != IOS_GetVersion())
{
gprintf("Reloading into IOS %i from %i...\n", ios, IOS_GetVersion()); gprintf("Reloading into IOS %i from %i...\n", ios, IOS_GetVersion());
Nand::Instance()->DeInit_ISFS(); Nand::Instance()->DeInit_ISFS();
iosOK = IOS_ReloadIOS(ios) == 0; iosOK = IOS_ReloadIOS(ios) == 0;
@ -102,6 +104,7 @@ bool loadIOS(int ios, bool launch_game, bool emu_channel)
load_ehc_module_ex(); load_ehc_module_ex();
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18) else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
load_dip_249(); load_dip_249();
DeviceHandler::Instance()->SetModes();
if(!emu_channel) if(!emu_channel)
{ {
@ -112,8 +115,11 @@ bool loadIOS(int ios, bool launch_game, bool emu_channel)
Disc_Init(); Disc_Init();
} }
else else
{
DeviceHandler::Instance()->MountAll();
Open_Inputs(); Open_Inputs();
} }
}
return iosOK; return iosOK;
#else #else

View File

@ -69,7 +69,7 @@ int main(int argc, char **argv)
iosOK = true; iosOK = true;
memset(&CurrentIOS, 0, sizeof(IOS_Info)); memset(&CurrentIOS, 0, sizeof(IOS_Info));
CurrentIOS.Version = 254; CurrentIOS.Version = 254;
CurrentIOS.Type = IOS_TYPE_D2X; CurrentIOS.Type = IOS_TYPE_NEEK2O;
CurrentIOS.Base = 254; CurrentIOS.Base = 254;
CurrentIOS.Revision = 999; CurrentIOS.Revision = 999;
DCFlushRange(&CurrentIOS, sizeof(IOS_Info)); DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
@ -77,12 +77,12 @@ int main(int argc, char **argv)
else if(*HW_AHBPROT != 0xFFFFFFFF) else if(*HW_AHBPROT != 0xFFFFFFFF)
{ {
gprintf("Loading cIOS: %d\n", mainIOS); gprintf("Loading cIOS: %d\n", mainIOS);
iosOK = loadIOS(mainIOS, false, false) && CustomIOS(CurrentIOS.Type); iosOK = loadIOS(mainIOS, true, true) && CustomIOS(CurrentIOS.Type);
} }
else else
{ {
gprintf("Using IOS%d and AHBPROT patched out\n", IOS_GetVersion()); gprintf("AHBPROT patched out, use IOS58\n");
iosOK = loadIOS(IOS_GetVersion(), false, false); iosOK = loadIOS(58, true, true);
} }
#else #else
iosOK = true; iosOK = true;
@ -98,7 +98,6 @@ int main(int argc, char **argv)
{ {
Open_Inputs(); //(re)init wiimote Open_Inputs(); //(re)init wiimote
#ifndef DOLPHIN #ifndef DOLPHIN
DeviceHandler::Instance()->MountSD();
const DISC_INTERFACE *handle = DeviceHandler::GetUSB0Interface(); const DISC_INTERFACE *handle = DeviceHandler::GetUSB0Interface();
bool deviceAvailable = false; bool deviceAvailable = false;
u8 timeout = 0; u8 timeout = 0;
@ -109,13 +108,10 @@ int main(int argc, char **argv)
break; break;
usleep(50000); usleep(50000);
} }
DeviceHandler::Instance()->MountAllUSB(); #endif
DeviceHandler::Instance()->MountAll();
if(DeviceHandler::Instance()->IsInserted(SD)) if(DeviceHandler::Instance()->IsInserted(SD))
deviceAvailable = true; deviceAvailable = true;
#else
bool deviceAvailable = true;
DeviceHandler::Instance()->MountAll();
#endif
bool dipOK = Disc_Init() >= 0; bool dipOK = Disc_Init() >= 0;
mainMenu = new CMenu(vid); mainMenu = new CMenu(vid);

View File

@ -809,6 +809,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
} }
u8 loader = min((u32)m_gcfg2.getInt(id, "gc_loader", 0), ARRAY_SIZE(CMenu::_GCLoader) - 1u); u8 loader = min((u32)m_gcfg2.getInt(id, "gc_loader", 0), ARRAY_SIZE(CMenu::_GCLoader) - 1u);
bool memcard_emu = m_gcfg2.getBool(id, "devo_memcard_emu", false);
if(disc) if(disc)
{ {
@ -856,8 +857,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
else if(loader == 2 || (loader == 0 && m_devo_installed && strcasestr(path.c_str(), "boot.bin") == NULL)) else if(loader == 2 || (loader == 0 && m_devo_installed && strcasestr(path.c_str(), "boot.bin") == NULL))
{ {
loader = 2; loader = 2;
bool memcard_emu = m_gcfg2.getBool(id, "devo_memcard_emu", false); DEVO_GetLoader(m_dataDir.c_str());
DEVO_SetOptions(path.c_str(), DeviceName[currentPartition], m_dataDir.c_str(), id.c_str(), memcard_emu);
} }
m_gcfg1.save(true); m_gcfg1.save(true);
@ -865,21 +865,24 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
m_cat.save(true); m_cat.save(true);
m_cfg.save(true); m_cfg.save(true);
cleanup(); cleanup();
#ifndef DOLPHIN #ifndef DOLPHIN
USBStorage2_Deinit(); USBStorage2_Deinit();
USB_Deinitialize(); USB_Deinitialize();
Nand::Instance()->DeInit_ISFS();
#endif #endif
GC_SetVideoMode(videoMode, videoSetting); GC_SetVideoMode(videoMode, videoSetting);
GC_SetLanguage(GClanguage); GC_SetLanguage(GClanguage);
if(loader == 2) if(loader == 2)
{ {
loadIOS(58, true, true); loadIOS(58, true, true);
writeStub(); writeStub();
DEVO_SetOptions(path.c_str(), DeviceName[currentPartition], id.c_str(), memcard_emu);
DEVO_Boot(); DEVO_Boot();
} }
DML_New_WriteOptions();
Nand::Instance()->DeInit_ISFS(); DML_New_WriteOptions();
WII_Initialize(); WII_Initialize();
if(WII_LaunchTitle(0x100000100LL) < 0) if(WII_LaunchTitle(0x100000100LL) < 0)
Sys_LoadMenu(); Sys_LoadMenu();

View File

@ -687,7 +687,7 @@ int CMenu::main(void)
{ {
_showWaitMessage(); _showWaitMessage();
_hideMain(); _hideMain();
bool isD2XnewerThanV6 = false; bool isD2XnewerThanV6 = (CurrentIOS.Type == IOS_TYPE_NEEK2O);
if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X) if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X)
isD2XnewerThanV6 = true; isD2XnewerThanV6 = true;
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0)) if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0))

View File

@ -200,7 +200,7 @@ void CMenu::_enableNandEmu(bool fromconfig)
if(!disable) if(!disable)
{ {
bool isD2XnewerThanV6 = false; bool isD2XnewerThanV6 = (CurrentIOS.Type == IOS_TYPE_NEEK2O);
if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X) if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X)
isD2XnewerThanV6 = true; isD2XnewerThanV6 = true;
if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !neek2o() && !m_tempView) if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !neek2o() && !m_tempView)

View File

@ -25,6 +25,7 @@ enum
IOS_TYPE_WANIN, IOS_TYPE_WANIN,
IOS_TYPE_HERMES, IOS_TYPE_HERMES,
IOS_TYPE_KWIIRK, IOS_TYPE_KWIIRK,
IOS_TYPE_NEEK2O,
IOS_TYPE_NORMAL_IOS, IOS_TYPE_NORMAL_IOS,
IOS_TYPE_STUB, IOS_TYPE_STUB,
}; };