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-08-21 18:33:44 +02:00
|
|
|
#include "channel/nand.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "devicemounter/DeviceHandler.hpp"
|
|
|
|
#include "devicemounter/usbstorage.h"
|
|
|
|
#include "gecko/gecko.h"
|
|
|
|
#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 "odip_frag.h"
|
|
|
|
#include "mload_modules.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-08-21 18:33:44 +02:00
|
|
|
extern "C" { extern u8 currentPartition; }
|
2012-07-16 16:05:57 +02:00
|
|
|
u8 use_port1 = 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-07-16 16:05:57 +02:00
|
|
|
static int load_ehc_module_ex(void)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-07-16 16:05:57 +02:00
|
|
|
ehcmodule = ehcmodule_5;
|
|
|
|
size_ehcmodule = size_ehcmodule_5;
|
|
|
|
dip_plugin = odip_frag;
|
|
|
|
size_dip_plugin = size_odip_frag;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-07-16 16:05:57 +02:00
|
|
|
u8 *ehc_cfg = search_for_ehcmodule_cfg((u8 *)ehcmodule, size_ehcmodule);
|
|
|
|
if (ehc_cfg)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-07-16 16:05:57 +02:00
|
|
|
ehc_cfg += 12;
|
|
|
|
ehc_cfg[0] = use_port1;
|
|
|
|
gprintf("EHC Port info = %i\n", ehc_cfg[0]);
|
|
|
|
DCFlushRange((void *) (((u32)ehc_cfg[0]) & ~31), 32);
|
|
|
|
}
|
|
|
|
if(use_port1) // release port 0 and use port 1
|
|
|
|
{
|
|
|
|
u32 dat=0;
|
|
|
|
u32 addr;
|
|
|
|
|
|
|
|
// get EHCI base registers
|
|
|
|
mload_getw((void *) 0x0D040000, &addr);
|
|
|
|
|
|
|
|
addr&=0xff;
|
|
|
|
addr+=0x0D040000;
|
|
|
|
|
|
|
|
mload_getw((void *) (addr+0x44), &dat);
|
|
|
|
if((dat & 0x2001)==1)
|
|
|
|
mload_setw((void *) (addr+0x44), 0x2000);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-07-16 16:05:57 +02:00
|
|
|
mload_getw((void *) (addr+0x48), &dat);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-07-16 16:05:57 +02:00
|
|
|
if((dat & 0x2000)==0x2000)
|
|
|
|
mload_setw((void *) (addr+0x48), 0x1001);
|
|
|
|
}
|
|
|
|
load_ehc_module();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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...");
|
|
|
|
int ret = mload_module((void *) dip_plugin_249, size_dip_plugin_249);
|
|
|
|
gprintf("%d\n", ret);
|
|
|
|
mload_close();
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 02:00:49 +02:00
|
|
|
bool loadIOS(int ios, bool launch_game, bool emu_channel)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-07-14 18:19:41 +02:00
|
|
|
#ifndef DOLPHIN
|
2012-01-21 21:57:41 +01:00
|
|
|
Close_Inputs();
|
|
|
|
DeviceHandler::Instance()->UnMountAll();
|
|
|
|
WDVD_Close();
|
2012-07-18 16:09:28 +02:00
|
|
|
USBStorage2_Deinit();
|
2012-07-16 16:05:57 +02:00
|
|
|
mload_close();
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-08-18 15:38:25 +02:00
|
|
|
gprintf("Reloading into IOS %i from %i...\n", ios, IOS_GetVersion());
|
2012-08-21 18:33:44 +02:00
|
|
|
Nand::Instance()->DeInit_ISFS();
|
2012-01-21 21:57:41 +01:00
|
|
|
bool iosOK = IOS_ReloadIOS(ios) == 0;
|
2012-08-21 18:33:44 +02:00
|
|
|
Nand::Instance()->Init_ISFS();
|
|
|
|
gprintf("AHBPROT after IOS Reload: %u\n", (*HW_AHBPROT == 0xFFFFFFFF));
|
2012-01-21 21:57:41 +01:00
|
|
|
|
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-08-11 14:27:38 +02:00
|
|
|
|
2012-07-26 02:00:49 +02:00
|
|
|
if(!emu_channel)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-07-26 02:00:49 +02:00
|
|
|
if(launch_game)
|
|
|
|
{
|
|
|
|
DeviceHandler::Instance()->Mount(currentPartition);
|
|
|
|
DeviceHandler::Instance()->Open_WBFS(currentPartition);
|
|
|
|
Disc_Init();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Open_Inputs();
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return iosOK;
|
2012-07-14 18:19:41 +02:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
2012-05-12 23:08:43 +02:00
|
|
|
}
|