Skip to content

Commit

Permalink
add extra ram patch to standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Sep 12, 2024
1 parent 37cd14f commit f709b1e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
4 changes: 2 additions & 2 deletions core/compat/pentazemin/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ void AdrenalineOnModuleStart(SceModule2 * mod){
if (strcmp(mod->modname, "sceImpose_Driver") == 0) {
PatchImposeDriver(mod->text_addr);
// perfect time to apply extra memory patch
if (se_config->force_high_memory) unlockVitaMemory();
if (se_config->force_high_memory) unlockVitaMemory(52);
else{
int apitype = sceKernelInitApitype();
if (apitype == 0x141){
int paramsize=4;
int use_highmem = 0;
if (sctrlGetInitPARAM("MEMSIZE", NULL, &paramsize, &use_highmem) >= 0 && use_highmem){
unlockVitaMemory();
unlockVitaMemory(52);
se_config->force_high_memory = 1;
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/compat/pentazemin/vitamem.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <systemctrl.h>
#include "sysmem.h"

void unlockVitaMemory(){
void unlockVitaMemory(u32 user_size_mib){

int apitype = sceKernelInitApitype(); // prevent in pops and vsh
if (apitype == 0x144 || apitype == 0x155 || apitype == 0x200 || apitype == 0x210 || apitype == 0x220 || apitype == 0x300)
Expand All @@ -35,7 +35,7 @@ void unlockVitaMemory(){


u32 kernel_size = 0; // EXTRA_RAM_SIZE - extra_user_ram; // p11 size
u32 user_size = 52 * 1024 * 1024; // new p2 size
u32 user_size = user_size_mib * 1024 * 1024; // new p2 size

// modify p2
partition = GetPartition(PSP_MEMORY_PARTITION_USER);
Expand All @@ -48,5 +48,5 @@ void unlockVitaMemory(){
partition->address = 0x88800000 + user_size;
partition->data->size = (((kernel_size >> 8) << 9) | 0xFC);

sctrlHENSetMemory(52, 0);
sctrlHENSetMemory(user_size_mib, 0);
}
1 change: 1 addition & 0 deletions core/compat/vita/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ C_OBJS = \
filesystem.o \
$(ARKROOT)/libs/libsploit/patches.o \
$(ARKROOT)/core/compat/psp/cwpatch.o \
$(ARKROOT)/core/compat/pentazemin/vitamem.o \
$(ARKROOT)/core/systemctrl/src/dummy.o \

OBJS = \
Expand Down
2 changes: 1 addition & 1 deletion core/compat/vita/rebootex/patches.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void SetMemoryPartitionTablePatched(void *sysmem_config, SceSysmemPartTable *tab
// Add flash0 ramfs as partition 11
SetMemoryPartitionTable(sysmem_config, table);
table->extVshell.addr = EXTRA_RAM;
table->extVshell.size = EXTRA_RAM_SIZE;
table->extVshell.size = 12*1024*1024;
}

int PatchSysMem(void *a0, void *sysmem_config)
Expand Down
54 changes: 33 additions & 21 deletions core/compat/vita/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,39 @@ void ARKVitaOnModuleStart(SceModule2 * mod){
goto flush;
}

if (strcmp(mod->modname, "sceImpose_Driver") == 0) {
// perfect time to apply extra memory patch
if (se_config->force_high_memory) unlockVitaMemory(36);
else{
int apitype = sceKernelInitApitype();
if (apitype == 0x141){
int paramsize=4;
int use_highmem = 0;
if (sctrlGetInitPARAM("MEMSIZE", NULL, &paramsize, &use_highmem) >= 0 && use_highmem){
unlockVitaMemory(36);
se_config->force_high_memory = 1;
}
}
}
// enable inferno cache
if (se_config->iso_cache){
int (*CacheInit)(int, int, int) = sctrlHENFindFunction("PRO_Inferno_Driver", "inferno_driver", 0x8CDE7F95);
if (CacheInit){
se_config->iso_cache_size = 32 * 1024;
se_config->iso_cache_num = 64;
CacheInit(32 * 1024, 64, (se_config->force_high_memory)?2:11); // 2MB cache for Adrenaline
}
if (se_config->iso_cache == 2){
int (*CacheSetPolicy)(int) = sctrlHENFindFunction("PRO_Inferno_Driver", "inferno_driver", 0xC0736FD6);
if (CacheSetPolicy){
se_config->iso_cache_policy = CACHE_POLICY_RR;
CacheSetPolicy(CACHE_POLICY_RR);
}
}
}
goto flush;
}

// Boot Complete Action not done yet
if(booted == 0)
{
Expand All @@ -147,30 +180,9 @@ void ARKVitaOnModuleStart(SceModule2 * mod){
if (se_config->msspeed)
msstorCacheInit("ms");

// enable inferno cache
if (se_config->iso_cache){
int (*CacheInit)(int, int, int) = sctrlHENFindFunction("PRO_Inferno_Driver", "inferno_driver", 0x8CDE7F95);
if (CacheInit){
se_config->iso_cache_size = 4 * 1024;
se_config->iso_cache_num = 16;
CacheInit(4 * 1024, 16, 1); // 64KB cache for PS Vita standalone, in kernel
}
if (se_config->iso_cache == 2){
int (*CacheSetPolicy)(int) = sctrlHENFindFunction("PRO_Inferno_Driver", "inferno_driver", 0xC0736FD6);
if (CacheSetPolicy){
se_config->iso_cache_policy = CACHE_POLICY_RR;
CacheSetPolicy(CACHE_POLICY_RR);
}
}
}

// Apply Directory IO PSP Emulation
patchFileSystemDirSyscall();

// Patch to redirect flash to ms0
//patchFileIO();
//redirectFlashFileSystem();

// Patch sceKernelExitGame Syscalls
REDIRECT_FUNCTION(sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x05572A5F), K_EXTRACT_IMPORT(exitLauncher));
REDIRECT_FUNCTION(sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x2AC9954B), K_EXTRACT_IMPORT(exitLauncher));
Expand Down
1 change: 1 addition & 0 deletions extras/menus/arkMenu/include/ark_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ settings_entry* ark_conf_entries_vita[] = {
(settings_entry*)&pspclock,
(settings_entry*)&powersave,
(settings_entry*)&defaultclock,
(settings_entry*)&highmem,
(settings_entry*)&mscache,
(settings_entry*)&infernocache,
};
Expand Down

0 comments on commit f709b1e

Please sign in to comment.