sim: arm/d10v/h8300/m68hc11/microblaze/mips/mn10300/moxie/sh/v850: convert to common sim_{fetch,store}_register

This commit is contained in:
Mike Frysinger 2015-12-30 03:28:45 -05:00
parent c78dff2291
commit e1211e5506
20 changed files with 169 additions and 86 deletions

View File

@ -1,3 +1,11 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (sim_store_register): Rename to ...
(arm_reg_store): ... this.
(sim_fetch_register): Rename to ...
(arm_reg_fetch): ... this.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -431,11 +431,8 @@ tomem (struct ARMul_State *state,
}
}
int
sim_store_register (SIM_DESC sd ATTRIBUTE_UNUSED,
int rn,
unsigned char *memory,
int length)
static int
arm_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
init ();
@ -539,11 +536,8 @@ sim_store_register (SIM_DESC sd ATTRIBUTE_UNUSED,
return length;
}
int
sim_fetch_register (SIM_DESC sd ATTRIBUTE_UNUSED,
int rn,
unsigned char *memory,
int length)
static int
arm_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
ARMword regval;
int len = length;
@ -870,6 +864,8 @@ sim_open (SIM_OPEN_KIND kind,
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = arm_reg_fetch;
CPU_REG_STORE (cpu) = arm_reg_store;
CPU_PC_FETCH (cpu) = arm_pc_get;
CPU_PC_STORE (cpu) = arm_pc_set;
}

View File

@ -1,3 +1,12 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (d10v_reg_store, d10v_reg_fetch): Define.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
(sim_store_register): Rename to ...
(d10v_reg_store): ... this. Rename cpu to sd.
(sim_fetch_register): Rename to ...
(d10v_reg_fetch): ... this. Rename cpu to sd.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -742,6 +742,9 @@ free_state (SIM_DESC sd)
sim_state_free (sd);
}
static int d10v_reg_fetch (SIM_CPU *, int, unsigned char *, int);
static int d10v_reg_store (SIM_CPU *, int, unsigned char *, int);
SIM_DESC
sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
@ -806,6 +809,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = d10v_reg_fetch;
CPU_REG_STORE (cpu) = d10v_reg_store;
CPU_PC_FETCH (cpu) = d10v_pc_get;
CPU_PC_STORE (cpu) = d10v_pc_set;
}
@ -1196,10 +1201,10 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env)
return SIM_RC_OK;
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
d10v_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
SIM_CPU *cpu = STATE_CPU (sd, 0);
SIM_DESC sd = CPU_STATE (cpu);
int size;
switch ((enum sim_d10v_regs) rn)
{
@ -1280,10 +1285,10 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return size;
}
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
d10v_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
SIM_CPU *cpu = STATE_CPU (sd, 0);
SIM_DESC sd = CPU_STATE (cpu);
int size;
switch ((enum sim_d10v_regs) rn)
{

View File

@ -1,3 +1,11 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (sim_store_register): Rename to ...
(h8300_reg_store): ... this. Declare sd.
(sim_fetch_register): Rename to ...
(h8300_reg_fetch): ... this. Declare sd.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* compile.c (lreg): Delete.

View File

@ -4600,10 +4600,10 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
return size;
}
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *value, int length)
static int
h8300_reg_store (SIM_CPU *cpu, int rn, unsigned char *value, int length)
{
SIM_DESC sd = CPU_STATE (cpu);
int longval;
int shortval;
int intval;
@ -4665,9 +4665,10 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *value, int length)
return length;
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *buf, int length)
static int
h8300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *buf, int length)
{
SIM_DESC sd = CPU_STATE (cpu);
int v;
int longreg = 0;
@ -4963,6 +4964,8 @@ sim_open (SIM_OPEN_KIND kind,
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = h8300_reg_fetch;
CPU_REG_STORE (cpu) = h8300_reg_store;
CPU_PC_FETCH (cpu) = h8300_pc_get;
CPU_PC_STORE (cpu) = h8300_pc_set;
}

View File

@ -1,3 +1,12 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (m68hc11_reg_store, m68hc11_reg_fetch): Define.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
(sim_store_register): Rename to ...
(m68hc11_reg_store): ... this. Delete local cpu var.
(sim_fetch_register): Rename to ...
(m68hc11_reg_fetch): ... this. Delete local cpu var.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -413,6 +413,9 @@ m68hc11_pc_set (sim_cpu *cpu, sim_cia pc)
cpu_set_pc (cpu, pc);
}
static int m68hc11_reg_fetch (SIM_CPU *, int, unsigned char *, int);
static int m68hc11_reg_store (SIM_CPU *, int, unsigned char *, int);
SIM_DESC
sim_open (SIM_OPEN_KIND kind, host_callback *callback,
bfd *abfd, char **argv)
@ -492,6 +495,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = m68hc11_reg_fetch;
CPU_REG_STORE (cpu) = m68hc11_reg_store;
CPU_PC_FETCH (cpu) = m68hc11_pc_get;
CPU_PC_STORE (cpu) = m68hc11_pc_set;
}
@ -553,14 +558,12 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
return sim_prepare_for_program (sd, abfd);
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
m68hc11_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
sim_cpu *cpu;
uint16 val;
int size = 2;
cpu = STATE_CPU (sd, 0);
switch (rn)
{
case A_REGNUM:
@ -619,13 +622,10 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return size;
}
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
m68hc11_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
uint16 val;
sim_cpu *cpu;
cpu = STATE_CPU (sd, 0);
val = *memory++;
if (length == 2)

View File

@ -1,3 +1,11 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (sim_store_register): Rename to ...
(microblaze_reg_store): ... this. Delete local cpu var.
(sim_fetch_register): Rename to ...
(microblaze_reg_fetch): ... this. Delete local cpu var.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -304,11 +304,9 @@ sim_engine_run (SIM_DESC sd,
CPU.cycles += memops; /* and memop cycle delays */
}
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
microblaze_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
SIM_CPU *cpu = STATE_CPU (sd, 0);
if (rn < NUM_REGS + NUM_SPECIAL && rn >= 0)
{
if (length == 4)
@ -328,10 +326,9 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return 0;
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
microblaze_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
SIM_CPU *cpu = STATE_CPU (sd, 0);
long ival;
if (rn < NUM_REGS + NUM_SPECIAL && rn >= 0)
@ -447,6 +444,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = microblaze_reg_fetch;
CPU_REG_STORE (cpu) = microblaze_reg_store;
CPU_PC_FETCH (cpu) = microblaze_pc_get;
CPU_PC_STORE (cpu) = microblaze_pc_set;

View File

@ -1,3 +1,14 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (mips_reg_store, mips_reg_fetch): Define.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
(sim_store_register): Rename to ...
(mips_reg_store): ... this. Delete local cpu var.
Update sim_io_eprintf calls.
(sim_fetch_register): Rename to ...
(mips_reg_fetch): ... this. Delete local cpu var.
Update sim_io_eprintf calls.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -342,6 +342,9 @@ mips_pc_set (sim_cpu *cpu, sim_cia pc)
PC = pc;
}
static int mips_reg_fetch (SIM_CPU *, int, unsigned char *, int);
static int mips_reg_store (SIM_CPU *, int, unsigned char *, int);
SIM_DESC
sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
@ -803,6 +806,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = mips_reg_fetch;
CPU_REG_STORE (cpu) = mips_reg_store;
CPU_PC_FETCH (cpu) = mips_pc_get;
CPU_PC_STORE (cpu) = mips_pc_set;
}
@ -840,15 +845,11 @@ mips_sim_close (SIM_DESC sd, int quitting)
#endif
}
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
mips_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */
/* NOTE: gdb (the client) stores registers in target byte order
while the simulator uses host byte order */
#ifdef DEBUG
sim_io_printf(sd,"sim_store_register(%d,*memory=0x%s);\n",rn,pr_addr(*((SIM_ADDR *)memory)));
#endif /* DEBUG */
/* Unfortunately this suffers from the same problem as the register
numbering one. We need to know what the width of each logical
@ -856,12 +857,10 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
if (cpu->register_widths[rn] == 0)
{
sim_io_eprintf(sd,"Invalid register width for %d (register store ignored)\n",rn);
sim_io_eprintf (CPU_STATE (cpu), "Invalid register width for %d (register store ignored)\n", rn);
return 0;
}
if (rn >= FGR_BASE && rn < FGR_BASE + NR_FGR)
{
cpu->fpr_state[rn - FGR_BASE] = fmt_uninterpreted;
@ -925,26 +924,18 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return 0;
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
mips_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */
/* NOTE: gdb (the client) stores registers in target byte order
while the simulator uses host byte order */
#ifdef DEBUG
#if 0 /* FIXME: doesn't compile */
sim_io_printf(sd,"sim_fetch_register(%d=0x%s,mem) : place simulator registers into memory\n",rn,pr_addr(registers[rn]));
#endif
#endif /* DEBUG */
if (cpu->register_widths[rn] == 0)
{
sim_io_eprintf (sd, "Invalid register width for %d (register fetch ignored)\n",rn);
sim_io_eprintf (CPU_STATE (cpu), "Invalid register width for %d (register fetch ignored)\n", rn);
return 0;
}
/* Any floating point register */
if (rn >= FGR_BASE && rn < FGR_BASE + NR_FGR)
{

View File

@ -1,3 +1,12 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (mn10300_reg_store, mn10300_reg_fetch): Define.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
(sim_store_register): Rename to ...
(mn10300_reg_store): ... this.
(sim_fetch_register): Rename to ...
(mn10300_reg_fetch): ... this.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (MN10300_OBJS): Delete sim-hload.o.

View File

@ -86,6 +86,9 @@ mn10300_pc_set (sim_cpu *cpu, sim_cia pc)
PC = pc;
}
static int mn10300_reg_fetch (SIM_CPU *, int, unsigned char *, int);
static int mn10300_reg_store (SIM_CPU *, int, unsigned char *, int);
/* These default values correspond to expected usage for the chip. */
SIM_DESC
@ -308,6 +311,8 @@ sim_open (SIM_OPEN_KIND kind,
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = mn10300_reg_fetch;
CPU_REG_STORE (cpu) = mn10300_reg_store;
CPU_PC_FETCH (cpu) = mn10300_pc_get;
CPU_PC_STORE (cpu) = mn10300_pc_set;
}
@ -338,11 +343,8 @@ sim_create_inferior (SIM_DESC sd,
/* FIXME These would more efficient to use than load_mem/store_mem,
but need to be changed to use the memory map. */
int
sim_fetch_register (SIM_DESC sd,
int rn,
unsigned char *memory,
int length)
static int
mn10300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
reg_t reg = State.regs[rn];
uint8 *a = memory;
@ -353,11 +355,8 @@ sim_fetch_register (SIM_DESC sd,
return length;
}
int
sim_store_register (SIM_DESC sd,
int rn,
unsigned char *memory,
int length)
static int
mn10300_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
uint8 *a = memory;
State.regs[rn] = (a[3] << 24) + (a[2] << 16) + (a[1] << 8) + a[0];

View File

@ -1,3 +1,11 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (sim_store_register): Rename to ...
(moxie_reg_store): ... this.
(sim_fetch_register): Rename to ...
(moxie_reg_fetch): ... this.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -1111,8 +1111,8 @@ sim_engine_run (SIM_DESC sd,
} while (1);
}
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
moxie_reg_store (SIM_CPU *scpu, int rn, unsigned char *memory, int length)
{
if (rn < NUM_MOXIE_REGS && rn >= 0)
{
@ -1131,8 +1131,8 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return 0;
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
moxie_reg_fetch (SIM_CPU *scpu, int rn, unsigned char *memory, int length)
{
if (rn < NUM_MOXIE_REGS && rn >= 0)
{
@ -1237,6 +1237,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = moxie_reg_fetch;
CPU_REG_STORE (cpu) = moxie_reg_store;
CPU_PC_FETCH (cpu) = moxie_pc_get;
CPU_PC_STORE (cpu) = moxie_pc_set;

View File

@ -1,3 +1,11 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (sim_store_register): Rename to ...
(sh_reg_store): ... this.
(sim_fetch_register): Rename to ...
(sh_reg_fetch): ... this.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -1977,8 +1977,8 @@ enum {
REGBANK_MACL = 19
};
int
sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
sh_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
unsigned val;
@ -2150,8 +2150,8 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return length;
}
int
sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
static int
sh_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
int val;
@ -2460,6 +2460,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = sh_reg_fetch;
CPU_REG_STORE (cpu) = sh_reg_store;
CPU_PC_FETCH (cpu) = sh_pc_get;
CPU_PC_STORE (cpu) = sh_pc_set;
}

View File

@ -1,3 +1,12 @@
2015-12-30 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (v850_reg_store, v850_reg_fetch): Define.
(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
(sim_store_register): Rename to ...
(v850_reg_store): ... this.
(sim_fetch_register): Rename to ...
(v850_reg_fetch): ... this.
2015-12-27 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-hload.o.

View File

@ -188,6 +188,9 @@ v850_pc_set (sim_cpu *cpu, sim_cia pc)
PC = pc;
}
static int v850_reg_fetch (SIM_CPU *, int, unsigned char *, int);
static int v850_reg_store (SIM_CPU *, int, unsigned char *, int);
SIM_DESC
sim_open (SIM_OPEN_KIND kind,
host_callback * cb,
@ -296,6 +299,8 @@ sim_open (SIM_OPEN_KIND kind,
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_REG_FETCH (cpu) = v850_reg_fetch;
CPU_REG_STORE (cpu) = v850_reg_store;
CPU_PC_FETCH (cpu) = v850_pc_get;
CPU_PC_STORE (cpu) = v850_pc_set;
}
@ -315,21 +320,15 @@ sim_create_inferior (SIM_DESC sd,
return SIM_RC_OK;
}
int
sim_fetch_register (SIM_DESC sd,
int rn,
unsigned char * memory,
int length)
static int
v850_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
*(unsigned32*)memory = H2T_4 (State.regs[rn]);
return -1;
}
int
sim_store_register (SIM_DESC sd,
int rn,
unsigned char * memory,
int length)
static int
v850_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
{
State.regs[rn] = T2H_4 (*(unsigned32 *) memory);
return length;