X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fnew_dynarec%2Fnew_dynarec.c;h=fb42a90a721a2e02d4e371a86182b8a50a872823;hp=9b8f153c0fbcf82852cb17eb60102fe3ac72ef57;hb=3d624f890e4350179851e958fe071b2fd7a56bec;hpb=57871462a0b157066bbc4a763c59b61085436609 diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 9b8f153c..fb42a90a 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -22,14 +22,7 @@ #include //include for uint64_t #include -#include "../recomp.h" -#include "../recomph.h" //include for function prototypes -#include "../macros.h" -#include "../r4300.h" -#include "../ops.h" -#include "../interupt.h" - -#include "../../memory/memory.h" +#include "emu_if.h" //emulator interface #include @@ -258,8 +251,9 @@ void nullf() {} #define assem_debug nullf #define inv_debug nullf -void tlb_hacks() +static void tlb_hacks() { +#ifndef DISABLE_TLB // Goldeneye hack if (strncmp((char *) ROM_HEADER->nom, "GOLDENEYE",9) == 0) { @@ -301,18 +295,35 @@ void tlb_hacks() } } } +#endif } -// Get address from virtual address -// This is called from the recompiled JR/JALR instructions -void *get_addr(u_int vaddr) +static u_int get_page(u_int vaddr) { u_int page=(vaddr^0x80000000)>>12; - u_int vpage=page; +#ifndef DISABLE_TLB if(page>262143&&tlb_LUT_r[vaddr>>12]) page=(tlb_LUT_r[vaddr>>12]^0x80000000)>>12; +#endif if(page>2048) page=2048+(page&2047); + return page; +} + +static u_int get_vpage(u_int vaddr) +{ + u_int vpage=(vaddr^0x80000000)>>12; +#ifndef DISABLE_TLB if(vpage>262143&&tlb_LUT_r[vaddr>>12]) vpage&=2047; // jump_dirty uses a hash of the virtual address instead +#endif if(vpage>2048) vpage=2048+(vpage&2047); + return vpage; +} + +// Get address from virtual address +// This is called from the recompiled JR/JALR instructions +void *get_addr(u_int vaddr) +{ + u_int page=get_page(vaddr); + u_int vpage=get_vpage(vaddr); struct ll_entry *head; //printf("TRACE: count=%d next=%d (get_addr %x,page %d)\n",Count,next_interupt,vaddr,page); head=jump_in[page]; @@ -339,10 +350,12 @@ void *get_addr(u_int vaddr) invalid_code[vaddr>>12]=0; memory_map[vaddr>>12]|=0x40000000; if(vpage<2048) { +#ifndef DISABLE_TLB if(tlb_LUT_r[vaddr>>12]) { invalid_code[tlb_LUT_r[vaddr>>12]>>12]=0; memory_map[tlb_LUT_r[vaddr>>12]>>12]|=0x40000000; } +#endif restore_candidate[vpage>>3]|=1<<(vpage&7); } else restore_candidate[page>>3]|=1<<(page&7); @@ -390,12 +403,8 @@ void *get_addr_32(u_int vaddr,u_int flags) int *ht_bin=hash_table[((vaddr>>16)^vaddr)&0xFFFF]; if(ht_bin[0]==vaddr) return (void *)ht_bin[1]; if(ht_bin[2]==vaddr) return (void *)ht_bin[3]; - u_int page=(vaddr^0x80000000)>>12; - u_int vpage=page; - if(page>262143&&tlb_LUT_r[vaddr>>12]) page=(tlb_LUT_r[vaddr>>12]^0x80000000)>>12; - if(page>2048) page=2048+(page&2047); - if(vpage>262143&&tlb_LUT_r[vaddr>>12]) vpage&=2047; // jump_dirty uses a hash of the virtual address instead - if(vpage>2048) vpage=2048+(vpage&2047); + u_int page=get_page(vaddr); + u_int vpage=get_vpage(vaddr); struct ll_entry *head; head=jump_in[page]; while(head!=NULL) { @@ -430,10 +439,12 @@ void *get_addr_32(u_int vaddr,u_int flags) invalid_code[vaddr>>12]=0; memory_map[vaddr>>12]|=0x40000000; if(vpage<2048) { +#ifndef DISABLE_TLB if(tlb_LUT_r[vaddr>>12]) { invalid_code[tlb_LUT_r[vaddr>>12]>>12]=0; memory_map[tlb_LUT_r[vaddr>>12]>>12]|=0x40000000; } +#endif restore_candidate[vpage>>3]|=1<<(vpage&7); } else restore_candidate[page>>3]|=1<<(page&7); @@ -974,9 +985,7 @@ void *check_addr(u_int vaddr) if(((ht_bin[3]-MAX_OUTPUT_BLOCK_SIZE-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2))) if(isclean(ht_bin[3])) return (void *)ht_bin[3]; } - u_int page=(vaddr^0x80000000)>>12; - if(page>262143&&tlb_LUT_r[vaddr>>12]) page=(tlb_LUT_r[vaddr>>12]^0x80000000)>>12; - if(page>2048) page=2048+(page&2047); + u_int page=get_page(vaddr); struct ll_entry *head; head=jump_in[page]; while(head!=NULL) { @@ -1104,12 +1113,8 @@ int invalidate_page(u_int page) void invalidate_block(u_int block) { int modified; - u_int page,vpage; - page=vpage=block^0x80000; - if(page>262143&&tlb_LUT_r[block]) page=(tlb_LUT_r[block]^0x80000000)>>12; - if(page>2048) page=2048+(page&2047); - if(vpage>262143&&tlb_LUT_r[block]) vpage&=2047; // jump_dirty uses a hash of the virtual address instead - if(vpage>2048) vpage=2048+(vpage&2047); + u_int page=get_page(block<<12); + u_int vpage=get_vpage(block<<12); inv_debug("INVALIDATE: %x (%d)\n",block<<12,page); //inv_debug("invalid_code[block]=%d\n",invalid_code[block]); u_int first,last; @@ -1152,6 +1157,7 @@ void invalidate_block(u_int block) // Don't trap writes invalid_code[block]=1; +#ifndef DISABLE_TLB // If there is a valid TLB entry for this page, remove write protect if(tlb_LUT_w[block]) { assert(tlb_LUT_r[block]==tlb_LUT_w[block]); @@ -1162,6 +1168,7 @@ void invalidate_block(u_int block) if(real_block>=0x80000&&real_block<0x80800) memory_map[real_block]=((u_int)rdram-0x80000000)>>2; } else if(block>=0x80000&&block<0x80800) memory_map[block]=((u_int)rdram-0x80000000)>>2; +#endif #ifdef __arm__ if(modified) __clear_cache((void *)BASE_ADDR,(void *)BASE_ADDR+(1<>12; - if(page>262143&&tlb_LUT_r[vaddr>>12]) page=(tlb_LUT_r[vaddr>>12]^0x80000000)>>12; - if(page>4095) page=2048+(page&2047); + u_int page=get_page(vaddr); inv_debug("add_link: %x -> %x (%d)\n",(int)src,vaddr,page); ll_add(jump_out+page,vaddr,src); //int ptr=get_pointer(src); @@ -1251,7 +1258,9 @@ void clean_blocks(u_int page) void * clean_addr=(void *)get_clean_addr((int)head->addr); if((((u_int)clean_addr-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2))) { u_int ppage=page; +#ifndef DISABLE_TLB if(page<2048&&tlb_LUT_r[head->vaddr>>12]) ppage=(tlb_LUT_r[head->vaddr>>12]^0x80000000)>>12; +#endif inv_debug("INV: Restored %x (%x/%x)\n",head->vaddr, (int)head->addr, (int)clean_addr); //printf("page=%x, addr=%x\n",page,head->vaddr); //assert(head->vaddr>>12==(page|0x80000)); @@ -1953,14 +1962,6 @@ int rchecksum() sum^=((u_int *)reg)[i]; return sum; } -int fchecksum() -{ - int i; - int sum=0; - for(i=0;i<64;i++) - sum^=((u_int *)reg_cop1_fgr_64)[i]; - return sum; -} void rlist() { int i; @@ -1968,10 +1969,12 @@ void rlist() for(i=0;i<32;i++) printf("r%d:%8x%8x ",i,((int *)(reg+i))[1],((int *)(reg+i))[0]); printf("\n"); +#ifndef DISABLE_COP1 printf("TRACE: "); for(i=0;i<32;i++) printf("f%d:%8x%8x ",i,((int*)reg_cop1_simple[i])[1],*((int*)reg_cop1_simple[i])); printf("\n"); +#endif } void enabletrace() @@ -3307,6 +3310,7 @@ void storelr_assemble(int i,struct regstat *i_regs) void c1ls_assemble(int i,struct regstat *i_regs) { +#ifndef DISABLE_COP1 int s,th,tl; int temp,ar; int map=-1; @@ -3481,6 +3485,9 @@ void c1ls_assemble(int i,struct regstat *i_regs) emit_call((int)memdebug); emit_popa(); }/**/ +#else + cop1_unusable(i, i_regs); +#endif } #ifndef multdiv_assemble @@ -6192,12 +6199,8 @@ static void pagespan_ds() { assem_debug("initial delay slot:\n"); u_int vaddr=start+1; - u_int page=(0x80000000^vaddr)>>12; - u_int vpage=page; - if(page>262143&&tlb_LUT_r[vaddr>>12]) page=(tlb_LUT_r[page^0x80000]^0x80000000)>>12; - if(page>2048) page=2048+(page&2047); - if(vpage>262143&&tlb_LUT_r[vaddr>>12]) vpage&=2047; // jump_dirty uses a hash of the virtual address instead - if(vpage>2048) vpage=2048+(vpage&2047); + u_int page=get_page(vaddr); + u_int vpage=get_vpage(vaddr); ll_add(jump_dirty+vpage,vaddr,(void *)out); do_dirty_stub_ds(); ll_add(jump_in+page,vaddr,(void *)out); @@ -7381,10 +7384,12 @@ void new_dynarec_init() PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) <= 0) {printf("mmap() failed\n");} +#ifdef MUPEN64 rdword=&readmem_dword; fake_pc.f.r.rs=&readmem_dword; fake_pc.f.r.rt=&readmem_dword; fake_pc.f.r.rd=&readmem_dword; +#endif int n; for(n=0x80000;n<0x80800;n++) invalid_code[n]=1; @@ -7474,11 +7479,14 @@ int new_recompile_block(int addr) //rlist(); start = (u_int)addr&~3; //assert(((u_int)addr&1)==0); +#ifdef MUPEN64 if ((int)addr >= 0xa4000000 && (int)addr < 0xa4001000) { source = (u_int *)((u_int)SP_DMEM+start-0xa4000000); pagelimit = 0xa4001000; } - else if ((int)addr >= 0x80000000 && (int)addr < 0x80800000) { + else +#endif + if ((int)addr >= 0x80000000 && (int)addr < 0x80800000) { source = (u_int *)((u_int)rdram+start-0x80000000); pagelimit = 0x80800000; } @@ -10352,12 +10360,8 @@ int new_recompile_block(int addr) if(instr_addr[i]) // TODO - delay slots (=null) { u_int vaddr=start+i*4; - u_int page=(0x80000000^vaddr)>>12; - u_int vpage=page; - if(page>262143&&tlb_LUT_r[vaddr>>12]) page=(tlb_LUT_r[page^0x80000]^0x80000000)>>12; - if(page>2048) page=2048+(page&2047); - if(vpage>262143&&tlb_LUT_r[vaddr>>12]) vpage&=2047; // jump_dirty uses a hash of the virtual address instead - if(vpage>2048) vpage=2048+(vpage&2047); + u_int page=get_page(vaddr); + u_int vpage=get_vpage(vaddr); literal_pool(256); //if(!(is32[i]&(~unneeded_reg_upper[i])&~(1LL<