2012-11-15 00:39:56 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-17 17:44:03 +02:00
|
|
|
#include "Utilities/Log.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/Memory/Memory.h"
|
|
|
|
|
#include "Emu/System.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
#include "Emu/SysCalls/SysCalls.h"
|
|
|
|
|
|
|
|
|
|
SysCallBase sc_heap("sys_heap");
|
|
|
|
|
|
|
|
|
|
struct HeapInfo
|
|
|
|
|
{
|
|
|
|
|
u32 heap_addr;
|
|
|
|
|
u32 align;
|
|
|
|
|
u32 size;
|
|
|
|
|
|
|
|
|
|
HeapInfo(u32 _heap_addr, u32 _align, u32 _size)
|
|
|
|
|
: heap_addr(_heap_addr)
|
|
|
|
|
, align(_align)
|
|
|
|
|
, size(_size)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int sys_heap_create_heap(const u32 heap_addr, const u32 align, const u32 size)
|
2014-02-02 20:49:10 +01:00
|
|
|
{
|
2012-11-15 00:39:56 +01:00
|
|
|
sc_heap.Warning("sys_heap_create_heap(heap_addr=0x%x, align=0x%x, size=0x%x)", heap_addr, align, size);
|
2014-02-02 20:49:10 +01:00
|
|
|
|
|
|
|
|
u32 heap_id = sc_heap.GetNewId(new HeapInfo(heap_addr, align, size));
|
2014-02-13 12:13:05 +01:00
|
|
|
sc_heap.Warning("*** sys_heap created: id = %d", heap_id);
|
2014-02-02 20:49:10 +01:00
|
|
|
return heap_id;
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int sys_heap_malloc(const u32 heap_id, const u32 size)
|
|
|
|
|
{
|
2014-02-13 12:13:05 +01:00
|
|
|
sc_heap.Warning("sys_heap_malloc(heap_id=%d, size=0x%x)", heap_id, size);
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-01-19 04:14:11 +01:00
|
|
|
HeapInfo* heap;
|
|
|
|
|
if(!sc_heap.CheckId(heap_id, heap)) return CELL_ESRCH;
|
|
|
|
|
|
2014-02-07 22:55:25 +01:00
|
|
|
return Memory.Alloc(size, 1);
|
2014-02-02 20:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-13 12:13:05 +01:00
|
|
|
int _sys_heap_memalign(u32 heap_id, u32 align, u32 size)
|
2014-02-02 20:49:10 +01:00
|
|
|
{
|
2014-02-13 12:13:05 +01:00
|
|
|
sc_heap.Warning("_sys_heap_memalign(heap_id=%d, align=0x%x, size=0x%x)", heap_id, align, size);
|
2014-02-02 20:49:10 +01:00
|
|
|
|
|
|
|
|
HeapInfo* heap;
|
|
|
|
|
if(!sc_heap.CheckId(heap_id, heap)) return CELL_ESRCH;
|
|
|
|
|
|
|
|
|
|
return Memory.Alloc(size, align);
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|