mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Kernel: Avoid two different Heap structs.
This commit is contained in:
parent
a60759cca3
commit
d7fa5928d4
2 changed files with 13 additions and 9 deletions
|
@ -15,6 +15,7 @@
|
|||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <map>
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Common/Serialize/SerializeMap.h"
|
||||
|
@ -25,7 +26,6 @@
|
|||
#include "Core/HLE/sceKernelMemory.h"
|
||||
#include "Core/HLE/sceHeap.h"
|
||||
#include "Core/Util/BlockAllocator.h"
|
||||
#include <map>
|
||||
|
||||
struct Heap {
|
||||
Heap() : alloc(4) {}
|
||||
|
@ -43,7 +43,7 @@ struct Heap {
|
|||
}
|
||||
};
|
||||
|
||||
std::map<u32,Heap*> heapList;
|
||||
static std::map<u32, Heap *> heapList;
|
||||
|
||||
static Heap *getHeap(u32 addr) {
|
||||
auto found = heapList.find(addr);
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
#include "Core/HLE/sceKernelMemory.h"
|
||||
#include "Core/Util/BlockAllocator.h"
|
||||
|
||||
static const u32 HEAP_BLOCK_HEADER_SIZE = 8;
|
||||
static const u32 KERNEL_HEAP_BLOCK_HEADER_SIZE = 8;
|
||||
static const bool g_fromBottom = false;
|
||||
|
||||
struct Heap : public KernelObject {
|
||||
// This object and the functions here are available for kernel code only, not game code.
|
||||
// This differs from code like sceKernelMutex, which is available for games.
|
||||
// This exists in PPSSPP mainly because certain game patches use these kernel modules.
|
||||
|
||||
struct KernelHeap : public KernelObject {
|
||||
int uid = 0;
|
||||
int partitionId = 0;
|
||||
u32 size = 0;
|
||||
|
@ -48,7 +52,7 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char
|
|||
return SCE_KERNEL_ERROR_NO_MEMORY; // Blind guess
|
||||
}
|
||||
|
||||
Heap *heap = new Heap();
|
||||
KernelHeap *heap = new KernelHeap();
|
||||
SceUID uid = kernelObjects.Create(heap);
|
||||
|
||||
heap->partitionId = partitionId;
|
||||
|
@ -63,10 +67,10 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char
|
|||
|
||||
static int sceKernelAllocHeapMemory(int heapId, int size) {
|
||||
u32 error;
|
||||
Heap *heap = kernelObjects.Get<Heap>(heapId, error);
|
||||
KernelHeap *heap = kernelObjects.Get<KernelHeap>(heapId, error);
|
||||
if (heap) {
|
||||
// There's 8 bytes at the end of every block, reserved.
|
||||
u32 memSize = HEAP_BLOCK_HEADER_SIZE + size;
|
||||
u32 memSize = KERNEL_HEAP_BLOCK_HEADER_SIZE + size;
|
||||
u32 addr = heap->alloc.Alloc(memSize, true);
|
||||
return hleLogSuccessInfoX(SCEKERNEL, addr);
|
||||
} else {
|
||||
|
@ -76,10 +80,10 @@ static int sceKernelAllocHeapMemory(int heapId, int size) {
|
|||
|
||||
static int sceKernelDeleteHeap(int heapId) {
|
||||
u32 error;
|
||||
Heap *heap = kernelObjects.Get<Heap>(heapId, error);
|
||||
KernelHeap *heap = kernelObjects.Get<KernelHeap>(heapId, error);
|
||||
if (heap) {
|
||||
userMemory.Free(heap->address);
|
||||
kernelObjects.Destroy<Heap>(heap->uid);
|
||||
kernelObjects.Destroy<KernelHeap>(heap->uid);
|
||||
return hleLogSuccessInfoX(SCEKERNEL, 0);
|
||||
} else {
|
||||
return hleLogError(SCEKERNEL, error, "sceKernelDeleteHeap(%d): invalid heapId", heapId);
|
||||
|
|
Loading…
Add table
Reference in a new issue