some drc integration work
authornotaz <notasas@gmail.com>
Sun, 21 Nov 2010 19:44:49 +0000 (21:44 +0200)
committernotaz <notasas@gmail.com>
Sun, 21 Nov 2010 19:44:49 +0000 (21:44 +0200)
Makefile
frontend/config.h
frontend/plugin.c
libpcsxcore/new_dynarec/assem_arm.h
libpcsxcore/new_dynarec/emu_if.c [new file with mode: 0644]
libpcsxcore/new_dynarec/emu_if.h
libpcsxcore/new_dynarec/linkage_arm.s
libpcsxcore/psxmem.c
libpcsxcore/r3000a.h

index 0dd79ee..28b3d7c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,15 @@
 #CROSS_COMPILE=
+AS = $(CROSS_COMPILE)as
 CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld
 
-CFLAGS += -Wall -ggdb -Ifrontend
+CFLAGS += -ggdb -Ifrontend
 LDFLAGS += -lz -lpthread -ldl
 ifdef CROSS_COMPILE
-CFLAGS += -O2 -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp -ffast-math
+CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp -ffast-math
+endif
+ifndef DEBUG
+CFLAGS += -O2
 endif
 TARGET = pcsx
 
@@ -18,6 +22,11 @@ OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore
        libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
        libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
        libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
+# dynarec
+OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o \
+       libpcsxcore/new_dynarec/emu_if.o
+libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
+
 # spu
 OBJS += plugins/dfsound/adsr.o plugins/dfsound/dma.o plugins/dfsound/oss.o plugins/dfsound/reverb.o \
        plugins/dfsound/xa.o plugins/dfsound/freeze.o plugins/dfsound/cfg.o plugins/dfsound/registers.o \
@@ -40,7 +49,7 @@ OBJS += frontend/main.o frontend/plugin.o frontend/plugin_lib.o
 OBJS += frontend/linux/fbdev.o
 
 $(TARGET): $(OBJS)
-       $(CC) -o $@ $^ $(LDFLAGS)
+       $(CC) -o $@ $^ $(LDFLAGS) -Wl,-Map=$@.map
 
 clean:
        $(RM) $(TARGET) $(OBJS)
index b11f75d..e8b255d 100644 (file)
@@ -1,5 +1,5 @@
 #define MAXPATHLEN 256
-#define NOPSXREC
+//#define NOPSXREC
 #define __LINUX__
 #define PACKAGE_NAME "pcsx"
 #define PACKAGE_VERSION "1.9"
index d6aca8a..6cde989 100644 (file)
@@ -253,6 +253,9 @@ pc_hook_func              (SPU_playCDDAchannel, (short *a0, int a1), (a0, a1), P
 
 void pcnt_hook_plugins(void)
 {
+       /* test it first */
+       pcnt_get();
+
        hook_it(GPU_writeStatus);
        hook_it(GPU_writeData);
        hook_it(GPU_writeDataMem);
index a1a2b52..d97c0f2 100644 (file)
@@ -45,7 +45,7 @@
 
 extern char *invc_ptr;
 
-#define BASE_ADDR 0x7000000 // Code generator target address
+#define BASE_ADDR 0x2000000 // Code generator target address
 #define TARGET_SIZE_2 24 // 2^24 = 16 megabytes
 
 // This is defined in linkage_arm.s, but gcc -O3 likes this better
diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c
new file mode 100644 (file)
index 0000000..cee61cc
--- /dev/null
@@ -0,0 +1,95 @@
+#include <stdio.h>
+
+#include "emu_if.h"
+
+char invalid_code[0x100000];
+
+void MFC0(void)
+{
+       printf("MFC0!\n");
+}
+
+void gen_interupt()
+{
+       printf("gen_interupt\n");
+}
+
+void check_interupt()
+{
+       printf("check_interupt\n");
+}
+
+void read_nomem_new()
+{
+       printf("read_nomem_new\n");
+}
+
+static void read_mem()
+{
+       printf("read_mem %08x\n", address);
+}
+
+static void write_mem()
+{
+       printf("write_mem %08x\n", address);
+}
+
+void (*readmem[0x10000])();
+void (*readmemb[0x10000])();
+void (*readmemh[0x10000])();
+void (*writemem[0x10000])();
+void (*writememb[0x10000])();
+void (*writememh[0x10000])();
+
+
+static int ari64_init()
+{
+       size_t i;
+       new_dynarec_init();
+
+       for (i = 0; i < sizeof(readmem) / sizeof(readmem[0]); i++) {
+               readmem[i] = read_mem;
+               writemem[i] = write_mem;
+       }
+       memcpy(readmemb, readmem, sizeof(readmem));
+       memcpy(readmemh, readmem, sizeof(readmem));
+       memcpy(writememb, writemem, sizeof(writemem));
+       memcpy(writememh, writemem, sizeof(writemem));
+}
+
+static void ari64_reset()
+{
+       /* hmh */
+       printf("ari64_reset\n");
+}
+
+static void ari64_execute()
+{
+/*
+       FILE *f = fopen("/mnt/ntz/dev/pnd/tmp/ram.dump", "wb");
+       fwrite((void *)0x80000000, 1, 0x200000, f);
+       fclose(f);
+       exit(1);
+*/
+       printf("psxNextsCounter %d, psxNextCounter %d\n", psxNextsCounter, psxNextCounter);
+       printf("ari64_execute %08x\n", psxRegs.pc);
+       new_dyna_start(psxRegs.pc);
+}
+
+static void ari64_clear(u32 Addr, u32 Size)
+{
+}
+
+static void ari64_shutdown()
+{
+       new_dynarec_cleanup();
+}
+
+R3000Acpu psxRec = {
+       ari64_init,
+       ari64_reset,
+       ari64_execute,
+// TODO        recExecuteBlock,
+       ari64_clear,
+       ari64_shutdown
+};
index 50dc2a8..f5e4b55 100644 (file)
@@ -28,15 +28,15 @@ extern int FCR0, FCR31;
 extern void (*readmem[0x10000])();
 extern void (*readmemb[0x10000])();
 extern void (*readmemh[0x10000])();
-extern void (*readmemd[0x10000])();
 extern void (*writemem[0x10000])();
 extern void (*writememb[0x10000])();
 extern void (*writememh[0x10000])();
-extern void (*writememd[0x10000])();
 
-extern unsigned int address, word;
-extern unsigned char byte;
+extern unsigned int address;
+extern unsigned int readmem_word; /* same as readmem_dword */
+extern unsigned int word;      /* write */
 extern unsigned short hword;
+extern unsigned char byte;
 
 /* cycles */
 extern unsigned int next_interupt;
index f838fcb..f1b0f8c 100644 (file)
@@ -34,12 +34,9 @@ rdram = 0x80000000
        .global reg
        .global hi
        .global lo
-       .global reg_cop1_simple
-       .global reg_cop1_double
        .global reg_cop0
        .global FCR0
        .global FCR31
-       .global rounding_modes
        .global next_interupt
        .global cycle_count
        .global last_count
@@ -49,22 +46,25 @@ rdram = 0x80000000
        .global invc_ptr
        .global address
        .global readmem_dword
+       .global readmem_word
        .global dword
        .global word
        .global hword
        .global byte
        .global branch_target
        .global PC
-       .global fake_pc
        .global mini_ht
        .global restore_candidate
        .global memory_map
+       /* psx */
+       .global psxRegs
+
        .bss
        .align  4
        .type   dynarec_local, %object
-       .size   dynarec_local, 64
+       .size   dynarec_local, dynarec_local_end-dynarec_local
 dynarec_local:
-       .space  64+16+16+8+8+8+8+256+8+8+128+128+128+16+8+132+4+256+512+4194304
+       .space  dynarec_local_end-dynarec_local /*0x400630*/
 next_interupt = dynarec_local + 64
        .type   next_interupt, %object
        .size   next_interupt, 4
@@ -90,6 +90,7 @@ address = invc_ptr + 4
        .type   address, %object
        .size   address, 4
 readmem_dword = address + 4
+readmem_word = readmem_dword
        .type   readmem_dword, %object
        .size   readmem_dword, 8
 dword = readmem_dword + 8
@@ -111,37 +112,51 @@ FCR31 = FCR0 + 4
        .type   FCR31, %object
        .size   FCR31, 4
 reg = FCR31 + 4
+
+/* psxRegs */
+psxRegs = reg
        .type   reg, %object
-       .size   reg, 256
-hi = reg + 256
+       .size   reg, 128
+       .size   psxRegs, psxRegs_end-psxRegs
+hi = reg + 128
        .type   hi, %object
-       .size   hi, 8
-lo = hi + 8
+       .size   hi, 4
+lo = hi + 4
        .type   lo, %object
-       .size   lo, 8
-reg_cop0 = lo + 8
+       .size   lo, 4
+reg_cop0 = lo + 4
        .type   reg_cop0, %object
        .size   reg_cop0, 128
-reg_cop1_simple = reg_cop0 + 128
-       .type   reg_cop1_simple, %object
-       .size   reg_cop1_simple, 128
-reg_cop1_double = reg_cop1_simple + 128
-       .type   reg_cop1_double, %object
-       .size   reg_cop1_double, 128
-rounding_modes = reg_cop1_double + 128
-       .type   rounding_modes, %object
-       .size   rounding_modes, 16
-branch_target = rounding_modes + 16
-       .type   branch_target, %object
-       .size   branch_target, 4
-PC = branch_target + 4
+reg_cop2d = reg_cop0 + 128
+       .type   reg_cop2d, %object
+       .size   reg_cop2d, 128
+reg_cop2c = reg_cop2d + 128
+       .type   reg_cop2c, %object
+       .size   reg_cop2c, 128
+PC = reg_cop2c + 128
        .type   PC, %object
        .size   PC, 4
-fake_pc = PC + 4
-       .type   fake_pc, %object
-       .size   fake_pc, 132
-/* 4 bytes free */
-mini_ht = fake_pc + 136
+code = PC + 4
+       .type   code, %object
+       .size   code, 4
+cycle = code + 4
+       .type   cycle, %object
+       .size   cycle, 4
+interrupt = cycle + 4
+       .type   interrupt, %object
+       .size   interrupt, 4
+intCycle = interrupt + 4
+       .type   intCycle, %object
+       .size   intCycle, 128
+psxRegs_end = intCycle + 128
+
+align0 = psxRegs_end /* just for alignment */
+       .type   align0, %object
+       .size   align0, 4
+branch_target = align0 + 4
+       .type   branch_target, %object
+       .size   branch_target, 4
+mini_ht = branch_target + 4
        .type   mini_ht, %object
        .size   mini_ht, 256
 restore_candidate = mini_ht + 256
@@ -150,6 +165,7 @@ restore_candidate = mini_ht + 256
 memory_map = restore_candidate + 512
        .type   memory_map, %object
        .size   memory_map, 4194304
+dynarec_local_end = memory_map + 4194304
 
        .text
        .align  2
@@ -158,17 +174,11 @@ memory_map = restore_candidate + 512
 dyna_linker:
        /* r0 = virtual target address */
        /* r1 = instruction to patch */
-       ldr     r4, .tlbptr
-       lsr     r5, r0, #12
        mov     r12, r0
-       cmp     r0, #0xC0000000
        mov     r6, #4096
-       ldrge   r12, [r4, r5, lsl #2]
        mov     r2, #0x80000
        ldr     r3, .jiptr
-       tst     r12, r12
        sub     r6, r6, #1
-       moveq   r12, r0
        ldr     r7, [r1]
        eor     r2, r2, r12, lsr #12
        and     r6, r6, r12, lsr #12
@@ -281,17 +291,11 @@ exec_pagefault:
 dyna_linker_ds:
        /* r0 = virtual target address */
        /* r1 = instruction to patch */
-       ldr     r4, .tlbptr
-       lsr     r5, r0, #12
        mov     r12, r0
-       cmp     r0, #0xC0000000
        mov     r6, #4096
-       ldrge   r12, [r4, r5, lsl #2]
        mov     r2, #0x80000
        ldr     r3, .jiptr
-       tst     r12, r12
        sub     r6, r6, #1
-       moveq   r12, r0
        ldr     r7, [r1]
        eor     r2, r2, r12, lsr #12
        and     r6, r6, r12, lsr #12
@@ -380,8 +384,6 @@ dyna_linker_ds:
        .word   jump_in
 .jdptr:
        .word   jump_dirty
-.tlbptr:
-       .word   tlb_LUT_r
 .htptr:
        .word   hash_table
        .align  2
@@ -719,16 +721,14 @@ jump_eret:
        .type   new_dyna_start, %function
 new_dyna_start:
        ldr     r12, .dlptr
-       mov     r0, #0xa4000000
        stmia   r12, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
        sub     fp, r12, #28
-       add     r0, r0, #0x40
        bl      new_recompile_block
        ldr     r0, [fp, #next_interupt-dynarec_local]
        ldr     r10, [fp, #reg_cop0+36-dynarec_local] /* Count */
        str     r0, [fp, #last_count-dynarec_local]
        sub     r10, r10, r0
-       mov     pc, #0x7000000
+       mov     pc, #0x2000000
 .dlptr:
        .word   dynarec_local+28
        .size   new_dyna_start, .-new_dyna_start
@@ -789,7 +789,13 @@ do_invalidate:
        .align  2
        .global read_nomem_new
        .type   read_nomem_new, %function
-read_nomem_new:
+/*read_nomem_new:*/
+read_nomemb_new:
+read_nomemh_new:
+read_nomemd_new:
+       /* should never happen */
+       b       read_nomem_new
+/*
        ldr     r2, [fp, #address-dynarec_local]
        add     r12, fp, #memory_map-dynarec_local
        lsr     r0, r2, #12
@@ -800,63 +806,11 @@ read_nomem_new:
        ldr     r0, [r2, r12, lsl #2]
        str     r0, [fp, #readmem_dword-dynarec_local]
        mov     pc, lr
+*/
        .size   read_nomem_new, .-read_nomem_new
        .align  2
        .global read_nomemb_new
        .type   read_nomemb_new, %function
-read_nomemb_new:
-       ldr     r2, [fp, #address-dynarec_local]
-       add     r12, fp, #memory_map-dynarec_local
-       lsr     r0, r2, #12
-       ldr     r12, [r12, r0, lsl #2]
-       mov     r1, #8
-       tst     r12, r12
-       bmi     tlb_exception
-       eor     r2, r2, #3
-       ldrb    r0, [r2, r12, lsl #2]
-       str     r0, [fp, #readmem_dword-dynarec_local]
-       mov     pc, lr
-       .size   read_nomemb_new, .-read_nomemb_new
-       .align  2
-       .global read_nomemh_new
-       .type   read_nomemh_new, %function
-read_nomemh_new:
-       ldr     r2, [fp, #address-dynarec_local]
-       add     r12, fp, #memory_map-dynarec_local
-       lsr     r0, r2, #12
-       ldr     r12, [r12, r0, lsl #2]
-       mov     r1, #8
-       tst     r12, r12
-       bmi     tlb_exception
-       lsl     r12, r12, #2
-       eor     r2, r2, #2
-       ldrh    r0, [r2, r12]
-       str     r0, [fp, #readmem_dword-dynarec_local]
-       mov     pc, lr
-       .size   read_nomemh_new, .-read_nomemh_new
-       .align  2
-       .global read_nomemd_new
-       .type   read_nomemd_new, %function
-read_nomemd_new:
-       ldr     r2, [fp, #address-dynarec_local]
-       add     r12, fp, #memory_map-dynarec_local
-       lsr     r0, r2, #12
-       ldr     r12, [r12, r0, lsl #2]
-       mov     r1, #8
-       tst     r12, r12
-       bmi     tlb_exception
-       lsl     r12, r12, #2
-/*     ldrd    r0, [r2, r12]*/
-       add     r3, r2, #4
-       ldr     r0, [r2, r12]
-       ldr     r1, [r3, r12]
-       str     r0, [fp, #readmem_dword+4-dynarec_local]
-       str     r1, [fp, #readmem_dword-dynarec_local]
-       mov     pc, lr
-       .size   read_nomemd_new, .-read_nomemd_new
-       .align  2
-       .global write_nomem_new
-       .type   write_nomem_new, %function
 write_nomem_new:
        str     r3, [fp, #24]
        str     lr, [fp, #28]
index fc4a90e..cc27552 100644 (file)
@@ -67,7 +67,7 @@ int psxMemInit() {
        memset(psxMemRLUT, 0, 0x10000 * sizeof(void *));
        memset(psxMemWLUT, 0, 0x10000 * sizeof(void *));
 
-       psxM = mmap(0, 0x00220000,
+       psxM = mmap((void *)0x80000000, 0x00220000,
                PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 
        psxP = &psxM[0x200000];
@@ -76,7 +76,7 @@ int psxMemInit() {
        psxR = (s8 *)malloc(0x00080000);
 
        if (psxMemRLUT == NULL || psxMemWLUT == NULL || 
-               psxM == NULL || psxP == NULL || psxH == NULL) {
+               psxM != (void *)0x80000000 || psxP == NULL || psxH == NULL) {
                SysMessage(_("Error allocating memory!"));
                return -1;
        }
index 51cd37c..9379f45 100644 (file)
@@ -40,7 +40,7 @@ typedef struct {
 
 extern R3000Acpu *psxCpu;
 extern R3000Acpu psxInt;
-#if (defined(__x86_64__) || defined(__i386__) || defined(__sh__) || defined(__ppc__)) && !defined(NOPSXREC)
+#if (defined(__x86_64__) || defined(__i386__) || defined(__sh__) || defined(__ppc__) || defined(__arm__)) && !defined(NOPSXREC)
 extern R3000Acpu psxRec;
 #define PSXREC
 #endif