From a06c1d6e156b90ce9bfa18664256dfe8f815857e Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 23 Dec 2010 19:18:36 +0200 Subject: [PATCH] drc: map bios and fix dummy reads --- libpcsxcore/new_dynarec/linkage_arm.s | 22 ++++++++++++++++++++++ libpcsxcore/new_dynarec/pcsxmem.c | 12 +++++++++++- libpcsxcore/psxmem.c | 8 +++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/libpcsxcore/new_dynarec/linkage_arm.s b/libpcsxcore/new_dynarec/linkage_arm.s index 906c466d..8f1a2b2f 100644 --- a/libpcsxcore/new_dynarec/linkage_arm.s +++ b/libpcsxcore/new_dynarec/linkage_arm.s @@ -803,6 +803,9 @@ new_dyna_start: .global ari_write_ram_mirror8 .global ari_write_ram_mirror16 .global ari_write_ram_mirror32 +.global ari_read_bios8 +.global ari_read_bios16 +.global ari_read_bios32 .global ari_read_io8 .global ari_read_io16 .global ari_read_io32 @@ -893,6 +896,25 @@ ari_write_ram_mirror32: ari_write_ram_mirror (3<<11), word, str +.macro ari_read_bios_mirror bic_const op + ldr r0, [fp, #address-dynarec_local] + orr r0, r0, #0x80000000 + bic r0, r0, #(0x20000000|\bic_const) @ map to 0x9fc... + \op r0, [r0] + str r0, [fp, #readmem_dword-dynarec_local] + mov pc, lr +.endm + +ari_read_bios8: + ari_read_bios_mirror 0, ldrb + +ari_read_bios16: + ari_read_bios_mirror 1, ldrh + +ari_read_bios32: + ari_read_bios_mirror 3, ldr + + @ for testing .macro ari_read_io_old tab_shift str lr, [sp, #-8]! @ EABI alignment.. diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c index dc3ce690..a323c18d 100644 --- a/libpcsxcore/new_dynarec/pcsxmem.c +++ b/libpcsxcore/new_dynarec/pcsxmem.c @@ -72,6 +72,9 @@ extern void ari_write_ram32(); extern void ari_write_ram_mirror8(); extern void ari_write_ram_mirror16(); extern void ari_write_ram_mirror32(); +extern void ari_read_bios8(); +extern void ari_read_bios16(); +extern void ari_read_bios32(); extern void ari_read_io8(); extern void ari_read_io16(); extern void ari_read_io32(); @@ -295,7 +298,7 @@ void new_dyna_pcsx_mem_init(void) writemem[i] = write_mem32; #if 1 readmemb[i] = readmemh[i] = readmem[i] = read_mem_dummy; - readmemb[i] = readmemh[i] = readmem[i] = write_mem_dummy; + writememb[i] = writememh[i] = writemem[i] = write_mem_dummy; #endif } @@ -320,6 +323,13 @@ void new_dyna_pcsx_mem_init(void) writemem[i] = ari_write_ram32; } + // BIOS and it's mirrors + for (i = 0x1fc0; i < 0x1fc8; i++) { + readmemb[i] = readmemb[0x8000|i] = readmemb[0xa000|i] = ari_read_bios8; + readmemh[i] = readmemh[0x8000|i] = readmemh[0xa000|i] = ari_read_bios16; + readmem[i] = readmem[0x8000|i] = readmem[0xa000|i] = ari_read_bios32; + } + // I/O readmemb[0x1f80] = ari_read_io8; readmemh[0x1f80] = ari_read_io16; diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index cc27552a..898eac9c 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -73,10 +73,12 @@ int psxMemInit() { psxP = &psxM[0x200000]; psxH = &psxM[0x210000]; - psxR = (s8 *)malloc(0x00080000); + psxR = mmap((void *)0x9fc00000, 0x80000, + PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (psxMemRLUT == NULL || psxMemWLUT == NULL || - psxM != (void *)0x80000000 || psxP == NULL || psxH == NULL) { + psxM != (void *)0x80000000 || psxR != (void *)0x9fc00000 || + psxP == NULL || psxH == NULL) { SysMessage(_("Error allocating memory!")); return -1; } @@ -132,8 +134,8 @@ void psxMemReset() { void psxMemShutdown() { munmap(psxM, 0x00220000); + munmap(psxR, 0x80000); - free(psxR); free(psxMemRLUT); free(psxMemWLUT); } -- 2.39.5