mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-12 14:00:27 +02:00
Address Unknown's feedback
https://github.com/hrydgard/ppsspp/pull/7965/files
This commit is contained in:
1 parent
3604a92bee
commit
bf73d3d663
14 files changed
+147
-153
No files matched your search
@@ -2287,128 +2287,6 @@ const HLEFunction SysMemUserForUser[] = {
|
||||
{0XD8DE5C1E, &WrapU_V<SysMemUserForUser_D8DE5C1E>, "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<u32, HeapInformation *> 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<FPL>(heap->uid);
|
||||
heapInformationList.erase(heapId);
|
||||
return hleLogSuccessInfoX(SCEKERNEL, 0, "");
|
||||
}
|
||||
|
||||
const HLEFunction SysMemForKernel[] =
|
||||
{
|
||||
{ 0X636C953B, &WrapI_II<sceKernelAllocHeapMemory>, "sceKernelAllocHeapMemory", 'I', "ii" },
|
||||
{ 0XC9805775, &WrapI_I<sceKernelDeleteHeap>, "sceKernelDeleteHeap", 'I', "i" },
|
||||
{ 0X1C1FBFE7, &WrapI_IIIC<sceKernelCreateHeap>, "sceKernelCreateHeap", 'I', "iiis" },
|
||||
};
|
||||
|
||||
void Register_SysMemForKernel()
|
||||
{
|
||||
RegisterModule("SysMemForKernel", ARRAY_SIZE(SysMemForKernel), SysMemForKernel);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user