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
sky-hardware.o \
sky-libvpe.o \
sky-pke.o \
+ sky-vu.o \
sky-vu0.o \
sky-vu1.o \
sky-gdb.o
m16run.o \
MIPS_EXTRA_OBJS = @mips_extra_objs@
+MIPS_EXTRA_LIBS = @mips_extra_libs@
SIM_OBJS = \
$(SIM_@sim_gen@_OBJ) \
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
$(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
#include "sysdep.h"
+/* start-sanitize-sky */
+#ifdef TARGET_SKY
+#include "sky-vu.h"
+#endif
+/* end-sanitize-sky */
+
#ifndef PARAMS
#define PARAMS(x)
#endif
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 );
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 );
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] );
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] );
#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;
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
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 =
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*/);
#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
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];
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 =
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*/);
#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