From 01d267961e8e7a20812dba544c643d4517d6a23b Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 2 Nov 2021 00:44:56 +0200 Subject: [PATCH] drc: rework for 64bit, part 4 --- libpcsxcore/new_dynarec/assem_arm.c | 6 ++-- libpcsxcore/new_dynarec/emu_if.h | 5 +-- libpcsxcore/new_dynarec/new_dynarec.c | 47 +++++++++++++-------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 23b47bad..0f280592 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -296,7 +296,7 @@ static int isclean(void *addr) } // get source that block at addr was compiled from (host pointers) -static void get_bounds(void *addr,u_int *start,u_int *end) +static void get_bounds(void *addr, u_char **start, u_char **end) { u_int *ptr = addr; #ifndef HAVE_ARMV7 @@ -325,8 +325,8 @@ static void get_bounds(void *addr,u_int *start,u_int *end) #endif if((*ptr&0xFF000000)!=0xeb000000) ptr++; assert((*ptr&0xFF000000)==0xeb000000); // bl instruction - *start=source; - *end=source+len; + *start=(u_char *)source; + *end=(u_char *)source+len; } /* Register allocation */ diff --git a/libpcsxcore/new_dynarec/emu_if.h b/libpcsxcore/new_dynarec/emu_if.h index 17abab0b..494ca7ef 100644 --- a/libpcsxcore/new_dynarec/emu_if.h +++ b/libpcsxcore/new_dynarec/emu_if.h @@ -86,6 +86,7 @@ extern void *zeromem_ptr; extern void *scratch_buf_ptr; // same as invalid_code, just a region for ram write checks (inclusive) +// (psx/guest address range) extern u32 inv_code_start, inv_code_end; /* cycles/irqs */ @@ -100,7 +101,7 @@ void pcsx_mtc0_ds(u32 reg, u32 val); extern void SysPrintf(const char *fmt, ...); #ifdef RAM_FIXED -#define rdram ((u_int)0x80000000) +#define rdram ((u_char *)0x80000000) #else -#define rdram ((u_int)psxM) +#define rdram ((u_char *)psxM) #endif diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 61dac47a..0f56082c 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -194,9 +194,9 @@ struct link_entry static int expirep; static u_int stop_after_jal; #ifndef RAM_FIXED - static u_int ram_offset; + static uintptr_t ram_offset; #else - static const u_int ram_offset=0; + static const uintptr_t ram_offset=0; #endif int new_dynarec_hacks; @@ -1020,14 +1020,14 @@ void invalidate_block(u_int block) head=jump_dirty[vpage]; //printf("page=%d vpage=%d\n",page,vpage); while(head!=NULL) { - u_int start,end; if(vpage>2047||(head->vaddr>>12)==block) { // Ignore vaddr hash collision - get_bounds(head->addr,&start,&end); - //printf("start: %x end: %x\n",start,end); - if(page<2048&&start>=(u_int)rdram&&end<(u_int)rdram+RAM_SIZE) { - if(((start-(u_int)rdram)>>12)<=page&&((end-1-(u_int)rdram)>>12)>=page) { - if((((start-(u_int)rdram)>>12)&2047)>12)&2047; - if((((end-1-(u_int)rdram)>>12)&2047)>last) last=((end-1-(u_int)rdram)>>12)&2047; + u_char *start, *end; + get_bounds(head->addr, &start, &end); + //printf("start: %p end: %p\n", start, end); + if (page < 2048 && start >= rdram && end < rdram+RAM_SIZE) { + if (((start-rdram)>>12) <= page && ((end-1-rdram)>>12) >= page) { + if ((((start-rdram)>>12)&2047) < first) first = ((start-rdram)>>12)&2047; + if ((((end-1-rdram)>>12)&2047) > last) last = ((end-1-rdram)>>12)&2047; } } } @@ -1058,12 +1058,11 @@ void invalidate_addr(u_int addr) } for(;pg1<=page;pg1++) { for(head=jump_dirty[pg1];head!=NULL;head=head->next) { - u_int start,end; - get_bounds(head->addr,&start,&end); - if(ram_offset) { - start-=ram_offset; - end-=ram_offset; - } + u_char *start_h, *end_h; + u_int start, end; + get_bounds(head->addr, &start_h, &end_h); + start = (uintptr_t)start_h - ram_offset; + end = (uintptr_t)end_h - ram_offset; if(start<=addr_main&&addr_mainaddr_max) addr_max=end; @@ -1137,14 +1136,14 @@ void clean_blocks(u_int page) if(!invalid_code[head->vaddr>>12]) { // Don't restore blocks which are about to expire from the cache if (doesnt_expire_soon(head->addr)) { - u_int start,end; if(verify_dirty(head->addr)) { + u_char *start, *end; //printf("Possibly Restore %x (%p)\n",head->vaddr, head->addr); u_int i; u_int inv=0; - get_bounds(head->addr,&start,&end); - if(start-(u_int)rdram>12;i<=(end-1-(u_int)rdram+0x80000000)>>12;i++) { + get_bounds(head->addr, &start, &end); + if (start - rdram < RAM_SIZE) { + for (i = (start-rdram+0x80000000)>>12; i <= (end-1-rdram+0x80000000)>>12; i++) { inv|=invalid_code[i]; } } @@ -6671,7 +6670,7 @@ void new_dynarec_init() arch_init(); new_dynarec_test(); #ifndef RAM_FIXED - ram_offset=(u_int)rdram-0x80000000; + ram_offset=(uintptr_t)rdram-0x80000000; #endif if (ram_offset!=0) SysPrintf("warning: RAM is not directly mapped, performance will suffer\n"); @@ -6703,18 +6702,18 @@ static u_int *get_source_start(u_int addr, u_int *limit) (0xa0000000 <= addr && addr < 0xa0200000)) { // used for BIOS calls mostly? *limit = (addr&0xa0000000)|0x00200000; - return (u_int *)((u_int)rdram + (addr&0x1fffff)); + return (u_int *)(rdram + (addr&0x1fffff)); } else if (!Config.HLE && ( /* (0x9fc00000 <= addr && addr < 0x9fc80000) ||*/ (0xbfc00000 <= addr && addr < 0xbfc80000))) { // BIOS *limit = (addr & 0xfff00000) | 0x80000; - return (u_int *)((u_int)psxR + (addr&0x7ffff)); + return (u_int *)((u_char *)psxR + (addr&0x7ffff)); } else if (addr >= 0x80000000 && addr < 0x80000000+RAM_SIZE) { *limit = (addr & 0x80600000) + 0x00200000; - return (u_int *)((u_int)rdram + (addr&0x1fffff)); + return (u_int *)(rdram + (addr&0x1fffff)); } return NULL; } @@ -9651,7 +9650,7 @@ int new_recompile_block(int addr) // Align code if(((u_int)out)&7) emit_addnop(13); #endif - assert((u_int)out-(u_int)beginning