diff --git a/Makefile.vita b/Makefile.vita index b439a29468..90b3f0a118 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -158,7 +158,7 @@ $(TARGET).elf: $(OBJ) libretro_vita.a vita-make-fself -c -s $< $@ %.vpk: %.self - vita-mksfoex -s TITLE_ID=$(VITA_TITLE_ID) "$(VITA_TITLE_NAME)" param.sfo + vita-mksfoex -s TITLE_ID=$(VITA_TITLE_ID) "$(VITA_TITLE_NAME)" -d ATTRIBUTE2=12 param.sfo vita-pack-vpk -s param.sfo -b $< $@ clean: diff --git a/Makefile.vita.salamander b/Makefile.vita.salamander index 7a7959ed8b..eaee618249 100644 --- a/Makefile.vita.salamander +++ b/Makefile.vita.salamander @@ -55,7 +55,7 @@ OBJS = frontend/frontend_salamander.o \ all: $(TARGET).vpk %.vpk: eboot.bin - vita-mksfoex -s TITLE_ID=$(TITLE_ID) "$(TARGET)" param.sfo + vita-mksfoex -s TITLE_ID=$(TITLE_ID) "$(TARGET)" -d ATTRIBUTE2=12 param.sfo vita-pack-vpk -s param.sfo -b eboot.bin $@ eboot.bin: $(TARGET).velf diff --git a/bootstrap/vita/sbrk.c b/bootstrap/vita/sbrk.c index 991e2f6c18..11164c9c89 100644 --- a/bootstrap/vita/sbrk.c +++ b/bootstrap/vita/sbrk.c @@ -4,9 +4,11 @@ #include <psp2/kernel/sysmem.h> #include <psp2/kernel/threadmgr.h> +#define RAM_THRESHOLD 0xA00000 // Memory left to the system for threads and other internal stuffs + static int _newlib_heap_memblock; static unsigned _newlib_heap_size; -static char *_newlib_heap_base, *_newlib_heap_end, *_newlib_heap_cur; +char *_newlib_heap_base, *_newlib_heap_end, *_newlib_heap_cur; static char _newlib_sbrk_mutex[32] __attribute__ ((aligned (8))); static int _newlib_vm_memblock; @@ -50,11 +52,16 @@ void _init_vita_heap(void) { if (sceKernelCreateLwMutex((struct SceKernelLwMutexWork*)_newlib_sbrk_mutex, "sbrk mutex", 0, 0, 0) < 0) { goto failure; } + + // Always allocating the max avaliable USER_RW mem on the system + SceKernelFreeMemorySizeInfo info; + info.size = sizeof(SceKernelFreeMemorySizeInfo); + sceKernelGetFreeMemorySize(&info); if (&_newlib_heap_size_user != NULL) { _newlib_heap_size = _newlib_heap_size_user; }else{ - _newlib_heap_size = 256 * 1024 * 1024; + _newlib_heap_size = info.size_user - RAM_THRESHOLD; } _newlib_heap_size -= _newlib_vm_size; diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 64e182c6f2..9944b26fff 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -560,6 +560,16 @@ enum retro_language frontend_psp_get_user_language(void) sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &langid); return psp_get_retro_lang_from_langid(langid); } + +static uint64_t frontend_psp_get_mem_total(void) +{ + return _newlib_heap_end - _newlib_heap_base; +} + +static uint64_t frontend_psp_get_mem_used(void) +{ + return _newlib_heap_end - _newlib_heap_cur; +} #endif frontend_ctx_driver_t frontend_ctx_psp = { @@ -582,8 +592,13 @@ frontend_ctx_driver_t frontend_ctx_psp = { frontend_psp_get_architecture, frontend_psp_get_powerstate, frontend_psp_parse_drive_list, +#ifdef VITA + frontend_psp_get_mem_total, + frontend_psp_get_mem_used, +#else NULL, /* get_mem_total */ NULL, /* get_mem_free */ +#endif NULL, /* install_signal_handler */ NULL, /* get_sighandler_state */ NULL, /* set_sighandler_state */