* Makefile.in: Delete stuff moved to ../common/Make-common.in.
authorDavid Edelsohn <dje.gcc@gmail.com>
Wed, 20 Nov 1996 09:38:10 +0000 (09:38 +0000)
committerDavid Edelsohn <dje.gcc@gmail.com>
Wed, 20 Nov 1996 09:38:10 +0000 (09:38 +0000)
(SIM_{OBJS,EXTRA_LIBS,EXTRA_LIBDEPS,EXTRA_ALL,EXTRA_INSTALL}): Define.
(SIM_{EXTRA_CLEAN,EXTRA_CFLAGS}): Define.
* configure.in: Simplify using macros in ../common/aclocal.m4.
Call AC_CHECK_HEADERS(stdlib.h).
* configure: Regenerated.
* config.in: New file.
* func.c (sim_set_callbacks): Delete, moved to
* interf.c (sim_set_callbacks): here.
(sim_callback): New global.
Rewrite all calls to printf_filtered to go through callback.
(sim_size,sim_trace): New functions.
(sim_{insert,remove}_breakpoint): #if 0 out.
* sis.c: #include "config.h".  #include <stdlib.h> if present.
(main): Coerce fprintf arg to INIT_DISASSEMBLE_INFO to fprintf_ftype.
* sis.h: #include "callback.h".

sim/erc32/.Sanitize
sim/erc32/ChangeLog
sim/erc32/Makefile.in
sim/erc32/configure.in
sim/erc32/sis.c [new file with mode: 0644]

index e74b029..9c595fe 100644 (file)
@@ -29,6 +29,7 @@ NEWS
 README.erc32
 README.gdb
 README.sis
+config.in
 configure
 configure.in
 end.c
index 0daf110..7505be1 100644 (file)
@@ -1,6 +1,29 @@
+Wed Nov 20 01:30:12 1996  Doug Evans  <dje@canuck.cygnus.com>
+
+       * Makefile.in: Delete stuff moved to ../common/Make-common.in.
+       (SIM_{OBJS,EXTRA_LIBS,EXTRA_LIBDEPS,EXTRA_ALL,EXTRA_INSTALL}): Define.
+       (SIM_{EXTRA_CLEAN,EXTRA_CFLAGS}): Define.
+       * configure.in: Simplify using macros in ../common/aclocal.m4.
+       Call AC_CHECK_HEADERS(stdlib.h).
+       * configure: Regenerated.
+       * config.in: New file.
+       * func.c (sim_set_callbacks): Delete, moved to
+       * interf.c (sim_set_callbacks): here.
+       (sim_callback): New global.
+       Rewrite all calls to printf_filtered to go through callback.
+       (sim_size,sim_trace): New functions.
+       (sim_{insert,remove}_breakpoint): #if 0 out.
+       * sis.c: #include "config.h".  #include <stdlib.h> if present.
+       (main): Coerce fprintf arg to INIT_DISASSEMBLE_INFO to fprintf_ftype.
+       * sis.h: #include "callback.h".
+
+Thu Oct  3 16:12:03 1996  Jason Molenda  (crash@godzilla.cygnus.co.jp)
+
+       * Makefile.in (clean): Move config.log to distclean.
+
 Wed Oct  2 16:57:57 1996  Jason Molenda  (crash@godzilla.cygnus.co.jp)
 
-       * Makefile.in (clean): Remove config.log.
+       * Makefile.in (clean): Also remove config.log.
 
 Sat Sep 14 00:00:46 1996  Ian Lance Taylor  <ian@cygnus.com>
 
index 9cd5588..cc4b586 100644 (file)
@@ -1,5 +1,5 @@
 #    Makefile template for Configure for the erc32sim library.
-#    Copyright (C) 1993 Free Software Foundation, Inc.
+#    Copyright (C) 1993, 1996 Free Software Foundation, Inc.
 #    Written by Cygnus Support
 #    Modified by J.Gaisler ESA/ESTEC
 # 
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-VPATH = @srcdir@
-srcdir = @srcdir@
+# SIM_AC_OUTPUT combines this with ../common/Make-common.in to produce the
+# real Makefile.
 
-prefix = @prefix@
-exec_prefix = @exec_prefix@
+## Begin config
+SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
+SIM_EXTRA_LIBS = ../../readline/libreadline.a -ltermcap -lm
+SIM_EXTRA_LIBDEPS = ../../readline/libreadline.a
+SIM_EXTRA_ALL = sis
+SIM_EXTRA_INSTALL = install-sis
+SIM_EXTRA_CLEAN = clean-sis
 
-host_alias = @host_alias@
-target_alias = @target_alias@
-program_transform_name = @program_transform_name@
-bindir = @bindir@
-libdir = @libdir@
-tooldir = $(exec_prefix)/$(target_alias)
-
-datadir = @datadir@
-mandir = @mandir@
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-man3dir = $(mandir)/man3
-man4dir = $(mandir)/man4
-man5dir = $(mandir)/man5
-man6dir = $(mandir)/man6
-man7dir = $(mandir)/man7
-man8dir = $(mandir)/man8
-man9dir = $(mandir)/man9
-infodir = @infodir@
-includedir = @includedir@
-
-SHELL = /bin/sh
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)'
-INSTALL_XFORM1= $(INSTALL_XFORM) -b=.1
-
-AR = @AR@
-AR_FLAGS = rc
-CC = @CC@
-CFLAGS = @CFLAGS@
-MAKEINFO = makeinfo
-RANLIB = @RANLIB@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-
-#
 # UARTS run at about 115200 baud (simulator time). Add -DFAST_UART to
 # CFLAGS if faster (infinite) UART speed is desired. Might affect the
 # behaviour of UART interrupt routines ...
-#
-
-CFLAGS2 = -g -O3 -DSTAT -DFAST_UART -DIUREV0 -DMECREV0
+SIM_EXTRA_CFLAGS = -DSTAT -DFAST_UART -DIUREV0 -DMECREV0
+## End config
 
-INCDIR = $(srcdir)/../../include
-CSEARCH = -I. -I$(srcdir) -I$(INCDIR) -I../../bfd -I$(srcdir)/../../bfd \
-               -I$(srcdir)/../../gdb -I$(srcdir)/../../gdb/config
-DEP = mkdep
+# `sis' doesn't need interf.o.
+SIS_OFILES = exec.o erc32.o func.o help.o float.o
 
+sis: sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
+       $(CC) $(ALL_CFLAGS) -o sis \
+         sis.o $(SIS_OFILES) $(COMMON_OBJS) $(EXTRA_LIBS)
 
-TARGETLIB = libsim.a
-
-CFILES = sis.c exec.c erc32.c interf.c run.c help.c float.c
-OFILES =  exec.o erc32.o func.o help.o float.o
-
-
-all: end.h sis run $(TARGETLIB)
-
-end : $(srcdir)/end.c
+# FIXME: This computes the build host's endianness, doesn't it?
+# There is AC_C_BIGENDIAN but it doesn't handle float endianness.
+# [Are int/float endians every different on a sparc?]
+end: $(srcdir)/end.c
        $(CC_FOR_BUILD) $(srcdir)/end.c -o end
-
-end.h : end
+end.h: end
        ./end > end.h
 
-sis: sis.o $(OFILES)
-       $(CC) $(CFLAGS) $(CLAGS2) -o sis sis.o $(OFILES) \
-       ../../opcodes/libopcodes.a ../../readline/libreadline.a \
-       ../../bfd/libbfd.a ../../libiberty/libiberty.a \
-       -ltermcap -lm
-
-run: run.o interf.o $(OFILES)
-       $(CC) $(CFLAGS) $(CLAGS2) -o run run.o interf.o $(OFILES) \
-       ../../opcodes/libopcodes.a ../../readline/libreadline.a \
-       ../../bfd/libbfd.a ../../libiberty/libiberty.a \
-       -ltermcap -lm
-
-clean:
-       rm -f *.o libsim.a sis run end end.h config.log
-
-distclean: clean
-       rm -rf Makefile config.status sysdep.h
-
-#### host and target dependent Makefile fragments come in here.
-###
-
-FLAGS_TO_PASS = \
-       "against=$(against)" \
-       "AR=$(AR)" \
-       "AR_FLAGS=$(AR_FLAGS)" \
-       "CC=$(CC)" \
-       "CFLAGS=$(CFLAGS)" \
-       "RANLIB=$(RANLIB)" \
-       "MAKEINFO=$(MAKEINFO)" \
-       "INSTALL=$(INSTALL)" \
-       "INSTALL_DATA=$(INSTALL_DATA)" \
-       "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
-       "BISON=$(BISON)"
-
-$(OFILES) sis.o interf.o : end.h sis.h
-
-.c.o:
-       $(CC) -c $(CFLAGS) $(CFLAGS2) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) $<
-
-
-# C source files that correspond to .o's.
-
-STAGESTUFF = $(TARGETLIB) $(OFILES)
-
-all: $(TARGETLIB) 
-
-
-.NOEXPORT:
-
-check:
-
-info:
-clean-info:
-install-info:
-
-# HDEPFILES comes from the host config; TDEPFILES from the target config.
-
+# Copy the files into directories where they will be run.
+install-sis:
+       $(INSTALL_XFORM) sis $(bindir)/sis
 
-$(TARGETLIB): $(OFILES) interf.o
-        rm -f $(TARGETLIB)
-        $(AR) $(AR_FLAGS) $(TARGETLIB) $(OFILES) interf.o
-        $(RANLIB) $(TARGETLIB)
+clean-sis:
+       rm -f sis end end.h
 
 # Circumvent Sun Make bug with VPATH.
-sparc-opc.o: sparc-opc.c
-
-tags etags: TAGS
-
-TAGS: force
-       etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c
-
-
-sis.o: sis.c sis.h end.h
-exec.o: exec.c sis.h end.h
 erc32.o: erc32.c sis.h end.h
+exec.o: exec.c sis.h end.h
+float.o: float.c sis.h end.h
+func.o: func.c
+help.o: help.c
 interf.o: interf.c sis.h end.h 
 run.o: run.c
-help.o: help.c
-float.o: float.c sis.h end.h
-
-# Mark everything as depending on config.status, since the timestamp on
-# sysdep.h might actually move backwards if we reconfig and relink it
-# to a different hosts/h-xxx.h file.  This will force a recompile anyway.
-RECONFIG = config.status
-
-# Dummy target to force execution of dependent targets.
-#
-force:
-
-# Copy the files into directories where they will be run.
-install:
-       $(INSTALL_XFORM) sis $(bindir)/sis ;  \
-       n=`echo sis | sed '$(program_transform_name)'`; \
-       rm -f $(bindir)/sis;  \
-       ln $(bindir)/$$n $(bindir)/sis \
-         || $(INSTALL_PROGRAM) sis $(bindir)/sis; \
-       test -d $(tooldir) || mkdir $(tooldir); \
-       test -d $(tooldir)/bin || mkdir $(tooldir)/bin; \
-       rm -f $(tooldir)/bin/sis;  \
-       ln $(bindir)/$$n $(tooldir)/bin/sis \
-         || $(INSTALL_PROGRAM) sis $(tooldir)/bin/sis; \
-
-
-Makefile: $(srcdir)/Makefile.in
-       $(SHELL) ./config.status
+sis.o: sis.c sis.h end.h
index 33ad604..501b59e 100644 (file)
@@ -2,29 +2,8 @@ dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.5)dnl
 AC_INIT(Makefile.in)
 
-AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
-AC_CANONICAL_SYSTEM
-AC_ARG_PROGRAM
-AC_PROG_CC
-AC_PROG_INSTALL
+SIM_AC_COMMON
 
-. ${srcdir}/../../bfd/configure.host
+AC_CHECK_HEADERS(stdlib.h)
 
-AC_SUBST(CFLAGS)
-AC_SUBST(HDEFINES)
-AR=${AR-ar}
-AC_SUBST(AR)
-AC_PROG_RANLIB
-
-# Put a plausible default for CC_FOR_BUILD in Makefile.
-AC_C_CROSS
-if test -z "$CC_FOR_BUILD"; then
-  if test "x$cross_compiling" = "xno"; then
-    CC_FOR_BUILD='$(CC)'
-  else
-    CC_FOR_BUILD=gcc
-  fi
-fi
-AC_SUBST(CC_FOR_BUILD)
-
-AC_OUTPUT(Makefile)
+SIM_AC_OUTPUT
diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
new file mode 100644 (file)
index 0000000..5834e5a
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * This file is part of SIS.
+ * 
+ * SIS, SPARC instruction simulator. Copyright (C) 1995 Jiri Gaisler, European
+ * Space Agency
+ * 
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
+ * Mass Ave, Cambridge, MA 02139, USA.
+ * 
+ */
+
+#include "config.h"
+
+#include <signal.h>
+#include <string.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+#include "sis.h"
+#include <dis-asm.h>
+
+#ifndef fprintf
+extern          fprintf();
+#endif
+
+#define        VAL(x)  strtol(x,(char *)NULL,0)
+
+extern char    *readline(char *prompt);        /* GNU readline function */
+
+/* Command history buffer length - MUST be binary */
+#define HIST_LEN       64
+
+extern struct disassemble_info dinfo;
+extern struct pstate sregs;
+extern struct estate ebase;
+
+extern int      ctrl_c;
+extern int      nfp;
+extern int      sis_verbose;
+extern char    *sis_version;
+extern struct estate ebase;
+extern struct evcell evbuf[];
+extern struct irqcell irqarr[];
+extern int      irqpend, ext_irl;
+extern char     uart_dev1[];
+extern char     uart_dev2[];
+
+#ifdef IUREV0
+extern int      iurev0;
+#endif
+
+#ifdef MECREV0
+extern int      mecrev0;
+#endif
+
+run_sim(sregs, go, icount, dis)
+    struct pstate  *sregs;
+    int             go;
+    unsigned int    icount;
+    int             dis;
+{
+    int             mexc, ws;
+
+    sregs->starttime = time(NULL);
+    while (!sregs->err_mode & (go || (icount > 0))) {
+       if (sregs->bptnum && check_bpt(sregs))
+           return (BPT_HIT);
+       sregs->bphit = 0;
+       sregs->fhold = 0;
+       sregs->hold = 0;
+       sregs->icnt = 0;
+
+       sregs->asi = 9 - ((sregs->psr & 0x080) >> 7);
+
+#ifdef IUREV0
+       if (iurev0 && sregs->rett_err) {
+           sregs->asi &= ~0x1;
+           sregs->asi |= ((sregs->psr & 0x040) >> 6);
+       }
+#endif
+
+       mexc = memory_read(sregs->asi, sregs->pc, &sregs->inst, &sregs->hold);
+
+       if (sregs->annul) {
+           sregs->annul = 0;
+           sregs->icnt = 1;
+           sregs->pc = sregs->npc;
+           sregs->npc = sregs->npc + 4;
+           mexc = 0;           /* Traps ignored during annul */
+       } else {
+           check_interrupts(sregs);
+           if (sregs->trap) {
+               sregs->err_mode = execute_trap(sregs);
+           } else {
+               if (mexc) {
+                   sregs->trap = I_ACC_EXC;
+               } else {
+                   if (sregs->histlen) {
+                       sregs->histbuf[sregs->histind].addr = sregs->pc;
+                       sregs->histbuf[sregs->histind].time = ebase.simtime;
+                       sregs->histind++;
+                       if (sregs->histind >= sregs->histlen)
+                           sregs->histind = 0;
+                   }
+                   if (dis) {
+                       printf(" %8u ", ebase.simtime);
+                       dis_mem(sregs->pc, 1, &dinfo);
+                   }
+                   dispatch_instruction(sregs);
+               }
+               icount--;
+           }
+           if (sregs->trap) {
+               sregs->err_mode = execute_trap(sregs);
+           }
+       }
+       advance_time(sregs);
+       if (ctrl_c) {
+           go = icount = 0;
+       }
+    }
+    sregs->tottime += time(NULL) - sregs->starttime;
+    if (sregs->err_mode)
+       error_mode(sregs->pc);
+    if (sregs->err_mode)
+       return (ERROR);
+    if (ctrl_c) {
+       ctrl_c = 0;
+       return (CTRL_C);
+    }
+    return (TIME_OUT);
+}
+
+main(argc, argv)
+    int             argc;
+    char          **argv;
+{
+
+    int             cont = 1;
+    int             stat = 1;
+    int             freq = 14;
+    int             copt = 0;
+
+    char            lastcmd[128] = "reg";
+    char           *cmd, *cfile, *bacmd;
+    char           *cmdq[HIST_LEN];
+    int             cmdi = 0;
+    int             i;
+
+    for (i = 0; i < 64; i++)
+       cmdq[i] = 0;
+    printf("\n SIS - SPARC intruction simulator %s,  copyright Jiri Gaisler 1995\n", sis_version);
+    printf(" Bug-reports to jgais@wd.estec.esa.nl\n\n");
+    while (stat < argc) {
+       if (argv[stat][0] == '-') {
+           if (strcmp(argv[stat], "-v") == 0) {
+               sis_verbose = 1;
+           } else if (strcmp(argv[stat], "-c") == 0) {
+               if ((stat + 1) < argc) {
+                   copt = 1;
+                   cfile = argv[++stat];
+               }
+           } else if (strcmp(argv[stat], "-nfp") == 0)
+               nfp = 1;
+#ifdef IUREV0
+           else if (strcmp(argv[stat], "-iurev0") == 0)
+               iurev0 = 1;
+#endif
+#ifdef MECREV0
+           else if (strcmp(argv[stat], "-mecrev0") == 0)
+               mecrev0 = 1;
+#endif
+           else if (strcmp(argv[stat], "-uart1") == 0) {
+               if ((stat + 1) < argc)
+                   strcpy(uart_dev1, argv[++stat]);
+           } else if (strcmp(argv[stat], "-uart2") == 0) {
+               if ((stat + 1) < argc)
+                   strcpy(uart_dev2, argv[++stat]);
+           } else if (strcmp(argv[stat], "-freq") == 0) {
+               if ((stat + 1) < argc)
+                   freq = VAL(argv[++stat]);
+           } else {
+               printf("unknown option %s\n", argv[stat]);
+               usage();
+               exit(1);
+           }
+       } else {
+           bfd_load(argv[stat]);
+       }
+       stat++;
+    }
+#ifdef IUREV0
+    if (iurev0)
+       printf(" simulating IU rev.0 jmpl/restore bug\n");
+#endif
+#ifdef MECREV0
+    if (iurev0)
+       printf(" simulating MEC rev.0 timer and uart interrupt bug\n");
+#endif
+    if (nfp)
+       printf("FPU disabled\n");
+    sregs.freq = freq;
+
+    INIT_DISASSEMBLE_INFO(dinfo, stdout, (fprintf_ftype) fprintf);
+
+    using_history();
+    init_signals();
+    ebase.simtime = 0;
+    reset_all();
+    init_bpt(&sregs);
+    init_sim();
+#ifdef STAT
+    reset_stat(&sregs);
+#endif
+
+    if (copt) {
+       bacmd = (char *) malloc(256);
+       strcpy(bacmd, "batch ");
+       strcat(bacmd, cfile);
+       exec_cmd(&sregs, bacmd);
+    }
+    while (cont) {
+
+       if (cmdq[cmdi] != 0) {
+           remove_history(cmdq[cmdi]);
+           free(cmdq[cmdi]);
+           cmdq[cmdi] = 0;
+       }
+       cmdq[cmdi] = readline("sis> ");
+       if (cmdq[cmdi] && *cmdq[cmdi])
+           add_history(cmdq[cmdi]);
+       if (cmdq[cmdi])
+           stat = exec_cmd(&sregs, cmdq[cmdi]);
+       else {
+           puts("\n");
+           exit(0);
+       }
+       switch (stat) {
+       case OK:
+           break;
+       case CTRL_C:
+           printf("\b\bInterrupt!\n");
+       case TIME_OUT:
+           printf(" Stopped at time %d\n", ebase.simtime);
+           break;
+       case BPT_HIT:
+           printf("breakpoint at 0x%08x reached\n", sregs.pc);
+           sregs.bphit = 1;
+           break;
+       case ERROR:
+           printf("IU in error mode (%d)\n", sregs.trap);
+           stat = 0;
+           printf(" %8d ", ebase.simtime);
+           dis_mem(sregs.pc, 1, &dinfo);
+           break;
+       default:
+           break;
+       }
+       ctrl_c = 0;
+       stat = OK;
+
+       cmdi = (cmdi + 1) & (HIST_LEN - 1);
+
+    }
+}