From 643c83c2a0cf6e08504c1512337d225ee2192692 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Sun, 6 Apr 2025 23:07:16 +0200 Subject: [PATCH] debugger: Find and build IOP module list --- pcsx2/DebugTools/BiosDebugData.cpp | 26 ++++++++++++++++++++++++++ pcsx2/DebugTools/BiosDebugData.h | 13 +++++++++++++ pcsx2/IopBios.cpp | 21 ++++++++------------- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/pcsx2/DebugTools/BiosDebugData.cpp b/pcsx2/DebugTools/BiosDebugData.cpp index b8e989f53a..9572d616f8 100644 --- a/pcsx2/DebugTools/BiosDebugData.cpp +++ b/pcsx2/DebugTools/BiosDebugData.cpp @@ -69,3 +69,29 @@ std::vector> getIOPThreads() return threads; } + +std::vector getIOPModules() +{ + u32 maddr = iopMemRead32(CurrentBiosInformation.iopModListAddr); + std::vector modlist; + + while (maddr != 0) + { + IopMod mod; + + mod.name = iopMemReadString(iopMemRead32(maddr + 4)); + 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); + + modlist.push_back(mod); + + maddr = iopMemRead32(maddr); + } + + return modlist; +} diff --git a/pcsx2/DebugTools/BiosDebugData.h b/pcsx2/DebugTools/BiosDebugData.h index b4008db1a0..e085ec08f2 100644 --- a/pcsx2/DebugTools/BiosDebugData.h +++ b/pcsx2/DebugTools/BiosDebugData.h @@ -178,5 +178,18 @@ private: IOPInternalThread data; }; +struct IopMod +{ + std::string name; + u16 version; + u32 text_addr; + u32 entry; + u32 gp; + u32 text_size; + u32 data_size; + u32 bss_size; +}; + std::vector> getIOPThreads(); +std::vector getIOPModules(); std::vector> getEEThreads(); diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index bb62194b50..11eb21d71f 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -1073,27 +1073,22 @@ namespace R3000A u32 GetModList(u32 a0reg) { - u32 lcptr = iopMemRead32(0x3f0); - u32 lcstring = irxFindLoadcore(lcptr); - u32 list = 0; + /* Loadcore puts a pointer to a static array at 0x3f0 */ + u32 bootmodes_ptr = iopMemRead32(0x3f0); + /* Search for the main loadcore struct from there */ + u32 lcstring = irxFindLoadcore(bootmodes_ptr); + u32 lc_struct = 0; if (lcstring == 0) { - list = lcptr - 0x20; + lc_struct = bootmodes_ptr - 0x20; } else { - list = lcstring + 0x18; + lc_struct = lcstring + 0x18; } - u32 mod = iopMemRead32(list); - - while (mod != 0) - { - mod = iopMemRead32(mod); - } - - return list; + return lc_struct + 0x10; } // Gets the thread list ptr from thbase