From 5f7a3a8ca920f4337833ee91d7937febc1d01140 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Fri, 22 Aug 2014 16:11:13 +0200 Subject: [PATCH] Read EE threads from bios (thanks @gregory38) --- pcsx2/CMakeLists.txt | 6 ++- pcsx2/DebugTools/BiosDebugData.cpp | 28 +++++++++++ pcsx2/DebugTools/BiosDebugData.h | 50 +++++++++++++++++++ pcsx2/windows/VCprojects/pcsx2.vcxproj | 2 + .../windows/VCprojects/pcsx2.vcxproj.filters | 6 +++ pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj | 2 + .../VCprojects/pcsx2_vs2012.vcxproj.filters | 6 +++ pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj | 4 +- .../VCprojects/pcsx2_vs2013.vcxproj.filters | 8 ++- 9 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 pcsx2/DebugTools/BiosDebugData.cpp create mode 100644 pcsx2/DebugTools/BiosDebugData.h diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index fcbbaccf5b..88b197efbd 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -267,7 +267,8 @@ set(pcsx2DebugToolsSources DebugTools/DisR3000A.cpp DebugTools/DisR5900asm.cpp DebugTools/DisVU0Micro.cpp - DebugTools/DisVU1Micro.cpp) + DebugTools/DisVU1Micro.cpp + DebugTools/BiosDebugData.cpp) # DebugTools headers set(pcsx2DebugToolsHeaders @@ -282,7 +283,8 @@ set(pcsx2DebugToolsHeaders DebugTools/Debug.h DebugTools/DisASm.h DebugTools/DisVUmicro.h - DebugTools/DisVUops.h) + DebugTools/DisVUops.h + DebugTools/BiosDebugData.h) # gui sources set(pcsx2GuiSources diff --git a/pcsx2/DebugTools/BiosDebugData.cpp b/pcsx2/DebugTools/BiosDebugData.cpp new file mode 100644 index 0000000000..85964d814f --- /dev/null +++ b/pcsx2/DebugTools/BiosDebugData.cpp @@ -0,0 +1,28 @@ +#include "PrecompiledHeader.h" +#include "BiosDebugData.h" +#include "../Memory.h" + +std::vector getEEThreads() +{ + std::vector threads; + + if (CurrentBiosInformation == NULL) + return threads; + + u32 start = CurrentBiosInformation->threadListAddr & 0x3fffff; + for (int tid = 0; tid < 256; tid++) + { + EEThread thread; + + EEInternalThread* internal = (EEInternalThread*) PSM(start+tid*sizeof(EEInternalThread)); + if (internal->status != THS_BAD) + { + thread.tid = tid; + thread.data = *internal; + threads.push_back(thread); + } + } + + return threads; +} + diff --git a/pcsx2/DebugTools/BiosDebugData.h b/pcsx2/DebugTools/BiosDebugData.h new file mode 100644 index 0000000000..e0daca58c2 --- /dev/null +++ b/pcsx2/DebugTools/BiosDebugData.h @@ -0,0 +1,50 @@ +#pragma once +#include "Pcsx2Types.h" +#include "../ps2/BiosTools.h" + +struct EEInternalThread { // internal struct + u32 prev; + u32 next; + int status; + u32 entry; + u32 stack; + u32 gpReg; + short currentPriority; + short initPriority; + int waitType; + int semaId; + int wakeupCount; + int attr; + int option; + u32 entry_init; + int argc; + u32 argstring; + u32 stack_bottom; //FIXME + int stackSize; + u32 root; + u32 heap_base; +}; + +enum { + THS_BAD = 0x00, + THS_RUN = 0x01, + THS_READY = 0x02, + THS_WAIT = 0x04, + THS_SUSPEND = 0x08, + THS_WAIT_SUSPEND = 0x0C, + THS_DORMANT = 0x10, +}; + +enum { + WAIT_NONE = 0, + WAIT_WAKEUP_REQ = 1, + WAIT_SEMA = 2, +}; + +struct EEThread +{ + u32 tid; + EEInternalThread data; +}; + +std::vector getEEThreads(); \ No newline at end of file diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj b/pcsx2/windows/VCprojects/pcsx2.vcxproj index ae8f19fca2..18f6823584 100644 --- a/pcsx2/windows/VCprojects/pcsx2.vcxproj +++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj @@ -426,6 +426,7 @@ + @@ -712,6 +713,7 @@ + diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters index 32a0e46274..8ebc4642ab 100644 --- a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters +++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters @@ -820,6 +820,9 @@ System\Ps2\Debug + + System\Ps2\Debug + System\Ps2\Debug @@ -1236,6 +1239,9 @@ System\Ps2\Debug + + System\Ps2\Debug + System\Ps2\Debug diff --git a/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj b/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj index 002ebdab4c..26b283f10f 100644 --- a/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj +++ b/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj @@ -411,6 +411,7 @@ + @@ -698,6 +699,7 @@ + diff --git a/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj.filters b/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj.filters index cfbae94ea9..1153d41a4f 100644 --- a/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj.filters +++ b/pcsx2/windows/VCprojects/pcsx2_vs2012.vcxproj.filters @@ -835,6 +835,9 @@ System\Ps2\Debug + + System\Ps2\Debug + System\Ps2\Debug @@ -1251,6 +1254,9 @@ System\Ps2\Debug + + System\Ps2\Debug + System\Ps2\Debug diff --git a/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj b/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj index fde2077b2a..5f345811a1 100644 --- a/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj +++ b/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj @@ -411,6 +411,7 @@ + @@ -698,6 +699,7 @@ + @@ -938,4 +940,4 @@ - + \ No newline at end of file diff --git a/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj.filters b/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj.filters index 3eef87385e..ec441c1b3e 100644 --- a/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj.filters +++ b/pcsx2/windows/VCprojects/pcsx2_vs2013.vcxproj.filters @@ -850,6 +850,9 @@ System\Ps2\Debug + + System\Ps2\Debug + @@ -1263,6 +1266,9 @@ System\Ps2\Debug + + System\Ps2\Debug + @@ -1345,4 +1351,4 @@ AppHost\Resources - + \ No newline at end of file