Add dynarec support for PS3

This commit is contained in:
OsirizX 2023-01-11 09:46:50 -08:00 committed by irixxxx
parent 0512a22869
commit 08be5f1dab
3 changed files with 31 additions and 4 deletions

View file

@ -188,13 +188,9 @@ else ifneq (,$(filter $(platform), ps3 psl1ght))
CFLAGS += -DFAMEC_NO_GOTOS -D__PS3__
STATIC_LINKING = 1
STATIC_LINKING_LINK = 1
NO_MMAP = 1
ifeq ($(platform), psl1ght)
FLAGS += -D__PSL1GHT__
endif
# PS3 has memory mapped in a way not suitable for DRC
use_sh2drc = 0
use_svpdrc = 0
# PSP
else ifeq ($(platform), psp1)

View file

@ -40,6 +40,7 @@
// reserved: r0(zero), r1(stack), r2(TOC), r13(TID)
// additionally reserved on OSX: r31(PIC), r30(frame), r11(parentframe)
// for OSX PIC code, on function calls r12 must contain the called address
#define TOC_REG 2
#define RET_REG 3
#define PARAM_REGS { 3, 4, 5, 6, 7, 8, 9, 10 }
#define PRESERVED_REGS { 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }
@ -1506,19 +1507,36 @@ static int emith_cond_check(int cond)
#define emith_call_cond(cond, target) \
emith_call(target)
#ifdef __PS3__
#define emith_call_reg(r) do { \
emith_read_r_r_offs_ptr(TOC_REG, r, 8); \
emith_read_r_r_offs_ptr(r, r, 0); \
EMIT(PPC_MTSP_REG(r, CTR)); \
EMIT(PPC_BLCTRCOND(BXX)); \
} while(0)
#else
#define emith_call_reg(r) do { \
EMIT(PPC_MTSP_REG(r, CTR)); \
EMIT(PPC_BLCTRCOND(BXX)); \
} while(0)
#endif
#define emith_abicall_ctx(offs) do { \
emith_ctx_read_ptr(CR, offs); \
emith_call_reg(CR); \
} while (0)
#ifdef __PS3__
#define emith_abijump_reg(r) \
if ((r) != CR) emith_move_r_r(CR, r); \
emith_read_r_r_offs_ptr(TOC_REG, CR, 8); \
emith_read_r_r_offs_ptr(CR, CR, 0); \
emith_jump_reg(CR)
#else
#define emith_abijump_reg(r) \
if ((r) != CR) emith_move_r_r(CR, r); \
emith_jump_reg(CR)
#endif
#define emith_abijump_reg_c(cond, r) \
emith_abijump_reg(r)
#define emith_abicall(target) \

View file

@ -62,6 +62,12 @@ static int ctr_svchack_successful = 0;
static int sceBlock;
int getVMBlock();
int _newlib_vm_size_user = 1 << TARGET_SIZE_2;
#elif defined(__PS3__)
#include <sys/process.h>
#include <ps3mapi_ps3_lib.h>
static uint64_t page_table[2] = {0, 0};
#endif
#include "libretro_core_options.h"
@ -471,6 +477,9 @@ void *plat_mem_get_for_drc(size_t size)
// For WiiU, a slice of RWX memory left from the exploit is used, see:
// https://github.com/embercold/pcsx_rearmed/commit/af0453223
mem = (void *)(0x01000000 - size);
#elif defined __PS3__
ps3mapi_process_page_allocate(sysProcessGetPid(), size, PAGE_SIZE_AUTO, 0x2F, 1, page_table);
mem = (void *)page_table[0];
#endif
return mem;
}
@ -2374,6 +2383,10 @@ void retro_deinit(void)
free(vout_buf);
free(retro_palette);
ps2 = NULL;
#elif defined(__PS3__)
free(vout_buf);
if (page_table[0] > 0 && page_table[1] > 0)
ps3mapi_process_page_free(sysProcessGetPid(), 0x2F, page_table);
#else
free(vout_buf);
#endif