X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fnew_dynarec%2Fassem_arm.c;h=95304103c8527f4507b36cf62072e915b1893070;hp=ed89bb05afb786c745dfee6aa9f623baaa0e8bcc;hb=009faf24e665b66283558234920faab03b781d6c;hpb=535d208a8473e9255919b1e5bfe0b5aa88f6992a diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index ed89bb05..95304103 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -66,8 +66,41 @@ const u_int jump_vaddr_reg[16] = { 0, 0}; +void invalidate_addr_r0(); +void invalidate_addr_r1(); +void invalidate_addr_r2(); +void invalidate_addr_r3(); +void invalidate_addr_r4(); +void invalidate_addr_r5(); +void invalidate_addr_r6(); +void invalidate_addr_r7(); +void invalidate_addr_r8(); +void invalidate_addr_r9(); +void invalidate_addr_r10(); +void invalidate_addr_r12(); + +const u_int invalidate_addr_reg[16] = { + (int)invalidate_addr_r0, + (int)invalidate_addr_r1, + (int)invalidate_addr_r2, + (int)invalidate_addr_r3, + (int)invalidate_addr_r4, + (int)invalidate_addr_r5, + (int)invalidate_addr_r6, + (int)invalidate_addr_r7, + (int)invalidate_addr_r8, + (int)invalidate_addr_r9, + (int)invalidate_addr_r10, + 0, + (int)invalidate_addr_r12, + 0, + 0, + 0}; + #include "fpu.h" +unsigned int needs_clear_cache[1<<(TARGET_SIZE_2-17)]; + /* Linker */ void set_jump_target(int addr,u_int target) @@ -2193,6 +2226,13 @@ void emit_addsr12(int rs1,int rs2,int rt) output_w32(0xe0800620|rd_rn_rm(rt,rs1,rs2)); } +void emit_callne(int a) +{ + assem_debug("blne %x\n",a); + u_int offset=genjmp(a); + output_w32(0x1b000000|offset); +} + // Used to preload hash table entries void emit_prefetch(void *addr) { @@ -2562,6 +2602,10 @@ emit_extjump_ds(int addr, int target) emit_extjump2(addr, target, (int)dyna_linker_ds); } +#ifdef PCSX +#include "pcsxmem_inline.c" +#endif + do_readstub(int n) { assem_debug("do_readstub %x\n",start+stubs[n][3]*4); @@ -2615,7 +2659,9 @@ do_readstub(int n) } emit_movimm(ftable,0); emit_addimm(cc<0?2:cc,2*stubs[n][6]+2,2); +#ifndef PCSX emit_movimm(start+stubs[n][3]*4+(((regs[i].was32>>rs1[i])&1)<<1)+ds,3); +#endif //emit_readword((int)&last_count,temp); //emit_add(cc,temp,cc); //emit_writeword(cc,(int)&Count); @@ -2623,6 +2669,7 @@ do_readstub(int n) emit_call((int)&indirect_jump_indexed); //emit_callreg(rs); //emit_readword_dualindexedx4(rs,HOST_TEMPREG,15); +#ifndef PCSX // We really shouldn't need to update the count here, // but not doing so causes random crashes... emit_readword((int)&Count,HOST_TEMPREG); @@ -2633,6 +2680,7 @@ do_readstub(int n) if(cc<0) { emit_storereg(CCREG,HOST_TEMPREG); } +#endif //emit_popa(); restore_regs(reglist); //if((cc=get_reg(regmap,CCREG))>=0) { @@ -2677,6 +2725,10 @@ inline_readstub(int type, int i, u_int addr, signed char regmap[], int target, i ftable=(int)readmemd; #endif assert(ftable!=0); +#ifdef PCSX + if(pcsx_direct_read(type,addr,target?rs:-1,rt)) + return; +#endif if(target==0) emit_movimm(addr,rs); emit_writeword(rs,(int)&address); @@ -2691,15 +2743,18 @@ inline_readstub(int type, int i, u_int addr, signed char regmap[], int target, i emit_movimm(((u_int *)ftable)[addr>>16],0); //emit_readword((int)&last_count,12); emit_addimm(cc<0?2:cc,CLOCK_DIVIDER*(adj+1),2); +#ifndef PCSX if((signed int)addr>=(signed int)0xC0000000) { // Pagefault address int ds=regmap!=regs[i].regmap; emit_movimm(start+i*4+(((regs[i].was32>>rs1[i])&1)<<1)+ds,3); } +#endif //emit_add(12,2,2); //emit_writeword(2,(int)&Count); //emit_call(((u_int *)ftable)[addr>>16]); emit_call((int)&indirect_jump); +#ifndef PCSX // We really shouldn't need to update the count here, // but not doing so causes random crashes... emit_readword((int)&Count,HOST_TEMPREG); @@ -2710,6 +2765,7 @@ inline_readstub(int type, int i, u_int addr, signed char regmap[], int target, i if(cc<0) { emit_storereg(CCREG,HOST_TEMPREG); } +#endif //emit_popa(); restore_regs(reglist); if(rt>=0) { @@ -2799,7 +2855,9 @@ do_writestub(int n) } emit_movimm(ftable,0); emit_addimm(cc<0?2:cc,2*stubs[n][6]+2,2); +#ifndef PCSX emit_movimm(start+stubs[n][3]*4+(((regs[i].was32>>rs1[i])&1)<<1)+ds,3); +#endif //emit_readword((int)&last_count,temp); //emit_addimm(cc,2*stubs[n][5]+2,cc); //emit_add(cc,temp,cc); @@ -2829,6 +2887,10 @@ inline_writestub(int type, int i, u_int addr, signed char regmap[], int target, int rt=get_reg(regmap,target); assert(rs>=0); assert(rt>=0); +#ifdef PCSX + if(pcsx_direct_write(type,addr,rs,rt,regmap)) + return; +#endif int ftable=0; if(type==STOREB_STUB) ftable=(int)writememb; @@ -2869,11 +2931,13 @@ inline_writestub(int type, int i, u_int addr, signed char regmap[], int target, emit_movimm(((u_int *)ftable)[addr>>16],0); //emit_readword((int)&last_count,12); emit_addimm(cc<0?2:cc,CLOCK_DIVIDER*(adj+1),2); +#ifndef PCSX if((signed int)addr>=(signed int)0xC0000000) { // Pagefault address int ds=regmap!=regs[i].regmap; emit_movimm(start+i*4+(((regs[i].was32>>rs1[i])&1)<<1)+ds,3); } +#endif //emit_add(12,2,2); //emit_writeword(2,(int)&Count); //emit_call(((u_int *)ftable)[addr>>16]); @@ -2928,7 +2992,10 @@ do_unalignedwritestub(int n) } emit_movimm((u_int)readmem,0); emit_addimm(cc<0?2:cc,2*stubs[n][6]+2,2); - emit_movimm(start+stubs[n][3]*4+(((regs[i].was32>>rs1[i])&1)<<1)+ds,3); // XXX: can be rm'd? +#ifndef PCSX + // pagefault address + emit_movimm(start+stubs[n][3]*4+(((regs[i].was32>>rs1[i])&1)<<1)+ds,3); +#endif emit_call((int)&indirect_jump_indexed); restore_regs(reglist); @@ -3690,10 +3757,11 @@ void c2op_assemble(int i,struct regstat *i_regs) if (gte_handlers[c2op]!=NULL) { int cc=get_reg(i_regs->regmap,CCREG); - emit_movimm(source[i],temp); // opcode + emit_movimm(source[i],1); // opcode if (cc>=0&>e_cycletab[c2op]) - emit_addimm(cc,gte_cycletab[c2op]/2,cc); // XXX: cound just adjust ccadj? - emit_writeword(temp,(int)&psxRegs.code); + emit_addimm(cc,gte_cycletab[c2op]/2,cc); // XXX: could just adjust ccadj? + emit_addimm(FP,(int)&psxRegs.CP2D.r[0]-(int)&dynarec_local,0); // cop2 regs + emit_writeword(1,(int)&psxRegs.code); emit_call((int)gte_handlers[c2op]); } @@ -4784,6 +4852,38 @@ void wb_invalidate_arm(signed char pre[],signed char entry[],uint64_t dirty,uint #define wb_invalidate wb_invalidate_arm */ +// Clearing the cache is rather slow on ARM Linux, so mark the areas +// that need to be cleared, and then only clear these areas once. +void do_clear_cache() +{ + int i,j; + for (i=0;i<(1<<(TARGET_SIZE_2-17));i++) + { + u_int bitmap=needs_clear_cache[i]; + if(bitmap) { + u_int start,end; + for(j=0;j<32;j++) + { + if(bitmap&(1<