mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 19:01:56 +01:00
-fixed fatal bug in usb mounting (broken timeout for slow hdds)
-fixed devolution usage with slow hdds
This commit is contained in:
parent
b6b22aae27
commit
185ad059c0
@ -29,9 +29,12 @@
|
||||
#include <ogc/mutex.h>
|
||||
#include <ogc/system.h>
|
||||
#include <sdcard/gcsd.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include "DeviceHandler.hpp"
|
||||
#include "defines.h"
|
||||
#include "sdhc.h"
|
||||
#include "usbstorage.h"
|
||||
#include "usbstorage_libogc.h"
|
||||
#include "loader/cios.h"
|
||||
#include "loader/wbfs.h"
|
||||
|
||||
@ -59,7 +62,9 @@ void DeviceHandler::DestroyInstance()
|
||||
void DeviceHandler::MountAll()
|
||||
{
|
||||
MountSD();
|
||||
#ifndef DOLPHIN
|
||||
MountAllUSB();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountAll(bool ShutdownUSB)
|
||||
@ -168,6 +173,9 @@ bool DeviceHandler::MountUSB(int pos)
|
||||
|
||||
bool DeviceHandler::MountAllUSB()
|
||||
{
|
||||
/* Wait for our slowass HDD */
|
||||
WaitForDevice(GetUSB0Interface());
|
||||
/* Get Partitions and Mount them */
|
||||
if(!usb0)
|
||||
usb0 = new PartitionHandle(GetUSB0Interface());
|
||||
if(usb0 && usb0->GetPartitionCount() < 1)
|
||||
@ -381,3 +389,34 @@ PartitionHandle *DeviceHandler::GetUSBHandleFromPartition(int part) const
|
||||
else
|
||||
return usb1;
|
||||
}
|
||||
|
||||
void DeviceHandler::WaitForDevice(const DISC_INTERFACE *Handle)
|
||||
{
|
||||
if(Handle == NULL)
|
||||
return;
|
||||
time_t timeout = time(NULL);
|
||||
while(time(NULL) - timeout < 20)
|
||||
{
|
||||
if(Handle->startup() && Handle->isInserted())
|
||||
break;
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceHandler::MountDevolution(int CurrentPartition)
|
||||
{
|
||||
int NewPartition = (CurrentPartition == SD ? CurrentPartition : CurrentPartition - 1);
|
||||
const DISC_INTERFACE *handle = (CurrentPartition == SD) ? &__io_wiisd : &__io_usbstorage_ogc;
|
||||
/* We need to wait for the device to get ready for a remount */
|
||||
WaitForDevice(handle);
|
||||
/* Only mount the partition we need */
|
||||
OGC_Device = new PartitionHandle(handle);
|
||||
return OGC_Device->Mount(NewPartition, DeviceName[CurrentPartition], true);
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountDevolution(int CurrentPartition)
|
||||
{
|
||||
int NewPartition = (CurrentPartition == SD ? CurrentPartition : CurrentPartition - 1);
|
||||
OGC_Device->UnMount(NewPartition);
|
||||
delete OGC_Device;
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ class DeviceHandler
|
||||
bool SD_Inserted() { if(sd) return sd->IsInserted(); return false; }
|
||||
bool USB0_Inserted() { if(usb0) return usb0->IsInserted(); return false; }
|
||||
bool USB1_Inserted() { if(usb1) return usb1->IsInserted(); return false; }
|
||||
void WaitForDevice(const DISC_INTERFACE *Handle);
|
||||
|
||||
void UnMountSD() { if(sd) delete sd; sd = NULL; }
|
||||
void UnMountUSB(int pos);
|
||||
@ -107,8 +108,12 @@ class DeviceHandler
|
||||
s32 Open_WBFS(int dev);
|
||||
static int PartitionToUSBPort(int part);
|
||||
static int PartitionToPortPartition(int part);
|
||||
|
||||
/* Special Devolution Stuff */
|
||||
bool MountDevolution(int CurrentPartition);
|
||||
void UnMountDevolution(int CurrentPartition);
|
||||
private:
|
||||
DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0) { }
|
||||
DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0), OGC_Device(0) { }
|
||||
~DeviceHandler();
|
||||
bool MountUSB(int part);
|
||||
|
||||
@ -119,6 +124,9 @@ class DeviceHandler
|
||||
PartitionHandle * gcb;
|
||||
PartitionHandle * usb0;
|
||||
PartitionHandle * usb1;
|
||||
|
||||
/* Special Devolution Stuff */
|
||||
PartitionHandle *OGC_Device;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -156,7 +156,7 @@ s32 USBStorage2_SetPort(s8 port)
|
||||
|
||||
gprintf("Changing USB port to port %i....\n", port);
|
||||
//must be called before USBStorage2_Init (default port 0)
|
||||
if(fd >= 0 && !usb_libogc_mode)
|
||||
if(fd >= 0)
|
||||
ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_SET_PORT, "i:", usb2_port);
|
||||
|
||||
return ret;
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
|
||||
// for directory parsing and low-level file I/O
|
||||
#include <sys/types.h>
|
||||
@ -29,9 +28,7 @@
|
||||
#include <dirent.h>
|
||||
|
||||
#include "gc/gc.hpp"
|
||||
#include "fat.h"
|
||||
#include "devicemounter/sdhc.h"
|
||||
#include "devicemounter/usbstorage_libogc.h"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "gecko/gecko.h"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "loader/utils.h"
|
||||
@ -211,10 +208,10 @@ void DEVO_GetLoader(const char *loader)
|
||||
gprintf("%s\n", (char*)loader_bin + 4);
|
||||
}
|
||||
|
||||
void DEVO_SetOptions(const char *isopath, const char *partition, const char *gameID, bool memcard_emu)
|
||||
void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *gameID, bool memcard_emu)
|
||||
{
|
||||
// re-mount device we need
|
||||
fatMountSimple(partition, strncasecmp(partition, "sd", 2) ? &__io_usbstorage_ogc : &__io_wiisd);
|
||||
DeviceHandler::Instance()->MountDevolution(CurrentPartition);
|
||||
|
||||
//start writing cfg to mem
|
||||
struct stat st;
|
||||
@ -252,9 +249,9 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *gam
|
||||
|
||||
// make sure these directories exist, they are required for Devolution to function correctly
|
||||
char full_path[256];
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps", partition);
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps", DeviceName[CurrentPartition]);
|
||||
fsop_MakeFolder(full_path);
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo", partition);
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo", DeviceName[CurrentPartition]);
|
||||
fsop_MakeFolder(full_path);
|
||||
|
||||
if(memcard_emu)
|
||||
@ -263,9 +260,9 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *gam
|
||||
// this file can be located anywhere since it's passed by cluster, not name
|
||||
// it must be at least 16MB though
|
||||
if(gameID[3] == 'J') //Japanese Memory Card
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/memcard_jap.bin", partition);
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/memcard_jap.bin", DeviceName[CurrentPartition]);
|
||||
else
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/memcard.bin", partition);
|
||||
snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/memcard.bin", DeviceName[CurrentPartition]);
|
||||
|
||||
// check if file doesn't exist or is less than 16MB
|
||||
if(stat(full_path, &st) == -1 || st.st_size < 16<<20)
|
||||
@ -301,7 +298,7 @@ void DEVO_SetOptions(const char *isopath, const char *partition, const char *gam
|
||||
// flush disc ID and Devolution config out to memory
|
||||
DCFlushRange((void*)0x80000000, 64);
|
||||
|
||||
fatUnmount(partition);
|
||||
DeviceHandler::Instance()->UnMountDevolution(CurrentPartition);
|
||||
}
|
||||
|
||||
void DEVO_Boot()
|
||||
|
@ -81,7 +81,7 @@ typedef struct global_config
|
||||
|
||||
bool DEVO_Installed(const char *path);
|
||||
void DEVO_GetLoader(const char *loader);
|
||||
void DEVO_SetOptions(const char *isopath, const char *partition, const char *gameID, bool memcard_emum);
|
||||
void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *gameID, bool memcard_emum);
|
||||
void DEVO_Boot();
|
||||
|
||||
// General
|
||||
|
@ -93,16 +93,7 @@ int main(int argc, char **argv)
|
||||
// Init
|
||||
Sys_Init();
|
||||
Sys_ExitTo(EXIT_TO_HBC);
|
||||
#ifndef DOLPHIN
|
||||
const DISC_INTERFACE *handle = DeviceHandler::GetUSB0Interface();
|
||||
u8 timeout = time(NULL);
|
||||
while(time(NULL) - timeout < 20)
|
||||
{
|
||||
if(handle->startup() && handle->isInserted())
|
||||
break;
|
||||
usleep(50000);
|
||||
}
|
||||
#endif
|
||||
|
||||
DeviceHandler::Instance()->MountAll();
|
||||
vid.waitMessage(0.15f);
|
||||
bool dipOK = WDVD_Init() >= 0;
|
||||
|
@ -884,26 +884,25 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
|
||||
|
||||
GC_SetVideoMode(videoMode, videoSetting);
|
||||
GC_SetLanguage(GClanguage);
|
||||
if(loader == 2)
|
||||
|
||||
if(loader == 2 && !disc)
|
||||
{
|
||||
if(AHBRPOT_Patched())
|
||||
loadIOS(58, false);
|
||||
else //use cIOS instead to make sure Devolution works anyways
|
||||
loadIOS(mainIOS, false);
|
||||
DEVO_SetOptions(path.c_str(), DeviceName[currentPartition], id.c_str(), memcard_emu);
|
||||
}
|
||||
ShutdownBeforeExit();
|
||||
if(loader == 1 || disc)
|
||||
{
|
||||
DML_New_WriteOptions();
|
||||
WII_Initialize();
|
||||
WII_LaunchTitle(0x100000100LL);
|
||||
}
|
||||
else if(loader == 2)
|
||||
{
|
||||
ShutdownBeforeExit();
|
||||
DEVO_SetOptions(path.c_str(), currentPartition, id.c_str(), memcard_emu);
|
||||
writeStub();
|
||||
DEVO_Boot();
|
||||
}
|
||||
else
|
||||
{
|
||||
DML_New_WriteOptions();
|
||||
ShutdownBeforeExit();
|
||||
WII_Initialize();
|
||||
WII_LaunchTitle(0x100000100LL);
|
||||
}
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user