notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
drc: possibly the missing piece for Vita
[pcsx_rearmed.git]
/
libpcsxcore
/
new_dynarec
/
new_dynarec.c
diff --git
a/libpcsxcore/new_dynarec/new_dynarec.c
b/libpcsxcore/new_dynarec/new_dynarec.c
index
27d9d46
..
e937b76
100644
(file)
--- a/
libpcsxcore/new_dynarec/new_dynarec.c
+++ b/
libpcsxcore/new_dynarec/new_dynarec.c
@@
-29,10
+29,6
@@
#ifdef _3DS
#include <3ds_utils.h>
#endif
#ifdef _3DS
#include <3ds_utils.h>
#endif
-#ifdef VITA
-#include <psp2/kernel/sysmem.h>
-static int sceBlock;
-#endif
#include "new_dynarec_config.h"
#include "../psxhle.h"
#include "new_dynarec_config.h"
#include "../psxhle.h"
@@
-354,6
+350,14
@@
static void pass_args(int a0, int a1);
static void emit_far_jump(const void *f);
static void emit_far_call(const void *f);
static void emit_far_jump(const void *f);
static void emit_far_call(const void *f);
+#ifdef VITA
+#include <psp2/kernel/sysmem.h>
+static int sceBlock;
+// note: this interacts with RetroArch's Vita bootstrap code: bootstrap/vita/sbrk.c
+extern int getVMBlock();
+int _newlib_vm_size_user = sizeof(*ndrc);
+#endif
+
static void mprotect_w_x(void *start, void *end, int is_x)
{
#ifdef NO_WRITE_EXEC
static void mprotect_w_x(void *start, void *end, int is_x)
{
#ifdef NO_WRITE_EXEC
@@
-6789,7
+6793,7
@@
static void new_dynarec_test(void)
SysPrintf("linkage_arm* miscompilation/breakage detected.\n");
}
SysPrintf("linkage_arm* miscompilation/breakage detected.\n");
}
- SysPrintf("testing if we can run recompiled code
...\n"
);
+ SysPrintf("testing if we can run recompiled code
@%p...\n", out
);
((volatile u_int *)out)[0]++; // make cache dirty
for (i = 0; i < ARRAY_SIZE(ret); i++) {
((volatile u_int *)out)[0]++; // make cache dirty
for (i = 0; i < ARRAY_SIZE(ret); i++) {
@@
-6841,14
+6845,22
@@
void new_dynarec_init(void)
{
SysPrintf("Init new dynarec\n");
{
SysPrintf("Init new dynarec\n");
+#ifdef _3DS
+ check_rosalina();
+#endif
#ifdef BASE_ADDR_DYNAMIC
#ifdef VITA
#ifdef BASE_ADDR_DYNAMIC
#ifdef VITA
- sceBlock =
sceKernelAllocMemBlockForVM("code", 1 << TARGET_SIZE_2
);
+ sceBlock =
getVMBlock(); //sceKernelAllocMemBlockForVM("code", sizeof(*ndrc)
);
if (sceBlock < 0)
SysPrintf("sceKernelAllocMemBlockForVM failed\n");
int ret = sceKernelGetMemBlockBase(sceBlock, (void **)&ndrc);
if (ret < 0)
SysPrintf("sceKernelGetMemBlockBase failed\n");
if (sceBlock < 0)
SysPrintf("sceKernelAllocMemBlockForVM failed\n");
int ret = sceKernelGetMemBlockBase(sceBlock, (void **)&ndrc);
if (ret < 0)
SysPrintf("sceKernelGetMemBlockBase failed\n");
+ sceKernelOpenVMDomain();
+ sceClibPrintf("translation_cache = 0x%08lx\n ", (long)ndrc->translation_cache);
+ #elif defined(_MSC_VER)
+ ndrc = VirtualAlloc(NULL, sizeof(*ndrc), MEM_COMMIT | MEM_RESERVE,
+ PAGE_EXECUTE_READWRITE);
#else
uintptr_t desired_addr = 0;
#ifdef __ELF__
#else
uintptr_t desired_addr = 0;
#ifdef __ELF__
@@
-6866,7
+6878,8
@@
void new_dynarec_init(void)
#else
#ifndef NO_WRITE_EXEC
// not all systems allow execute in data segment by default
#else
#ifndef NO_WRITE_EXEC
// not all systems allow execute in data segment by default
- if (mprotect(ndrc, sizeof(ndrc->translation_cache) + sizeof(ndrc->tramp.ops),
+ // size must be 4K aligned for 3DS?
+ if (mprotect(ndrc, sizeof(*ndrc),
PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
SysPrintf("mprotect() failed: %s\n", strerror(errno));
#endif
PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
SysPrintf("mprotect() failed: %s\n", strerror(errno));
#endif
@@
-6890,8
+6903,8
@@
void new_dynarec_cleanup(void)
int n;
#ifdef BASE_ADDR_DYNAMIC
#ifdef VITA
int n;
#ifdef BASE_ADDR_DYNAMIC
#ifdef VITA
- sceKernelFreeMemBlock(sceBlock);
- sceBlock = -1;
+
//
sceKernelFreeMemBlock(sceBlock);
+
//
sceBlock = -1;
#else
if (munmap(ndrc, sizeof(*ndrc)) < 0)
SysPrintf("munmap() failed\n");
#else
if (munmap(ndrc, sizeof(*ndrc)) < 0)
SysPrintf("munmap() failed\n");
@@
-7154,9
+7167,9
@@
int new_recompile_block(u_int addr)
/* Pass 1 disassembly */
/* Pass 1 disassembly */
- for
(i=0;!done;i++) {
- dops[i].bt=0;
-
dops[i].ooo=0
;
+ for
(i = 0; !done; i++)
+ {
+
memset(&dops[i], 0, sizeof(dops[i]))
;
op2=0;
minimum_free_regs[i]=0;
dops[i].opcode=op=source[i]>>26;
op2=0;
minimum_free_regs[i]=0;
dops[i].opcode=op=source[i]>>26;
@@
-7596,12
+7609,12
@@
int new_recompile_block(u_int addr)
do_in_intrp=1;
}
}
do_in_intrp=1;
}
}
- if(do_in_intrp) {
-
dops[i-1].rs1=CCREG
;
- dops[i-1].
rs2=dops[i-1].rt1=dops[i-1].rt2=0
;
-
ba[i-1]=-1
;
-
dops[i-1].itype=INTCALL
;
- done
=
2;
+ if
(do_in_intrp) {
+
memset(&dops[i-1], 0, sizeof(dops[i-1]))
;
+ dops[i-1].
itype = INTCALL
;
+
dops[i-1].rs1 = CCREG
;
+
ba[i-1] = -1
;
+ done
=
2;
i--; // don't compile the DS
}
}
i--; // don't compile the DS
}
}
@@
-7710,7
+7723,10
@@
int new_recompile_block(u_int addr)
current.u=branch_unneeded_reg[i]&~((1LL<<dops[i+1].rs1)|(1LL<<dops[i+1].rs2));
current.u&=~((1LL<<dops[i].rs1)|(1LL<<dops[i].rs2));
current.u|=1;
current.u=branch_unneeded_reg[i]&~((1LL<<dops[i+1].rs1)|(1LL<<dops[i+1].rs2));
current.u&=~((1LL<<dops[i].rs1)|(1LL<<dops[i].rs2));
current.u|=1;
- } else { SysPrintf("oops, branch at end of block with no delay slot\n");abort(); }
+ } else {
+ SysPrintf("oops, branch at end of block with no delay slot @%08x\n", start + i*4);
+ abort();
+ }
}
dops[i].is_ds=ds;
if(ds) {
}
dops[i].is_ds=ds;
if(ds) {