Merge pull request #7092 from JosJuice/wii-devkit

Set 0x0000002C to NDEV 2.1 when running a debug-signed Wii disc
This commit is contained in:
Léo Lam 2018-06-07 15:52:07 +02:00 committed by GitHub
commit dd7c558be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 14 deletions

View File

@ -43,6 +43,7 @@
#include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/ES.h"
#include "Core/IOS/FS/FileSystem.h" #include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h" #include "Core/IOS/IOS.h"
#include "Core/IOS/IOSC.h"
#include "Core/IOS/Uids.h" #include "Core/IOS/Uids.h"
#include "Core/PatchEngine.h" #include "Core/PatchEngine.h"
#include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCAnalyst.h"
@ -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, // 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. // 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)); IOS::HLE::GetIOS()->BootIOS(Titles::IOS(58));
} }
else else

View File

@ -13,6 +13,7 @@
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Core/IOS/IOSC.h"
#include "DiscIO/Blob.h" #include "DiscIO/Blob.h"
#include "DiscIO/Enums.h" #include "DiscIO/Enums.h"
#include "DiscIO/Volume.h" #include "DiscIO/Volume.h"
@ -116,7 +117,7 @@ private:
static bool Load_BS2(const std::string& boot_rom_filename); static bool Load_BS2(const std::string& boot_rom_filename);
static void SetupGCMemory(); static void SetupGCMemory();
static bool SetupWiiMemory(); static bool SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type);
}; };
class BootExecutableReader class BootExecutableReader

View File

@ -25,6 +25,7 @@
#include "Core/IOS/ES/Formats.h" #include "Core/IOS/ES/Formats.h"
#include "Core/IOS/FS/FileSystem.h" #include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h" #include "Core/IOS/IOS.h"
#include "Core/IOS/IOSC.h"
#include "Core/IOS/Uids.h" #include "Core/IOS/Uids.h"
#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/MMU.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
@ -214,7 +215,7 @@ bool CBoot::EmulatedBS2_GC(const DiscIO::Volume& volume)
return RunApploader(/*is_wii*/ false, 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 = { static const std::map<DiscIO::Region, const RegionSetting> region_settings = {
{DiscIO::Region::NTSC_J, {"JPN", "NTSC", "JP", "LJ"}}, {DiscIO::Region::NTSC_J, {"JPN", "NTSC", "JP", "LJ"}},
@ -294,7 +295,8 @@ bool CBoot::SetupWiiMemory()
Memory::Write_U32(0x0D15EA5E, 0x00000020); // Another magic word Memory::Write_U32(0x0D15EA5E, 0x00000020); // Another magic word
Memory::Write_U32(0x00000001, 0x00000024); // Unknown Memory::Write_U32(0x00000001, 0x00000024); // Unknown
Memory::Write_U32(Memory::REALRAM_SIZE, 0x00000028); // MEM1 size 24MB Memory::Write_U32(Memory::REALRAM_SIZE, 0x00000028); // MEM1 size 24MB
Memory::Write_U32(0x00000023, 0x0000002c); // Production Board Model 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(0x00000000, 0x00000030); // Init
Memory::Write_U32(0x817FEC60, 0x00000034); // Init Memory::Write_U32(0x817FEC60, 0x00000034); // Init
// 38, 3C should get start, size of FST through apploader // 38, 3C should get start, size of FST through apploader
@ -381,7 +383,8 @@ bool CBoot::EmulatedBS2_Wii(const DiscIO::Volume& volume)
Memory::Write_U32(0, 0x3194); Memory::Write_U32(0, 0x3194);
Memory::Write_U32(static_cast<u32>(data_partition.offset >> 2), 0x3198); 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; return false;
DVDRead(volume, 0x00000000, 0x00000000, 0x20, DiscIO::PARTITION_NONE); // Game Code DVDRead(volume, 0x00000000, 0x00000000, 0x20, DiscIO::PARTITION_NONE); // Game Code

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cinttypes>
#include <memory> #include <memory>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@ -12,6 +13,7 @@
#include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/ES.h"
#include "Core/IOS/ES/Formats.h" #include "Core/IOS/ES/Formats.h"
#include "Core/IOS/IOS.h" #include "Core/IOS/IOS.h"
#include "Core/IOS/IOSC.h"
#include "Core/WiiUtils.h" #include "Core/WiiUtils.h"
#include "DiscIO/WiiWad.h" #include "DiscIO/WiiWad.h"
@ -21,9 +23,15 @@ bool CBoot::BootNANDTitle(const u64 title_id)
state->type = 0x04; // TYPE_NANDBOOT state->type = 0x04; // TYPE_NANDBOOT
}); });
auto* ios = IOS::HLE::GetIOS(); auto es = IOS::HLE::GetIOS()->GetES();
SetupWiiMemory(); const IOS::ES::TicketReader ticket = es->FindSignedTicket(title_id);
return ios->GetES()->LaunchTitle(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) bool CBoot::Boot_WiiWAD(const DiscIO::WiiWAD& wad)

View File

@ -443,10 +443,13 @@ std::array<u8, 16> TicketReader::GetTitleKey(const HLE::IOSC& iosc) const
std::array<u8, 16> TicketReader::GetTitleKey() const std::array<u8, 16> TicketReader::GetTitleKey() const
{ {
const bool is_rvt = (GetIssuer() == "Root-CA00000002-XS00000006"); return GetTitleKey(HLE::IOSC{GetConsoleType()});
const HLE::IOSC::ConsoleType console_type = }
is_rvt ? HLE::IOSC::ConsoleType::RVT : HLE::IOSC::ConsoleType::Retail;
return GetTitleKey(HLE::IOSC{console_type}); 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) void TicketReader::DeleteTicket(u64 ticket_id_to_delete)

View File

@ -242,6 +242,9 @@ public:
// and constructs a temporary IOSC instance. // and constructs a temporary IOSC instance.
std::array<u8, 16> GetTitleKey() const; 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. // Deletes a ticket with the given ticket ID from the internal buffer.
void DeleteTicket(u64 ticket_id); void DeleteTicket(u64 ticket_id);