Files

118 lines
2.7 KiB
C++
Raw Permalink Normal View History

// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
2024-07-30 13:42:36 +02:00
// SPDX-License-Identifier: GPL-3.0+
2014-10-28 08:20:32 +01:00
#include "BiosDebugData.h"
2021-10-08 13:12:03 +02:00
#include "IopMem.h"
2021-05-14 01:42:47 +02:00
#include "Memory.h"
#include "VMManager.h"
2021-10-08 13:12:03 +02:00
std::vector<std::unique_ptr<BiosThread>> getEEThreads()
{
2025-11-22 07:02:37 +00:00
if (!VMManager::HasValidVM() || CurrentBiosInformation.eeThreadListAddr == 0)
return {};
2021-10-08 13:12:03 +02:00
const u32 start = CurrentBiosInformation.eeThreadListAddr & 0x3fffff;
2025-11-22 07:02:37 +00:00
std::vector<std::unique_ptr<BiosThread>> threads;
for (int tid = 0; tid < 256; tid++)
{
2025-11-22 07:02:37 +00:00
EEInternalThread* internal = static_cast<EEInternalThread*>(
PSM(start + tid * sizeof(EEInternalThread)));
2025-11-22 07:02:37 +00:00
if (internal && internal->status != (int)ThreadStatus::THS_BAD)
threads.emplace_back(std::make_unique<EEThread>(tid, *internal));
}
2021-10-08 13:12:03 +02:00
return threads;
}
std::vector<std::unique_ptr<BiosThread>> getIOPThreads()
{
if (!VMManager::HasValidVM() || CurrentBiosInformation.iopThreadListAddr == 0)
return {};
2021-10-08 13:12:03 +02:00
std::vector<std::unique_ptr<BiosThread>> threads;
2021-10-08 13:12:03 +02:00
u32 item = iopMemRead32(CurrentBiosInformation.iopThreadListAddr);
for (int i = 0; item != 0; i++)
2021-10-08 13:12:03 +02:00
{
if (i > 1000)
return {};
2021-10-08 13:12:03 +02:00
IOPInternalThread data{};
u16 tag = iopMemRead16(item + 0x8);
if (tag != 0x7f01)
{
// something went wrong
return {};
}
2026-04-23 22:11:52 +02:00
data.stacMem = iopMemRead32(item + 0x3c);
data.stackSize = iopMemRead32(item + 0x40);
2021-10-08 13:12:03 +02:00
data.status = iopMemRead8(item + 0xc);
data.tid = iopMemRead16(item + 0xa);
data.entrypoint = iopMemRead32(item + 0x38);
2026-02-27 20:56:42 +01:00
data.waitstate = iopMemRead16(item + 0x1c);
data.waitId = iopMemRead32(item + 0x20);
data.initPriority = iopMemRead16(item + 0xe);
2021-10-08 13:12:03 +02:00
data.regCtx = iopMemRead32(item + 0x10);
2021-10-08 13:12:03 +02:00
data.PC = iopMemRead32(data.regCtx + 0x8c);
2021-10-08 13:12:03 +02:00
2025-11-22 07:02:37 +00:00
threads.emplace_back(std::make_unique<IOPThread>(data));
2021-10-08 13:12:03 +02:00
item = iopMemRead32(item + 0x24);
}
return threads;
}
2025-04-06 23:07:16 +02:00
std::vector<IopMod> getIOPModules()
{
if (!VMManager::HasValidVM() || CurrentBiosInformation.iopModListAddr == 0)
return {};
2025-04-06 23:07:16 +02:00
u32 maddr = iopMemRead32(CurrentBiosInformation.iopModListAddr);
std::vector<IopMod> modlist;
for (int i = 0; maddr != 0; i++)
2025-04-06 23:07:16 +02:00
{
if (maddr >= Ps2MemSize::ExposedIopRam)
2025-05-21 14:32:13 +02:00
{
// outside of memory
return {};
}
if (i > 1000)
2025-05-21 14:32:13 +02:00
return {};
2025-11-22 07:02:37 +00:00
IopMod& mod = modlist.emplace_back();
2025-05-21 14:32:13 +02:00
2025-05-20 19:31:02 +02:00
u32 nstr = iopMemRead32(maddr + 4);
if (nstr)
{
mod.name = iopMemReadString(iopMemRead32(maddr + 4));
}
else
{
mod.name = "(NULL)";
}
2025-04-06 23:07:16 +02:00
mod.version = iopMemRead16(maddr + 8);
mod.entry = iopMemRead32(maddr + 0x10);
mod.gp = iopMemRead32(maddr + 0x14);
mod.text_addr = iopMemRead32(maddr + 0x18);
mod.text_size = iopMemRead32(maddr + 0x1c);
mod.data_size = iopMemRead32(maddr + 0x20);
mod.bss_size = iopMemRead32(maddr + 0x24);
maddr = iopMemRead32(maddr);
}
return modlist;
}