From 863eb83e4c549ebc01d12318ba2d2a946547796a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 21 Sep 2013 10:03:49 -0700 Subject: [PATCH] Add support for sceGeGetStack() for debugging. --- Core/HLE/sceGe.cpp | 7 +++++++ GPU/GPUCommon.cpp | 27 +++++++++++++++++++++++++++ GPU/GPUCommon.h | 1 + GPU/GPUInterface.h | 1 + 4 files changed, 36 insertions(+) diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index f30f9ff558..34c5c0a9d8 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -552,6 +552,12 @@ u32 sceGeGetCmd(int cmd) return gstate.cmdmem[cmd]; // Does not mask away the high bits. } +int sceGeGetStack(int index, u32 stackPtr) +{ + WARN_LOG_REPORT(SCEGE, "sceGeGetStack(%i, %08x)", index, stackPtr); + return gpu->GetStack(index, stackPtr); +} + u32 sceGeEdramSetAddrTranslation(int new_size) { bool outsideRange = new_size != 0 && (new_size < 0x200 || new_size > 0x1000); @@ -588,6 +594,7 @@ const HLEFunction sceGe_user[] = {0x438A385A, WrapU_U, "sceGeSaveContext"}, {0x0BF608FB, WrapU_U, "sceGeRestoreContext"}, {0x5FB86AB0, WrapI_U, "sceGeListDeQueue"}, + {0xE66CB92E, WrapI_IU, "sceGeGetStack"}, }; void Register_sceGe_user() diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 3be6236732..5b7a2102f1 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -157,6 +157,33 @@ int GPUCommon::ListSync(int listid, int mode) { return PSP_GE_LIST_COMPLETED; } +int GPUCommon::GetStack(int index, u32 stackPtr) { + easy_guard guard(listLock); + if (currentList == NULL) { + // Seems like it doesn't return an error code? + return 0; + } + + if (currentList->stackptr <= index) { + return SCE_KERNEL_ERROR_INVALID_INDEX; + } + + if (index >= 0) { + PSPPointer stack; + stack = stackPtr; + if (stack.IsValid()) { + auto entry = currentList->stack[index]; + // Not really sure what most of these values are. + stack[0] = 0; + stack[1] = entry.pc + 4; + stack[2] = entry.offsetAddr; + stack[7] = entry.baseAddr; + } + } + + return currentList->stackptr; +} + u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer args, bool head) { easy_guard guard(listLock); // TODO Check the stack values in missing arg and ajust the stack depth diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index bd3333276c..70fbc8223c 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -34,6 +34,7 @@ public: virtual u32 DequeueList(int listid); virtual int ListSync(int listid, int mode); virtual u32 DrawSync(int mode); + virtual int GetStack(int index, u32 stackPtr); virtual void DoState(PointerWrap &p); virtual bool FramebufferDirty() { SyncThread(); diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index f2e1fb68a1..0bb6bd5df3 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -197,6 +197,7 @@ public: virtual int ListSync(int listid, int mode) = 0; virtual u32 Continue() = 0; virtual u32 Break(int mode) = 0; + virtual int GetStack(int index, u32 stackPtr) = 0; virtual void InterruptStart(int listid) = 0; virtual void InterruptEnd(int listid) = 0;