Core/Boot: Pass around System.
This commit is contained in:
10 files changed
+43
-40
No files matched your search
@@ -321,26 +321,24 @@ static const DiscIO::VolumeDisc* SetDisc(std::unique_ptr<DiscIO::VolumeDisc> dis
|
||||
return pointer;
|
||||
}
|
||||
|
||||
bool CBoot::DVDRead(const DiscIO::VolumeDisc& disc, u64 dvd_offset, u32 output_address, u32 length,
|
||||
const DiscIO::Partition& partition)
|
||||
bool CBoot::DVDRead(Core::System& system, const DiscIO::VolumeDisc& disc, u64 dvd_offset,
|
||||
u32 output_address, u32 length, const DiscIO::Partition& partition)
|
||||
{
|
||||
std::vector<u8> buffer(length);
|
||||
if (!disc.Read(dvd_offset, length, buffer.data(), partition))
|
||||
return false;
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
memory.CopyToEmu(output_address, buffer.data(), length);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoot::DVDReadDiscID(const DiscIO::VolumeDisc& disc, u32 output_address)
|
||||
bool CBoot::DVDReadDiscID(Core::System& system, const DiscIO::VolumeDisc& disc, u32 output_address)
|
||||
{
|
||||
std::array<u8, 0x20> buffer;
|
||||
if (!disc.Read(0, buffer.size(), buffer.data(), DiscIO::PARTITION_NONE))
|
||||
return false;
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
memory.CopyToEmu(output_address, buffer.data(), buffer.size());
|
||||
|
||||
@@ -550,14 +548,14 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
// 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(system, IOS::HLE::IOSC::ConsoleType::Retail);
|
||||
IOS::HLE::GetIOS()->BootIOS(Titles::IOS(58));
|
||||
IOS::HLE::GetIOS()->BootIOS(system, Titles::IOS(58));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupGCMemory(system, guard);
|
||||
}
|
||||
|
||||
if (!executable.reader->LoadIntoMemory())
|
||||
if (!executable.reader->LoadIntoMemory(system))
|
||||
{
|
||||
PanicAlertFmtT("Failed to load the executable to memory.");
|
||||
return false;
|
||||
|
||||
@@ -171,9 +171,10 @@ public:
|
||||
static bool LoadMapFromFilename(const Core::CPUThreadGuard& guard);
|
||||
|
||||
private:
|
||||
static bool DVDRead(const DiscIO::VolumeDisc& disc, u64 dvd_offset, u32 output_address,
|
||||
u32 length, const DiscIO::Partition& partition);
|
||||
static bool DVDReadDiscID(const DiscIO::VolumeDisc& disc, u32 output_address);
|
||||
static bool DVDRead(Core::System& system, const DiscIO::VolumeDisc& disc, u64 dvd_offset,
|
||||
u32 output_address, u32 length, const DiscIO::Partition& partition);
|
||||
static bool DVDReadDiscID(Core::System& system, const DiscIO::VolumeDisc& disc,
|
||||
u32 output_address);
|
||||
static void RunFunction(Core::System& system, u32 address);
|
||||
|
||||
static void UpdateDebugger_MapLoaded();
|
||||
@@ -213,7 +214,7 @@ public:
|
||||
virtual u32 GetEntryPoint() const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual bool IsWii() const = 0;
|
||||
virtual bool LoadIntoMemory(bool only_in_mem1 = false) const = 0;
|
||||
virtual bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const = 0;
|
||||
virtual bool LoadSymbols(const Core::CPUThreadGuard& guard) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -148,7 +148,7 @@ bool CBoot::RunApploader(Core::System& system, const Core::CPUThreadGuard& guard
|
||||
INFO_LOG_FMT(BOOT, "Invalid apploader. Your disc image is probably corrupted.");
|
||||
return false;
|
||||
}
|
||||
DVDRead(volume, offset + 0x20, 0x01200000, *size + *trailer, partition);
|
||||
DVDRead(system, volume, offset + 0x20, 0x01200000, *size + *trailer, partition);
|
||||
|
||||
// TODO - Make Apploader(or just RunFunction()) debuggable!!!
|
||||
|
||||
@@ -195,7 +195,7 @@ bool CBoot::RunApploader(Core::System& system, const Core::CPUThreadGuard& guard
|
||||
|
||||
INFO_LOG_FMT(BOOT, "DVDRead: offset: {:08x} memOffset: {:08x} length: {}", dvd_offset,
|
||||
ram_address, length);
|
||||
DVDRead(volume, dvd_offset, ram_address, length, partition);
|
||||
DVDRead(system, volume, dvd_offset, ram_address, length, partition);
|
||||
|
||||
DiscIO::Riivolution::ApplyApploaderMemoryPatches(guard, riivolution_patches, ram_address,
|
||||
length);
|
||||
@@ -284,7 +284,7 @@ bool CBoot::EmulatedBS2_GC(Core::System& system, const Core::CPUThreadGuard& gua
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
vertex_shader_manager.InvalidateXFRange(XFMEM_POSTMATRICES + 0x3d * 4, XFMEM_POSTMATRICES_END);
|
||||
|
||||
DVDReadDiscID(volume, 0x00000000);
|
||||
DVDReadDiscID(system, volume, 0x00000000);
|
||||
|
||||
auto& memory = system.GetMemory();
|
||||
bool streaming = memory.Read_U8(0x80000008);
|
||||
@@ -554,7 +554,7 @@ bool CBoot::EmulatedBS2_Wii(Core::System& system, const Core::CPUThreadGuard& gu
|
||||
const u64 ios = ios_override >= 0 ? Titles::IOS(static_cast<u32>(ios_override)) : tmd.GetIOSId();
|
||||
|
||||
const auto console_type = volume.GetTicket(data_partition).GetConsoleType();
|
||||
if (!SetupWiiMemory(system, console_type) || !IOS::HLE::GetIOS()->BootIOS(ios))
|
||||
if (!SetupWiiMemory(system, console_type) || !IOS::HLE::GetIOS()->BootIOS(system, ios))
|
||||
return false;
|
||||
|
||||
auto di =
|
||||
@@ -563,13 +563,13 @@ bool CBoot::EmulatedBS2_Wii(Core::System& system, const Core::CPUThreadGuard& gu
|
||||
di->InitializeIfFirstTime();
|
||||
di->ChangePartition(data_partition);
|
||||
|
||||
DVDReadDiscID(volume, 0x00000000);
|
||||
DVDReadDiscID(system, volume, 0x00000000);
|
||||
|
||||
// This is some kind of consistency check that is compared to the 0x00
|
||||
// values as the game boots. This location keeps the 4 byte ID for as long
|
||||
// as the game is running. The 6 byte ID at 0x00 is overwritten sometime
|
||||
// after this check during booting.
|
||||
DVDRead(volume, 0, 0x3180, 4, partition);
|
||||
DVDRead(system, volume, 0, 0x3180, 4, partition);
|
||||
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
|
||||
|
||||
@@ -110,15 +110,14 @@ bool DolReader::Initialize(const std::vector<u8>& buffer)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DolReader::LoadIntoMemory(bool only_in_mem1) const
|
||||
bool DolReader::LoadIntoMemory(Core::System& system, bool only_in_mem1) const
|
||||
{
|
||||
if (!m_is_valid)
|
||||
return false;
|
||||
|
||||
if (m_is_ancast)
|
||||
return LoadAncastIntoMemory();
|
||||
return LoadAncastIntoMemory(system);
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// load all text (code) sections
|
||||
@@ -149,7 +148,7 @@ bool DolReader::LoadIntoMemory(bool only_in_mem1) const
|
||||
}
|
||||
|
||||
// On a real console this would be done in the Espresso bootrom
|
||||
bool DolReader::LoadAncastIntoMemory() const
|
||||
bool DolReader::LoadAncastIntoMemory(Core::System& system) const
|
||||
{
|
||||
// The ancast image will always be in data section 0
|
||||
const auto& section = m_data_sections[0];
|
||||
@@ -227,7 +226,6 @@ bool DolReader::LoadAncastIntoMemory() const
|
||||
body_size))
|
||||
return false;
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// Copy the Ancast header to the emu
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
bool IsWii() const override { return m_is_wii; }
|
||||
bool IsAncast() const { return m_is_ancast; };
|
||||
u32 GetEntryPoint() const override { return m_dolheader.entryPoint; }
|
||||
bool LoadIntoMemory(bool only_in_mem1 = false) const override;
|
||||
bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const override;
|
||||
bool LoadSymbols(const Core::CPUThreadGuard& guard) const override { return false; }
|
||||
|
||||
private:
|
||||
@@ -63,5 +63,5 @@ private:
|
||||
// Copy sections to internal buffers
|
||||
bool Initialize(const std::vector<u8>& buffer);
|
||||
|
||||
bool LoadAncastIntoMemory() const;
|
||||
bool LoadAncastIntoMemory(Core::System& system) const;
|
||||
};
|
||||
@@ -124,7 +124,7 @@ const char* ElfReader::GetSectionName(int section) const
|
||||
}
|
||||
|
||||
// This is just a simple elf loader, good enough to load elfs generated by devkitPPC
|
||||
bool ElfReader::LoadIntoMemory(bool only_in_mem1) const
|
||||
bool ElfReader::LoadIntoMemory(Core::System& system, bool only_in_mem1) const
|
||||
{
|
||||
INFO_LOG_FMT(BOOT, "String section: {}", header->e_shstrndx);
|
||||
|
||||
@@ -136,7 +136,6 @@ bool ElfReader::LoadIntoMemory(bool only_in_mem1) const
|
||||
|
||||
INFO_LOG_FMT(BOOT, "{} segments:", header->e_phnum);
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// Copy segments into ram.
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
ElfMachine GetMachine() const { return (ElfMachine)(header->e_machine); }
|
||||
u32 GetEntryPoint() const override { return entryPoint; }
|
||||
u32 GetFlags() const { return (u32)(header->e_flags); }
|
||||
bool LoadIntoMemory(bool only_in_mem1 = false) const override;
|
||||
bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const override;
|
||||
bool LoadSymbols(const Core::CPUThreadGuard& guard) const override;
|
||||
// TODO: actually check for validity.
|
||||
bool IsValid() const override { return true; }
|
||||
|
||||
Reference in new issue
Block a user