2012-05-12 23:08:43 +02:00
|
|
|
|
|
|
|
#include <ogc/machine/processor.h>
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "alt_ios.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "cios.h"
|
|
|
|
#include "disc.h"
|
2012-08-11 14:27:38 +02:00
|
|
|
#include "nk.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "sys.h"
|
|
|
|
#include "wbfs.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "wdvd.h"
|
2012-10-13 00:25:22 +02:00
|
|
|
#include "booter/external_booter.hpp"
|
2012-08-21 18:33:44 +02:00
|
|
|
#include "channel/nand.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "devicemounter/DeviceHandler.hpp"
|
2012-08-25 17:10:57 +02:00
|
|
|
#include "devicemounter/sdhc.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "devicemounter/usbstorage.h"
|
2012-12-08 17:17:35 +01:00
|
|
|
#include "gecko/gecko.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "memory/mem2.hpp"
|
2012-08-21 18:33:44 +02:00
|
|
|
#include "memory/memory.h"
|
2012-07-16 16:05:57 +02:00
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
// mload from uloader by Hermes
|
|
|
|
#include "mload.h"
|
|
|
|
#include "ehcmodule_5.h"
|
|
|
|
#include "dip_plugin_249.h"
|
|
|
|
#include "mload_modules.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2020-04-29 01:03:24 +02:00
|
|
|
void load_ehc_module_ex(void)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-09-28 19:24:04 +02:00
|
|
|
u8 *ehc_cfg = search_for_ehcmodule_cfg((u8 *)ehcmodule_5, size_ehcmodule_5);
|
|
|
|
if(ehc_cfg)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-07-16 16:05:57 +02:00
|
|
|
ehc_cfg += 12;
|
2013-03-24 13:10:21 +01:00
|
|
|
ehc_cfg[0] = currentPort;
|
2012-07-16 16:05:57 +02:00
|
|
|
gprintf("EHC Port info = %i\n", ehc_cfg[0]);
|
|
|
|
DCFlushRange((void *) (((u32)ehc_cfg[0]) & ~31), 32);
|
|
|
|
}
|
|
|
|
load_ehc_module();
|
|
|
|
}
|
|
|
|
|
|
|
|
void load_dip_249()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-07-16 16:05:57 +02:00
|
|
|
gprintf("Starting mload\n");
|
|
|
|
if(mload_init() < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gprintf("Loading 249 dip...");
|
2012-09-28 19:24:04 +02:00
|
|
|
int ret = mload_module((void *)dip_plugin_249, size_dip_plugin_249);
|
2012-07-16 16:05:57 +02:00
|
|
|
gprintf("%d\n", ret);
|
|
|
|
mload_close();
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-08-25 17:10:57 +02:00
|
|
|
bool loadIOS(int ios, bool MountDevices)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-09-05 17:52:32 +02:00
|
|
|
int CurIOS = IOS_GetVersion();
|
2012-08-24 20:01:40 +02:00
|
|
|
bool ret = true;
|
|
|
|
|
2012-12-22 21:57:23 +01:00
|
|
|
if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB)
|
2012-08-24 00:29:15 +02:00
|
|
|
{
|
2012-10-20 15:24:30 +02:00
|
|
|
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
|
2018-08-01 14:27:12 +02:00
|
|
|
ShutdownBeforeExit();// unmount all, close inputs and dvd drive, deinit ISFS, and close network
|
|
|
|
NandHandle.Patch_AHB(); //apply a patch so the new IOS will also have AHBPROT disabled
|
|
|
|
ret = IOS_ReloadIOS(ios) == 0;// convert ret value to true or false
|
|
|
|
gprintf("AHBPROT disabled after IOS Reload: %s\n", AHBPROT_Patched() ? "yes" : "no");
|
|
|
|
NandHandle.Init_ISFS();// re init ISFS
|
|
|
|
WDVD_Init();// re open dvd drive
|
2012-08-24 00:29:15 +02:00
|
|
|
}
|
2018-08-01 14:27:12 +02:00
|
|
|
/* Init_ISFS() before calling IOS_GetCurrentIOSInfo() */
|
2012-08-11 14:27:38 +02:00
|
|
|
IOS_GetCurrentIOSInfo();
|
|
|
|
if(CurrentIOS.Type == IOS_TYPE_HERMES)
|
2012-07-16 16:05:57 +02:00
|
|
|
load_ehc_module_ex();
|
2012-08-11 14:27:38 +02:00
|
|
|
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
|
2012-07-16 16:05:57 +02:00
|
|
|
load_dip_249();
|
2012-09-22 15:47:52 +02:00
|
|
|
DeviceHandle.SetModes();
|
2018-08-01 14:27:12 +02:00
|
|
|
if(MountDevices && ios != CurIOS)// remount sd and USB if desired
|
2012-09-22 15:47:52 +02:00
|
|
|
DeviceHandle.MountAll();
|
2012-08-11 14:27:38 +02:00
|
|
|
|
2012-08-24 20:01:40 +02:00
|
|
|
return ret;
|
2012-05-12 23:08:43 +02:00
|
|
|
}
|