* sky-vu.c: new file to read/write VU registers
authorRon Unrau <runrau@cygnus>
Fri, 27 Mar 1998 14:44:39 +0000 (14:44 +0000)
committerRon Unrau <runrau@cygnus>
Fri, 27 Mar 1998 14:44:39 +0000 (14:44 +0000)
        * Makefile.in .Sanitize: add sky-vu.c
* sky-vu.h: define registers as enum, export read/write routines
        * sky-vu[01].[ch]: use register read/write routines in sky-vu.c
        * interp.c: use register read/write routines in sky-vu.c

sim/mips/.Sanitize
sim/mips/Makefile.in
sim/mips/interp.c
sim/mips/sky-vu0.c
sim/mips/sky-vu0.h
sim/mips/sky-vu1.c
sim/mips/sky-vu1.h

index 816d8a8fca96ddd1468085fbd9f253d6aff128eb..455c5e74f6badd685527690a196744027b0b77ad 100644 (file)
@@ -35,7 +35,7 @@ sky_files="ChangeLog.sky sky-device.c sky-device.h sky-dma.c sky-dma.h sky-bits.
 sky_files="$sky_files sky-engine.c sky-gpuif.c sky-gpuif.h"
 sky_files="$sky_files sky-hardware.c sky-hardware.h sky-gdb.c"
 sky_files="$sky_files sky-libvpe.c sky-libvpe.h sky-pke.c sky-pke.h"
-sky_files="$sky_files sky-vpe.h sky-vu.h sky-vu0.c sky-vu0.h sky-vu1.c sky-vu1.h"
+sky_files="$sky_files sky-vpe.h sky-vu.h sky-vu.c sky-vu0.c sky-vu0.h sky-vu1.c sky-vu1.h"
 if ( echo $* | grep keep\-sky > /dev/null ) ; then
         keep_these_too="${sky_files} ${keep_these_too}"
 else
index 157cee4390278cf7204ab39ff96e624c55516308..184c0f577415bb7e810356be0ed1939beddd84b3 100644 (file)
@@ -17,6 +17,7 @@ SIM_SKY_OBJS = \
        sky-hardware.o \
        sky-libvpe.o \
        sky-pke.o \
+       sky-vu.o \
        sky-vu0.o \
        sky-vu1.o \
        sky-gdb.o
@@ -46,6 +47,7 @@ SIM_M16_OBJ = \
        m16run.o \
 
 MIPS_EXTRA_OBJS = @mips_extra_objs@
+MIPS_EXTRA_LIBS = @mips_extra_libs@
 
 SIM_OBJS = \
        $(SIM_@sim_gen@_OBJ) \
@@ -77,6 +79,8 @@ SIM_EXTRA_CLEAN = clean-extra
 
 SIM_EXTRA_ALL = $(SIM_@sim_gen@_ALL)
 
+SIM_EXTRA_LIBS = $(MIPS_EXTRA_LIBS)
+
 # List of main object files for `run'.
 SIM_RUN_OBJS = nrun.o
 
@@ -127,6 +131,9 @@ IGEN_INCLUDE=\
        $(srcdir)/vr5400.igen \
        $(srcdir)/mdmx.igen \
        $(end-sanitize-vr5400) \
+       $(start-sanitize-vr4320) \
+       $(srcdir)/vr4320.igen \
+       $(end-sanitize-vr4320) \
        $(srcdir)/m16.igen
 
 SIM_IGEN_ALL = tmp-igen
index 0dc36e10b2e14e4a7dc3147abab3c6cff3a544d5..0be63da5eb950b011c5bd6b9b84097380f52588c 100644 (file)
@@ -66,6 +66,12 @@ code on the hardware.
 
 #include "sysdep.h"
 
+/* start-sanitize-sky */
+#ifdef TARGET_SKY
+#include "sky-vu.h"
+#endif
+/* end-sanitize-sky */
+
 #ifndef PARAMS
 #define PARAMS(x) 
 #endif
@@ -666,10 +672,7 @@ sim_store_register (sd,rn,memory,length)
       rn = rn - NUM_R5900_REGS;
 
       if (rn < NUM_VU_INTEGER_REGS)
-       {
-         vu_regs[0].i[rn] = T2H_2( *(unsigned short *) memory );
-         size = 2;
-       }
+       size = write_vu_int_reg (&(vu0_state.regs), rn, memory);
       else if( rn < NUM_VU_REGS )
        vu_regs[0].f[rn - NUM_VU_INTEGER_REGS] 
          = T2H_4( *(unsigned int *) memory );
@@ -677,10 +680,7 @@ sim_store_register (sd,rn,memory,length)
        rn = rn - NUM_VU_REGS;
 
        if( rn < NUM_VU_INTEGER_REGS ) 
-         {
-           vu_regs[1].i[rn] = T2H_2( *(unsigned short *) memory );
-           size = 2;
-         }
+         size = write_vu_int_reg (&(vu1_state.regs), rn, memory);
        else if( rn < NUM_VU_REGS )
          vu_regs[1].f[rn - NUM_VU_INTEGER_REGS] 
            = T2H_4( *(unsigned int *) memory );
@@ -768,10 +768,7 @@ sim_fetch_register (sd,rn,memory,length)
       rn = rn - NUM_R5900_REGS;
 
       if (rn < NUM_VU_INTEGER_REGS)
-       {
-         *((unsigned short *) memory) = H2T_2( vu_regs[0].i[rn] );
-         size = 2;
-       }
+       size = read_vu_int_reg (&(vu0_state.regs), rn, memory);
       else if (rn < NUM_VU_REGS)
        *((unsigned int *) memory) 
          = H2T_4( vu_regs[0].f[rn - NUM_VU_INTEGER_REGS] );
@@ -780,10 +777,7 @@ sim_fetch_register (sd,rn,memory,length)
          rn = rn - NUM_VU_REGS;
        
          if (rn < NUM_VU_INTEGER_REGS) 
-           {
-             (*(unsigned short *) memory) = H2T_2( vu_regs[1].i[rn] );
-             size = 2;
-           }
+           size = read_vu_int_reg (&(vu1_state.regs), rn, memory);
          else if (rn < NUM_VU_REGS)
            (*(unsigned int *) memory) 
              = H2T_4( vu_regs[1].f[rn - NUM_VU_INTEGER_REGS] );
index dc42ce5cdcee445b78d69e470311052397b47604..a685713e4cc19e141173bb2f8f816696ca3aedb3 100644 (file)
@@ -5,8 +5,11 @@
 #include "sim-main.h"
 
 #include "sky-device.h"
+#include "sky-vu.h"
 #include "sky-vu0.h"
 
+VectorUnitState vu0_state;
+
 /* these are aligned versions of zalloc() pointers - do not zfree()! */
 static char* vu0_mem0_buffer = 0;
 static char* vu0_mem1_buffer = 0;
@@ -26,8 +29,16 @@ vu0_io_read_buffer(device *me,
                       sim_cpu *processor,
                       sim_cia cia)
 {
-       printf("%s: Read!\n", me->name);
-       return nr_bytes;
+  if (addr < VU0_REGISTER_WINDOW_START)
+    return 0;
+
+  addr -= VU0_REGISTER_WINDOW_START;
+
+  /* Adjust nr_bytes if too big */
+  if ((addr + nr_bytes) > VU_REG_END)
+    nr_bytes -= addr + nr_bytes - VU_REG_END;
+
+  return read_vu_registers (&vu0_state, addr, nr_bytes, dest);
 }
 
 static int
@@ -39,8 +50,16 @@ vu0_io_write_buffer(device *me,
                     sim_cpu *processor,
                     sim_cia cia)
 {
-       printf("%s: Write!\n", me->name);
-       return nr_bytes;
+  if (addr < VU0_REGISTER_WINDOW_START)
+    return 0;
+
+  addr -= VU0_REGISTER_WINDOW_START;
+
+  /* Adjust nr_bytes if too big */
+  if ((addr + nr_bytes) > VU_REG_END)
+    nr_bytes -= addr + nr_bytes - VU_REG_END;
+
+  return write_vu_registers (&vu0_state, addr, nr_bytes, source);
 }
 
 device vu0_device = 
@@ -59,7 +78,7 @@ vu0_attach(SIM_DESC sd)
                    access_read_write,
                    0 /*space ???*/,
                    VU0_REGISTER_WINDOW_START,
-                   VU0_REGISTER_WINDOW_SIZE /*nr_bytes*/,
+                   VU_REG_END /*nr_bytes*/,
                    0 /*modulo*/,
                    &vu0_device,
                    NULL /*buffer*/);
index 263b606951383fc129083ff354e63dd8b3040b11..2519384ec9a73837fb9f9d7ee8fa2294a1da51d7 100644 (file)
@@ -18,21 +18,7 @@ void vu0_issue(void);
 
 #define VU0_REGISTER_WINDOW_START 0x10000c00
 
-#define VU0_VF00               0x10000c00
-/* ... */
-#define VU0_VF31               0x10000df0
-
-#define VU0_VI00               0x10000e00
-/* ... */
-#define VU0_VI15               0x10000ef0
-
-/* ... */
-
 #define VPE0_STAT              0x10000fd0
 #define VU0_CIA                        0x10000fe0
 
-#define VU0_REGISTER_WINDOW_END   0x10000ff0
-
-#define VU0_REGISTER_WINDOW_SIZE (VU0_REGISTER_WINDOW_END - VU0_REGISTER_WINDOW_START)
-
 #endif
index 9ab7856cb77df8c809995bb6f89cc0ba40ef957a..c7f7b4a936d09bfe72d3bf8a1f3f5cb7fa23fbf2 100644 (file)
@@ -27,10 +27,6 @@ void init_vu(VectorUnitState *state,
             char* mem_buffer, unsigned mem_qw_size);
 
 #if 0
-int vu1_busy(void) {
-    if (vu1_state.runState == VU_READY) { return 0; } else { return 1; }
-}
-
 static void dump_mem() {
     int i;
     typedef int T[2048][4];  
@@ -51,108 +47,44 @@ vu1_issue(void)
 
 static int
 vu1_io_read_register_window(device *me,
-                   void *dest,
-                   int space,
-                   address_word addr,
-                   unsigned nr_bytes,
-                   sim_cpu *processor,
-                   sim_cia cia)
+                           void *dest,
+                           int space,
+                           address_word addr,
+                           unsigned nr_bytes,
+                           sim_cpu *processor,
+                           sim_cia cia)
 {
-       /* Slow and crappy hack ... */
-
-       
-       int i;
-
-       char source_buffer[VU1_REGISTER_WINDOW_SIZE];
-       char* src;
-
-       assert(nr_bytes == 1 || nr_bytes == 2 || nr_bytes == 4 || nr_bytes == 8 || nr_bytes == 16);
-
-       memcpy(source_buffer, &vu1_state.regs.VF[0][0], 0x200); /* copy VF registers */ 
-       for (i = 0; i<16; i++ ) {
-           *(short*)&source_buffer[0x200 + i*16] = vu1_state.regs.VI[i];
-       }
-       *(u_long*)&source_buffer[VU1_MST   - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MST;
-       *(u_long*)&source_buffer[VU1_MMC   - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MMC;
-       *(u_long*)&source_buffer[VU1_MCP   - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MCP;
-       *(u_long*)&source_buffer[VU1_MR    - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MR;
-       *(u_long*)&source_buffer[VU1_MI    - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MI;
-       *(u_long*)&source_buffer[VU1_MQ    - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MQ;
-       *(u_long*)&source_buffer[VU1_MP    - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MP;
-       *(u_long*)&source_buffer[VU1_MTPC  - VU1_REGISTER_WINDOW_START] = vu1_state.regs.MTPC;
-
-       {
-           u_long stat;
-           stat = 0;
-           if (vu1_state.runState == VU_RUN || vu1_state.runState == VU_BREAK)
-               SET_BIT(stat, VPU_STAT_VBS1_BIT);
-           
-           *(u_long*)&source_buffer[VPE1_STAT - VU1_REGISTER_WINDOW_START] = H2T_4(stat);
-       }
+  if (addr < VU1_REGISTER_WINDOW_START)
+    return 0;
 
-       *(u_long*)&source_buffer[VU1_CIA  - VU1_REGISTER_WINDOW_START] = H2T_4(vu1_state.junk._vpepc);
-       /* XXX: other H2T_N's needed around here. */
+  addr -= VU1_REGISTER_WINDOW_START;
 
-#if 0
-       printf("%s: Read: %x, %d, dest: %x, space: %d, %x!\n", me->name, (int)addr, nr_bytes, (int)dest, space, *(int*)&(vu1_state.regs.VPE_STAT));
-       printf("        vu1_state.regs.VPE_STAT = %x\n", *(int*)&(vu1_state.regs.VPE_STAT));
-#endif
+  /* Adjust nr_bytes if too big */
+  if ((addr + nr_bytes) > VU_REG_END)
+    nr_bytes -= addr + nr_bytes - VU_REG_END;
 
-       if (addr + nr_bytes > VU1_REGISTER_WINDOW_END) {
-           fprintf(stderr, "Error: Read past end of vu1 register window!!!\n");
-           exit(1);
-       }
-
-       src = &source_buffer[0] + (addr - VU1_REGISTER_WINDOW_START);
-       memcpy(dest, src, nr_bytes);
-       return nr_bytes;
+  return read_vu_registers (&vu1_state, addr, nr_bytes, dest);
 }
 
 static int
 vu1_io_write_register_window(device *me,
-                    const void *source,
-                    int space,
-                    address_word addr,
-                    unsigned nr_bytes,
-                    sim_cpu *processor,
-                    sim_cia cia)
+                            const void *source,
+                            int space,
+                            address_word addr,
+                            unsigned nr_bytes,
+                            sim_cpu *processor,
+                            sim_cia cia)
 {
-       char *dest;
-
-       assert(nr_bytes == 4);
-
-       if (addr == VPE1_STAT) {
-           /* Do nothing, read only register. */
-           sim_warning("vu1: Write to read/only register at address %lx.\n", (u_long)addr);
-           return nr_bytes;
-       } else if (addr == VU1_MST) {
-           /* Magic switch to set _TOP register */
-           vu1_state.junk._TOP = T2H_4(*(int*)source);         
-           return nr_bytes;
-        } else if (addr == VU1_CIA) {
-           vu1_state.junk.pc = vu1_state.junk._vpepc = T2H_4(*(int*)source);
-           vu1_state.runState = VU_RUN;
-           vu1_state.junk.eflag = 0;
-           vu1_state.junk.peflag = 0;
-           return nr_bytes;
-       }
-
-       /* Everything else does nothing... */
-       sim_warning("vu1: Write to unimplemented control register at address %lx.\n", (u_long)addr);
-       return nr_bytes;
-
-       /*printf("%s: Write: %x, %d, source: %x, space: %d!\n", me->name, (int)addr, nr_bytes, (int)source, space);*/
-
-       if (addr + nr_bytes > VU1_REGISTER_WINDOW_END) {
-           fprintf(stderr, "Error: Read past end of vu1 register window!!!\n");
-           exit(1);
-       }
+  if (addr < VU1_REGISTER_WINDOW_START)
+    return 0;
 
-       dest = ((char*) (&vu1_state.regs)) + (addr - VU1_REGISTER_WINDOW_START);
+  addr -= VU1_REGISTER_WINDOW_START;
 
-       memcpy(dest, source, nr_bytes);
+  /* Adjust nr_bytes if too big */
+  if ((addr + nr_bytes) > VU_REG_END)
+    nr_bytes -= addr + nr_bytes - VU_REG_END;
 
-       return nr_bytes;
+  return write_vu_registers (&vu1_state, addr, nr_bytes, source);
 }
 
 device vu1_device = 
@@ -172,7 +104,7 @@ vu1_init(SIM_DESC sd)
                    access_read_write,
                    0 /*space ???*/,
                    VU1_REGISTER_WINDOW_START,
-                   VU1_REGISTER_WINDOW_SIZE /*nr_bytes*/,
+                   VU_REG_END /*nr_bytes*/,
                    0 /*modulo*/,
                    &vu1_device,
                    NULL /*buffer*/);
index c724f6a17cb70a82b82b221e9e2ce5ffce48033b..17e9d99a674da601954b8ffab3eef1e8d4b4fe26 100644 (file)
@@ -20,30 +20,8 @@ int vu1_busy(void);
 
 #define VU1_REGISTER_WINDOW_START 0x11007000
 
-#define VU1_VF00               0x11007000
-/* ... */
-#define VU1_VF31               0x110071f0
-
-#define VU1_VI00               0x11007200
-/* ... */
-#define VU1_VI15               0x110072f0
-
-#define VU1_MST                        0x11007300
-#define VU1_MMC                        0x11007310
-#define VU1_MCP                        0x11007320
-#define VU1_MR                 0x11007330
-#define VU1_MI                 0x11007340
-#define VU1_MQ                 0x11007350
-#define VU1_MP                 0x11007360
-#define VU1_MTPC               0x110073a0
-#define VPE1_STAT              0x110073d0
-
+/* FIX ME: These should be derived from enum in sky-vu.h */
 #define VPU_STAT               0x110073d0
-
 #define VU1_CIA                        0x110073e0
 
-#define VU1_REGISTER_WINDOW_END   0x110073f0
-
-#define VU1_REGISTER_WINDOW_SIZE (VU1_REGISTER_WINDOW_END - VU1_REGISTER_WINDOW_START)
-
 #endif