drc: map bios and fix dummy reads
authornotaz <notasas@gmail.com>
Thu, 23 Dec 2010 17:18:36 +0000 (19:18 +0200)
committernotaz <notasas@gmail.com>
Thu, 23 Dec 2010 17:18:36 +0000 (19:18 +0200)
libpcsxcore/new_dynarec/linkage_arm.s
libpcsxcore/new_dynarec/pcsxmem.c
libpcsxcore/psxmem.c

index 906c466..8f1a2b2 100644 (file)
@@ -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..
index dc3ce69..a323c18 100644 (file)
@@ -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;
index cc27552..898eac9 100644 (file)
@@ -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);
 }