mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 19:01:56 +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/system.h>
|
||||
#include <sdcard/gcsd.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include "cios.h"
|
||||
#include "DeviceHandler.hpp"
|
||||
#include "wbfs.h"
|
||||
#include "usbstorage.h"
|
||||
|
||||
#ifdef DOLPHIN
|
||||
const DISC_INTERFACE __io_sdhc = __io_wiisd;
|
||||
#else
|
||||
extern const DISC_INTERFACE __io_sdhc;
|
||||
#endif
|
||||
#include "sdhc.h"
|
||||
|
||||
DeviceHandler * DeviceHandler::instance = NULL;
|
||||
|
||||
@ -50,19 +44,15 @@ DeviceHandler::~DeviceHandler()
|
||||
|
||||
DeviceHandler * DeviceHandler::Instance()
|
||||
{
|
||||
if (instance == NULL)
|
||||
{
|
||||
if(instance == NULL)
|
||||
instance = new DeviceHandler();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DeviceHandler::DestroyInstance()
|
||||
{
|
||||
if(instance)
|
||||
{
|
||||
delete instance;
|
||||
}
|
||||
instance = NULL;
|
||||
}
|
||||
|
||||
@ -134,19 +124,28 @@ void DeviceHandler::UnMount(int dev)
|
||||
|
||||
bool DeviceHandler::MountSD()
|
||||
{
|
||||
if(!sd)
|
||||
if(sd)
|
||||
{
|
||||
if(neek2o())
|
||||
sd = new PartitionHandle(&__io_wiisd);
|
||||
else
|
||||
sd = new PartitionHandle(&__io_sdhc);
|
||||
if(sd->GetPartitionCount() < 1)
|
||||
{
|
||||
delete sd;
|
||||
sd = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
delete sd;
|
||||
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;
|
||||
}
|
||||
gprintf("SD Card found.\n");
|
||||
|
||||
//! Mount only one SD Partition
|
||||
return sd->Mount(0, DeviceName[SD], true);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <sdcard/gcsd.h>
|
||||
#include "cios.h"
|
||||
#include "PartitionHandle.h"
|
||||
#include "utils.h"
|
||||
@ -34,14 +35,8 @@
|
||||
#include "fat.h"
|
||||
#include "ext2.h"
|
||||
#include "wbfs.h"
|
||||
#include <sdcard/gcsd.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
|
||||
#ifdef DOLPHIN
|
||||
const DISC_INTERFACE __io_sdhc = __io_wiisd;
|
||||
#else
|
||||
extern const DISC_INTERFACE __io_sdhc;
|
||||
#endif
|
||||
#include "usbstorage.h"
|
||||
#include "sdhc.h"
|
||||
|
||||
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ 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)
|
||||
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));
|
||||
if(GetWbfsHandle(pos))
|
||||
return true;
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include <gccore.h>
|
||||
#include "libwbfs/libwbfs.h"
|
||||
#include "usbstorage.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -72,6 +72,7 @@ static s32 hid = -1, fd = -1;
|
||||
static u32 usb2_port = -1; //current USB port
|
||||
bool hddInUse[2] = { false, false };
|
||||
u32 hdd_sector_size[2] = { 512, 512 };
|
||||
bool first = false;
|
||||
|
||||
extern void* SYS_AllocArena2MemLo(u32 size,u32 align);
|
||||
|
||||
@ -137,6 +138,7 @@ s32 USBStorage2_SetPort(u32 port)
|
||||
|
||||
s32 ret = -1;
|
||||
usb2_port = port;
|
||||
first = true;
|
||||
|
||||
gprintf("Changing USB port to port %i....\n", port);
|
||||
//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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -79,6 +79,23 @@ bool D2X(u8 ios, u8 *base)
|
||||
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.
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
signed_blob *TMD = GetTMD(ios, &TMD_Length);
|
||||
if(TMD == 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);
|
||||
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
|
||||
|
||||
@ -113,8 +122,43 @@ iosinfo_t *GetInfo(u8 ios)
|
||||
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)
|
||||
{
|
||||
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;
|
||||
switch(slot)
|
||||
{
|
||||
@ -122,7 +166,7 @@ int get_ios_type(u8 slot)
|
||||
case 223:
|
||||
case 224:
|
||||
case 225:
|
||||
if(IOS_GetRevision() == 1)
|
||||
if(iosTMD->title_version == 1)
|
||||
return IOS_TYPE_KWIIRK;
|
||||
else
|
||||
return IOS_TYPE_HERMES;
|
||||
@ -143,6 +187,7 @@ int get_ios_type(u8 slot)
|
||||
else
|
||||
return IOS_TYPE_NO_CIOS;
|
||||
}
|
||||
MEM2_free(TMD_Buffer);
|
||||
}
|
||||
|
||||
int is_ios_type(int type, u8 slot)
|
||||
|
@ -21,6 +21,7 @@ typedef struct _iosinfo_t
|
||||
bool neek2o(void);
|
||||
bool D2X(u8 ios, u8 *base);
|
||||
iosinfo_t *GetInfo(u8 ios);
|
||||
signed_blob *GetTMD(u8 ios, u32 *TMD_Length);
|
||||
int is_ios_type(int type, u8 slot);
|
||||
int get_ios_type(u8 slot);
|
||||
bool shadow_mload();
|
||||
|
@ -278,7 +278,13 @@ void CMenu::init(void)
|
||||
m_cfg.getBool("NAND", "disable", true);
|
||||
|
||||
_installed_cios.clear();
|
||||
_load_installed_cioses();
|
||||
if(!neek2o())
|
||||
_load_installed_cioses();
|
||||
else
|
||||
{
|
||||
extern int mainIOS;
|
||||
_installed_cios[mainIOS] = mainIOS;
|
||||
}
|
||||
|
||||
snprintf(m_app_update_drive, sizeof(m_app_update_drive), "%s:/", drive);
|
||||
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()
|
||||
{
|
||||
if(_installed_cios.size() > 0)
|
||||
return;
|
||||
|
||||
gprintf("Loading cIOS map\n");
|
||||
_installed_cios[0] = 1;
|
||||
|
||||
for(u8 slot = 200; slot < 254; slot++)
|
||||
{
|
||||
u8 base = 1;
|
||||
iosinfo_t *info = GetInfo(slot);
|
||||
if(D2X(slot, &base))
|
||||
{
|
||||
gprintf("Found d2x base %u in slot %u\n", base, slot);
|
||||
_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);
|
||||
_installed_cios[slot] = 1;
|
||||
_installed_cios[slot] = slot;
|
||||
}
|
||||
if(info != NULL)
|
||||
MEM2_free(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user