mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 03:11:58 +01:00
-added back debug HDD size/sector info (more fancy this time :P)
-added debug SD information if found or not and if in __io_wiisd mode (for dolphin-emu, neek, hermes ios) -added automatically test if __io_wiisd mode works (no need to overwrite things anymore to test that) -added more intelligent IOS check (stub check, version check) -removed unneeded cIOS information in neek mode
This commit is contained in:
parent
7aac10d1ec
commit
8d099e9041
@ -29,17 +29,11 @@
|
|||||||
#include <ogc/mutex.h>
|
#include <ogc/mutex.h>
|
||||||
#include <ogc/system.h>
|
#include <ogc/system.h>
|
||||||
#include <sdcard/gcsd.h>
|
#include <sdcard/gcsd.h>
|
||||||
#include <sdcard/wiisd_io.h>
|
|
||||||
#include "cios.h"
|
#include "cios.h"
|
||||||
#include "DeviceHandler.hpp"
|
#include "DeviceHandler.hpp"
|
||||||
#include "wbfs.h"
|
#include "wbfs.h"
|
||||||
#include "usbstorage.h"
|
#include "usbstorage.h"
|
||||||
|
#include "sdhc.h"
|
||||||
#ifdef DOLPHIN
|
|
||||||
const DISC_INTERFACE __io_sdhc = __io_wiisd;
|
|
||||||
#else
|
|
||||||
extern const DISC_INTERFACE __io_sdhc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DeviceHandler * DeviceHandler::instance = NULL;
|
DeviceHandler * DeviceHandler::instance = NULL;
|
||||||
|
|
||||||
@ -50,19 +44,15 @@ DeviceHandler::~DeviceHandler()
|
|||||||
|
|
||||||
DeviceHandler * DeviceHandler::Instance()
|
DeviceHandler * DeviceHandler::Instance()
|
||||||
{
|
{
|
||||||
if (instance == NULL)
|
if(instance == NULL)
|
||||||
{
|
|
||||||
instance = new DeviceHandler();
|
instance = new DeviceHandler();
|
||||||
}
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandler::DestroyInstance()
|
void DeviceHandler::DestroyInstance()
|
||||||
{
|
{
|
||||||
if(instance)
|
if(instance)
|
||||||
{
|
|
||||||
delete instance;
|
delete instance;
|
||||||
}
|
|
||||||
instance = NULL;
|
instance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,19 +124,28 @@ void DeviceHandler::UnMount(int dev)
|
|||||||
|
|
||||||
bool DeviceHandler::MountSD()
|
bool DeviceHandler::MountSD()
|
||||||
{
|
{
|
||||||
if(!sd)
|
if(sd)
|
||||||
{
|
{
|
||||||
if(neek2o())
|
delete sd;
|
||||||
sd = new PartitionHandle(&__io_wiisd);
|
sd = NULL;
|
||||||
else
|
}
|
||||||
sd = new PartitionHandle(&__io_sdhc);
|
sd = new PartitionHandle(&__io_sdhc);
|
||||||
if(sd->GetPartitionCount() < 1)
|
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;
|
delete sd;
|
||||||
sd = NULL;
|
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);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <sdcard/gcsd.h>
|
||||||
#include "cios.h"
|
#include "cios.h"
|
||||||
#include "PartitionHandle.h"
|
#include "PartitionHandle.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -34,14 +35,8 @@
|
|||||||
#include "fat.h"
|
#include "fat.h"
|
||||||
#include "ext2.h"
|
#include "ext2.h"
|
||||||
#include "wbfs.h"
|
#include "wbfs.h"
|
||||||
#include <sdcard/gcsd.h>
|
#include "usbstorage.h"
|
||||||
#include <sdcard/wiisd_io.h>
|
#include "sdhc.h"
|
||||||
|
|
||||||
#ifdef DOLPHIN
|
|
||||||
const DISC_INTERFACE __io_sdhc = __io_wiisd;
|
|
||||||
#else
|
|
||||||
extern const DISC_INTERFACE __io_sdhc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ extended partition */
|
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ extended partition */
|
||||||
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
|
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
|
||||||
@ -179,7 +174,7 @@ bool PartitionHandle::Mount(int pos, const char * name, bool forceFAT)
|
|||||||
{
|
{
|
||||||
if(interface == &__io_usbstorage2_port0 || interface == &__io_usbstorage2_port1)
|
if(interface == &__io_usbstorage2_port0 || interface == &__io_usbstorage2_port1)
|
||||||
SetWbfsHandle(pos, wbfs_open_partition(__WBFS_ReadUSB, __WBFS_WriteUSB, NULL, USBStorage2_GetSectorSize(), GetSecCount(pos), GetLBAStart(pos), 0));
|
SetWbfsHandle(pos, wbfs_open_partition(__WBFS_ReadUSB, __WBFS_WriteUSB, NULL, USBStorage2_GetSectorSize(), GetSecCount(pos), GetLBAStart(pos), 0));
|
||||||
else if((neek2o() && interface == &__io_wiisd) || (!neek2o() && interface == &__io_sdhc))
|
else if(interface == &__io_sdhc)
|
||||||
SetWbfsHandle(pos, wbfs_open_partition(__WBFS_ReadSDHC, __WBFS_WriteSDHC, NULL, 512, GetSecCount(pos), GetLBAStart(pos), 0));
|
SetWbfsHandle(pos, wbfs_open_partition(__WBFS_ReadSDHC, __WBFS_WriteSDHC, NULL, 512, GetSecCount(pos), GetLBAStart(pos), 0));
|
||||||
if(GetWbfsHandle(pos))
|
if(GetWbfsHandle(pos))
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include "libwbfs/libwbfs.h"
|
#include "libwbfs/libwbfs.h"
|
||||||
#include "usbstorage.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ static s32 hid = -1, fd = -1;
|
|||||||
static u32 usb2_port = -1; //current USB port
|
static u32 usb2_port = -1; //current USB port
|
||||||
bool hddInUse[2] = { false, false };
|
bool hddInUse[2] = { false, false };
|
||||||
u32 hdd_sector_size[2] = { 512, 512 };
|
u32 hdd_sector_size[2] = { 512, 512 };
|
||||||
|
bool first = false;
|
||||||
|
|
||||||
extern void* SYS_AllocArena2MemLo(u32 size,u32 align);
|
extern void* SYS_AllocArena2MemLo(u32 size,u32 align);
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ s32 USBStorage2_SetPort(u32 port)
|
|||||||
|
|
||||||
s32 ret = -1;
|
s32 ret = -1;
|
||||||
usb2_port = port;
|
usb2_port = port;
|
||||||
|
first = true;
|
||||||
|
|
||||||
gprintf("Changing USB port to port %i....\n", port);
|
gprintf("Changing USB port to port %i....\n", port);
|
||||||
//must be called before USBStorage2_Init (default port 0)
|
//must be called before USBStorage2_Init (default port 0)
|
||||||
@ -161,7 +163,21 @@ s32 USBStorage2_GetCapacity(u32 port, u32 *_sector_size)
|
|||||||
|
|
||||||
ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", §or_size);
|
ret = IOS_IoctlvFormat(hid, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", §or_size);
|
||||||
|
|
||||||
if (ret && _sector_size) *_sector_size = sector_size;
|
if(first)
|
||||||
|
{
|
||||||
|
gprintf(" * * * * * * * * * * * *\n");
|
||||||
|
gprintf(" * HDD Information\n * Sectors: %lu\n", ret);
|
||||||
|
u32 size = ((((ret / 1024U) * sector_size) / 1024U) / 1024U);
|
||||||
|
if(size >= 1000U)
|
||||||
|
gprintf(" * Size [Sector Size]: %lu.%lu TB [%u]\n", size / 1024U, (size * 100U) % 1024U, sector_size);
|
||||||
|
else
|
||||||
|
gprintf(" * Size [Sector Size]: %lu GB [%u]\n", size, sector_size);
|
||||||
|
gprintf(" * * * * * * * * * * * *\n");
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret && _sector_size)
|
||||||
|
*_sector_size = sector_size;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,23 @@ bool D2X(u8 ios, u8 *base)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signed_blob *GetTMD(u8 ios, u32 *TMD_Length)
|
||||||
|
{
|
||||||
|
if(ES_GetStoredTMDSize(TITLE_ID(1, ios), TMD_Length) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
signed_blob *TMD = (signed_blob*)MEM2_alloc(ALIGN32(*TMD_Length));
|
||||||
|
if(TMD == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(ES_GetStoredTMD(TITLE_ID(1, ios), TMD, *TMD_Length) < 0)
|
||||||
|
{
|
||||||
|
MEM2_free(TMD);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return TMD;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads the ios info struct from the .app file.
|
* Reads the ios info struct from the .app file.
|
||||||
* @return pointer to iosinfo_t on success else NULL. The user is responsible for freeing the buffer.
|
* @return pointer to iosinfo_t on success else NULL. The user is responsible for freeing the buffer.
|
||||||
@ -87,18 +104,10 @@ bool D2X(u8 ios, u8 *base)
|
|||||||
iosinfo_t *GetInfo(u8 ios)
|
iosinfo_t *GetInfo(u8 ios)
|
||||||
{
|
{
|
||||||
u32 TMD_Length;
|
u32 TMD_Length;
|
||||||
if (ES_GetStoredTMDSize(TITLE_ID(1, ios), &TMD_Length) < 0) return NULL;
|
signed_blob *TMD = GetTMD(ios, &TMD_Length);
|
||||||
|
if(TMD == NULL)
|
||||||
signed_blob *TMD = (signed_blob*)MEM2_alloc(ALIGN32(TMD_Length));
|
|
||||||
if (TMD == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (ES_GetStoredTMD(TITLE_ID(1, ios), TMD, TMD_Length) < 0)
|
|
||||||
{
|
|
||||||
MEM2_free(TMD);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||||
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
|
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
|
||||||
|
|
||||||
@ -113,8 +122,43 @@ iosinfo_t *GetInfo(u8 ios)
|
|||||||
return iosinfo;
|
return iosinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 Title_GetSize_FromTMD(tmd *tmd_data)
|
||||||
|
{
|
||||||
|
u32 cnt, size = 0;
|
||||||
|
|
||||||
|
/* Calculate title size */
|
||||||
|
for (cnt = 0; cnt < tmd_data->num_contents; cnt++) {
|
||||||
|
tmd_content *content = &tmd_data->contents[cnt];
|
||||||
|
|
||||||
|
/* Add content size */
|
||||||
|
size += content->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
int get_ios_type(u8 slot)
|
int get_ios_type(u8 slot)
|
||||||
{
|
{
|
||||||
|
u32 TMD_Length;
|
||||||
|
signed_blob *TMD_Buffer = GetTMD(slot, &TMD_Length);
|
||||||
|
if(TMD_Buffer == NULL)
|
||||||
|
return IOS_TYPE_NO_CIOS;
|
||||||
|
|
||||||
|
tmd *iosTMD = (tmd*)SIGNATURE_PAYLOAD(TMD_Buffer);
|
||||||
|
if(Title_GetSize_FromTMD(iosTMD) < 0x100000 || iosTMD->title_version == 65280)
|
||||||
|
{
|
||||||
|
MEM2_free(TMD_Buffer);
|
||||||
|
return IOS_TYPE_NO_CIOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
iosinfo_t *info = GetInfo(slot);
|
||||||
|
if(info == NULL)
|
||||||
|
{
|
||||||
|
MEM2_free(TMD_Buffer);
|
||||||
|
return IOS_TYPE_NO_CIOS;
|
||||||
|
}
|
||||||
|
MEM2_free(info);
|
||||||
|
|
||||||
u8 base = 0;
|
u8 base = 0;
|
||||||
switch(slot)
|
switch(slot)
|
||||||
{
|
{
|
||||||
@ -122,7 +166,7 @@ int get_ios_type(u8 slot)
|
|||||||
case 223:
|
case 223:
|
||||||
case 224:
|
case 224:
|
||||||
case 225:
|
case 225:
|
||||||
if(IOS_GetRevision() == 1)
|
if(iosTMD->title_version == 1)
|
||||||
return IOS_TYPE_KWIIRK;
|
return IOS_TYPE_KWIIRK;
|
||||||
else
|
else
|
||||||
return IOS_TYPE_HERMES;
|
return IOS_TYPE_HERMES;
|
||||||
@ -143,6 +187,7 @@ int get_ios_type(u8 slot)
|
|||||||
else
|
else
|
||||||
return IOS_TYPE_NO_CIOS;
|
return IOS_TYPE_NO_CIOS;
|
||||||
}
|
}
|
||||||
|
MEM2_free(TMD_Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_ios_type(int type, u8 slot)
|
int is_ios_type(int type, u8 slot)
|
||||||
|
@ -21,6 +21,7 @@ typedef struct _iosinfo_t
|
|||||||
bool neek2o(void);
|
bool neek2o(void);
|
||||||
bool D2X(u8 ios, u8 *base);
|
bool D2X(u8 ios, u8 *base);
|
||||||
iosinfo_t *GetInfo(u8 ios);
|
iosinfo_t *GetInfo(u8 ios);
|
||||||
|
signed_blob *GetTMD(u8 ios, u32 *TMD_Length);
|
||||||
int is_ios_type(int type, u8 slot);
|
int is_ios_type(int type, u8 slot);
|
||||||
int get_ios_type(u8 slot);
|
int get_ios_type(u8 slot);
|
||||||
bool shadow_mload();
|
bool shadow_mload();
|
||||||
|
@ -278,7 +278,13 @@ void CMenu::init(void)
|
|||||||
m_cfg.getBool("NAND", "disable", true);
|
m_cfg.getBool("NAND", "disable", true);
|
||||||
|
|
||||||
_installed_cios.clear();
|
_installed_cios.clear();
|
||||||
|
if(!neek2o())
|
||||||
_load_installed_cioses();
|
_load_installed_cioses();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extern int mainIOS;
|
||||||
|
_installed_cios[mainIOS] = mainIOS;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(m_app_update_drive, sizeof(m_app_update_drive), "%s:/", drive);
|
snprintf(m_app_update_drive, sizeof(m_app_update_drive), "%s:/", drive);
|
||||||
m_dataDir = sfmt("%s:/%s", drive, APPDATA_DIR);
|
m_dataDir = sfmt("%s:/%s", drive, APPDATA_DIR);
|
||||||
@ -2298,28 +2304,22 @@ bool CMenu::_loadFile(SmartBuf &buffer, u32 &size, const char *path, const char
|
|||||||
|
|
||||||
void CMenu::_load_installed_cioses()
|
void CMenu::_load_installed_cioses()
|
||||||
{
|
{
|
||||||
if(_installed_cios.size() > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gprintf("Loading cIOS map\n");
|
gprintf("Loading cIOS map\n");
|
||||||
_installed_cios[0] = 1;
|
_installed_cios[0] = 1;
|
||||||
|
|
||||||
for(u8 slot = 200; slot < 254; slot++)
|
for(u8 slot = 200; slot < 254; slot++)
|
||||||
{
|
{
|
||||||
u8 base = 1;
|
u8 base = 1;
|
||||||
iosinfo_t *info = GetInfo(slot);
|
|
||||||
if(D2X(slot, &base))
|
if(D2X(slot, &base))
|
||||||
{
|
{
|
||||||
gprintf("Found d2x base %u in slot %u\n", base, slot);
|
gprintf("Found d2x base %u in slot %u\n", base, slot);
|
||||||
_installed_cios[slot] = base;
|
_installed_cios[slot] = base;
|
||||||
}
|
}
|
||||||
else if(info != NULL && !is_ios_type(IOS_TYPE_NO_CIOS, slot))
|
else if(!is_ios_type(IOS_TYPE_NO_CIOS, slot))
|
||||||
{
|
{
|
||||||
gprintf("Found cIOS in slot %u\n", slot);
|
gprintf("Found cIOS in slot %u\n", slot);
|
||||||
_installed_cios[slot] = 1;
|
_installed_cios[slot] = slot;
|
||||||
}
|
}
|
||||||
if(info != NULL)
|
|
||||||
MEM2_free(info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user