-fixed some stupid default font bug (it was extracted twice lol)

-added new option, "force_cios_rev" (default 0 (=disabled)), if you 
set it to for example "force_cios_rev=250", then wiiflow will 
use IOS250 for the AUTO setting, for reload when using 
"force_cios_load" and when switching to emu nand in IOS58 mode
-added more detailed debug prints and on screen information about 
the currently loaded cIOS
-minor cleanup in nand get file and external booter
This commit is contained in:
fix94.1 2012-11-12 20:12:00 +00:00
parent b2fdc18998
commit f41e01ff87
22 changed files with 115 additions and 102 deletions

View File

@ -28,7 +28,6 @@ typedef struct _the_CFG {
s32 wbfsDevice;
u32 wbfsPart;
u8 GameBootType;
u8 mload_rev;
WIP_Code *wip_list;
u32 wip_count;
/* needed for channels */

View File

@ -31,10 +31,9 @@
#include "cios.h"
#include "gecko.h"
bool Hermes_shadow_mload(int mload_rev)
bool Hermes_shadow_mload()
{
int v51 = (5 << 4) & 1;
if(mload_rev >= v51)
if(CurrentIOS.Revision >= 5 && CurrentIOS.SubRevision >= 1)
{
IOS_Open("/dev/mload/OFF",0); // shadow /dev/mload supported in hermes cios v5.1
gprintf("Shadow mload\n");

View File

@ -20,6 +20,7 @@ typedef struct _iosinfo_t {
typedef struct _IOS_Info {
u32 Revision;
u32 SubRevision;
u8 Version;
u8 Type;
u8 Base;
@ -31,7 +32,7 @@ void IOS_GetCurrentIOSInfo();
bool IOS_D2X(u8 ios, u8 *base);
u8 IOS_GetType(u8 slot);
bool Hermes_shadow_mload(int mload_rev);
bool Hermes_shadow_mload();
void Hermes_Disable_EHC();
#ifdef __cplusplus

View File

@ -94,7 +94,7 @@ int main()
{
Disc_SetUSB((u8*)normalCFG.gameID, normalCFG.GameBootType == TYPE_WII_WBFS_EXT);
if(CurrentIOS.Type == IOS_TYPE_HERMES)
Hermes_shadow_mload(normalCFG.mload_rev);
Hermes_shadow_mload();
}
prog(20);
Disc_Open();

View File

@ -28,7 +28,6 @@ typedef struct _the_CFG {
s32 wbfsDevice;
u32 wbfsPart;
u8 GameBootType;
u8 mload_rev;
WIP_Code *wip_list;
u32 wip_count;
/* needed for channels */

View File

@ -106,7 +106,6 @@ void ExternalBooter_WiiGameSetup(bool wbfs, bool dvd, const char *ID)
normalCFG.fragments = frag_list;
normalCFG.wbfsDevice = wbfsDev;
normalCFG.wbfsPart = wbfs_part_idx;
normalCFG.mload_rev = mload_get_version();
}
void ExternalBooter_ChannelSetup(u64 title)

View File

@ -168,7 +168,7 @@ void Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
u32 size = 0;
if (isfs)
{
buf = ISFS_GetFile((u8 *)appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
buf = ISFS_GetFile(appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
if (size == 0)
{
if(buf != NULL)

View File

@ -42,7 +42,7 @@ bool Identify(u64 titleid)
gprintf("Reading TMD...");
sprintf(filepath, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(titleid), TITLE_LOWER(titleid));
u32 tmdSize;
u8 *tmdBuffer = ISFS_GetFile((u8 *) &filepath, &tmdSize, -1);
u8 *tmdBuffer = ISFS_GetFile(filepath, &tmdSize, -1);
if (tmdBuffer == NULL || tmdSize == 0)
{
gprintf("Failed!\n");
@ -62,9 +62,9 @@ bool Identify(u64 titleid)
gprintf("Success!\n");
gprintf("Reading certs...");
sprintf(filepath, "/sys/cert.sys");
strcpy(filepath, "/sys/cert.sys");
u32 certSize;
u8 *certBuffer = ISFS_GetFile((u8 *) &filepath, &certSize, -1);
u8 *certBuffer = ISFS_GetFile(filepath, &certSize, -1);
if (certBuffer == NULL || certSize == 0)
{
gprintf("Failed!\n");

View File

@ -68,7 +68,7 @@ u8 Channels::GetRequestedIOS(u64 title)
sprintf(tmd, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
u32 size;
u8 *titleTMD = (u8 *)ISFS_GetFile((u8 *) &tmd, &size, -1);
u8 *titleTMD = (u8 *)ISFS_GetFile(tmd, &size, -1);
if(titleTMD == NULL)
return 0;
@ -108,7 +108,7 @@ bool Channels::GetAppNameFromTmd(u64 title, char *app, bool dol, u32 *bootconten
sprintf(tmd, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
u32 size;
u8 *data = ISFS_GetFile((u8 *) &tmd, &size, -1);
u8 *data = ISFS_GetFile(tmd, &size, -1);
if (data == NULL || size < 0x208)
return ret;

View File

@ -40,6 +40,7 @@
#include "gecko/gecko.h"
#include "loader/alt_ios.h"
#include "loader/cios.h"
#include "loader/fs.h"
#include "loader/sys.h"
#include "loader/wbfs.h"
#include "memory/memory.h"
@ -70,6 +71,7 @@ void Nand::Init()
MountedDevice = 0;
EmuDevice = REAL_NAND;
Disabled = true;
AccessPatched = false;
Partition = 0;
FullMode = 0x100;
memset(NandPath, 0, sizeof(NandPath));
@ -1052,46 +1054,35 @@ extern "C" { extern s32 MagicPatches(s32); }
void Nand::Enable_ISFS_Patches(void)
{
if(AHBRPOT_Patched())
{
gprintf("Enabling ISFS Patches\n");
// Disable memory protection
write16(MEM_PROT, 0);
// Do patches
PatchAHB();
MagicPatches(1);
// Enable memory protection
write16(MEM_PROT, 1);
}
gprintf("Enabling ISFS Patches: %i\n", MagicPatches(1));
}
void Nand::Disable_ISFS_Patches(void)
{
if(AHBRPOT_Patched())
{
gprintf("Disabling ISFS Patches\n");
// Disable memory protection
write16(MEM_PROT, 0);
// Do patches
MagicPatches(0);
// Enable memory protection
write16(MEM_PROT, 1);
}
gprintf("Disabling ISFS Patches: %i\n", MagicPatches(0));
}
void Nand::Init_ISFS()
{
if(IOS_GetVersion() == 58)
{
Enable_ISFS_Patches();
AccessPatched = true;
}
gprintf("Init ISFS\n");
ISFS_Initialize();
if(IOS_GetVersion() == 58)
Enable_ISFS_Patches();
}
void Nand::DeInit_ISFS()
{
gprintf("Deinit ISFS\n");
ISFS_Deinitialize();
if(IOS_GetVersion() == 58)
if(AccessPatched)
{
Disable_ISFS_Patches();
AccessPatched = false;
}
}
/* Thanks to postloader for that patch */

View File

@ -95,6 +95,7 @@ private:
s32 Nand_Disable(void);
void PatchAHB(void);
bool ISFS_Check(void);
void Enable_ISFS_Patches(void);
void Disable_ISFS_Patches(void);
@ -125,6 +126,7 @@ private:
bool Disabled;
bool fake;
bool showprogress;
bool AccessPatched;
void *data;
dump_callback_t dumper;

View File

@ -70,7 +70,7 @@ iosinfo_t *IOS_GetInfo(u8 ios)
MEM2_free(TMD);
u32 size = 0;
u8 *buffer = ISFS_GetFile((u8 *)filepath, &size, sizeof(iosinfo_t));
u8 *buffer = ISFS_GetFile(filepath, &size, sizeof(iosinfo_t));
if(buffer == NULL || size == 0)
return NULL;
@ -164,29 +164,38 @@ u8 IOS_GetType(u8 slot)
void IOS_GetCurrentIOSInfo()
{
memset(&CurrentIOS, 0, sizeof(IOS_Info));
CurrentIOS.Revision = IOS_GetRevision();
CurrentIOS.Version = IOS_GetVersion();
CurrentIOS.Base = CurrentIOS.Version;
CurrentIOS.Revision = IOS_GetRevision();
CurrentIOS.SubRevision = 0;
CurrentIOS.Type = IOS_GetType(CurrentIOS.Version);
if(CurrentIOS.Type == IOS_TYPE_D2X)
{
iosinfo_t *iosInfo = IOS_GetInfo(CurrentIOS.Version);
CurrentIOS.Revision = iosInfo->version;
CurrentIOS.Base = iosInfo->baseios;
gprintf("D2X cIOS Base IOS%i\n", CurrentIOS.Base);
gprintf("D2X IOS%i[%i] v%i\n", CurrentIOS.Version, CurrentIOS.Base,
CurrentIOS.Revision);
MEM2_free(iosInfo);
}
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
else if(CurrentIOS.Type == IOS_TYPE_WANIN)
{
CurrentIOS.Base = wanin_mload_get_IOS_base();
gprintf("Waninkoko cIOS Base IOS%i\n", CurrentIOS.Base);
if(CurrentIOS.Revision >= 18)
CurrentIOS.Base = wanin_mload_get_IOS_base();
gprintf("Waninkoko IOS%i[%i] v%i\n", CurrentIOS.Version, CurrentIOS.Base,
CurrentIOS.Revision);
}
else if(CurrentIOS.Type == IOS_TYPE_HERMES && CurrentIOS.Revision >= 4)
else if(CurrentIOS.Type == IOS_TYPE_HERMES)
{
CurrentIOS.Base = mload_get_IOS_base();
gprintf("Hermes cIOS Base IOS%i\n", CurrentIOS.Base);
if(CurrentIOS.Revision > 4)
{
CurrentIOS.Revision = mload_get_version() >> 4;
CurrentIOS.SubRevision = mload_get_version() & 0xF;
}
gprintf("Hermes IOS%i[%i] v%d.%d\n", CurrentIOS.Version, CurrentIOS.Base,
CurrentIOS.Revision, CurrentIOS.SubRevision);
}
else
CurrentIOS.Base = CurrentIOS.Version;
DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
}

View File

@ -20,6 +20,7 @@ typedef struct _iosinfo_t {
typedef struct _IOS_Info {
u32 Revision;
u32 SubRevision;
u8 Version;
u8 Type;
u8 Base;

View File

@ -6,15 +6,16 @@
#include "fs.h"
#include "utils.h"
#include "gecko/gecko.h"
#include "memory/mem2.hpp"
static fstats stats ATTRIBUTE_ALIGN(32);
u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
u8 *ISFS_GetFile(const char *path, u32 *size, s32 length)
{
*size = 0;
s32 fd = ISFS_Open((const char *)path, ISFS_OPEN_READ);
//gprintf("ISFS_GetFile %s", path);
s32 fd = ISFS_Open(path, ISFS_OPEN_READ);
u8 *buf = NULL;
if(fd >= 0)
@ -38,11 +39,13 @@ u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
}
ISFS_Close(fd);
}
if(*size > 0)
{
//gprintf(" succeed!\n");
DCFlushRange(buf, *size);
ICInvalidateRange(buf, *size);
}
//else
// gprintf(" failed!\n");
return buf;
}

View File

@ -5,7 +5,7 @@
extern "C" {
#endif /* __cplusplus */
u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length);
u8 *ISFS_GetFile(const char *path, u32 *size, s32 length);
#ifdef __cplusplus
}

View File

@ -98,7 +98,7 @@ int main(int argc, char **argv)
if(useMainIOS || !DeviceHandle.UsablePartitionMounted())
{
useMainIOS = false;
mainMenu._TempLoadIOS();
mainMenu.TempLoadIOS();
iosOK = CustomIOS(CurrentIOS.Type);
}
}

View File

@ -188,8 +188,7 @@ void CMenu::init()
fsop_MakeFolder((char *)fmt("%s:/%s", DeviceName[i], APPDATA_DIR2)); //Make the apps dir, so saving wiiflow.ini does not fail.
break;
}
_loadDefaultFont(CONF_GetLanguage() == CONF_LANG_KOREAN);
loadDefaultFont();
if(drive == check) // Should not happen
{
@ -213,6 +212,12 @@ void CMenu::init()
WriteToSD = m_cfg.getBool("DEBUG", "sd_write_log", false);
bufferMessages = WriteToSD;
}
int ForceIOS = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
if(ForceIOS > 0)
{
gprintf("Using IOS%i instead of IOS%i as main cIOS.\n", ForceIOS, mainIOS);
mainIOS = ForceIOS;
}
useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false);
bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0);
@ -2225,7 +2230,7 @@ bool CMenu::_loadChannelList(void)
if(!disable_emu)
{
MusicPlayer.Stop();
_TempLoadIOS();
TempLoadIOS();
DeviceHandle.UnMount(currentPartition);
NandHandle.SetPaths(emuPath.c_str(), currentPartition, disable_emu);
if(NandHandle.Enable_Emu() < 0)
@ -2252,7 +2257,7 @@ bool CMenu::_loadList(void)
{
MusicPlayer.Stop();
NandHandle.Disable_Emu();
_TempLoadIOS(IOS_TYPE_NORMAL_IOS);
TempLoadIOS(IOS_TYPE_NORMAL_IOS);
}
gprintf("Switching View to %s\n", _domainFromView());
@ -2485,68 +2490,59 @@ typedef struct map_entry
u8 sha1[20];
} __attribute((packed)) map_entry_t;
void CMenu::_loadDefaultFont(bool korean)
void CMenu::loadDefaultFont(void)
{
u32 size;
if(m_base_font != NULL)
return;
u32 size = 0;
bool retry = false;
bool korean = (CONF_GetLanguage() == CONF_LANG_KOREAN);
char ISFS_Filename[32] ATTRIBUTE_ALIGN(32);
// Read content.map from ISFS
u8 *content = ISFS_GetFile((u8 *) "/shared1/content.map", &size, 0);
strcpy(ISFS_Filename, "/shared1/content.map");
u8 *content = ISFS_GetFile(ISFS_Filename, &size, -1);
if(content == NULL)
return;
int items = size / sizeof(map_entry_t);
u32 items = size / sizeof(map_entry_t);
//gprintf("Open content.map, size %d, items %d\n", size, items);
map_entry_t *cm = (map_entry_t *)content;
retry:
bool kor_font = (korean && !retry) || (!korean && retry);
map_entry_t *cm = (map_entry_t *) content;
for (int i = 0; i < items; i++)
for(u32 i = 0; i < items; i++)
{
if (memcmp(cm[i].sha1, kor_font ? WIIFONT_HASH_KOR : WIIFONT_HASH, 20) == 0)
if(m_base_font != NULL && m_wbf1_font != NULL && m_wbf2_font != NULL)
break;
if(memcmp(cm[i].sha1, kor_font ? WIIFONT_HASH_KOR : WIIFONT_HASH, 20) == 0 && m_base_font == NULL)
{
// Name found, load it and unpack it
char u8_font_filename[22] = {0};
strcpy(u8_font_filename, "/shared1/XXXXXXXX.app"); // Faster than sprintf
memcpy(u8_font_filename+9, cm[i].filename, 8);
u8 *u8_font_archive = ISFS_GetFile((u8 *) u8_font_filename, &size, 0);
//gprintf("Opened fontfile: %s: %d bytes\n", u8_font_filename, size);
sprintf(ISFS_Filename, "/shared1/%.8s.app", cm[i].filename); //who cares about the few ticks more?
u8 *u8_font_archive = ISFS_GetFile(ISFS_Filename, &size, -1);
if(u8_font_archive != NULL)
{
const u8 *font_file = u8_get_file_by_index(u8_font_archive, 1, &size); // There is only one file in that app
//gprintf("Extracted font: %d\n", size);
if(m_base_font)
MEM1_lo_free(m_base_font);
m_base_font = (u8*)MEM1_lo_alloc(size);
memcpy(m_base_font, font_file, size);
DCFlushRange(m_base_font, size);
m_base_font_size = size;
free(u8_font_archive);
}
break;
}
else if(memcmp(cm[i].sha1, WFB_HASH, 20) == 0)
else if(memcmp(cm[i].sha1, WFB_HASH, 20) == 0 && m_wbf1_font == NULL && m_wbf2_font == NULL)
{
// Name found, load it and unpack it
char font_filename[32] ATTRIBUTE_ALIGN(32);
strcpy(font_filename, "/shared1/XXXXXXXX.app"); // Faster than sprintf
memcpy(font_filename+9, cm[i].filename, 8);
u8 *u8_font_archive = ISFS_GetFile((u8 *)font_filename, &size, 0);
sprintf(ISFS_Filename, "/shared1/%.8s.app", cm[i].filename); //who cares about the few ticks more?
u8 *u8_font_archive = ISFS_GetFile(ISFS_Filename, &size, -1);
if(u8_font_archive != NULL)
{
const u8 *font_file1 = u8_get_file(u8_font_archive, "wbf1.brfna", &size);
if(m_wbf1_font)
MEM1_lo_free(m_wbf1_font);
m_wbf1_font = (u8*)MEM1_lo_alloc(size);
memcpy(m_wbf1_font, font_file1, size);
DCFlushRange(m_wbf1_font, size);
const u8 *font_file2 = u8_get_file(u8_font_archive, "wbf2.brfna", &size);
if(m_wbf2_font)
MEM1_lo_free(m_wbf2_font);
m_wbf2_font = (u8*)MEM1_lo_alloc(size);
memcpy(m_wbf2_font, font_file2, size);
DCFlushRange(m_wbf2_font, size);
@ -2555,22 +2551,23 @@ retry:
}
}
}
if (!retry)
if(!retry && m_base_font == NULL)
{
retry = true;
goto retry;
}
free(content);
}
void CMenu::_cleanupDefaultFont()
{
MEM1_lo_free(m_base_font);
m_base_font = NULL;
m_base_font_size = 0;
MEM1_lo_free(m_wbf1_font);
m_wbf1_font = NULL;
MEM1_lo_free(m_wbf2_font);
m_wbf2_font = NULL;
}
string CMenu::_getId()
@ -2660,7 +2657,9 @@ void CMenu::UpdateCache(u32 view)
int CMenu::MIOSisDML()
{
u32 size = 0;
u8 *appfile = ISFS_GetFile((u8*)"/title/00000001/00000101/content/0000000c.app", &size, 0);
char ISFS_Filename[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
strcpy(ISFS_Filename, "/title/00000001/00000101/content/0000000c.app");
u8 *appfile = ISFS_GetFile(ISFS_Filename, &size, -1);
if(appfile)
{
for(u32 i = 0; i < size; ++i)
@ -2700,7 +2699,7 @@ void CMenu::RemoveCover(const char *id)
fsop_deleteFile(CoverPath);
}
void CMenu::_TempLoadIOS(int IOS)
void CMenu::TempLoadIOS(int IOS)
{
/* Only temp reload in IOS58 mode */
if(useMainIOS || neek2o() || Sys_DolphinMode())

View File

@ -40,7 +40,8 @@ public:
void exitHandler(int ExitTo);
int main(void);
void cleanup(void);
void _TempLoadIOS(int IOS = 0);
void loadDefaultFont(void);
void TempLoadIOS(int IOS = 0);
u8 m_current_view;
private:
struct SZone
@ -985,7 +986,6 @@ private:
float _getCFFloat(const string &domain, const string &key, float def, bool otherScrnFmt = false);
void _cfParam(bool inc, int i, const SCFParamDesc &p, int cfVersion, bool wide);
void _buildMenus(void);
void _loadDefaultFont(bool korean);
void _cleanupDefaultFont();
void _Theme_Cleanup();
string _getId(void);

View File

@ -159,17 +159,26 @@ void CMenu::_textAbout(void)
thanks.toUTF8().c_str())
);
}
const char *IOS_Name = NULL;
switch(IOS_GetType(CurrentIOS.Version))
{
case IOS_TYPE_D2X:
IOS_Name = "D2X";
break;
case IOS_TYPE_WANIN:
IOS_Name = "Waninkoko";
break;
case IOS_TYPE_HERMES:
case IOS_TYPE_KWIIRK:
m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), CurrentIOS.Version, CurrentIOS.Base, CurrentIOS.Revision), true);
IOS_Name = "Hermes";
break;
case IOS_TYPE_NEEK2O:
case IOS_TYPE_NORMAL_IOS:
m_btnMgr.setText(m_aboutLblIOS, wfmt( L"IOS%i v%i", CurrentIOS.Version, CurrentIOS.Revision), true);
default:
break;
}
if(IOS_Name == NULL)
m_btnMgr.setText(m_aboutLblIOS, wfmt(L"IOS%i v%i", CurrentIOS.Version,
CurrentIOS.Revision), true);
else
m_btnMgr.setText(m_aboutLblIOS, wfmt(L"%s IOS%i[%i] v%d.%d", IOS_Name, CurrentIOS.Version,
CurrentIOS.Base, CurrentIOS.Revision, CurrentIOS.SubRevision), true);
}

View File

@ -391,7 +391,9 @@ bool CMenu::_isNetworkAvailable()
{
bool retval = false;
u32 size;
u8 *buf = ISFS_GetFile((u8 *) "/shared2/sys/net/02/config.dat", &size, -1);
char ISFS_Filepath[32] ATTRIBUTE_ALIGN(32);
strcpy(ISFS_Filepath, "/shared2/sys/net/02/config.dat");
u8 *buf = ISFS_GetFile(ISFS_Filepath, &size, -1);
if (buf && size > 4)
{
retval = buf[4] > 0; // There is a valid connection defined.

View File

@ -1166,7 +1166,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
} while(!(cover & 0x2));
}
}
_TempLoadIOS();
TempLoadIOS();
/* Open Disc */
if(Disc_Open(true) < 0)
{

View File

@ -313,7 +313,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
{
case CMenu::WO_ADD_GAME:
MusicPlayer.Stop();
_TempLoadIOS();
TempLoadIOS();
m_btnMgr.show(m_wbfsPBar);
m_btnMgr.setProgress(m_wbfsPBar, 0.f);
m_btnMgr.hide(m_wbfsBtnGo);
@ -459,7 +459,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
{
WDVD_StopMotor();
MusicPlayer.Stop();
_TempLoadIOS(IOS_TYPE_NORMAL_IOS);
TempLoadIOS(IOS_TYPE_NORMAL_IOS);
}
m_btnMgr.show(m_wbfsBtnBack);
}