Skip to content
Permalink
Browse files
Merge pull request #6247 from leoetlino/homebrew
Boot: Minor fixes for Wii homebrew
  • Loading branch information
leoetlino committed Dec 15, 2017
2 parents 2824454 + 3dd777b commit fa0cf5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
@@ -282,6 +282,18 @@ static void SetDefaultDisc()
SetDisc(DiscIO::CreateVolumeFromFilename(config.m_strDefaultISO));
}

static void CopyDefaultExceptionHandlers()
{
constexpr u32 EXCEPTION_HANDLER_ADDRESSES[] = {0x00000100, 0x00000200, 0x00000300, 0x00000400,
0x00000500, 0x00000600, 0x00000700, 0x00000800,
0x00000900, 0x00000C00, 0x00000D00, 0x00000F00,
0x00001300, 0x00001400, 0x00001700};

constexpr u32 RFI_INSTRUCTION = 0x4C000064;
for (const u32 address : EXCEPTION_HANDLER_ADDRESSES)
Memory::Write_U32(RFI_INSTRUCTION, address);
}

// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp
bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
{
@@ -332,10 +344,17 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)

SetupMSR();
SetupBAT(config.bWii);
CopyDefaultExceptionHandlers();

if (config.bWii)
{
HID4.SBE = 1;
PowerPC::ppcState.spr[SPR_HID0] = 0x0011c464;
PowerPC::ppcState.spr[SPR_HID4] = 0x82000000;

// Set a value for the SP. It doesn't matter where this points to,
// as long as it is a valid location. This value is taken from a homebrew binary.
PowerPC::ppcState.gpr[1] = 0x8004d4bc;

// Because there is no TMD to get the requested system (IOS) version from,
// we default to IOS58, which is the version used by the Homebrew Channel.
SetupWiiMemory();
@@ -78,6 +78,7 @@ void CBoot::SetupBAT(bool is_wii)
PowerPC::ppcState.spr[SPR_DBAT4L] = 0x10000002;
PowerPC::ppcState.spr[SPR_DBAT5U] = 0xd0001fff;
PowerPC::ppcState.spr[SPR_DBAT5L] = 0x1000002a;
HID4.SBE = 1;
}
PowerPC::DBATUpdated();
PowerPC::IBATUpdated();

0 comments on commit fa0cf5c

Please sign in to comment.