1996-08-29 01:06:42 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#include "sysdep.h"
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "remote-sim.h"
|
|
|
|
#include "callback.h"
|
|
|
|
|
|
|
|
#include "v850_sim.h"
|
|
|
|
|
1996-09-10 02:51:07 +00:00
|
|
|
#ifndef INLINE
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define INLINE inline
|
|
|
|
#else
|
|
|
|
#define INLINE
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
#define MEM_SIZE 18 /* V850 memory size is 18 bits XXX */
|
1996-08-29 01:06:42 +00:00
|
|
|
|
1996-09-03 16:25:51 +00:00
|
|
|
host_callback *v850_callback;
|
1996-09-11 20:54:21 +00:00
|
|
|
int v850_debug;
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
uint32 OP[4];
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
|
|
static struct hash_entry *lookup_hash PARAMS ((uint32 ins));
|
1996-09-10 02:51:07 +00:00
|
|
|
static long hash PARAMS ((long));
|
|
|
|
static void do_format_1_2 PARAMS ((uint32));
|
|
|
|
static void do_format_3 PARAMS ((uint32));
|
|
|
|
static void do_format_4 PARAMS ((uint32));
|
|
|
|
static void do_format_5 PARAMS ((uint32));
|
|
|
|
static void do_format_6 PARAMS ((uint32));
|
|
|
|
static void do_format_7 PARAMS ((uint32));
|
|
|
|
static void do_format_8 PARAMS ((uint32));
|
|
|
|
static void do_format_9_10 PARAMS ((uint32));
|
|
|
|
static void init_system PARAMS ((void));
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
|
|
#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];
|
|
|
|
|
1996-09-10 02:51:07 +00:00
|
|
|
|
|
|
|
static INLINE long
|
1996-08-29 01:06:42 +00:00
|
|
|
hash(insn)
|
|
|
|
long insn;
|
|
|
|
{
|
1996-08-30 16:35:10 +00:00
|
|
|
if ((insn & 0x0600) == 0
|
1996-09-10 02:51:07 +00:00
|
|
|
|| (insn & 0x0700) == 0x0200
|
|
|
|
|| (insn & 0x0700) == 0x0600
|
|
|
|
|| (insn & 0x0780) == 0x0700)
|
1996-08-29 23:39:23 +00:00
|
|
|
return (insn & 0x07e0) >> 5;
|
1996-08-30 16:35:10 +00:00
|
|
|
if ((insn & 0x0700) == 0x0300
|
|
|
|
|| (insn & 0x0700) == 0x0400
|
|
|
|
|| (insn & 0x0700) == 0x0500)
|
|
|
|
return (insn & 0x0780) >> 7;
|
|
|
|
if ((insn & 0x07c0) == 0x0780)
|
1996-08-29 23:39:23 +00:00
|
|
|
return (insn & 0x07c0) >> 6;
|
1996-08-30 16:35:10 +00:00
|
|
|
return (insn & 0x07e0) >> 5;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct hash_entry *
|
|
|
|
lookup_hash (ins)
|
|
|
|
uint32 ins;
|
|
|
|
{
|
|
|
|
struct hash_entry *h;
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
h = &hash_table[hash(ins)];
|
1996-08-29 01:06:42 +00:00
|
|
|
|
1996-09-10 02:51:07 +00:00
|
|
|
while ((ins & h->mask) != h->opcode)
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
|
|
|
if (h->next == NULL)
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "ERROR looking up hash for %x\n", ins);
|
1996-08-29 01:06:42 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
return (h);
|
|
|
|
}
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint8
|
|
|
|
get_byte (x)
|
|
|
|
uint8 *x;
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
return *x;
|
1996-08-29 23:39:23 +00:00
|
|
|
}
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint16
|
|
|
|
get_half (x)
|
|
|
|
uint8 *x;
|
1996-08-29 23:39:23 +00:00
|
|
|
{
|
|
|
|
uint8 *a = x;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
return (a[1] << 8) + (a[0]);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint32
|
1996-08-29 23:39:23 +00:00
|
|
|
get_word (x)
|
|
|
|
uint8 *x;
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
uint8 *a = x;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
return (a[3]<<24) + (a[2]<<16) + (a[1]<<8) + (a[0]);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
put_byte (addr, data)
|
1996-08-29 23:39:23 +00:00
|
|
|
uint8 *addr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint8 data;
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
uint8 *a = addr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
a[0] = data;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
void
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
put_half (addr, data)
|
1996-08-29 23:39:23 +00:00
|
|
|
uint8 *addr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint16 data;
|
1996-08-29 23:39:23 +00:00
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint8 *a = addr;
|
|
|
|
a[0] = data & 0xff;
|
|
|
|
a[1] = (data >> 8) & 0xff;
|
1996-08-29 23:39:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
put_word (addr, data)
|
1996-08-29 23:39:23 +00:00
|
|
|
uint8 *addr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
uint32 data;
|
1996-08-29 23:39:23 +00:00
|
|
|
{
|
|
|
|
uint8 *a = addr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
a[0] = data & 0xff;
|
|
|
|
a[1] = (data >> 8) & 0xff;
|
|
|
|
a[2] = (data >> 16) & 0xff;
|
|
|
|
a[3] = (data >> 24) & 0xff;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1996-08-29 23:39:23 +00:00
|
|
|
do_format_1_2 (insn)
|
1996-08-29 01:06:42 +00:00
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = insn & 0x1f;
|
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_3 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 03:48:13 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = (((insn & 0x70) >> 4) | ((insn & 0xf800) >> 8)) << 1;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_4 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 05:49:07 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = (insn >> 11) & 0x1f;
|
|
|
|
OP[1] = (insn & 0x7f);
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_5 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 04:27:48 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
1996-09-03 16:25:51 +00:00
|
|
|
OP[0] = (((insn & 0x3f) << 15) | ((insn >> 17) & 0x7fff)) << 1;
|
1996-08-30 04:27:48 +00:00
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_6 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = (insn >> 16) & 0xffff;
|
|
|
|
OP[1] = insn & 0x1f;
|
|
|
|
OP[2] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_7 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = insn & 0x1f;
|
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
OP[2] = (insn >> 16) & 0xffff;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_8 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 16:35:10 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = insn & 0x1f;
|
|
|
|
OP[1] = (insn >> 11) & 0x7;
|
|
|
|
OP[2] = (insn >> 16) & 0xffff;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1996-09-10 02:51:07 +00:00
|
|
|
do_format_9_10 (insn)
|
1996-08-29 01:06:42 +00:00
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = insn & 0x1f;
|
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_size (power)
|
|
|
|
int power;
|
|
|
|
|
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
if (State.mem)
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
free (State.mem);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
State.mem = (uint8 *)calloc(1,1<<MEM_SIZE);
|
|
|
|
if (!State.mem)
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "Memory allocation failed.\n");
|
1996-08-29 01:06:42 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_system ()
|
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
if (!State.mem)
|
1996-08-29 01:06:42 +00:00
|
|
|
sim_size(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_write (addr, buffer, size)
|
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
init_system ();
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
State.mem[i+addr] = buffer[i];
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_open (args)
|
|
|
|
char *args;
|
|
|
|
{
|
|
|
|
struct simops *s;
|
1996-09-10 02:51:07 +00:00
|
|
|
struct hash_entry *h;
|
1996-08-29 01:06:42 +00:00
|
|
|
if (args != NULL)
|
1996-09-11 20:54:21 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (strcmp (args, "-t") == 0)
|
1996-09-28 01:38:45 +00:00
|
|
|
v850_debug = DEBUG;
|
1996-09-11 20:54:21 +00:00
|
|
|
else
|
|
|
|
#endif
|
1996-09-28 01:38:45 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "ERROR: unsupported option(s): %s\n",args);
|
1996-09-11 20:54:21 +00:00
|
|
|
}
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
|
|
/* put all the opcodes in the hash table */
|
|
|
|
for (s = Simops; s->func; s++)
|
|
|
|
{
|
|
|
|
h = &hash_table[hash(s->opcode)];
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "sim_set_profile %d\n", n);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile_size (n)
|
|
|
|
int n;
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "sim_set_profile_size %d\n", n);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_resume (step, siggnal)
|
|
|
|
int step, siggnal;
|
|
|
|
{
|
|
|
|
uint32 inst, opcode;
|
|
|
|
reg_t oldpc;
|
|
|
|
|
1996-09-28 01:38:45 +00:00
|
|
|
PC = State.sregs[0];
|
|
|
|
|
1996-08-29 01:06:42 +00:00
|
|
|
if (step)
|
|
|
|
State.exception = SIGTRAP;
|
|
|
|
else
|
|
|
|
State.exception = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
inst = RLW (PC);
|
|
|
|
oldpc = PC;
|
1996-08-29 23:39:23 +00:00
|
|
|
opcode = (inst & 0x07e0) >> 5;
|
|
|
|
if ((opcode & 0x30) == 0
|
|
|
|
|| (opcode & 0x38) == 0x10)
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
do_format_1_2 (inst & 0xffff);
|
1996-08-29 01:06:42 +00:00
|
|
|
PC += 2;
|
|
|
|
}
|
|
|
|
else if ((opcode & 0x3C) == 0x18
|
|
|
|
|| (opcode & 0x3C) == 0x1C
|
|
|
|
|| (opcode & 0x3C) == 0x20
|
|
|
|
|| (opcode & 0x3C) == 0x24
|
|
|
|
|| (opcode & 0x3C) == 0x28)
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
do_format_4 (inst & 0xffff);
|
1996-08-29 01:06:42 +00:00
|
|
|
PC += 2;
|
|
|
|
}
|
1996-09-03 16:25:51 +00:00
|
|
|
else if ((opcode & 0x3C) == 0x2C)
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
do_format_3 (inst & 0xffff);
|
|
|
|
/* No PC update, it's done in the instruction. */
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
else if ((opcode & 0x38) == 0x30)
|
|
|
|
{
|
|
|
|
do_format_6 (inst);
|
|
|
|
PC += 4;
|
|
|
|
}
|
|
|
|
else if ((opcode & 0x3C) == 0x38)
|
|
|
|
{
|
|
|
|
do_format_7 (inst);
|
|
|
|
PC += 4;
|
|
|
|
}
|
|
|
|
else if ((opcode & 0x3E) == 0x3C)
|
|
|
|
{
|
|
|
|
do_format_5 (inst);
|
1996-08-30 04:27:48 +00:00
|
|
|
/* No PC update, it's done in the instruction. */
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
1996-08-29 23:39:23 +00:00
|
|
|
else if ((opcode & 0x3F) == 0x3E)
|
1996-08-29 01:06:42 +00:00
|
|
|
{
|
|
|
|
do_format_8 (inst);
|
|
|
|
PC += 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1996-09-10 02:51:07 +00:00
|
|
|
do_format_9_10 (inst);
|
1996-08-29 01:06:42 +00:00
|
|
|
PC += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!State.exception);
|
1996-09-28 01:38:45 +00:00
|
|
|
|
|
|
|
State.sregs[0] = PC;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_trace ()
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
v850_debug = DEBUG;
|
|
|
|
#endif
|
|
|
|
sim_resume (0, 0);
|
|
|
|
return 1;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_info (verbose)
|
|
|
|
int verbose;
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "sim_info\n");
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_create_inferior (start_address, argv, env)
|
|
|
|
SIM_ADDR start_address;
|
|
|
|
char **argv;
|
|
|
|
char **env;
|
|
|
|
{
|
|
|
|
PC = start_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_kill ()
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_callbacks(p)
|
|
|
|
host_callback *p;
|
|
|
|
{
|
1996-09-03 16:25:51 +00:00
|
|
|
v850_callback = p;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
1996-09-03 17:15:16 +00:00
|
|
|
/* All the code for exiting, signals, etc needs to be revamped.
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
|
|
This is enough to get c-torture limping though. */
|
1996-08-29 01:06:42 +00:00
|
|
|
void
|
|
|
|
sim_stop_reason (reason, sigrc)
|
|
|
|
enum sim_stop *reason;
|
|
|
|
int *sigrc;
|
|
|
|
{
|
|
|
|
|
1996-09-03 16:25:51 +00:00
|
|
|
*reason = sim_stopped;
|
1996-08-29 01:06:42 +00:00
|
|
|
if (State.exception == SIGQUIT)
|
1996-09-03 16:25:51 +00:00
|
|
|
*sigrc = 0;
|
1996-08-29 01:06:42 +00:00
|
|
|
else
|
1996-09-03 16:25:51 +00:00
|
|
|
*sigrc = State.exception;
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_fetch_register (rn, memory)
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
{
|
1996-09-28 01:38:45 +00:00
|
|
|
put_word (memory, State.regs[rn]);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_store_register (rn, memory)
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
{
|
1996-09-28 01:38:45 +00:00
|
|
|
State.regs[rn] = get_word (memory);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
1996-09-10 02:51:07 +00:00
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
sim_read (addr, buffer, size)
|
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
{
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 05:41:10 +00:00
|
|
|
buffer[i] = State.mem[addr + i];
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_do_command (cmd)
|
|
|
|
char *cmd;
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "sim_do_command: %s\n", cmd);
|
1996-08-29 01:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_load (prog, from_tty)
|
|
|
|
char *prog;
|
|
|
|
int from_tty;
|
|
|
|
{
|
|
|
|
/* Return nonzero so GDB will handle it. */
|
|
|
|
return 1;
|
|
|
|
}
|