From 043ef8c9d45ab90cc6d6011ab77cd31c9d34aacb Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 13 Sep 2015 22:31:56 +0800 Subject: [PATCH 01/13] Wrap some SysMemForKernel's nids #7960 --- Core/HLE/FunctionWrappers.h | 5 +++++ Core/HLE/sceKernel.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 39599d408fde..01124ea15735 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -134,6 +134,11 @@ template void WrapI_CIIIII RETURN(retval); } +template void WrapI_IIIC() { + u32 retval = func(PARAM(0), PARAM(1), PARAM(2), Memory::GetCharPointer(PARAM(3))); + RETURN(retval); +} + // Hm, do so many params get passed in registers? template void WrapI_IIIIIIU() { u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index ad571355ef15..f2efb41ad0db 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -904,6 +904,28 @@ void Register_LoadExecForKernel() RegisterModule("LoadExecForKernel", ARRAY_SIZE(LoadExecForKernel), LoadExecForKernel); } +static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) +{ + return hleLogError(SCEKERNEL, 0, ""); +} + +static int sceKernelAllocHeapMemory(int heapId, int size) +{ + return hleLogError(SCEKERNEL, 0, ""); +} + +static int sceKernelDeleteHeap(int heapId) +{ + return hleLogError(SCEKERNEL, 0, ""); +} + +const HLEFunction SysMemForKernel[] = +{ + {0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, + {0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "ii" }, + {0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, +}; + const HLEFunction ExceptionManagerForKernel[] = { {0X3FB264FC, nullptr, "sceKernelRegisterExceptionHandler", '?', "" }, From 8d8ba3e9637d65eda2c53267faadc60a17aedd8a Mon Sep 17 00:00:00 2001 From: sum2012 Date: Mon, 14 Sep 2015 06:05:12 +0800 Subject: [PATCH 02/13] oop --- Core/HLE/sceKernel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index f2efb41ad0db..c5c9f23b8026 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -922,7 +922,7 @@ static int sceKernelDeleteHeap(int heapId) const HLEFunction SysMemForKernel[] = { {0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, - {0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "ii" }, + {0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, {0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, }; From a8c2c02b828923ef320592e67ff79043f7eb77ef Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 15 Sep 2015 22:09:08 +0800 Subject: [PATCH 03/13] Move SysMemForKernel to sceKernelMemory As SysMemForUser in there --- Core/HLE/sceKernel.cpp | 5 +++++ Core/HLE/sceKernelMemory.cpp | 30 ++++++++++++++++++++++++++++++ Core/HLE/sceKernelMemory.h | 2 ++ 3 files changed, 37 insertions(+) diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index c5c9f23b8026..824c95149262 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -976,3 +976,8 @@ void Register_ThreadManForKernel() { RegisterModule("ThreadManForKernel", ARRAY_SIZE(ThreadManForKernel), ThreadManForKernel); } + +void Register_LoadExecForKernel() +{ + RegisterModule("LoadExecForKernel", ARRAY_SIZE(LoadExecForKernel), LoadExecForKernel); +} diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 46e53753979c..bacbd2220cd0 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2300,3 +2300,33 @@ void Register_SysMemForKernel() { void Register_SysMemUserForUser() { RegisterModule("SysMemUserForUser", ARRAY_SIZE(SysMemUserForUser), SysMemUserForUser); } + + +static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) +{ + return hleLogError(SCEKERNEL, 0, ""); +} + + +static int sceKernelAllocHeapMemory(int heapId, int size) +{ + return hleLogError(SCEKERNEL, 0, ""); +} + +static int sceKernelDeleteHeap(int heapId) +{ + return hleLogError(SCEKERNEL, 0, ""); +} + +const HLEFunction SysMemForKernel[] = +{ + { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, + { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, + { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, +}; + +void Register_SysMemForKernel() +{ + RegisterModule("SysMemForKernel", ARRAY_SIZE(SysMemForKernel), SysMemForKernel); +} + diff --git a/Core/HLE/sceKernelMemory.h b/Core/HLE/sceKernelMemory.h index 2396792436e9..96de13e23ef4 100644 --- a/Core/HLE/sceKernelMemory.h +++ b/Core/HLE/sceKernelMemory.h @@ -68,3 +68,5 @@ int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr); void Register_SysMemForKernel(); void Register_SysMemUserForUser(); +void Register_SysMemForKernel(); + From fed2b42c5fabbd3638bd029284ce0d55e99062cd Mon Sep 17 00:00:00 2001 From: sum2012 Date: Thu, 17 Sep 2015 06:35:52 +0800 Subject: [PATCH 04/13] Try to Implement SysMemForKernel --- Core/HLE/sceKernelMemory.cpp | 68 ++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index bacbd2220cd0..d5c2fa12400f 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2302,19 +2302,83 @@ void Register_SysMemUserForUser() { } +struct HeapInformation : public KernelObject { + //HeapInformation() :alloc(0) {} + HeapInformation() {} + int uid; + int partitionId; + u32 size; + int flags; + u32 address; + std::string name; + BlockAllocator alloc; + static int GetStaticIDType() { return SCE_KERNEL_TMID_Fpl; }// wrong + int GetIDType() const override { return SCE_KERNEL_TMID_Fpl; }// wrong +}; + +std::map heapList; + +static HeapInformation *getHeap(u32 heapId) { + auto found = heapList.find(heapId); + if (found == heapList.end()) { + return NULL; + } + return found->second; +} + +const u32 HEAP_BLOCK_HEADER_SIZE = 8; +const bool frombottom = false; + static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) { - return hleLogError(SCEKERNEL, 0, ""); + HeapInformation *heap = new HeapInformation; + heap->partitionId = partitionId; + heap->flags = flags; + heap->name = *Name; + int allocSize = (size + 3) & ~3; + heap->size = allocSize; + u32 addr = userMemory.Alloc(heap->size, frombottom, "SysMemForKernel-Heap"); + if (addr == (u32)-1) { + ERROR_LOG(HLE, "sceKernelCreateHeap(): Failed to allocate %i bytes memory", size); + heap->uid = -1; + delete heap; + } + heap->address = addr; + heap->alloc.Init(heap->address + 128, heap->size - 128); + SceUID uid = kernelObjects.Create(heap); + heap->uid = uid; + heapList[uid] = heap; + + + return hleLogError(SCEKERNEL, uid, ""); } static int sceKernelAllocHeapMemory(int heapId, int size) { - return hleLogError(SCEKERNEL, 0, ""); + HeapInformation *heap = getHeap(heapId); + if (!heap) { + ERROR_LOG(HLE, "sceKernelAllocHeapMemory cannot find heapId", heapId); + return 0; + } + + // There's 8 bytes at the end of every block, reserved. + u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; + u32 addr = heap->alloc.Alloc(memSize, true); + return hleLogError(SCEKERNEL, addr, ""); } static int sceKernelDeleteHeap(int heapId) { + HeapInformation *heap = getHeap(heapId); + if (!heap) { + ERROR_LOG(HLE, "sceKernelDeleteHeap(%i): invalid heapId", heapId); + return -1; + } + userMemory.Free(heap->address); + kernelObjects.Destroy(heap->uid); + heapList.erase(heapId); + delete heap; return hleLogError(SCEKERNEL, 0, ""); } From 6c4043b9de1a72ca6b62f640e017f1c818fe1bcd Mon Sep 17 00:00:00 2001 From: sum2012 Date: Thu, 17 Sep 2015 06:37:01 +0800 Subject: [PATCH 05/13] remove comment --- Core/HLE/sceKernelMemory.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index d5c2fa12400f..50c881ffb743 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2303,7 +2303,6 @@ void Register_SysMemUserForUser() { struct HeapInformation : public KernelObject { - //HeapInformation() :alloc(0) {} HeapInformation() {} int uid; int partitionId; From 52138f8ce83c6428430e032d84dff75a3b7b53cb Mon Sep 17 00:00:00 2001 From: sum2012 Date: Thu, 17 Sep 2015 21:33:36 +0800 Subject: [PATCH 06/13] Attempt to build fix non-windows --- Core/HLE/sceKernelMemory.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 50c881ffb743..f08b2cf25ac2 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2315,11 +2315,11 @@ struct HeapInformation : public KernelObject { int GetIDType() const override { return SCE_KERNEL_TMID_Fpl; }// wrong }; -std::map heapList; +std::map heapInformationList; static HeapInformation *getHeap(u32 heapId) { - auto found = heapList.find(heapId); - if (found == heapList.end()) { + auto found = heapInformationList.find(heapId); + if (found == heapInformationList.end()) { return NULL; } return found->second; @@ -2346,7 +2346,7 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char heap->alloc.Init(heap->address + 128, heap->size - 128); SceUID uid = kernelObjects.Create(heap); heap->uid = uid; - heapList[uid] = heap; + heapInformationList[uid] = heap; return hleLogError(SCEKERNEL, uid, ""); @@ -2376,7 +2376,7 @@ static int sceKernelDeleteHeap(int heapId) } userMemory.Free(heap->address); kernelObjects.Destroy(heap->uid); - heapList.erase(heapId); + heapInformationList.erase(heapId); delete heap; return hleLogError(SCEKERNEL, 0, ""); } From e1ce6c061eeb2092e66a5c2f090cb960ce2977d1 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 18 Sep 2015 19:17:27 +0800 Subject: [PATCH 07/13] Fix crash in sceKernelDeleteHeap --- Core/HLE/sceKernelMemory.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index f08b2cf25ac2..44c193851c1a 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2377,7 +2377,6 @@ static int sceKernelDeleteHeap(int heapId) userMemory.Free(heap->address); kernelObjects.Destroy(heap->uid); heapInformationList.erase(heapId); - delete heap; return hleLogError(SCEKERNEL, 0, ""); } From b12fbb9d3e1b7d25ed9ea5286bc19b34c0941196 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 18 Sep 2015 19:45:23 +0800 Subject: [PATCH 08/13] Attempt to make save status --- Core/HLE/sceKernelMemory.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 44c193851c1a..4af7629cd60e 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2313,10 +2313,30 @@ struct HeapInformation : public KernelObject { BlockAllocator alloc; static int GetStaticIDType() { return SCE_KERNEL_TMID_Fpl; }// wrong int GetIDType() const override { return SCE_KERNEL_TMID_Fpl; }// wrong + + void DoState(PointerWrap &p) { + p.Do(uid); + p.Do(partitionId); + p.Do(size); + p.Do(flags); + p.Do(address); + p.Do(name); + p.Do(alloc); + } }; std::map heapInformationList; +void __HeapInformationDoState(PointerWrap &p) { + auto s = p.Section("kernelHeap", 1); + if (!s) + return; + + if (s >= 1) { + p.Do(heapInformationList); + } +} + static HeapInformation *getHeap(u32 heapId) { auto found = heapInformationList.find(heapId); if (found == heapInformationList.end()) { From 3604a92beee1a3f0e3dad6bca8217f855ca79cdd Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 18 Sep 2015 19:50:20 +0800 Subject: [PATCH 09/13] Change to info log As this commit is work (tested on Tales of Phantasia with Chinese patch) --- Core/HLE/sceKernelMemory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 4af7629cd60e..436e31c16ad8 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2369,7 +2369,7 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char heapInformationList[uid] = heap; - return hleLogError(SCEKERNEL, uid, ""); + return hleLogSuccessInfoX(SCEKERNEL, uid, ""); } @@ -2384,7 +2384,7 @@ static int sceKernelAllocHeapMemory(int heapId, int size) // There's 8 bytes at the end of every block, reserved. u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; u32 addr = heap->alloc.Alloc(memSize, true); - return hleLogError(SCEKERNEL, addr, ""); + return hleLogSuccessInfoX(SCEKERNEL, addr, ""); } static int sceKernelDeleteHeap(int heapId) @@ -2397,7 +2397,7 @@ static int sceKernelDeleteHeap(int heapId) userMemory.Free(heap->address); kernelObjects.Destroy(heap->uid); heapInformationList.erase(heapId); - return hleLogError(SCEKERNEL, 0, ""); + return hleLogSuccessInfoX(SCEKERNEL, 0, ""); } const HLEFunction SysMemForKernel[] = From bf73d3d6639d36fd44c8e03ea3056b74c3faf45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 8 Aug 2019 17:13:47 +0200 Subject: [PATCH 10/13] Address Unknown's feedback https://github.com/hrydgard/ppsspp/pull/7965/files --- CMakeLists.txt | 2 + Core/Core.vcxproj | 2 + Core/Core.vcxproj.filters | 8 +- Core/HLE/sceKernel.cpp | 27 ------ Core/HLE/sceKernel.h | 1 + Core/HLE/sceKernelHeap.cpp | 115 ++++++++++++++++++++++++++ Core/HLE/sceKernelHeap.h | 5 ++ Core/HLE/sceKernelMemory.cpp | 122 ---------------------------- Core/HLE/sceKernelMemory.h | 2 - Core/HLE/sceKernelThread.h | 4 + UWP/CoreUWP/CoreUWP.vcxproj | 2 + UWP/CoreUWP/CoreUWP.vcxproj.filters | 8 +- android/jni/Android.mk | 1 + libretro/Makefile.common | 1 + 14 files changed, 147 insertions(+), 153 deletions(-) create mode 100644 Core/HLE/sceKernelHeap.cpp create mode 100644 Core/HLE/sceKernelHeap.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b5d256c21095..50cd7b535643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1590,6 +1590,8 @@ add_library(${CoreLibName} ${CoreLinkType} Core/HLE/sceKernelAlarm.h Core/HLE/sceKernelEventFlag.cpp Core/HLE/sceKernelEventFlag.h + Core/HLE/sceKernelHeap.cpp + Core/HLE/sceKernelHeap.h Core/HLE/sceKernelInterrupt.cpp Core/HLE/sceKernelInterrupt.h Core/HLE/sceKernelMbx.cpp diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 1c422c1593ef..5b675bd729d9 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -371,6 +371,7 @@ + @@ -899,6 +900,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 19698164c259..c95b6aa41fd4 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -740,6 +740,9 @@ HW + + HLE\Kernel + @@ -1373,10 +1376,13 @@ HW + + HLE\Kernel + - \ No newline at end of file + diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index 824c95149262..ad571355ef15 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -904,28 +904,6 @@ void Register_LoadExecForKernel() RegisterModule("LoadExecForKernel", ARRAY_SIZE(LoadExecForKernel), LoadExecForKernel); } -static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) -{ - return hleLogError(SCEKERNEL, 0, ""); -} - -static int sceKernelAllocHeapMemory(int heapId, int size) -{ - return hleLogError(SCEKERNEL, 0, ""); -} - -static int sceKernelDeleteHeap(int heapId) -{ - return hleLogError(SCEKERNEL, 0, ""); -} - -const HLEFunction SysMemForKernel[] = -{ - {0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, - {0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, - {0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, -}; - const HLEFunction ExceptionManagerForKernel[] = { {0X3FB264FC, nullptr, "sceKernelRegisterExceptionHandler", '?', "" }, @@ -976,8 +954,3 @@ void Register_ThreadManForKernel() { RegisterModule("ThreadManForKernel", ARRAY_SIZE(ThreadManForKernel), ThreadManForKernel); } - -void Register_LoadExecForKernel() -{ - RegisterModule("LoadExecForKernel", ARRAY_SIZE(LoadExecForKernel), LoadExecForKernel); -} diff --git a/Core/HLE/sceKernel.h b/Core/HLE/sceKernel.h index fa5928584bba..96e94cb76002 100644 --- a/Core/HLE/sceKernel.h +++ b/Core/HLE/sceKernel.h @@ -340,6 +340,7 @@ enum TMIDPurpose PPSSPP_KERNEL_TMID_PMB = 0x100002, PPSSPP_KERNEL_TMID_File = 0x100003, PPSSPP_KERNEL_TMID_DirList = 0x100004, + PPSSPP_KERNEL_TMID_Heap = 0x100005, }; typedef int SceUID; diff --git a/Core/HLE/sceKernelHeap.cpp b/Core/HLE/sceKernelHeap.cpp new file mode 100644 index 000000000000..fa146a93ee86 --- /dev/null +++ b/Core/HLE/sceKernelHeap.cpp @@ -0,0 +1,115 @@ +#pragma once + +#include + +#include "Common/ChunkFile.h" +#include "Core/HLE/HLE.h" +#include "Core/HLE/FunctionWrappers.h" +#include "Core/HLE/sceKernel.h" +#include "Core/HLE/sceKernelHeap.h" +#include "Core/HLE/sceKernelMemory.h" +#include "Core/Util/BlockAllocator.h" + +struct HeapInformation : public KernelObject { + int uid = 0; + int partitionId = 0; + u32 size = 0; + int flags = 0; + u32 address = 0; + std::string name; + BlockAllocator alloc; + + static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_UID; } + static int GetStaticIDType() { return PPSSPP_KERNEL_TMID_Heap; } + int GetIDType() const override { return PPSSPP_KERNEL_TMID_Heap; } + + void DoState(PointerWrap &p) { + p.Do(uid); + p.Do(partitionId); + p.Do(size); + p.Do(flags); + p.Do(address); + p.Do(name); + p.Do(alloc); + } +}; + +std::map heapInformationList; + +void __HeapInformationDoState(PointerWrap &p) { + auto s = p.Section("kernelHeap", 1); + if (!s) + return; + + if (s >= 1) { + p.Do(heapInformationList); + } +} + +static HeapInformation *getHeap(u32 heapId) { + auto found = heapInformationList.find(heapId); + if (found == heapInformationList.end()) { + return NULL; + } + return found->second; +} + +const u32 HEAP_BLOCK_HEADER_SIZE = 8; +const bool frombottom = false; + +static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) { + HeapInformation *heap = new HeapInformation; + heap->partitionId = partitionId; + heap->flags = flags; + heap->name = *Name; + int allocSize = (size + 3) & ~3; + heap->size = allocSize; + u32 addr = userMemory.Alloc(heap->size, frombottom, "SysMemForKernel-Heap"); + if (addr == (u32)-1) { + ERROR_LOG(HLE, "sceKernelCreateHeap(): Failed to allocate %i bytes memory", size); + heap->uid = -1; + delete heap; + } + heap->address = addr; + heap->alloc.Init(heap->address + 128, heap->size - 128); + SceUID uid = kernelObjects.Create(heap); + heap->uid = uid; + heapInformationList[uid] = heap; + return hleLogSuccessInfoX(SCEKERNEL, uid, ""); +} + +static int sceKernelAllocHeapMemory(int heapId, int size) { + HeapInformation *heap = getHeap(heapId); + if (!heap) { + ERROR_LOG(HLE, "sceKernelAllocHeapMemory cannot find heapId", heapId); + return 0; + } + + // There's 8 bytes at the end of every block, reserved. + u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; + u32 addr = heap->alloc.Alloc(memSize, true); + return hleLogSuccessInfoX(SCEKERNEL, addr, ""); +} + +static int sceKernelDeleteHeap(int heapId) { + HeapInformation *heap = getHeap(heapId); + if (!heap) { + ERROR_LOG(HLE, "sceKernelDeleteHeap(%i): invalid heapId", heapId); + return -1; + } + userMemory.Free(heap->address); + kernelObjects.Destroy(heap->uid); + heapInformationList.erase(heapId); + return hleLogSuccessInfoX(SCEKERNEL, 0, ""); +} + +const HLEFunction SysMemForKernel[] = +{ + { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, + { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, + { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, +}; + +void Register_SysMemForKernel() { + RegisterModule("SysMemForKernel", ARRAY_SIZE(SysMemForKernel), SysMemForKernel); +} diff --git a/Core/HLE/sceKernelHeap.h b/Core/HLE/sceKernelHeap.h new file mode 100644 index 000000000000..a880601a4449 --- /dev/null +++ b/Core/HLE/sceKernelHeap.h @@ -0,0 +1,5 @@ +#pragma once + +int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name); +int sceKernelAllocHeapMemory(int heapId, int size); +int sceKernelDeleteHeap(int heapId); diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 436e31c16ad8..40cccaa03d9b 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2287,128 +2287,6 @@ const HLEFunction SysMemUserForUser[] = { {0XD8DE5C1E, &WrapU_V, "SysMemUserForUser_D8DE5C1E", 'x', "" }, }; -const HLEFunction SysMemForKernel[] = { - {0x636C953B, nullptr, "SysMemForKernel_636c953b", '?', "" }, - {0xC9805775, nullptr, "SysMemForKernel_c9805775", '?', "" }, - {0x1C1FBFE7, nullptr, "SysMemForKernel_1c1fbfe7", '?', "" }, -}; - -void Register_SysMemForKernel() { - RegisterModule("SysMemForKernel", ARRAY_SIZE(SysMemForKernel), SysMemForKernel); -} - void Register_SysMemUserForUser() { RegisterModule("SysMemUserForUser", ARRAY_SIZE(SysMemUserForUser), SysMemUserForUser); } - - -struct HeapInformation : public KernelObject { - HeapInformation() {} - int uid; - int partitionId; - u32 size; - int flags; - u32 address; - std::string name; - BlockAllocator alloc; - static int GetStaticIDType() { return SCE_KERNEL_TMID_Fpl; }// wrong - int GetIDType() const override { return SCE_KERNEL_TMID_Fpl; }// wrong - - void DoState(PointerWrap &p) { - p.Do(uid); - p.Do(partitionId); - p.Do(size); - p.Do(flags); - p.Do(address); - p.Do(name); - p.Do(alloc); - } -}; - -std::map heapInformationList; - -void __HeapInformationDoState(PointerWrap &p) { - auto s = p.Section("kernelHeap", 1); - if (!s) - return; - - if (s >= 1) { - p.Do(heapInformationList); - } -} - -static HeapInformation *getHeap(u32 heapId) { - auto found = heapInformationList.find(heapId); - if (found == heapInformationList.end()) { - return NULL; - } - return found->second; -} - -const u32 HEAP_BLOCK_HEADER_SIZE = 8; -const bool frombottom = false; - -static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) -{ - HeapInformation *heap = new HeapInformation; - heap->partitionId = partitionId; - heap->flags = flags; - heap->name = *Name; - int allocSize = (size + 3) & ~3; - heap->size = allocSize; - u32 addr = userMemory.Alloc(heap->size, frombottom, "SysMemForKernel-Heap"); - if (addr == (u32)-1) { - ERROR_LOG(HLE, "sceKernelCreateHeap(): Failed to allocate %i bytes memory", size); - heap->uid = -1; - delete heap; - } - heap->address = addr; - heap->alloc.Init(heap->address + 128, heap->size - 128); - SceUID uid = kernelObjects.Create(heap); - heap->uid = uid; - heapInformationList[uid] = heap; - - - return hleLogSuccessInfoX(SCEKERNEL, uid, ""); -} - - -static int sceKernelAllocHeapMemory(int heapId, int size) -{ - HeapInformation *heap = getHeap(heapId); - if (!heap) { - ERROR_LOG(HLE, "sceKernelAllocHeapMemory cannot find heapId", heapId); - return 0; - } - - // There's 8 bytes at the end of every block, reserved. - u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; - u32 addr = heap->alloc.Alloc(memSize, true); - return hleLogSuccessInfoX(SCEKERNEL, addr, ""); -} - -static int sceKernelDeleteHeap(int heapId) -{ - HeapInformation *heap = getHeap(heapId); - if (!heap) { - ERROR_LOG(HLE, "sceKernelDeleteHeap(%i): invalid heapId", heapId); - return -1; - } - userMemory.Free(heap->address); - kernelObjects.Destroy(heap->uid); - heapInformationList.erase(heapId); - return hleLogSuccessInfoX(SCEKERNEL, 0, ""); -} - -const HLEFunction SysMemForKernel[] = -{ - { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, - { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, - { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, -}; - -void Register_SysMemForKernel() -{ - RegisterModule("SysMemForKernel", ARRAY_SIZE(SysMemForKernel), SysMemForKernel); -} - diff --git a/Core/HLE/sceKernelMemory.h b/Core/HLE/sceKernelMemory.h index 96de13e23ef4..2396792436e9 100644 --- a/Core/HLE/sceKernelMemory.h +++ b/Core/HLE/sceKernelMemory.h @@ -68,5 +68,3 @@ int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr); void Register_SysMemForKernel(); void Register_SysMemUserForUser(); -void Register_SysMemForKernel(); - diff --git a/Core/HLE/sceKernelThread.h b/Core/HLE/sceKernelThread.h index 73ba3474ba7e..14cc1fde781f 100644 --- a/Core/HLE/sceKernelThread.h +++ b/Core/HLE/sceKernelThread.h @@ -330,3 +330,7 @@ KernelObject *__KernelThreadEventHandlerObject(); SceUID sceKernelRegisterThreadEventHandler(const char *name, SceUID threadID, u32 mask, u32 handlerPtr, u32 commonArg); int sceKernelReleaseThreadEventHandler(SceUID uid); int sceKernelReferThreadEventHandlerStatus(SceUID uid, u32 infoPtr); + +int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name); +int sceKernelAllocHeapMemory(int heapId, int size); +int sceKernelDeleteHeap(int heapId); diff --git a/UWP/CoreUWP/CoreUWP.vcxproj b/UWP/CoreUWP/CoreUWP.vcxproj index 814930607bfc..0bbac0c46e94 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj +++ b/UWP/CoreUWP/CoreUWP.vcxproj @@ -466,6 +466,7 @@ + @@ -678,6 +679,7 @@ + diff --git a/UWP/CoreUWP/CoreUWP.vcxproj.filters b/UWP/CoreUWP/CoreUWP.vcxproj.filters index 07d1e0937168..7afcc97e719d 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj.filters +++ b/UWP/CoreUWP/CoreUWP.vcxproj.filters @@ -368,6 +368,9 @@ HLE + + HLE + HLE @@ -968,6 +971,9 @@ HLE + + HLE + HLE @@ -1298,4 +1304,4 @@ HW - \ No newline at end of file + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index d334324cf82d..6f23ada75f0f 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -360,6 +360,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Core/HLE/sceKernel.cpp \ $(SRC)/Core/HLE/sceKernelAlarm.cpp \ $(SRC)/Core/HLE/sceKernelEventFlag.cpp \ + $(SRC)/Core/HLE/sceKernelHeap.cpp \ $(SRC)/Core/HLE/sceKernelInterrupt.cpp \ $(SRC)/Core/HLE/sceKernelMemory.cpp \ $(SRC)/Core/HLE/sceKernelModule.cpp \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index d909df3ada36..b1fd51bdb670 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -389,6 +389,7 @@ SOURCES_CXX += $(NATIVEDIR)/math/dataconv.cpp \ $(COREDIR)/HLE/sceKernel.cpp \ $(COREDIR)/HLE/sceKernelAlarm.cpp \ $(COREDIR)/HLE/sceKernelEventFlag.cpp \ + $(COREDIR)/HLE/sceKernelHeap.cpp \ $(COREDIR)/HLE/sceKernelInterrupt.cpp \ $(COREDIR)/HLE/sceKernelMbx.cpp \ $(COREDIR)/HLE/sceKernelMemory.cpp \ From e0614b7ce28c604c57d39a5374ddb264b3631d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 8 Aug 2019 17:23:41 +0200 Subject: [PATCH 11/13] Use PPSSPP's kernel interface to retrieve Heap objects Allows us to get rid of DoState and the map<>. --- Core/HLE/sceKernel.cpp | 1 + Core/HLE/sceKernelHeap.cpp | 71 ++++++++++++++------------------------ Core/HLE/sceKernelHeap.h | 2 ++ 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index ad571355ef15..520295f2d929 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -50,6 +50,7 @@ #include "sceJpeg.h" #include "sceKernel.h" #include "sceKernelAlarm.h" +#include "sceKernelHeap.h" #include "sceKernelInterrupt.h" #include "sceKernelThread.h" #include "sceKernelMemory.h" diff --git a/Core/HLE/sceKernelHeap.cpp b/Core/HLE/sceKernelHeap.cpp index fa146a93ee86..8baa81a0ab10 100644 --- a/Core/HLE/sceKernelHeap.cpp +++ b/Core/HLE/sceKernelHeap.cpp @@ -10,7 +10,10 @@ #include "Core/HLE/sceKernelMemory.h" #include "Core/Util/BlockAllocator.h" -struct HeapInformation : public KernelObject { +const u32 HEAP_BLOCK_HEADER_SIZE = 8; +const bool frombottom = false; + +struct Heap : public KernelObject { int uid = 0; int partitionId = 0; u32 size = 0; @@ -34,31 +37,9 @@ struct HeapInformation : public KernelObject { } }; -std::map heapInformationList; - -void __HeapInformationDoState(PointerWrap &p) { - auto s = p.Section("kernelHeap", 1); - if (!s) - return; - - if (s >= 1) { - p.Do(heapInformationList); - } -} - -static HeapInformation *getHeap(u32 heapId) { - auto found = heapInformationList.find(heapId); - if (found == heapInformationList.end()) { - return NULL; - } - return found->second; -} - -const u32 HEAP_BLOCK_HEADER_SIZE = 8; -const bool frombottom = false; - static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) { - HeapInformation *heap = new HeapInformation; + Heap *heap = new Heap(); + SceUID uid = kernelObjects.Create(heap); heap->partitionId = partitionId; heap->flags = flags; heap->name = *Name; @@ -72,42 +53,42 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char } heap->address = addr; heap->alloc.Init(heap->address + 128, heap->size - 128); - SceUID uid = kernelObjects.Create(heap); heap->uid = uid; - heapInformationList[uid] = heap; return hleLogSuccessInfoX(SCEKERNEL, uid, ""); } static int sceKernelAllocHeapMemory(int heapId, int size) { - HeapInformation *heap = getHeap(heapId); - if (!heap) { + u32 error; + Heap *heap = kernelObjects.Get(heapId, error); + if (heap) { + // There's 8 bytes at the end of every block, reserved. + u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; + u32 addr = heap->alloc.Alloc(memSize, true); + return hleLogSuccessInfoX(SCEKERNEL, addr, ""); + } else { ERROR_LOG(HLE, "sceKernelAllocHeapMemory cannot find heapId", heapId); - return 0; + return error; } - - // There's 8 bytes at the end of every block, reserved. - u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; - u32 addr = heap->alloc.Alloc(memSize, true); - return hleLogSuccessInfoX(SCEKERNEL, addr, ""); } static int sceKernelDeleteHeap(int heapId) { - HeapInformation *heap = getHeap(heapId); - if (!heap) { + u32 error; + Heap *heap = kernelObjects.Get(heapId, error); + if (heap) { + userMemory.Free(heap->address); + kernelObjects.Destroy(heap->uid); + return hleLogSuccessInfoX(SCEKERNEL, 0, ""); + } else { ERROR_LOG(HLE, "sceKernelDeleteHeap(%i): invalid heapId", heapId); - return -1; + return error; } - userMemory.Free(heap->address); - kernelObjects.Destroy(heap->uid); - heapInformationList.erase(heapId); - return hleLogSuccessInfoX(SCEKERNEL, 0, ""); } const HLEFunction SysMemForKernel[] = { - { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, - { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, - { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, + { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, + { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, + { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, }; void Register_SysMemForKernel() { diff --git a/Core/HLE/sceKernelHeap.h b/Core/HLE/sceKernelHeap.h index a880601a4449..7b43021ac678 100644 --- a/Core/HLE/sceKernelHeap.h +++ b/Core/HLE/sceKernelHeap.h @@ -1,5 +1,7 @@ #pragma once +#include "Common/ChunkFile.h" + int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name); int sceKernelAllocHeapMemory(int heapId, int size); int sceKernelDeleteHeap(int heapId); From e3aa2f5e4c84669b9c1ff409f5b733d141e489f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 8 Aug 2019 19:00:27 +0200 Subject: [PATCH 12/13] Assorted fixes (build and crash) --- Core/HLE/HLETables.cpp | 1 + Core/HLE/sceKernelHeap.cpp | 25 +++++++++++++------------ Core/HLE/sceKernelHeap.h | 6 +----- Core/HLE/sceKernelMemory.h | 1 - 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Core/HLE/HLETables.cpp b/Core/HLE/HLETables.cpp index c62a564b7fa9..b4f0636f7709 100644 --- a/Core/HLE/HLETables.cpp +++ b/Core/HLE/HLETables.cpp @@ -40,6 +40,7 @@ #include "sceJpeg.h" #include "sceKernel.h" #include "sceKernelEventFlag.h" +#include "sceKernelHeap.h" #include "sceKernelMemory.h" #include "sceKernelInterrupt.h" #include "sceKernelModule.h" diff --git a/Core/HLE/sceKernelHeap.cpp b/Core/HLE/sceKernelHeap.cpp index 8baa81a0ab10..5aec59e8730f 100644 --- a/Core/HLE/sceKernelHeap.cpp +++ b/Core/HLE/sceKernelHeap.cpp @@ -1,5 +1,3 @@ -#pragma once - #include #include "Common/ChunkFile.h" @@ -26,7 +24,7 @@ struct Heap : public KernelObject { static int GetStaticIDType() { return PPSSPP_KERNEL_TMID_Heap; } int GetIDType() const override { return PPSSPP_KERNEL_TMID_Heap; } - void DoState(PointerWrap &p) { + void DoState(PointerWrap &p) override { p.Do(uid); p.Do(partitionId); p.Do(size); @@ -38,19 +36,22 @@ struct Heap : public KernelObject { }; static int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name) { + u32 allocSize = (size + 3) & ~3; + + // TODO: partitionId should probably decide if we allocate from userMemory or kernel or whatever... + u32 addr = userMemory.Alloc(allocSize, frombottom, "SysMemForKernel-Heap"); + if (addr == (u32)-1) { + ERROR_LOG(HLE, "sceKernelCreateHeap(partitionId=%d): Failed to allocate %d bytes memory", partitionId, size); + return SCE_KERNEL_ERROR_NO_MEMORY; // Blind guess + } + Heap *heap = new Heap(); SceUID uid = kernelObjects.Create(heap); + heap->partitionId = partitionId; heap->flags = flags; heap->name = *Name; - int allocSize = (size + 3) & ~3; heap->size = allocSize; - u32 addr = userMemory.Alloc(heap->size, frombottom, "SysMemForKernel-Heap"); - if (addr == (u32)-1) { - ERROR_LOG(HLE, "sceKernelCreateHeap(): Failed to allocate %i bytes memory", size); - heap->uid = -1; - delete heap; - } heap->address = addr; heap->alloc.Init(heap->address + 128, heap->size - 128); heap->uid = uid; @@ -66,7 +67,7 @@ static int sceKernelAllocHeapMemory(int heapId, int size) { u32 addr = heap->alloc.Alloc(memSize, true); return hleLogSuccessInfoX(SCEKERNEL, addr, ""); } else { - ERROR_LOG(HLE, "sceKernelAllocHeapMemory cannot find heapId", heapId); + ERROR_LOG(HLE, "sceKernelAllocHeapMemory(%d): cannot find heapId", heapId); return error; } } @@ -79,7 +80,7 @@ static int sceKernelDeleteHeap(int heapId) { kernelObjects.Destroy(heap->uid); return hleLogSuccessInfoX(SCEKERNEL, 0, ""); } else { - ERROR_LOG(HLE, "sceKernelDeleteHeap(%i): invalid heapId", heapId); + ERROR_LOG(HLE, "sceKernelDeleteHeap(%d): invalid heapId", heapId); return error; } } diff --git a/Core/HLE/sceKernelHeap.h b/Core/HLE/sceKernelHeap.h index 7b43021ac678..1279c7496232 100644 --- a/Core/HLE/sceKernelHeap.h +++ b/Core/HLE/sceKernelHeap.h @@ -1,7 +1,3 @@ #pragma once -#include "Common/ChunkFile.h" - -int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name); -int sceKernelAllocHeapMemory(int heapId, int size); -int sceKernelDeleteHeap(int heapId); +void Register_SysMemForKernel(); diff --git a/Core/HLE/sceKernelMemory.h b/Core/HLE/sceKernelMemory.h index 2396792436e9..dce6df77e04a 100644 --- a/Core/HLE/sceKernelMemory.h +++ b/Core/HLE/sceKernelMemory.h @@ -66,5 +66,4 @@ int sceKernelGetTlsAddr(SceUID uid); int sceKernelFreeTlspl(SceUID uid); int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr); -void Register_SysMemForKernel(); void Register_SysMemUserForUser(); From 34ae4cc5a9b20c5426ad6eec596dd1b4997215a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 26 Apr 2020 11:34:17 +0200 Subject: [PATCH 13/13] Address additional feedback from Unknown, finally --- Core/HLE/sceKernelHeap.cpp | 29 +++++++++++++---------------- Core/HLE/sceKernelThread.h | 4 ---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Core/HLE/sceKernelHeap.cpp b/Core/HLE/sceKernelHeap.cpp index 5aec59e8730f..7b99eca18479 100644 --- a/Core/HLE/sceKernelHeap.cpp +++ b/Core/HLE/sceKernelHeap.cpp @@ -8,8 +8,8 @@ #include "Core/HLE/sceKernelMemory.h" #include "Core/Util/BlockAllocator.h" -const u32 HEAP_BLOCK_HEADER_SIZE = 8; -const bool frombottom = false; +static const u32 HEAP_BLOCK_HEADER_SIZE = 8; +static const bool g_fromBottom = false; struct Heap : public KernelObject { int uid = 0; @@ -39,7 +39,7 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char u32 allocSize = (size + 3) & ~3; // TODO: partitionId should probably decide if we allocate from userMemory or kernel or whatever... - u32 addr = userMemory.Alloc(allocSize, frombottom, "SysMemForKernel-Heap"); + u32 addr = userMemory.Alloc(allocSize, g_fromBottom, "SysMemForKernel-Heap"); if (addr == (u32)-1) { ERROR_LOG(HLE, "sceKernelCreateHeap(partitionId=%d): Failed to allocate %d bytes memory", partitionId, size); return SCE_KERNEL_ERROR_NO_MEMORY; // Blind guess @@ -50,12 +50,12 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char heap->partitionId = partitionId; heap->flags = flags; - heap->name = *Name; + heap->name = Name ? Name : ""; // Not sure if this needs validation. heap->size = allocSize; heap->address = addr; heap->alloc.Init(heap->address + 128, heap->size - 128); heap->uid = uid; - return hleLogSuccessInfoX(SCEKERNEL, uid, ""); + return hleLogSuccessInfoX(SCEKERNEL, uid); } static int sceKernelAllocHeapMemory(int heapId, int size) { @@ -65,10 +65,9 @@ static int sceKernelAllocHeapMemory(int heapId, int size) { // There's 8 bytes at the end of every block, reserved. u32 memSize = HEAP_BLOCK_HEADER_SIZE + size; u32 addr = heap->alloc.Alloc(memSize, true); - return hleLogSuccessInfoX(SCEKERNEL, addr, ""); + return hleLogSuccessInfoX(SCEKERNEL, addr); } else { - ERROR_LOG(HLE, "sceKernelAllocHeapMemory(%d): cannot find heapId", heapId); - return error; + return hleLogError(SCEKERNEL, error, "sceKernelAllocHeapMemory(%d): invalid heapId", heapId); } } @@ -78,18 +77,16 @@ static int sceKernelDeleteHeap(int heapId) { if (heap) { userMemory.Free(heap->address); kernelObjects.Destroy(heap->uid); - return hleLogSuccessInfoX(SCEKERNEL, 0, ""); + return hleLogSuccessInfoX(SCEKERNEL, 0); } else { - ERROR_LOG(HLE, "sceKernelDeleteHeap(%d): invalid heapId", heapId); - return error; + return hleLogError(SCEKERNEL, error, "sceKernelDeleteHeap(%d): invalid heapId", heapId); } } -const HLEFunction SysMemForKernel[] = -{ - { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'I', "ii" }, - { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'I', "i" }, - { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'I', "iiis" }, +const HLEFunction SysMemForKernel[] = { + { 0X636C953B, &WrapI_II, "sceKernelAllocHeapMemory", 'x', "ii" }, + { 0XC9805775, &WrapI_I, "sceKernelDeleteHeap", 'i', "i" }, + { 0X1C1FBFE7, &WrapI_IIIC, "sceKernelCreateHeap", 'i', "iixs" }, }; void Register_SysMemForKernel() { diff --git a/Core/HLE/sceKernelThread.h b/Core/HLE/sceKernelThread.h index 14cc1fde781f..73ba3474ba7e 100644 --- a/Core/HLE/sceKernelThread.h +++ b/Core/HLE/sceKernelThread.h @@ -330,7 +330,3 @@ KernelObject *__KernelThreadEventHandlerObject(); SceUID sceKernelRegisterThreadEventHandler(const char *name, SceUID threadID, u32 mask, u32 handlerPtr, u32 commonArg); int sceKernelReleaseThreadEventHandler(SceUID uid); int sceKernelReferThreadEventHandlerStatus(SceUID uid, u32 infoPtr); - -int sceKernelCreateHeap(int partitionId, int size, int flags, const char *Name); -int sceKernelAllocHeapMemory(int heapId, int size); -int sceKernelDeleteHeap(int heapId);