Skip to content

Commit

Permalink
Assorted fixes (build and crash)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Aug 8, 2019
1 parent e02d5bf commit 7c60899
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions Core/HLE/HLETables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 13 additions & 12 deletions Core/HLE/sceKernelHeap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#pragma once

#include <string>

#include "Common/ChunkFile.h"
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand All @@ -79,7 +80,7 @@ static int sceKernelDeleteHeap(int heapId) {
kernelObjects.Destroy<Heap>(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;
}
}
Expand Down
6 changes: 1 addition & 5 deletions Core/HLE/sceKernelHeap.h
Original file line number Diff line number Diff line change
@@ -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();
1 change: 0 additions & 1 deletion Core/HLE/sceKernelMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ int sceKernelGetTlsAddr(SceUID uid);
int sceKernelFreeTlspl(SceUID uid);
int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr);

void Register_SysMemForKernel();
void Register_SysMemUserForUser();

0 comments on commit 7c60899

Please sign in to comment.