#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#ifdef __MACH__
+#include <unistd.h>
+#include <sys/syscall.h>
+#endif
#include "../libpcsxcore/misc.h"
#include "../libpcsxcore/psxcounters.h"
enum psxMapTag tag;
}psx_map_t;
+void* addr = NULL;
+
psx_map_t custom_psx_maps[] = {
{NULL, NULL, 0x210000, MAP_TAG_RAM}, // 0x80000000
{NULL, NULL, 0x010000, MAP_TAG_OTHER}, // 0x1f800000
{NULL, NULL, 0x200000, MAP_TAG_VRAM}, // 0x00000000
};
+int init_vita_mmap(){
+ int n;
+ void * tmpaddr;
+ addr = malloc(64*1024*1024);
+ if(addr==NULL)
+ return -1;
+ tmpaddr = ((u32)(addr+0xFFFFFF))&~0xFFFFFF;
+ custom_psx_maps[0].buffer=tmpaddr+0x2000000;
+ custom_psx_maps[1].buffer=tmpaddr+0x1800000;
+ custom_psx_maps[2].buffer=tmpaddr+0x1c00000;
+ custom_psx_maps[3].buffer=tmpaddr+0x0000000;
+ custom_psx_maps[4].buffer=tmpaddr+0x1000000;
+#if 0
+ for(n = 0; n < 5; n++){
+ sceClibPrintf("addr reserved %x\n",custom_psx_maps[n].buffer);
+ }
+#endif
+ return 0;
+}
+
+void deinit_vita_mmap(){
+ free(addr);
+}
+
void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed,
enum psxMapTag tag)
{
{
if ((custom_map->size == size) && (custom_map->tag == tag))
{
- int block, ret;
- char blockname[32];
- sprintf(blockname, "CODE 0x%08X",tag);
-
- block = sceKernelAllocMemBlock(blockname, size + 0x1000);
- if(block<=0){
- sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, tag);
- exit(1);
- }
-
- // get base address
- ret = sceKernelGetMemBlockBase(block, &custom_map->buffer);
- if (ret < 0)
- {
- sceClibPrintf("could get address @0x%08X 0x%08X 0x%08X \n", block, ret, tag);
- exit(1);
- }
- custom_map->buffer = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF;
- custom_map->target_map = block;
-
return custom_map->buffer;
}
}
{
if ((custom_map->buffer == ptr))
{
- sceKernelFreeMemBlock(custom_map->target_map);
- custom_map->buffer = NULL;
- custom_map->target_map = NULL;
return;
}
}
int i, ret;
bool found_bios = false;
+#ifdef __MACH__
+ // magic sauce to make the dynarec work on iOS
+ syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0);
+#endif
+
#ifdef _3DS
psxMapHook = pl_3ds_mmap;
psxUnmapHook = pl_3ds_munmap;
#endif
#ifdef VITA
+ if(init_vita_mmap()<0)
+ abort();
psxMapHook = pl_vita_mmap;
psxUnmapHook = pl_vita_munmap;
#endif
ret = emu_core_preinit();
-#ifdef _3DS
+#ifdef _3DS
/* emu_core_preinit sets the cpu to dynarec */
if(!__ctr_svchax)
Config.Cpu = CPU_INTERPRETER;
#endif
+ Config.Cpu = CPU_INTERPRETER;
+
ret |= emu_core_init();
if (ret != 0) {
SysPrintf("PCSX init failed.\n");
free(vout_buf);
#endif
vout_buf = NULL;
+
+#ifdef VITA
+ deinit_vita_mmap();
+#endif
}
#ifdef VITA