mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-25 21:19:54 +00:00
Thu Aug 1 17:05:24 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* ChangeLog, Makefile.in, configure, configure.in, d10v_sim.h, gencode.c, interp.c, simops.c: Created.
This commit is contained in:
parent
745a0437db
commit
2934d1c925
5
sim/d10v/ChangeLog
Normal file
5
sim/d10v/ChangeLog
Normal file
@ -0,0 +1,5 @@
|
||||
Thu Aug 1 17:05:24 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
|
||||
|
||||
* ChangeLog, Makefile.in, configure, configure.in, d10v_sim.h,
|
||||
gencode.c, interp.c, simops.c: Created.
|
||||
|
149
sim/d10v/Makefile.in
Normal file
149
sim/d10v/Makefile.in
Normal file
@ -0,0 +1,149 @@
|
||||
# Makefile template for Configure for the SH sim library.
|
||||
# Copyright (C) 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
|
||||
# Written by Cygnus Support.
|
||||
#
|
||||
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
VPATH = @srcdir@:@srcdir@/../common:@srcdir@/../../gdb/
|
||||
srcdir = @srcdir@
|
||||
srcroot = $(srcdir)/../..
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
host_alias = @host_alias@
|
||||
target_alias = @target_alias@
|
||||
program_transform_name = @program_transform_name@
|
||||
bindir = @bindir@
|
||||
|
||||
libdir = @libdir@
|
||||
tooldir = $(libdir)/$(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 = $(srcroot)/install.sh -c
|
||||
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@
|
||||
|
||||
HDEFINES = @HDEFINES@
|
||||
TDEFINES =
|
||||
|
||||
.NOEXPORT:
|
||||
MAKEOVERRIDES=
|
||||
|
||||
X=xstuff.o
|
||||
XL=-lX11
|
||||
X=
|
||||
XL=
|
||||
|
||||
INCDIR = $(srcdir)/../../include
|
||||
CSEARCH = -I. -I$(srcdir) -I../../include \
|
||||
-I../../bfd -I$(INCDIR) -I$(srcdir)/../../bfd -I$(srcdir)/../../gdb -I$(srcdir)/../../newlib/libc/sys/sh
|
||||
DEP = mkdep
|
||||
|
||||
all: run
|
||||
|
||||
run: interp.o $(X) run.o table.o callback.o simops.o
|
||||
$(CC) $(CFLAGS) -o run $(X) interp.o table.o callback.o simops.o run.o ../../bfd/libbfd.a ../../libiberty/libiberty.a $(XL) -lm
|
||||
|
||||
interp.o:interp.c table.c
|
||||
run.o:run.c
|
||||
|
||||
libsim.a:interp.o table.o simops.o
|
||||
$(AR) $(ARFLAGS) libsim.a interp.o table.o
|
||||
$(RANLIB) libsim.a
|
||||
|
||||
simops.h: gencode
|
||||
./gencode -h >$@
|
||||
|
||||
table.c: gencode simops.h
|
||||
./gencode >$@
|
||||
|
||||
gencode: gencode.c
|
||||
$(CC) $(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHE) -o gencode $(srcdir)/gencode.c ../../opcodes/libopcodes.a -lc
|
||||
|
||||
.c.o:
|
||||
$(CC) -c -DINSIDE_SIMULATOR $(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) $<
|
||||
|
||||
check:
|
||||
|
||||
info:
|
||||
clean-info:
|
||||
install-info:
|
||||
|
||||
tags etags: TAGS
|
||||
|
||||
TAGS: force
|
||||
etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c
|
||||
|
||||
clean:
|
||||
rm -f *.[oa] *~ core *.E *.p *.ip aout-params.h gen-aout
|
||||
rm -f run libsim.a
|
||||
|
||||
distclean mostlyclean maintainer-clean realclean: clean
|
||||
rm -f TAGS
|
||||
rm -f Makefile config.cache config.log config.status
|
||||
|
||||
# Dummy target to force execution of dependent targets.
|
||||
#
|
||||
force:
|
||||
|
||||
# Copy the files into directories where they will be run.
|
||||
install:
|
||||
$(INSTALL_XFORM) run $(bindir)/run
|
||||
|
||||
install-man: run.1
|
||||
$(INSTALL_XFORM1) $(srcdir)/run.1 $(man1dir)/run.1
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
$(SHELL) ./config.status
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
dep: $(CFILES)
|
||||
mkdep $(CFLAGS) $?
|
||||
|
||||
# What appears below is generated by a hacked mkdep using gcc -MM.
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
|
||||
|
||||
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
|
29
sim/d10v/configure.in
Normal file
29
sim/d10v/configure.in
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
. ${srcdir}/../../bfd/configure.host
|
||||
|
||||
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 "x$cross_compiling" = "xno"; then
|
||||
CC_FOR_BUILD='$(CC)'
|
||||
else
|
||||
CC_FOR_BUILD=gcc
|
||||
fi
|
||||
AC_SUBST(CC_FOR_BUILD)
|
||||
|
||||
AC_OUTPUT(Makefile)
|
104
sim/d10v/d10v_sim.h
Normal file
104
sim/d10v/d10v_sim.h
Normal file
@ -0,0 +1,104 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "ansidecl.h"
|
||||
#include "opcode/d10v.h"
|
||||
|
||||
/* FIXME: host defines */
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
typedef signed long long int64;
|
||||
|
||||
/* FIXME: D10V defines */
|
||||
typedef uint16 reg_t;
|
||||
|
||||
struct simops
|
||||
{
|
||||
long opcode;
|
||||
long mask;
|
||||
int format;
|
||||
int cycles;
|
||||
int unit;
|
||||
int exec_type;
|
||||
void (*func)();
|
||||
int numops;
|
||||
int operands[9];
|
||||
};
|
||||
|
||||
struct _state
|
||||
{
|
||||
reg_t regs[16]; /* general-purpose registers */
|
||||
reg_t cregs[15]; /* control registers */
|
||||
int64 a[2]; /* accumulators */
|
||||
uint8 SM;
|
||||
uint8 EA;
|
||||
uint8 DB;
|
||||
uint8 IE;
|
||||
uint8 RP;
|
||||
uint8 MD;
|
||||
uint8 FX;
|
||||
uint8 ST;
|
||||
uint8 F0;
|
||||
uint8 F1;
|
||||
uint8 C;
|
||||
uint8 exe;
|
||||
uint8 *imem;
|
||||
uint8 *dmem;
|
||||
} State;
|
||||
|
||||
extern uint16 OP[4];
|
||||
extern struct simops Simops[];
|
||||
|
||||
#define PC (State.cregs[2])
|
||||
#define PSW (State.cregs[0])
|
||||
#define BPSW (State.cregs[1])
|
||||
#define BPC (State.cregs[3])
|
||||
#define RPT_C (State.cregs[7])
|
||||
#define RPT_S (State.cregs[8])
|
||||
#define RPT_E (State.cregs[9])
|
||||
#define MOD_S (State.cregs[10])
|
||||
#define MOD_E (State.cregs[11])
|
||||
#define IBA (State.cregs[14])
|
||||
|
||||
#define SEXT3(x) ((((x)&0x7)^(~3))+4)
|
||||
|
||||
/* sign-extend a 4-bit number */
|
||||
#define SEXT4(x) ((((x)&0xf)^(~7))+8)
|
||||
|
||||
/* sign-extend an 8-bit number */
|
||||
#define SEXT8(x) ((((x)&0xff)^(~0x7f))+0x80)
|
||||
|
||||
/* sign-extend a 16-bit number */
|
||||
#define SEXT16(x) ((((x)&0xffff)^(~0x7fff))+0x8000)
|
||||
|
||||
#define BIT40 0x8000000000LL
|
||||
#define BIT44 0x80000000000LL
|
||||
#define MAX32 0x7fffffffLL
|
||||
#define MIN32 0xff80000000LL
|
||||
#define MASK32 0xffffffffLL
|
||||
#define MASK40 0xffffffffffLL
|
||||
#define MASK44 0xfffffffffffLL
|
||||
|
||||
|
||||
#define RB(x) (*((uint8 *)((x)+State.imem)))
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
|
||||
#define RW(x) (*((uint16 *)((x)+State.imem)))
|
||||
#define RLW(x) (*((uint32 *)((x)+State.imem)))
|
||||
#define SW(addr,data) RW(addr)=data
|
||||
|
||||
#else
|
||||
|
||||
uint32 get_longword_swap PARAMS ((uint16 x));
|
||||
uint16 get_word_swap PARAMS ((uint16 x));
|
||||
void write_word_swap PARAMS ((uint16 addr, uint16 data));
|
||||
|
||||
#define SW(addr,data) write_word_swap(addr,data)
|
||||
#define RW(x) get_word_swap(x)
|
||||
#define RLW(x) get_longword_swap(x)
|
||||
|
||||
#endif /* not WORDS_BIGENDIAN */
|
345
sim/d10v/interp.c
Normal file
345
sim/d10v/interp.c
Normal file
@ -0,0 +1,345 @@
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "remote-sim.h"
|
||||
#include "callback.h"
|
||||
|
||||
#include "d10v_sim.h"
|
||||
|
||||
#define IMEM_SIZE 18 /* D10V instruction memory size is 18 bits */
|
||||
#define DMEM_SIZE 16 /* Data memory */
|
||||
|
||||
uint16 OP[4];
|
||||
|
||||
static struct hash_entry *lookup_hash PARAMS ((uint32 ins, int size));
|
||||
|
||||
#define MAX_HASH 63
|
||||
struct hash_entry
|
||||
{
|
||||
struct hash_entry *next;
|
||||
long opcode;
|
||||
long mask;
|
||||
struct simops *ops;
|
||||
};
|
||||
|
||||
struct hash_entry hash_table[MAX_HASH+1];
|
||||
|
||||
static long
|
||||
hash(insn, format)
|
||||
long insn;
|
||||
int format;
|
||||
{
|
||||
if (format & LONG_OPCODE)
|
||||
return ((insn & 0x3F000000) >> 24);
|
||||
else
|
||||
return((insn & 0x7E00) >> 9);
|
||||
}
|
||||
|
||||
static struct hash_entry *
|
||||
lookup_hash (ins, size)
|
||||
uint32 ins;
|
||||
int size;
|
||||
{
|
||||
struct hash_entry *h;
|
||||
|
||||
if (size)
|
||||
h = &hash_table[(ins & 0x3F000000) >> 24];
|
||||
else
|
||||
h = &hash_table[(ins & 0x7E00) >> 9];
|
||||
|
||||
while ( (ins & h->mask) != h->opcode)
|
||||
{
|
||||
if (h->next == NULL)
|
||||
{
|
||||
printf ("ERROR looking up hash for %x\n",ins);
|
||||
exit(1);
|
||||
}
|
||||
h = h->next;
|
||||
}
|
||||
return (h);
|
||||
}
|
||||
|
||||
uint32
|
||||
get_longword_swap (x)
|
||||
uint16 x;
|
||||
{
|
||||
uint8 *a = (uint8 *)(x + State.imem);
|
||||
return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + (a[3]);
|
||||
}
|
||||
|
||||
uint16
|
||||
get_word_swap (x)
|
||||
uint16 x;
|
||||
{
|
||||
uint8 *a = (uint8 *)(x + State.imem);
|
||||
return (a[0]<<8) + a[1];
|
||||
}
|
||||
|
||||
void
|
||||
write_word_swap (addr, data)
|
||||
uint16 addr, data;
|
||||
{
|
||||
uint8 *a = (uint8 *)(addr + State.imem);
|
||||
a[0] = data >> 8;
|
||||
a[1] = data & 0xff;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_operands (struct simops *s, uint32 ins)
|
||||
{
|
||||
int i, shift, bits, flags;
|
||||
uint32 mask;
|
||||
for (i=0; i < s->numops; i++)
|
||||
{
|
||||
shift = s->operands[3*i];
|
||||
bits = s->operands[3*i+1];
|
||||
flags = s->operands[3*i+2];
|
||||
mask = 0x7FFFFFFF >> (31 - bits);
|
||||
OP[i] = (ins >> shift) & mask;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_long (ins)
|
||||
uint32 ins;
|
||||
{
|
||||
struct hash_entry *h;
|
||||
/* printf ("do_long %x\n",ins); */
|
||||
h = lookup_hash (ins, 1);
|
||||
get_operands (h->ops, ins);
|
||||
(h->ops->func)();
|
||||
}
|
||||
static void
|
||||
do_2_short (ins1, ins2)
|
||||
uint16 ins1, ins2;
|
||||
{
|
||||
struct hash_entry *h;
|
||||
/* printf ("do_2_short %x -> %x\n",ins1,ins2); */
|
||||
h = lookup_hash (ins1, 0);
|
||||
get_operands (h->ops, ins1);
|
||||
(h->ops->func)();
|
||||
h = lookup_hash (ins2, 0);
|
||||
get_operands (h->ops, ins2);
|
||||
(h->ops->func)();
|
||||
}
|
||||
static void
|
||||
do_parallel (ins1, ins2)
|
||||
uint16 ins1, ins2;
|
||||
{
|
||||
struct hash_entry *h1, *h2;
|
||||
/* printf ("do_parallel %x || %x\n",ins1,ins2); */
|
||||
h1 = lookup_hash (ins1, 0);
|
||||
get_operands (h1->ops, ins1);
|
||||
h2 = lookup_hash (ins2, 0);
|
||||
get_operands (h2->ops, ins2);
|
||||
if (h1->ops->exec_type == PARONLY)
|
||||
{
|
||||
(h1->ops->func)();
|
||||
if (State.exe)
|
||||
(h2->ops->func)();
|
||||
}
|
||||
else if (h2->ops->exec_type == PARONLY)
|
||||
{
|
||||
(h2->ops->func)();
|
||||
if (State.exe)
|
||||
(h1->ops->func)();
|
||||
}
|
||||
else
|
||||
{
|
||||
(h1->ops->func)();
|
||||
(h2->ops->func)();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sim_size (power)
|
||||
int power;
|
||||
|
||||
{
|
||||
if (State.imem)
|
||||
{
|
||||
free (State.imem);
|
||||
free (State.dmem);
|
||||
}
|
||||
|
||||
State.imem = (uint8 *)calloc(1,1<<IMEM_SIZE);
|
||||
State.dmem = (uint8 *)calloc(1,1<<DMEM_SIZE);
|
||||
if (!State.imem || !State.dmem )
|
||||
{
|
||||
fprintf (stderr,"Memory allocation failed.\n");
|
||||
exit(1);
|
||||
}
|
||||
printf ("Allocated %d bytes instruction memory and\n",1<<IMEM_SIZE);
|
||||
printf (" %d bytes data memory.\n",1<<DMEM_SIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
init_system ()
|
||||
{
|
||||
if (!State.imem)
|
||||
sim_size(1);
|
||||
}
|
||||
|
||||
int
|
||||
sim_write (addr, buffer, size)
|
||||
SIM_ADDR addr;
|
||||
unsigned char *buffer;
|
||||
int size;
|
||||
{
|
||||
int i;
|
||||
init_system ();
|
||||
|
||||
printf ("sim_write %d bytes to 0x%x\n",size,addr);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
State.imem[i+addr] = buffer[i];
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void
|
||||
sim_open (args)
|
||||
char *args;
|
||||
{
|
||||
struct simops *s;
|
||||
struct hash_entry *h, *prev;
|
||||
if (args != NULL)
|
||||
printf ("sim_open %s\n",args);
|
||||
|
||||
/* put all the opcodes in the hash table */
|
||||
for (s = Simops; s->func; s++)
|
||||
{
|
||||
h = &hash_table[hash(s->opcode,s->format)];
|
||||
|
||||
/* go to the last entry in the chain */
|
||||
while (h->next)
|
||||
h = h->next;
|
||||
|
||||
if (h->ops)
|
||||
{
|
||||
h->next = calloc(1,sizeof(struct hash_entry));
|
||||
h = h->next;
|
||||
}
|
||||
h->ops = s;
|
||||
h->mask = s->mask;
|
||||
h->opcode = s->opcode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sim_close (quitting)
|
||||
int quitting;
|
||||
{
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_profile (n)
|
||||
int n;
|
||||
{
|
||||
printf ("sim_set_profile %d\n",n);
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_profile_size (n)
|
||||
int n;
|
||||
{
|
||||
printf ("sim_set_profile_size %d\n",n);
|
||||
}
|
||||
|
||||
void
|
||||
sim_resume (step, siggnal)
|
||||
int step, siggnal;
|
||||
{
|
||||
uint32 inst;
|
||||
int i;
|
||||
reg_t oldpc;
|
||||
|
||||
printf ("sim_resume %d %d\n",step,siggnal);
|
||||
|
||||
while (1)
|
||||
{
|
||||
inst = RLW (PC << 2);
|
||||
oldpc = PC;
|
||||
switch (inst & 0xC0000000)
|
||||
{
|
||||
case 0xC0000000:
|
||||
/* long instruction */
|
||||
do_long (inst & 0x3FFFFFFF);
|
||||
break;
|
||||
case 0x80000000:
|
||||
/* R -> L */
|
||||
do_2_short ( inst & 0x7FFF, (inst & 0x3FFF8000) >> 15);
|
||||
break;
|
||||
case 0x40000000:
|
||||
/* L -> R */
|
||||
do_2_short ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF);
|
||||
break;
|
||||
case 0:
|
||||
do_parallel ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF);
|
||||
break;
|
||||
}
|
||||
|
||||
if (State.RP && PC == RPT_E)
|
||||
{
|
||||
RPT_C -= 1;
|
||||
if (RPT_C == 0)
|
||||
State.RP = 0;
|
||||
else
|
||||
PC = RPT_S;
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
if (PC == oldpc)
|
||||
PC++;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
sim_trace ()
|
||||
{
|
||||
printf ("sim_trace\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
sim_info (verbose)
|
||||
int verbose;
|
||||
{
|
||||
printf ("sim_verbose\n");
|
||||
}
|
||||
|
||||
void
|
||||
sim_create_inferior (start_address, argv, env)
|
||||
SIM_ADDR start_address;
|
||||
char **argv;
|
||||
char **env;
|
||||
{
|
||||
printf ("sim_create_inferior: PC=0x%x\n",start_address);
|
||||
PC = start_address >> 2;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sim_kill ()
|
||||
{
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_callbacks(p)
|
||||
host_callback *p;
|
||||
{
|
||||
printf ("sim_set_callbacks\n");
|
||||
/* callback = p; */
|
||||
}
|
||||
|
||||
void
|
||||
sim_stop_reason (reason, sigrc)
|
||||
enum sim_stop *reason;
|
||||
int *sigrc;
|
||||
{
|
||||
printf ("sim_stop_reason\n");
|
||||
}
|
1728
sim/d10v/simops.c
Normal file
1728
sim/d10v/simops.c
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user