Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set 0x0000002C to NDEV 2.1 when running a debug-signed Wii disc #7092

Merged
merged 1 commit into from Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/Core/Core/Boot/Boot.cpp
Expand Up @@ -43,6 +43,7 @@
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/IOSC.h"
#include "Core/IOS/Uids.h"
#include "Core/PatchEngine.h"
#include "Core/PowerPC/PPCAnalyst.h"
Expand Down Expand Up @@ -370,7 +371,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)

// 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();
SetupWiiMemory(IOS::HLE::IOSC::ConsoleType::Retail);
IOS::HLE::GetIOS()->BootIOS(Titles::IOS(58));
}
else
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Boot/Boot.h
Expand Up @@ -13,6 +13,7 @@
#include <vector>

#include "Common/CommonTypes.h"
#include "Core/IOS/IOSC.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
Expand Down Expand Up @@ -116,7 +117,7 @@ class CBoot
static bool Load_BS2(const std::string& boot_rom_filename);

static void SetupGCMemory();
static bool SetupWiiMemory();
static bool SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type);
};

class BootExecutableReader
Expand Down
13 changes: 8 additions & 5 deletions Source/Core/Core/Boot/Boot_BS2Emu.cpp
Expand Up @@ -25,6 +25,7 @@
#include "Core/IOS/ES/Formats.h"
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/IOSC.h"
#include "Core/IOS/Uids.h"
#include "Core/PowerPC/MMU.h"
#include "Core/PowerPC/PowerPC.h"
Expand Down Expand Up @@ -214,7 +215,7 @@ bool CBoot::EmulatedBS2_GC(const DiscIO::Volume& volume)
return RunApploader(/*is_wii*/ false, volume);
}

bool CBoot::SetupWiiMemory()
bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
{
static const std::map<DiscIO::Region, const RegionSetting> region_settings = {
{DiscIO::Region::NTSC_J, {"JPN", "NTSC", "JP", "LJ"}},
Expand Down Expand Up @@ -294,9 +295,10 @@ bool CBoot::SetupWiiMemory()
Memory::Write_U32(0x0D15EA5E, 0x00000020); // Another magic word
Memory::Write_U32(0x00000001, 0x00000024); // Unknown
Memory::Write_U32(Memory::REALRAM_SIZE, 0x00000028); // MEM1 size 24MB
Memory::Write_U32(0x00000023, 0x0000002c); // Production Board Model
Memory::Write_U32(0x00000000, 0x00000030); // Init
Memory::Write_U32(0x817FEC60, 0x00000034); // Init
u32 board_model = console_type == IOS::HLE::IOSC::ConsoleType::RVT ? 0x10000021 : 0x00000023;
Memory::Write_U32(board_model, 0x0000002c); // Board Model
Memory::Write_U32(0x00000000, 0x00000030); // Init
Memory::Write_U32(0x817FEC60, 0x00000034); // Init
// 38, 3C should get start, size of FST through apploader
Memory::Write_U32(0x8008f7b8, 0x000000e4); // Thread Init
Memory::Write_U32(Memory::REALRAM_SIZE, 0x000000f0); // "Simulated memory size" (debug mode?)
Expand Down Expand Up @@ -381,7 +383,8 @@ bool CBoot::EmulatedBS2_Wii(const DiscIO::Volume& volume)
Memory::Write_U32(0, 0x3194);
Memory::Write_U32(static_cast<u32>(data_partition.offset >> 2), 0x3198);

if (!SetupWiiMemory() || !IOS::HLE::GetIOS()->BootIOS(tmd.GetIOSId()))
const auto console_type = volume.GetTicket(data_partition).GetConsoleType();
if (!SetupWiiMemory(console_type) || !IOS::HLE::GetIOS()->BootIOS(tmd.GetIOSId()))
return false;

DVDRead(volume, 0x00000000, 0x00000000, 0x20, DiscIO::PARTITION_NONE); // Game Code
Expand Down
14 changes: 11 additions & 3 deletions Source/Core/Core/Boot/Boot_WiiWAD.cpp
Expand Up @@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <cinttypes>
#include <memory>

#include "Common/CommonTypes.h"
Expand All @@ -12,6 +13,7 @@
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/ES/Formats.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/IOSC.h"
#include "Core/WiiUtils.h"
#include "DiscIO/WiiWad.h"

Expand All @@ -21,9 +23,15 @@ bool CBoot::BootNANDTitle(const u64 title_id)
state->type = 0x04; // TYPE_NANDBOOT
});

auto* ios = IOS::HLE::GetIOS();
SetupWiiMemory();
return ios->GetES()->LaunchTitle(title_id);
auto es = IOS::HLE::GetIOS()->GetES();
const IOS::ES::TicketReader ticket = es->FindSignedTicket(title_id);
auto console_type = IOS::HLE::IOSC::ConsoleType::Retail;
if (ticket.IsValid())
console_type = ticket.GetConsoleType();
else
ERROR_LOG(BOOT, "No ticket was found for %016" PRIx64, title_id);
SetupWiiMemory(console_type);
return es->LaunchTitle(title_id);
}

bool CBoot::Boot_WiiWAD(const DiscIO::WiiWAD& wad)
Expand Down
11 changes: 7 additions & 4 deletions Source/Core/Core/IOS/ES/Formats.cpp
Expand Up @@ -443,10 +443,13 @@ std::array<u8, 16> TicketReader::GetTitleKey(const HLE::IOSC& iosc) const

std::array<u8, 16> TicketReader::GetTitleKey() const
{
const bool is_rvt = (GetIssuer() == "Root-CA00000002-XS00000006");
const HLE::IOSC::ConsoleType console_type =
is_rvt ? HLE::IOSC::ConsoleType::RVT : HLE::IOSC::ConsoleType::Retail;
return GetTitleKey(HLE::IOSC{console_type});
return GetTitleKey(HLE::IOSC{GetConsoleType()});
}

HLE::IOSC::ConsoleType TicketReader::GetConsoleType() const
{
const bool is_rvt = GetIssuer() == "Root-CA00000002-XS00000006";
return is_rvt ? HLE::IOSC::ConsoleType::RVT : HLE::IOSC::ConsoleType::Retail;
}

void TicketReader::DeleteTicket(u64 ticket_id_to_delete)
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/IOS/ES/Formats.h
Expand Up @@ -242,6 +242,9 @@ class TicketReader final : public SignedBlobReader
// and constructs a temporary IOSC instance.
std::array<u8, 16> GetTitleKey() const;

// Infers the console type (retail or devkit) based on the certificate issuer.
HLE::IOSC::ConsoleType GetConsoleType() const;

// Deletes a ticket with the given ticket ID from the internal buffer.
void DeleteTicket(u64 ticket_id);

Expand Down