mirror of
https://github.com/libretro/mgba.git
synced 2024-11-23 07:59:46 +00:00
(Libretro) Add Vita target
This commit is contained in:
parent
26969a26af
commit
b2aafdc279
@ -181,7 +181,7 @@ else ifeq ($(platform), vita)
|
||||
TARGET := $(TARGET_NAME)_libretro_vita.a
|
||||
CC = arm-vita-eabi-gcc$(EXE_EXT)
|
||||
AR = arm-vita-eabi-ar$(EXE_EXT)
|
||||
PLATFORM_DEFINES := -DVITA -DCC_RESAMPLER
|
||||
PLATFORM_DEFINES := -DVITA -DCC_RESAMPLER -DPSP2
|
||||
STATIC_LINKING = 1
|
||||
DEFINES += -std=c99
|
||||
|
||||
|
@ -56,7 +56,11 @@ SOURCES_C := $(CORE_DIR)/src/arm/arm.c \
|
||||
$(CORE_DIR)/src/util/crc32.c
|
||||
|
||||
ifeq ($(HAVE_VFS_FD),1)
|
||||
ifeq ($(platform), vita)
|
||||
SOURCES_C += $(CORE_DIR)/src/platform/psp2/sce-vfs.c
|
||||
else
|
||||
SOURCES_C += $(CORE_DIR)/src/util/vfs/vfs-fd.c
|
||||
endif
|
||||
else
|
||||
SOURCES_C += $(CORE_DIR)/src/util/vfs/vfs-file.c
|
||||
endif
|
||||
|
@ -4,11 +4,20 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/memory.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(GEKKO) || defined(__CELLOS_LV2__)
|
||||
/* stub */
|
||||
#elif defined(VITA)
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
#include <psp2/types.h>
|
||||
DECLARE_VECTOR(SceUIDList, SceUID);
|
||||
DEFINE_VECTOR(SceUIDList, SceUID);
|
||||
|
||||
static struct SceUIDList uids;
|
||||
static bool listInit = false;
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
|
||||
@ -26,6 +35,22 @@ void* anonymousMemoryMap(size_t size) {
|
||||
return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
#elif defined(__CELLOS_LV2__) || defined(GEKKO)
|
||||
return (void*)malloc(size);
|
||||
#elif defined(VITA)
|
||||
if (!listInit)
|
||||
SceUIDListInit(&uids, 8);
|
||||
if (size & 0xFFF)
|
||||
{
|
||||
// Align to 4kB pages
|
||||
size += ((~size) & 0xFFF) + 1;
|
||||
}
|
||||
SceUID memblock = sceKernelAllocMemBlock("anon", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, size, 0);
|
||||
if (memblock < 0)
|
||||
return 0;
|
||||
*SceUIDListAppend(&uids) = memblock;
|
||||
void* ptr;
|
||||
if (sceKernelGetMemBlockBase(memblock, &ptr) < 0)
|
||||
return 0;
|
||||
return ptr;
|
||||
#else
|
||||
return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
#endif
|
||||
@ -38,6 +63,22 @@ void mappedMemoryFree(void* memory, size_t size) {
|
||||
VirtualFree(memory, 0, MEM_RELEASE);
|
||||
#elif defined(__CELLOS_LV2__) || defined(GEKKO)
|
||||
free(memory);
|
||||
#elif defined(VITA)
|
||||
UNUSED(size);
|
||||
size_t i;
|
||||
for (i = 0; i < SceUIDListSize(&uids); ++i)
|
||||
{
|
||||
SceUID uid = *SceUIDListGetPointer(&uids, i);
|
||||
void* ptr;
|
||||
if (sceKernelGetMemBlockBase(uid, &ptr) < 0)
|
||||
continue;
|
||||
if (ptr == memory)
|
||||
{
|
||||
sceKernelFreeMemBlock(uid);
|
||||
SceUIDListUnshift(&uids, i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
munmap(memory, size);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user