1996-08-29 02:35:11 +02:00
|
|
|
#include <signal.h>
|
1996-08-02 02:23:31 +02:00
|
|
|
#include "sysdep.h"
|
1996-11-20 10:27:24 +01:00
|
|
|
#include "callback.h"
|
1996-08-02 02:23:31 +02:00
|
|
|
#include "remote-sim.h"
|
|
|
|
|
|
|
|
#include "d10v_sim.h"
|
|
|
|
|
|
|
|
#define IMEM_SIZE 18 /* D10V instruction memory size is 18 bits */
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
#define DMEM_SIZE 16 /* Data memory is 64K (but only 32K internal RAM) */
|
|
|
|
#define UMEM_SIZE 17 /* each unified memory region is 17 bits */
|
1996-08-02 02:23:31 +02:00
|
|
|
|
1996-09-04 17:41:43 +02:00
|
|
|
enum _leftright { LEFT_FIRST, RIGHT_FIRST };
|
|
|
|
|
1996-09-04 19:42:51 +02:00
|
|
|
int d10v_debug;
|
1996-09-04 17:41:43 +02:00
|
|
|
host_callback *d10v_callback;
|
1996-10-22 21:49:37 +02:00
|
|
|
unsigned long ins_type_counters[ (int)INS_MAX ];
|
1996-09-04 17:41:43 +02:00
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
uint16 OP[4];
|
|
|
|
|
1996-10-30 23:43:02 +01:00
|
|
|
static int init_text_p = 0;
|
|
|
|
asection *text;
|
|
|
|
bfd_vma text_start;
|
|
|
|
bfd_vma text_end;
|
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
static long hash PARAMS ((long insn, int format));
|
1996-08-02 02:23:31 +02:00
|
|
|
static struct hash_entry *lookup_hash PARAMS ((uint32 ins, int size));
|
1996-10-22 21:49:37 +02:00
|
|
|
static void get_operands PARAMS ((struct simops *s, uint32 ins));
|
|
|
|
static void do_long PARAMS ((uint32 ins));
|
|
|
|
static void do_2_short PARAMS ((uint16 ins1, uint16 ins2, enum _leftright leftright));
|
|
|
|
static void do_parallel PARAMS ((uint16 ins1, uint16 ins2));
|
|
|
|
static char *add_commas PARAMS ((char *buf, int sizeof_buf, unsigned long value));
|
|
|
|
extern void sim_size PARAMS ((int power));
|
|
|
|
static void init_system PARAMS ((void));
|
|
|
|
extern int sim_write PARAMS ((SIM_ADDR addr, unsigned char *buffer, int size));
|
|
|
|
extern void sim_open PARAMS ((char *args));
|
|
|
|
extern void sim_close PARAMS ((int quitting));
|
|
|
|
extern void sim_set_profile PARAMS ((int n));
|
|
|
|
extern void sim_set_profile_size PARAMS ((int n));
|
|
|
|
extern void sim_resume PARAMS ((int step, int siggnal));
|
|
|
|
extern void sim_info PARAMS ((int verbose));
|
|
|
|
extern void sim_create_inferior PARAMS ((SIM_ADDR start_address, char **argv, char **env));
|
|
|
|
extern void sim_kill PARAMS ((void));
|
|
|
|
extern void sim_set_callbacks PARAMS ((host_callback *p));
|
|
|
|
extern void sim_stop_reason PARAMS ((enum sim_stop *reason, int *sigrc));
|
|
|
|
extern void sim_fetch_register PARAMS ((int rn, unsigned char *memory));
|
|
|
|
extern void sim_store_register PARAMS ((int rn, unsigned char *memory));
|
|
|
|
extern int sim_read PARAMS ((SIM_ADDR addr, unsigned char *buffer, int size));
|
|
|
|
extern void sim_do_command PARAMS ((char *cmd));
|
|
|
|
|
|
|
|
#ifndef INLINE
|
|
|
|
#if defined(__GNUC__) && defined(__OPTIMIZE__)
|
|
|
|
#define INLINE __inline__
|
|
|
|
#else
|
|
|
|
#define INLINE
|
|
|
|
#endif
|
|
|
|
#endif
|
1996-08-02 02:23:31 +02:00
|
|
|
|
|
|
|
#define MAX_HASH 63
|
|
|
|
struct hash_entry
|
|
|
|
{
|
|
|
|
struct hash_entry *next;
|
|
|
|
long opcode;
|
|
|
|
long mask;
|
1996-11-20 10:27:24 +01:00
|
|
|
int size;
|
1996-08-02 02:23:31 +02:00
|
|
|
struct simops *ops;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hash_entry hash_table[MAX_HASH+1];
|
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
INLINE static long
|
1996-08-02 02:23:31 +02:00
|
|
|
hash(insn, format)
|
|
|
|
long insn;
|
|
|
|
int format;
|
|
|
|
{
|
|
|
|
if (format & LONG_OPCODE)
|
|
|
|
return ((insn & 0x3F000000) >> 24);
|
|
|
|
else
|
|
|
|
return((insn & 0x7E00) >> 9);
|
|
|
|
}
|
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
INLINE static struct hash_entry *
|
1996-08-02 02:23:31 +02:00
|
|
|
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];
|
|
|
|
|
1996-11-20 10:27:24 +01:00
|
|
|
while ((ins & h->mask) != h->opcode || h->size != size)
|
1996-08-02 02:23:31 +02:00
|
|
|
{
|
|
|
|
if (h->next == NULL)
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR looking up hash for %x at PC %x\n",ins, PC);
|
1996-10-22 21:49:37 +02:00
|
|
|
exit (1);
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
return (h);
|
|
|
|
}
|
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
INLINE static void
|
1996-08-02 02:23:31 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-30 23:43:02 +01:00
|
|
|
bfd_vma
|
|
|
|
decode_pc ()
|
|
|
|
{
|
|
|
|
asection *s;
|
|
|
|
if (!init_text_p)
|
|
|
|
{
|
|
|
|
init_text_p = 1;
|
|
|
|
for (s = exec_bfd->sections; s; s = s->next)
|
|
|
|
if (strcmp (bfd_get_section_name (exec_bfd, s), ".text") == 0)
|
|
|
|
{
|
|
|
|
text = s;
|
|
|
|
text_start = bfd_get_section_vma (exec_bfd, s);
|
|
|
|
text_end = text_start + bfd_section_size (exec_bfd, s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (PC << 2) + text_start;
|
|
|
|
}
|
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
static void
|
|
|
|
do_long (ins)
|
|
|
|
uint32 ins;
|
|
|
|
{
|
|
|
|
struct hash_entry *h;
|
1996-09-04 19:42:51 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
if ((d10v_debug & DEBUG_INSTRUCTION) != 0)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "do_long 0x%x\n", ins);
|
|
|
|
#endif
|
1996-08-02 02:23:31 +02:00
|
|
|
h = lookup_hash (ins, 1);
|
|
|
|
get_operands (h->ops, ins);
|
1996-09-04 17:41:43 +02:00
|
|
|
State.ins_type = INS_LONG;
|
1996-09-04 19:42:51 +02:00
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
(h->ops->func)();
|
|
|
|
}
|
1996-09-15 05:46:52 +02:00
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
static void
|
1996-09-04 17:41:43 +02:00
|
|
|
do_2_short (ins1, ins2, leftright)
|
1996-08-02 02:23:31 +02:00
|
|
|
uint16 ins1, ins2;
|
1996-09-04 17:41:43 +02:00
|
|
|
enum _leftright leftright;
|
1996-08-02 02:23:31 +02:00
|
|
|
{
|
|
|
|
struct hash_entry *h;
|
1996-09-15 05:46:52 +02:00
|
|
|
reg_t orig_pc = PC;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
enum _ins_type first, second;
|
1996-09-15 05:46:52 +02:00
|
|
|
|
1996-09-04 19:42:51 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
if ((d10v_debug & DEBUG_INSTRUCTION) != 0)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "do_2_short 0x%x (%s) -> 0x%x\n",
|
|
|
|
ins1, (leftright) ? "left" : "right", ins2);
|
|
|
|
#endif
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
|
|
|
if (leftright == LEFT_FIRST)
|
|
|
|
{
|
|
|
|
first = INS_LEFT;
|
|
|
|
second = INS_RIGHT;
|
|
|
|
ins_type_counters[ (int)INS_LEFTRIGHT ]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
first = INS_RIGHT;
|
|
|
|
second = INS_LEFT;
|
|
|
|
ins_type_counters[ (int)INS_RIGHTLEFT ]++;
|
|
|
|
}
|
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
h = lookup_hash (ins1, 0);
|
|
|
|
get_operands (h->ops, ins1);
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
State.ins_type = first;
|
1996-09-04 19:42:51 +02:00
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
(h->ops->func)();
|
1996-09-15 05:46:52 +02:00
|
|
|
|
|
|
|
/* If the PC has changed (ie, a jump), don't do the second instruction */
|
1996-10-15 17:44:10 +02:00
|
|
|
if (orig_pc == PC && !State.exception)
|
1996-09-15 05:46:52 +02:00
|
|
|
{
|
|
|
|
h = lookup_hash (ins2, 0);
|
|
|
|
get_operands (h->ops, ins2);
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
State.ins_type = second;
|
1996-09-15 05:46:52 +02:00
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
ins_type_counters[ (int)INS_CYCLES ]++;
|
1996-09-15 05:46:52 +02:00
|
|
|
(h->ops->func)();
|
|
|
|
}
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
else if (orig_pc != PC && !State.exception)
|
|
|
|
ins_type_counters[ (int)INS_COND_JUMP ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
1996-09-15 05:46:52 +02:00
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
static void
|
|
|
|
do_parallel (ins1, ins2)
|
|
|
|
uint16 ins1, ins2;
|
|
|
|
{
|
|
|
|
struct hash_entry *h1, *h2;
|
1996-09-04 19:42:51 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
if ((d10v_debug & DEBUG_INSTRUCTION) != 0)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "do_parallel 0x%x || 0x%x\n", ins1, ins2);
|
|
|
|
#endif
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
ins_type_counters[ (int)INS_PARALLEL ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
h1 = lookup_hash (ins1, 0);
|
|
|
|
h2 = lookup_hash (ins2, 0);
|
1996-08-29 02:35:11 +02:00
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
if (h1->ops->exec_type == PARONLY)
|
|
|
|
{
|
1996-08-29 02:35:11 +02:00
|
|
|
get_operands (h1->ops, ins1);
|
1996-10-22 21:49:37 +02:00
|
|
|
State.ins_type = INS_LEFT_COND_TEST;
|
1996-09-04 19:42:51 +02:00
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
(h1->ops->func)();
|
|
|
|
if (State.exe)
|
1996-08-29 02:35:11 +02:00
|
|
|
{
|
1996-10-22 21:49:37 +02:00
|
|
|
ins_type_counters[ (int)INS_COND_TRUE ]++;
|
1996-08-29 02:35:11 +02:00
|
|
|
get_operands (h2->ops, ins2);
|
1996-10-22 21:49:37 +02:00
|
|
|
State.ins_type = INS_RIGHT_COND_EXE;
|
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-29 02:35:11 +02:00
|
|
|
(h2->ops->func)();
|
|
|
|
}
|
1996-10-22 21:49:37 +02:00
|
|
|
else
|
|
|
|
ins_type_counters[ (int)INS_COND_FALSE ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
else if (h2->ops->exec_type == PARONLY)
|
|
|
|
{
|
1996-08-29 02:35:11 +02:00
|
|
|
get_operands (h2->ops, ins2);
|
1996-10-22 21:49:37 +02:00
|
|
|
State.ins_type = INS_RIGHT_COND_TEST;
|
1996-09-04 19:42:51 +02:00
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
(h2->ops->func)();
|
|
|
|
if (State.exe)
|
1996-08-29 02:35:11 +02:00
|
|
|
{
|
1996-10-22 21:49:37 +02:00
|
|
|
ins_type_counters[ (int)INS_COND_TRUE ]++;
|
1996-08-29 02:35:11 +02:00
|
|
|
get_operands (h1->ops, ins1);
|
1996-10-22 21:49:37 +02:00
|
|
|
State.ins_type = INS_LEFT_COND_EXE;
|
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-29 02:35:11 +02:00
|
|
|
(h1->ops->func)();
|
|
|
|
}
|
1996-10-22 21:49:37 +02:00
|
|
|
else
|
|
|
|
ins_type_counters[ (int)INS_COND_FALSE ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1996-08-29 02:35:11 +02:00
|
|
|
get_operands (h1->ops, ins1);
|
1996-09-04 17:41:43 +02:00
|
|
|
State.ins_type = INS_LEFT_PARALLEL;
|
1996-09-04 19:42:51 +02:00
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
1996-08-02 02:23:31 +02:00
|
|
|
(h1->ops->func)();
|
1996-10-15 17:44:10 +02:00
|
|
|
if (!State.exception)
|
|
|
|
{
|
|
|
|
get_operands (h2->ops, ins2);
|
|
|
|
State.ins_type = INS_RIGHT_PARALLEL;
|
|
|
|
ins_type_counters[ (int)State.ins_type ]++;
|
|
|
|
(h2->ops->func)();
|
|
|
|
}
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
static char *
|
|
|
|
add_commas(buf, sizeof_buf, value)
|
|
|
|
char *buf;
|
|
|
|
int sizeof_buf;
|
|
|
|
unsigned long value;
|
|
|
|
{
|
|
|
|
int comma = 3;
|
|
|
|
char *endbuf = buf + sizeof_buf - 1;
|
|
|
|
|
|
|
|
*--endbuf = '\0';
|
|
|
|
do {
|
|
|
|
if (comma-- == 0)
|
|
|
|
{
|
|
|
|
*--endbuf = ',';
|
|
|
|
comma = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
*--endbuf = (value % 10) + '0';
|
|
|
|
} while ((value /= 10) != 0);
|
|
|
|
|
|
|
|
return endbuf;
|
|
|
|
}
|
1996-08-02 02:23:31 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
sim_size (power)
|
|
|
|
int power;
|
|
|
|
|
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
int i;
|
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
if (State.imem)
|
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
for (i=0;i<128;i++)
|
|
|
|
{
|
|
|
|
if (State.umem[i])
|
|
|
|
{
|
|
|
|
free (State.umem[i]);
|
|
|
|
State.umem[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
1996-08-02 02:23:31 +02:00
|
|
|
free (State.imem);
|
|
|
|
free (State.dmem);
|
|
|
|
}
|
|
|
|
|
|
|
|
State.imem = (uint8 *)calloc(1,1<<IMEM_SIZE);
|
|
|
|
State.dmem = (uint8 *)calloc(1,1<<DMEM_SIZE);
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
for (i=1;i<127;i++)
|
|
|
|
State.umem[i] = NULL;
|
|
|
|
State.umem[0] = (uint8 *)calloc(1,1<<UMEM_SIZE);
|
|
|
|
State.umem[1] = (uint8 *)calloc(1,1<<UMEM_SIZE);
|
|
|
|
State.umem[2] = (uint8 *)calloc(1,1<<UMEM_SIZE);
|
|
|
|
State.umem[127] = (uint8 *)calloc(1,1<<UMEM_SIZE);
|
|
|
|
if (!State.imem || !State.dmem || !State.umem[0] || !State.umem[1] || !State.umem[2] || !State.umem[127] )
|
1996-08-02 02:23:31 +02:00
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "Memory allocation failed.\n");
|
1996-08-02 02:23:31 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
|
|
|
SET_IMAP0(0x1000);
|
|
|
|
SET_IMAP1(0x1000);
|
|
|
|
SET_DMAP(0);
|
1996-10-15 17:44:10 +02:00
|
|
|
|
1996-09-04 19:42:51 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
if ((d10v_debug & DEBUG_MEMSIZE) != 0)
|
|
|
|
{
|
1996-10-22 21:49:37 +02:00
|
|
|
char buffer[20];
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"Allocated %s bytes instruction memory and\n",
|
|
|
|
add_commas (buffer, sizeof (buffer), (1UL<<IMEM_SIZE)));
|
|
|
|
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, " %s bytes data memory.\n",
|
|
|
|
add_commas (buffer, sizeof (buffer), (1UL<<IMEM_SIZE)));
|
1996-09-04 19:42:51 +02:00
|
|
|
}
|
1996-09-04 17:41:43 +02:00
|
|
|
#endif
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_system ()
|
|
|
|
{
|
|
|
|
if (!State.imem)
|
|
|
|
sim_size(1);
|
|
|
|
}
|
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
static int
|
|
|
|
xfer_mem (addr, buffer, size, write)
|
1996-08-02 02:23:31 +02:00
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
int write;
|
1996-08-02 02:23:31 +02:00
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (!State.imem)
|
|
|
|
init_system ();
|
1996-08-02 02:23:31 +02:00
|
|
|
|
1996-10-15 17:44:10 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
if ((d10v_debug & DEBUG_INSTRUCTION) != 0)
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
{
|
|
|
|
if (write)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "sim_write %d bytes to 0x%x\n", size, addr);
|
|
|
|
else
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "sim_read %d bytes from 0x%x\n", size, addr);
|
|
|
|
}
|
1996-10-15 17:44:10 +02:00
|
|
|
#endif
|
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
/* to access data, we use the following mapping */
|
|
|
|
/* 0x01000000 - 0x0103ffff : instruction memory */
|
|
|
|
/* 0x02000000 - 0x0200ffff : data memory */
|
|
|
|
/* 0x03000000 - 0x03ffffff : unified memory */
|
1996-10-15 17:44:10 +02:00
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if ( (addr & 0x03000000) == 0x03000000)
|
|
|
|
{
|
|
|
|
/* UNIFIED MEMORY */
|
|
|
|
int segment;
|
|
|
|
addr &= ~0x03000000;
|
|
|
|
segment = addr >> UMEM_SIZE;
|
|
|
|
addr &= 0x1ffff;
|
|
|
|
if (!State.umem[segment])
|
|
|
|
State.umem[segment] = (uint8 *)calloc(1,1<<UMEM_SIZE);
|
|
|
|
if (!State.umem[segment])
|
|
|
|
{
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "Memory allocation failed.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,"Allocated %s bytes unified memory to region %d\n",
|
|
|
|
add_commas (buffer, sizeof (buffer), (1UL<<IMEM_SIZE)), segment);
|
|
|
|
#endif
|
|
|
|
/* FIXME: need to check size and read/write multiple segments if necessary */
|
|
|
|
if (write)
|
|
|
|
memcpy (State.umem[segment]+addr, buffer, size);
|
|
|
|
else
|
|
|
|
memcpy (buffer, State.umem[segment]+addr, size);
|
|
|
|
}
|
|
|
|
else if ( (addr & 0x03000000) == 0x02000000)
|
|
|
|
{
|
|
|
|
/* DATA MEMORY */
|
|
|
|
addr &= ~0x02000000;
|
|
|
|
if (size > (1<<(DMEM_SIZE-1)))
|
|
|
|
{
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR: data section is only %d bytes.\n",1<<(DMEM_SIZE-1));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (write)
|
|
|
|
memcpy (State.dmem+addr, buffer, size);
|
|
|
|
else
|
|
|
|
memcpy (buffer, State.dmem+addr, size);
|
|
|
|
}
|
|
|
|
else if ( (addr & 0x03000000) == 0x01000000)
|
|
|
|
{
|
|
|
|
/* INSTRUCTION MEMORY */
|
|
|
|
addr &= ~0x01000000;
|
|
|
|
if (size > (1<<IMEM_SIZE))
|
|
|
|
{
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR: inst section is only %d bytes.\n",1<<IMEM_SIZE);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (write)
|
|
|
|
memcpy (State.imem+addr, buffer, size);
|
|
|
|
else
|
|
|
|
memcpy (buffer, State.imem+addr, size);
|
|
|
|
}
|
|
|
|
else if (write)
|
|
|
|
{
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR: address 0x%x is not in valid range\n",addr);
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "Instruction addresses start at 0x01000000\n");
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "Data addresses start at 0x02000000\n");
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "Unified addresses start at 0x03000000\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
1996-10-15 17:44:10 +02:00
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
|
|
|
int
|
|
|
|
sim_write (addr, buffer, size)
|
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
return xfer_mem( addr, buffer, size, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_read (addr, buffer, size)
|
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
return xfer_mem( addr, buffer, size, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
void
|
|
|
|
sim_open (args)
|
|
|
|
char *args;
|
|
|
|
{
|
|
|
|
struct simops *s;
|
1996-10-22 21:49:37 +02:00
|
|
|
struct hash_entry *h;
|
1996-09-04 20:50:13 +02:00
|
|
|
static int init_p = 0;
|
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
if (args != NULL)
|
1996-09-04 20:50:13 +02:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (strcmp (args, "-t") == 0)
|
|
|
|
d10v_debug = DEBUG;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unsupported option(s): %s\n",args);
|
|
|
|
}
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
1996-08-02 02:23:31 +02:00
|
|
|
/* put all the opcodes in the hash table */
|
1996-09-04 20:50:13 +02:00
|
|
|
if (!init_p++)
|
1996-08-02 02:23:31 +02:00
|
|
|
{
|
1996-09-04 20:50:13 +02:00
|
|
|
for (s = Simops; s->func; s++)
|
1996-08-02 02:23:31 +02:00
|
|
|
{
|
1996-09-04 20:50:13 +02:00
|
|
|
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;
|
1996-11-20 10:27:24 +01:00
|
|
|
h->size = s->is_long;
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_close (quitting)
|
|
|
|
int quitting;
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile (n)
|
|
|
|
int n;
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "sim_set_profile %d\n",n);
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile_size (n)
|
|
|
|
int n;
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "sim_set_profile_size %d\n",n);
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
|
|
|
uint8 *
|
|
|
|
dmem_addr( addr )
|
|
|
|
uint32 addr;
|
|
|
|
{
|
|
|
|
int seg;
|
|
|
|
|
|
|
|
addr &= 0xffff;
|
|
|
|
|
|
|
|
if (addr > 0xbfff)
|
|
|
|
{
|
|
|
|
if ( (addr & 0xfff0) != 0xff00)
|
1996-10-30 23:43:02 +01:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "Data address 0x%lx is in I/O space, pc = 0x%lx.\n",
|
|
|
|
(long)addr, (long)decode_pc ());
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
return State.dmem + addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (addr > 0x7fff)
|
|
|
|
{
|
|
|
|
if (DMAP & 0x1000)
|
|
|
|
{
|
|
|
|
/* instruction memory */
|
|
|
|
return (DMAP & 0xf) * 0x4000 + State.imem;
|
|
|
|
}
|
|
|
|
/* unified memory */
|
|
|
|
/* this is ugly because we allocate unified memory in 128K segments and */
|
|
|
|
/* dmap addresses 16k segments */
|
1996-11-20 10:27:24 +01:00
|
|
|
seg = (DMAP & 0x3ff) >> 3;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (State.umem[seg] == NULL)
|
|
|
|
{
|
1996-10-30 23:43:02 +01:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unified memory region %d unmapped, pc = 0x%lx\n",
|
|
|
|
seg, (long)decode_pc ());
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
1996-11-20 10:27:24 +01:00
|
|
|
return State.umem[seg] + (DMAP & 7) * 0x4000;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return State.dmem + addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint8 *
|
|
|
|
pc_addr()
|
|
|
|
{
|
|
|
|
uint32 pc = ((uint32)PC) << 2;
|
|
|
|
uint16 imap;
|
|
|
|
|
|
|
|
if (pc & 0x20000)
|
|
|
|
imap = IMAP1;
|
|
|
|
else
|
|
|
|
imap = IMAP0;
|
|
|
|
|
|
|
|
if (imap & 0x1000)
|
|
|
|
return State.imem + pc;
|
|
|
|
|
|
|
|
if (State.umem[imap & 0xff] == NULL)
|
|
|
|
{
|
1996-10-30 23:43:02 +01:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unified memory region %d unmapped, pc = 0x%lx\n",
|
|
|
|
imap & 0xff, (long)PC);
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
State.exception = SIGILL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return State.umem[imap & 0xff] + pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-11-20 10:27:24 +01:00
|
|
|
static int stop_simulator;
|
|
|
|
|
|
|
|
static void
|
|
|
|
sim_ctrl_c()
|
|
|
|
{
|
|
|
|
stop_simulator = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Run (or resume) the program. */
|
1996-08-02 02:23:31 +02:00
|
|
|
void
|
|
|
|
sim_resume (step, siggnal)
|
|
|
|
int step, siggnal;
|
|
|
|
{
|
1996-11-20 10:27:24 +01:00
|
|
|
void (*prev) ();
|
1996-08-02 02:23:31 +02:00
|
|
|
uint32 inst;
|
|
|
|
|
1996-09-04 19:42:51 +02:00
|
|
|
/* (*d10v_callback->printf_filtered) (d10v_callback, "sim_resume (%d,%d) PC=0x%x\n",step,siggnal,PC); */
|
1996-10-22 01:17:43 +02:00
|
|
|
State.exception = 0;
|
1996-11-20 10:27:24 +01:00
|
|
|
prev = signal(SIGINT, sim_ctrl_c);
|
|
|
|
stop_simulator = step;
|
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
do
|
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
inst = get_longword( pc_addr() );
|
1996-11-20 10:27:24 +01:00
|
|
|
State.pc_changed = 0;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
ins_type_counters[ (int)INS_CYCLES ]++;
|
|
|
|
switch (inst & 0xC0000000)
|
1996-10-22 21:49:37 +02:00
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
case 0xC0000000:
|
|
|
|
/* long instruction */
|
|
|
|
do_long (inst & 0x3FFFFFFF);
|
|
|
|
break;
|
|
|
|
case 0x80000000:
|
|
|
|
/* R -> L */
|
|
|
|
do_2_short ( inst & 0x7FFF, (inst & 0x3FFF8000) >> 15, 0);
|
|
|
|
break;
|
|
|
|
case 0x40000000:
|
|
|
|
/* L -> R */
|
|
|
|
do_2_short ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF, 1);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
do_parallel ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF);
|
|
|
|
break;
|
1996-10-22 21:49:37 +02:00
|
|
|
}
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
|
|
|
if (State.RP && PC == RPT_E)
|
1996-10-22 21:49:37 +02:00
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
RPT_C -= 1;
|
|
|
|
if (RPT_C == 0)
|
|
|
|
State.RP = 0;
|
|
|
|
else
|
|
|
|
PC = RPT_S;
|
1996-10-22 21:49:37 +02:00
|
|
|
}
|
1996-11-20 10:27:24 +01:00
|
|
|
else if (!State.pc_changed)
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
PC++;
|
1996-10-22 21:49:37 +02:00
|
|
|
}
|
1996-11-20 10:27:24 +01:00
|
|
|
while ( !State.exception && !stop_simulator);
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
if (step && !State.exception)
|
|
|
|
State.exception = SIGTRAP;
|
1996-11-20 10:27:24 +01:00
|
|
|
|
|
|
|
signal(SIGINT, prev);
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_trace ()
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
d10v_debug = DEBUG;
|
|
|
|
#endif
|
|
|
|
sim_resume (0, 0);
|
|
|
|
return 1;
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_info (verbose)
|
|
|
|
int verbose;
|
|
|
|
{
|
1996-10-22 21:49:37 +02:00
|
|
|
char buf1[40];
|
|
|
|
char buf2[40];
|
|
|
|
char buf3[40];
|
|
|
|
char buf4[40];
|
|
|
|
char buf5[40];
|
|
|
|
unsigned long left = ins_type_counters[ (int)INS_LEFT ] + ins_type_counters[ (int)INS_LEFT_COND_EXE ];
|
|
|
|
unsigned long left_nops = ins_type_counters[ (int)INS_LEFT_NOPS ];
|
|
|
|
unsigned long left_parallel = ins_type_counters[ (int)INS_LEFT_PARALLEL ];
|
|
|
|
unsigned long left_cond = ins_type_counters[ (int)INS_LEFT_COND_TEST ];
|
|
|
|
unsigned long left_total = left + left_parallel + left_cond + left_nops;
|
|
|
|
|
|
|
|
unsigned long right = ins_type_counters[ (int)INS_RIGHT ] + ins_type_counters[ (int)INS_RIGHT_COND_EXE ];
|
|
|
|
unsigned long right_nops = ins_type_counters[ (int)INS_RIGHT_NOPS ];
|
|
|
|
unsigned long right_parallel = ins_type_counters[ (int)INS_RIGHT_PARALLEL ];
|
|
|
|
unsigned long right_cond = ins_type_counters[ (int)INS_RIGHT_COND_TEST ];
|
|
|
|
unsigned long right_total = right + right_parallel + right_cond + right_nops;
|
|
|
|
|
|
|
|
unsigned long unknown = ins_type_counters[ (int)INS_UNKNOWN ];
|
|
|
|
unsigned long ins_long = ins_type_counters[ (int)INS_LONG ];
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
unsigned long parallel = ins_type_counters[ (int)INS_PARALLEL ];
|
|
|
|
unsigned long leftright = ins_type_counters[ (int)INS_LEFTRIGHT ];
|
|
|
|
unsigned long rightleft = ins_type_counters[ (int)INS_RIGHTLEFT ];
|
1996-10-22 21:49:37 +02:00
|
|
|
unsigned long cond_true = ins_type_counters[ (int)INS_COND_TRUE ];
|
|
|
|
unsigned long cond_false = ins_type_counters[ (int)INS_COND_FALSE ];
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
unsigned long cond_jump = ins_type_counters[ (int)INS_COND_JUMP ];
|
1996-10-22 21:49:37 +02:00
|
|
|
unsigned long cycles = ins_type_counters[ (int)INS_CYCLES ];
|
|
|
|
unsigned long total = (unknown + left_total + right_total + ins_long);
|
|
|
|
|
|
|
|
int size = strlen (add_commas (buf1, sizeof (buf1), total));
|
|
|
|
int parallel_size = strlen (add_commas (buf1, sizeof (buf1),
|
|
|
|
(left_parallel > right_parallel) ? left_parallel : right_parallel));
|
|
|
|
int cond_size = strlen (add_commas (buf1, sizeof (buf1), (left_cond > right_cond) ? left_cond : right_cond));
|
|
|
|
int nop_size = strlen (add_commas (buf1, sizeof (buf1), (left_nops > right_nops) ? left_nops : right_nops));
|
|
|
|
int normal_size = strlen (add_commas (buf1, sizeof (buf1), (left > right) ? left : right));
|
|
|
|
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
"executed %*s left instruction(s), %*s normal, %*s parallel, %*s EXExxx, %*s nops\n",
|
1996-10-22 21:49:37 +02:00
|
|
|
size, add_commas (buf1, sizeof (buf1), left_total),
|
|
|
|
normal_size, add_commas (buf2, sizeof (buf2), left),
|
|
|
|
parallel_size, add_commas (buf3, sizeof (buf3), left_parallel),
|
|
|
|
cond_size, add_commas (buf4, sizeof (buf4), left_cond),
|
|
|
|
nop_size, add_commas (buf5, sizeof (buf5), left_nops));
|
|
|
|
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
"executed %*s right instruction(s), %*s normal, %*s parallel, %*s EXExxx, %*s nops\n",
|
1996-10-22 21:49:37 +02:00
|
|
|
size, add_commas (buf1, sizeof (buf1), right_total),
|
|
|
|
normal_size, add_commas (buf2, sizeof (buf2), right),
|
|
|
|
parallel_size, add_commas (buf3, sizeof (buf3), right_parallel),
|
|
|
|
cond_size, add_commas (buf4, sizeof (buf4), right_cond),
|
|
|
|
nop_size, add_commas (buf5, sizeof (buf5), right_nops));
|
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (ins_long)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"executed %*s long instruction(s)\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), ins_long));
|
|
|
|
|
|
|
|
if (parallel)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"executed %*s parallel instruction(s)\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), parallel));
|
|
|
|
|
|
|
|
if (leftright)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"executed %*s instruction(s) encoded L->R\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), leftright));
|
|
|
|
|
|
|
|
if (rightleft)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"executed %*s instruction(s) encoded R->L\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), rightleft));
|
1996-09-04 19:42:51 +02:00
|
|
|
|
1996-10-22 21:49:37 +02:00
|
|
|
if (unknown)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
"executed %*s unknown instruction(s)\n",
|
1996-10-22 21:49:37 +02:00
|
|
|
size, add_commas (buf1, sizeof (buf1), unknown));
|
1996-09-04 19:42:51 +02:00
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (cond_true)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"executed %*s instruction(s) due to EXExxx condition being true\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), cond_true));
|
1996-09-04 19:42:51 +02:00
|
|
|
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (cond_false)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"skipped %*s instruction(s) due to EXExxx condition being false\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), cond_false));
|
|
|
|
|
|
|
|
if (cond_jump)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
|
|
|
"skipped %*s instruction(s) due to conditional branch succeeding\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), cond_jump));
|
1996-09-04 19:42:51 +02:00
|
|
|
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
"executed %*s cycle(s)\n",
|
1996-10-22 21:49:37 +02:00
|
|
|
size, add_commas (buf1, sizeof (buf1), cycles));
|
1996-09-04 19:42:51 +02:00
|
|
|
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback,
|
1996-10-22 21:49:37 +02:00
|
|
|
"executed %*s total instructions\n",
|
|
|
|
size, add_commas (buf1, sizeof (buf1), total));
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_create_inferior (start_address, argv, env)
|
|
|
|
SIM_ADDR start_address;
|
|
|
|
char **argv;
|
|
|
|
char **env;
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (d10v_debug)
|
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "sim_create_inferior: PC=0x%x\n", start_address);
|
|
|
|
#endif
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
1996-10-15 17:44:10 +02:00
|
|
|
/* reset all state information */
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
memset (&State.regs, 0, (int)&State.imem - (int)&State.regs[0]);
|
|
|
|
|
1996-10-15 17:44:10 +02:00
|
|
|
/* set PC */
|
1996-08-02 02:23:31 +02:00
|
|
|
PC = start_address >> 2;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
|
|
|
|
/* cpu resets imap0 to 0 and imap1 to 0x7f, but D10V-EVA board */
|
|
|
|
/* resets imap0 and imap1 to 0x1000. */
|
|
|
|
|
|
|
|
SET_IMAP0(0x1000);
|
|
|
|
SET_IMAP1(0x1000);
|
|
|
|
SET_DMAP(0);
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_kill ()
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_callbacks(p)
|
|
|
|
host_callback *p;
|
|
|
|
{
|
1996-09-04 17:41:43 +02:00
|
|
|
d10v_callback = p;
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_stop_reason (reason, sigrc)
|
|
|
|
enum sim_stop *reason;
|
|
|
|
int *sigrc;
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
/* (*d10v_callback->printf_filtered) (d10v_callback, "sim_stop_reason: PC=0x%x\n",PC<<2); */
|
1996-08-29 02:35:11 +02:00
|
|
|
|
1996-09-18 15:23:31 +02:00
|
|
|
switch (State.exception)
|
1996-08-29 02:35:11 +02:00
|
|
|
{
|
1996-09-18 15:23:31 +02:00
|
|
|
case SIG_D10V_STOP: /* stop instruction */
|
1996-08-29 02:35:11 +02:00
|
|
|
*reason = sim_exited;
|
1996-09-18 15:23:31 +02:00
|
|
|
*sigrc = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIG_D10V_EXIT: /* exit trap */
|
|
|
|
*reason = sim_exited;
|
|
|
|
*sigrc = State.regs[2];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* some signal */
|
1996-08-29 02:35:11 +02:00
|
|
|
*reason = sim_stopped;
|
|
|
|
*sigrc = State.exception;
|
1996-09-18 15:23:31 +02:00
|
|
|
break;
|
1996-08-29 02:35:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_fetch_register (rn, memory)
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (!State.imem)
|
|
|
|
init_system();
|
|
|
|
|
|
|
|
if (rn > 34)
|
1996-11-01 04:15:44 +01:00
|
|
|
WRITE_64 (memory, State.a[rn-35]);
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
else if (rn == 32)
|
|
|
|
WRITE_16 (memory, IMAP0);
|
|
|
|
else if (rn == 33)
|
|
|
|
WRITE_16 (memory, IMAP1);
|
|
|
|
else if (rn == 34)
|
|
|
|
WRITE_16 (memory, DMAP);
|
1996-08-29 02:35:11 +02:00
|
|
|
else
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
WRITE_16 (memory, State.regs[rn]);
|
1996-08-29 02:35:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_store_register (rn, memory)
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
{
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
if (!State.imem)
|
|
|
|
init_system();
|
|
|
|
|
|
|
|
if (rn > 34)
|
1996-11-01 04:15:44 +01:00
|
|
|
State.a[rn-35] = READ_64 (memory) & MASK40;
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
else if (rn == 34)
|
|
|
|
SET_DMAP( READ_16(memory) );
|
|
|
|
else if (rn == 33)
|
|
|
|
SET_IMAP1( READ_16(memory) );
|
|
|
|
else if (rn == 32)
|
|
|
|
SET_IMAP0( READ_16(memory) );
|
1996-08-29 02:35:11 +02:00
|
|
|
else
|
Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com>
* interp.c (sim_size): Now allocates unified memory for imap segments
0,1,2, and 127. Initializes imap0 and imap1 to 0x1000. Initializes dmap to 0.
(sim_write): Just call xfer_mem().
(sim_read): Just call xfer_mem().
(xfer_mem): New function. Does appropriate memory mapping and copies bytes.
(dmem_addr): New function. Reads dmap register and translates data
addresses to local addresses.
(pc_addr): New function. Reads imap register and computes local address
corresponding to contents of the PC.
(sim_resume): Change to use pc_addr().
(sim_create_inferior): Change reinitialization code. Also reinitializes
imap[01] and dmap.
(sim_fetch_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
(sim_store_register): Add fake registers 32,33,34 for imap0, imap1, and dmap.
* simops.c (MEMPTR): Redefine to use dmem_addr().
(OP_5F00): Replace references to STate.imem with dmem_addr().
* d10v-sim.h (State): Remove mem_min and mem_max. Add umem[128].
(RB,SW,RW,SLW,RLW): Redefine to use dmem_addr().
(IMAP0,IMAP1,DMAP,SET_IMAP,SET_IMAP1,SET_DMAP): Define.
1996-10-29 21:31:08 +01:00
|
|
|
State.regs[rn]= READ_16 (memory);
|
1996-08-02 02:23:31 +02:00
|
|
|
}
|
1996-08-29 02:35:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_do_command (cmd)
|
|
|
|
char *cmd;
|
|
|
|
{
|
1996-09-04 19:42:51 +02:00
|
|
|
(*d10v_callback->printf_filtered) (d10v_callback, "sim_do_command: %s\n",cmd);
|
1996-08-29 02:35:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_load (prog, from_tty)
|
|
|
|
char *prog;
|
|
|
|
int from_tty;
|
|
|
|
{
|
|
|
|
/* Return nonzero so GDB will handle it. */
|
|
|
|
return 1;
|
|
|
|
}
|