From: Ron Unrau Date: Fri, 27 Mar 1998 14:44:39 +0000 (+0000) Subject: * sky-vu.c: new file to read/write VU registers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d44859a2d85f9515b99e0db40f06c6e60212110e;p=binutils-gdb.git * sky-vu.c: new file to read/write VU registers * 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 --- diff --git a/sim/mips/.Sanitize b/sim/mips/.Sanitize index 816d8a8fca9..455c5e74f6b 100644 --- a/sim/mips/.Sanitize +++ b/sim/mips/.Sanitize @@ -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 diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in index 157cee43902..184c0f57741 100644 --- a/sim/mips/Makefile.in +++ b/sim/mips/Makefile.in @@ -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 diff --git a/sim/mips/interp.c b/sim/mips/interp.c index 0dc36e10b2e..0be63da5eb9 100644 --- a/sim/mips/interp.c +++ b/sim/mips/interp.c @@ -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] ); diff --git a/sim/mips/sky-vu0.c b/sim/mips/sky-vu0.c index dc42ce5cdce..a685713e4cc 100644 --- a/sim/mips/sky-vu0.c +++ b/sim/mips/sky-vu0.c @@ -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*/); diff --git a/sim/mips/sky-vu0.h b/sim/mips/sky-vu0.h index 263b6069513..2519384ec9a 100644 --- a/sim/mips/sky-vu0.h +++ b/sim/mips/sky-vu0.h @@ -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 diff --git a/sim/mips/sky-vu1.c b/sim/mips/sky-vu1.c index 9ab7856cb77..c7f7b4a936d 100644 --- a/sim/mips/sky-vu1.c +++ b/sim/mips/sky-vu1.c @@ -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*/); diff --git a/sim/mips/sky-vu1.h b/sim/mips/sky-vu1.h index c724f6a17cb..17e9d99a674 100644 --- a/sim/mips/sky-vu1.h +++ b/sim/mips/sky-vu1.h @@ -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