1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 00:38:44 +00:00

[ORBIS] Improve memory reservation

This commit is contained in:
Francisco Javier Trujillo Mata 2021-09-19 00:43:42 +02:00
parent 4dd779467d
commit 7a15f81b39
2 changed files with 79 additions and 13 deletions

View File

@ -3,7 +3,7 @@ DEBUG ?= 0
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
HAVE_STATIC_DUMMY ?= 0
HAVE_STATIC_DUMMY ?= 1
HAVE_GLES3 ?= 0
HAVE_MOUSE ?= 0
HAVE_KEYBOARD ?= 0
@ -11,7 +11,7 @@ HAVE_KEYBOARD ?= 0
PS4_TITLE_ID := RETROARCH
PS4_TITLE_NAME := RetroArch
PC_DEVELOPMENT_IP_ADDRESS = 192.168.1.12
PC_DEVELOPMENT_IP_ADDRESS = 192.168.1.137
PC_DEVELOPMENT_UDP_PORT = 18194
DEBUG=1
AUTH_INFO = 000000000000000000000000001C004000FF000000000080000000000000000000000000000000000000008000400040000000000000008000000000000000080040FFFF000000F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -161,13 +161,16 @@ ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_END := --no-whole-archive
endif
PS4_LIBS += -lkernel_stub -lSceLibcInternal_stub -lSceSysmodule_stub -lSceSystemService_stub \
-lSceUserService_stub -lSceAudioOut_stub -lScePad_stub -lSceNet_stub -lSceNetCtl_stub -lScePigletv2VSH_stub -lSceOrbisCompat_stub -lorbis -lSceIme_stub
LIBS := $(WHOLE_START) -lretro_ps4 $(WHOLE_END) $(PS4_LIBS)
PS4_LIBS += -lkernel_stub -lSceLibcInternal_stub -lSceSysmodule_stub -lSceSystemService_stub -lSceNet_stub -lSceUserService_stub \
-lScePigletv2VSH_stub -lSceVideoOut_stub -lSceGnmDriver_stub -lorbisGl2 -lorbis -lScePad_stub -lSceAudioOut_stub \
-lSceIme_stub -lSceNetCtl_stub
# LIBS := $(WHOLE_START) -lretro_ps4 $(WHOLE_END) $(PS4_LIBS)
LIBS := $(WHOLE_START) $(WHOLE_END) $(PS4_LIBS)
CFLAGS := -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -mcmodel=large -Wno-zero-length-array -Wno-format-pedantic -emit-obj -std=c11 $(ARCHFLAGS) $(INCDIRS) $(DEFINES)
CXXFLAGS := -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -Wall -pedantic -m64 -mcmodel=large -Wno-zero-length-array -Wno-format-pedantic -emit-obj -std=c++11 $(ARCHFLAGS) $(INCDIRS) $(DEFINES)
CXXFLAGS := -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -Wall -pedantic -mcmodel=large -Wno-zero-length-array -Wno-format-pedantic -emit-obj -std=c++11 $(ARCHFLAGS) $(INCDIRS) $(DEFINES)
LDFLAGS := -isysroot $(ORBISDEV)/usr -L. -Llib -Wl,--gc-sections -Wl,-z -Wl,max-page-size=0x4000 -Wl,--dynamic-linker="/libexec/ld-elf.so.1" -Wl,-pie -Wl,--eh-frame-hdr -L$(ORBISDEV)/usr/lib -target x86_64-scei-ps4-elf -T $(ORBISDEV)/linker.x
ARFLAGS := rcs
@ -203,7 +206,7 @@ $(TARGET).a: $(OBJ)
#$(OO_PS4_TOOLCHAIN)/bin/$(CDIR)/create-eboot -in=$(TARGET).elf -out=$(TARGET).oelf --paid 0x3800000000000011
install:
@cp homebrew.self /usr/local/orbisdev/git/ps4sh/bin/hostapp
@cp homebrew.self $(SELF_PATH_INSTALL)
@echo "Installed!"
oelf:
@orbis-elf-create $(TARGET).elf homebrew.oelf

View File

@ -54,7 +54,7 @@
#include <libSceSysmodule.h>
#include <defines/ps4_defines.h>
#include "../../memory/ps4/user_mem.h"
// #include "user_mem.h"
#include <pthread.h>
@ -122,6 +122,38 @@ SceKernelModule s_shacc_module;
static enum frontend_fork orbis_fork_mode = FRONTEND_FORK_NONE;
#define MEM_SIZE (3UL * 1024 * 1024 * 1024) /* 2600 MiB */
#define MEM_ALIGN (16UL * 1024)
const char *sceKernelGetFsSandboxRandomWord();
int sceKernelReserveVirtualRange(void **, size_t, int, size_t);
int sceKernelMapNamedSystemFlexibleMemory(void** addrInOut, size_t len, int prot, int flags, const char* name);
typedef void* OrbisMspace;
OrbisMspace sceLibcMspaceCreate(char *, void *, size_t, void *);
void * sceLibcMspaceMalloc(OrbisMspace, size_t size);
void sceLibcMspaceFree(OrbisMspace, void *);
static OrbisMspace s_mspace = 0;
static void *address = 0;
static size_t s_mem_size = MEM_SIZE;
static int max_malloc(size_t initial_value, int increment, const char *desc)
{
char *p_block;
size_t chunk = initial_value;
printf("Check maximum contigous block we can allocate (%s accurate)\n", desc);
while ((p_block = sceLibcMspaceMalloc(s_mspace, ++chunk * increment)) != NULL) {
sceLibcMspaceFree(s_mspace,p_block);
}
chunk--;
printf("Maximum possible %s we can allocate is %i\n", desc, chunk);
return chunk;
}
#if defined(HAVE_TAUON_SDK)
void catchReturnFromMain(int exit_code)
{
@ -260,6 +292,8 @@ static void frontend_orbis_get_env(int *argc, char *argv[],
dir_check_defaults("host0:app/custom.ini");
#endif
RARCH_LOG("[%s][%s][%d]\n",__FILE__,__PRETTY_FUNCTION__,__LINE__);
}
static void frontend_orbis_deinit(void *data)
@ -276,12 +310,39 @@ static void frontend_orbis_shutdown(bool unused)
return;
}
static void prepareMemoryAllocation()
{
int res = sceKernelReserveVirtualRange(&address, MEM_SIZE, 0, MEM_ALIGN);
printf("sceKernelReserveVirtualRange %x %x\n", res, address);
res = sceKernelMapNamedSystemFlexibleMemory(&address, MEM_SIZE, 0x2, 0x0010, "TEST");
printf("sceKernelMapNamedSystemFlexibleMemory %x %x\n", res, address);
s_mspace = sceLibcMspaceCreate("User Mspace", address, MEM_SIZE, 0);
printf("sceLibcMspaceCreate %p \n", s_mspace);
printf("TOTAL MEMORY %d %s\n", max_malloc(0, 1024 * 1024, "MB"), "MB");
}
static bool initApp()
{
int ret=initOrbisLinkAppVanillaGl();
if(ret==0)
{
debugNetInit(PC_DEVELOPMENT_IP_ADDRESS,PC_DEVELOPMENT_UDP_PORT,3);
debugNetPrintf(DEBUGNET_INFO,"[TEMPLATE3] Ready to have a lot of fun\n");
sceSystemServiceHideSplashScreen();
return true;
}
return false;
}
static void frontend_orbis_init(void *data)
{
int ret=initOrbisLinkAppVanillaGl();
sceSystemServiceHideSplashScreen();
printf("[%s][%s][%d]\n",__FILE__,__PRETTY_FUNCTION__,__LINE__);
int ret=initApp();
printf("[%s][%s][%d]\n",__FILE__,__PRETTY_FUNCTION__,__LINE__);
prepareMemoryAllocation();
printf("[%s][%s][%d]\n",__FILE__,__PRETTY_FUNCTION__,__LINE__);
logger_init();
RARCH_LOG("[%s][%s][%d] Hello from retroarch level info\n",__FILE__,__PRETTY_FUNCTION__,__LINE__);
@ -298,6 +359,8 @@ static void frontend_orbis_init(void *data)
verbosity_enable();
printf("[%s][%s][%d]\n",__FILE__,__PRETTY_FUNCTION__,__LINE__);
}
static void frontend_orbis_exec(const char *path, bool should_load_game)
@ -445,7 +508,7 @@ static int frontend_orbis_parse_drive_list(void *data, bool load_content)
// }
frontend_ctx_driver_t frontend_ctx_orbis = {
NULL, /*frontend_orbis_get_env,*/
frontend_orbis_get_env,
frontend_orbis_init,
frontend_orbis_deinit,
frontend_orbis_exitspawn,