1996-08-29 09:06:42 +08:00
|
|
|
#include <signal.h>
|
|
|
|
#include "sysdep.h"
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "remote-sim.h"
|
|
|
|
#include "callback.h"
|
|
|
|
|
|
|
|
#include "v850_sim.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 13:41:10 +08:00
|
|
|
#define MEM_SIZE 18 /* V850 memory size is 18 bits XXX */
|
1996-08-29 09:06:42 +08:00
|
|
|
|
1996-09-04 00:25:51 +08:00
|
|
|
host_callback *v850_callback;
|
|
|
|
|
|
|
|
|
|
|
|
uint32 OP[4];
|
1996-08-29 09:06:42 +08:00
|
|
|
|
|
|
|
static struct hash_entry *lookup_hash PARAMS ((uint32 ins));
|
|
|
|
|
|
|
|
#define MAX_HASH 63
|
|
|
|
struct hash_entry
|
|
|
|
{
|
|
|
|
struct hash_entry *next;
|
|
|
|
long opcode;
|
|
|
|
long mask;
|
|
|
|
struct simops *ops;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hash_entry hash_table[MAX_HASH+1];
|
|
|
|
|
|
|
|
static long
|
|
|
|
hash(insn)
|
|
|
|
long insn;
|
|
|
|
{
|
1996-08-31 00:35:10 +08:00
|
|
|
if ((insn & 0x0600) == 0
|
|
|
|
|| (insn & 0x0700) == 0x0200)
|
1996-08-30 07:39:23 +08:00
|
|
|
return (insn & 0x07e0) >> 5;
|
1996-08-31 00:35:10 +08:00
|
|
|
if ((insn & 0x0700) == 0x0300
|
|
|
|
|| (insn & 0x0700) == 0x0400
|
|
|
|
|| (insn & 0x0700) == 0x0500)
|
|
|
|
return (insn & 0x0780) >> 7;
|
|
|
|
if ((insn & 0x0700) == 0x0600)
|
1996-08-30 07:39:23 +08:00
|
|
|
return (insn & 0x07e0) >> 5;
|
1996-08-31 00:35:10 +08:00
|
|
|
if ((insn & 0x0780) == 0x0700)
|
1996-08-30 07:39:23 +08:00
|
|
|
return (insn & 0x07e0) >> 5;
|
1996-08-31 00:35:10 +08:00
|
|
|
if ((insn & 0x07c0) == 0x0780)
|
1996-08-30 07:39:23 +08:00
|
|
|
return (insn & 0x07c0) >> 6;
|
1996-08-31 00:35:10 +08:00
|
|
|
if ((insn & 0x07E0) == 0x07C0)
|
|
|
|
return (insn & 0x07e0) >> 5;
|
|
|
|
return (insn & 0x07e0) >> 5;
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct hash_entry *
|
|
|
|
lookup_hash (ins)
|
|
|
|
uint32 ins;
|
|
|
|
{
|
|
|
|
struct hash_entry *h;
|
|
|
|
|
1996-08-30 07:39:23 +08:00
|
|
|
h = &hash_table[hash(ins)];
|
1996-08-29 09:06:42 +08:00
|
|
|
|
|
|
|
while ( (ins & h->mask) != h->opcode)
|
|
|
|
{
|
|
|
|
if (h->next == NULL)
|
|
|
|
{
|
|
|
|
printf ("ERROR looking up hash for %x\n",ins);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
return (h);
|
|
|
|
}
|
|
|
|
|
* 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 13:41:10 +08:00
|
|
|
uint8
|
|
|
|
get_byte (x)
|
|
|
|
uint8 *x;
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
return *x;
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
uint16
|
|
|
|
get_half (x)
|
|
|
|
uint8 *x;
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
return (a[1] << 8) + (a[0]);
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
uint32
|
1996-08-30 07:39:23 +08:00
|
|
|
get_word (x)
|
|
|
|
uint8 *x;
|
1996-08-29 09:06:42 +08:00
|
|
|
{
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
return (a[3]<<24) + (a[2]<<16) + (a[1]<<8) + (a[0]);
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
put_byte (addr, data)
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
uint8 data;
|
1996-08-29 09:06:42 +08:00
|
|
|
{
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
a[0] = data;
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
put_half (addr, data)
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
uint16 data;
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
uint8 *a = addr;
|
|
|
|
a[0] = data & 0xff;
|
|
|
|
a[1] = (data >> 8) & 0xff;
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
put_word (addr, data)
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
uint32 data;
|
1996-08-30 07:39:23 +08: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 13:41:10 +08:00
|
|
|
a[0] = data & 0xff;
|
|
|
|
a[1] = (data >> 8) & 0xff;
|
|
|
|
a[2] = (data >> 16) & 0xff;
|
|
|
|
a[3] = (data >> 24) & 0xff;
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1996-08-30 07:39:23 +08:00
|
|
|
do_format_1_2 (insn)
|
1996-08-29 09:06:42 +08:00
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 07:39:23 +08:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = insn & 0x1f;
|
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_3 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 11:48:13 +08:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = (((insn & 0x70) >> 4) | ((insn & 0xf800) >> 8)) << 1;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_4 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 13:49:07 +08:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = (insn >> 11) & 0x1f;
|
|
|
|
OP[1] = (insn & 0x7f);
|
|
|
|
(h->ops->func) ();
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_5 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 12:27:48 +08:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
1996-09-04 00:25:51 +08:00
|
|
|
OP[0] = (((insn & 0x3f) << 15) | ((insn >> 17) & 0x7fff)) << 1;
|
1996-08-30 12:27:48 +08:00
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_6 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 07:39:23 +08: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 09:06:42 +08: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 13:41:10 +08: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 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_format_8 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-31 00:35:10 +08: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 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_formats_9_10 (insn)
|
|
|
|
uint32 insn;
|
|
|
|
{
|
1996-08-30 07:39:23 +08:00
|
|
|
struct hash_entry *h;
|
|
|
|
|
|
|
|
h = lookup_hash (insn);
|
|
|
|
OP[0] = insn & 0x1f;
|
|
|
|
OP[1] = (insn >> 11) & 0x1f;
|
|
|
|
(h->ops->func) ();
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
if (State.mem)
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
free (State.mem);
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
State.mem = (uint8 *)calloc(1,1<<MEM_SIZE);
|
|
|
|
if (!State.mem)
|
1996-08-29 09:06:42 +08:00
|
|
|
{
|
|
|
|
fprintf (stderr,"Memory allocation failed.\n");
|
|
|
|
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 13:41:10 +08:00
|
|
|
if (!State.mem)
|
1996-08-29 09:06:42 +08: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 13:41:10 +08:00
|
|
|
State.mem[i+addr] = buffer[i];
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_open (args)
|
|
|
|
char *args;
|
|
|
|
{
|
|
|
|
struct simops *s;
|
|
|
|
struct hash_entry *h, *prev;
|
|
|
|
if (args != NULL)
|
|
|
|
printf ("sim_open %s\n",args);
|
|
|
|
|
|
|
|
/* put all the opcodes in the hash table */
|
|
|
|
for (s = Simops; s->func; s++)
|
|
|
|
{
|
|
|
|
h = &hash_table[hash(s->opcode)];
|
|
|
|
|
|
|
|
/* go to the last entry in the chain */
|
|
|
|
while (h->next)
|
|
|
|
h = h->next;
|
|
|
|
|
|
|
|
if (h->ops)
|
|
|
|
{
|
|
|
|
h->next = calloc(1,sizeof(struct hash_entry));
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
h->ops = s;
|
|
|
|
h->mask = s->mask;
|
|
|
|
h->opcode = s->opcode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_close (quitting)
|
|
|
|
int quitting;
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile (n)
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
printf ("sim_set_profile %d\n",n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile_size (n)
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
printf ("sim_set_profile_size %d\n",n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_resume (step, siggnal)
|
|
|
|
int step, siggnal;
|
|
|
|
{
|
|
|
|
uint32 inst, opcode;
|
|
|
|
int i;
|
|
|
|
reg_t oldpc;
|
|
|
|
|
|
|
|
|
|
|
|
if (step)
|
|
|
|
State.exception = SIGTRAP;
|
|
|
|
else
|
|
|
|
State.exception = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
inst = RLW (PC);
|
|
|
|
oldpc = PC;
|
1996-08-30 07:39:23 +08:00
|
|
|
opcode = (inst & 0x07e0) >> 5;
|
|
|
|
if ((opcode & 0x30) == 0
|
|
|
|
|| (opcode & 0x38) == 0x10)
|
1996-08-29 09:06:42 +08:00
|
|
|
{
|
1996-08-30 07:39:23 +08:00
|
|
|
do_format_1_2 (inst & 0xffff);
|
1996-08-29 09:06:42 +08:00
|
|
|
PC += 2;
|
|
|
|
}
|
|
|
|
else if ((opcode & 0x3C) == 0x18
|
|
|
|
|| (opcode & 0x3C) == 0x1C
|
|
|
|
|| (opcode & 0x3C) == 0x20
|
|
|
|
|| (opcode & 0x3C) == 0x24
|
|
|
|
|| (opcode & 0x3C) == 0x28)
|
|
|
|
{
|
1996-08-30 07:39:23 +08:00
|
|
|
do_format_4 (inst & 0xffff);
|
1996-08-29 09:06:42 +08:00
|
|
|
PC += 2;
|
|
|
|
}
|
1996-09-04 00:25:51 +08:00
|
|
|
else if ((opcode & 0x3C) == 0x2C)
|
1996-08-29 09:06:42 +08:00
|
|
|
{
|
1996-08-30 07:39:23 +08:00
|
|
|
do_format_3 (inst & 0xffff);
|
|
|
|
/* No PC update, it's done in the instruction. */
|
1996-08-29 09:06:42 +08: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 12:27:48 +08:00
|
|
|
/* No PC update, it's done in the instruction. */
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
1996-08-30 07:39:23 +08:00
|
|
|
else if ((opcode & 0x3F) == 0x3E)
|
1996-08-29 09:06:42 +08:00
|
|
|
{
|
|
|
|
do_format_8 (inst);
|
|
|
|
PC += 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
do_formats_9_10 (inst);
|
|
|
|
PC += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!State.exception);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_trace ()
|
|
|
|
{
|
|
|
|
printf ("sim_trace\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_info (verbose)
|
|
|
|
int verbose;
|
|
|
|
{
|
|
|
|
printf ("sim_info\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
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-04 00:25:51 +08:00
|
|
|
v850_callback = p;
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
1996-09-04 00:25:51 +08:00
|
|
|
/* All the code for exiting, signals, etc needs to be revamped. */
|
|
|
|
|
|
|
|
This is enough to get c-torture limping though. */
|
1996-08-29 09:06:42 +08:00
|
|
|
void
|
|
|
|
sim_stop_reason (reason, sigrc)
|
|
|
|
enum sim_stop *reason;
|
|
|
|
int *sigrc;
|
|
|
|
{
|
|
|
|
|
1996-09-04 00:25:51 +08:00
|
|
|
*reason = sim_stopped;
|
1996-08-29 09:06:42 +08:00
|
|
|
if (State.exception == SIGQUIT)
|
1996-09-04 00:25:51 +08:00
|
|
|
*sigrc = 0;
|
1996-08-29 09:06:42 +08:00
|
|
|
else
|
1996-09-04 00:25:51 +08:00
|
|
|
*sigrc = State.exception;
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_fetch_register (rn, memory)
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
{
|
|
|
|
*(uint32 *)memory = State.regs[rn];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_store_register (rn, memory)
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
{
|
|
|
|
State.regs[rn]= *(uint32 *)memory;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 13:41:10 +08:00
|
|
|
buffer[i] = State.mem[addr + i];
|
1996-08-29 09:06:42 +08:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_do_command (cmd)
|
|
|
|
char *cmd;
|
|
|
|
{
|
|
|
|
printf("sim_do_command: %s\n",cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_load (prog, from_tty)
|
|
|
|
char *prog;
|
|
|
|
int from_tty;
|
|
|
|
{
|
|
|
|
/* Return nonzero so GDB will handle it. */
|
|
|
|
return 1;
|
|
|
|
}
|