+2021-05-17 Mike Frysinger <vapier@gentoo.org>
+
+ * interp.c (do_call): Change sd to avr_sim_state.
+ (step_once): Likewise.
+ (sim_open): Likewise.
+ (sim_create_inferior): Likewise.
+ * sim-main.h (SIM_HAVE_COMMON_SIM_STATE): Define.
+ (struct sim_state): Delete.
+ (struct avr_sim_state): New struct.
+ (AVR_SIM_STATE): Define.
+
2021-05-16 Mike Frysinger <vapier@gentoo.org>
* interp.c: Replace config.h include with defs.h.
static void
do_call (SIM_CPU *cpu, unsigned int npc)
{
- SIM_DESC sd = CPU_STATE (cpu);
+ const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
unsigned int sp = read_word (REG_SP);
/* Big endian! */
sram[sp--] = cpu->pc;
sram[sp--] = cpu->pc >> 8;
- if (sd->avr_pc22)
+ if (state->avr_pc22)
{
sram[sp--] = cpu->pc >> 16;
cpu->cycles++;
/* Fall through */
case OP_ret:
{
- SIM_DESC sd = CPU_STATE (cpu);
+ const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
unsigned int sp = read_word (REG_SP);
- if (sd->avr_pc22)
+ if (state->avr_pc22)
{
cpu->pc = sram[++sp] << 16;
cpu->cycles++;
struct bfd *abfd, char * const *argv)
{
int i;
- SIM_DESC sd = sim_state_alloc (kind, cb);
+ SIM_DESC sd = sim_state_alloc_extra (kind, cb, sizeof (struct avr_sim_state));
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
/* The cpu data is kept in a separately allocated chunk of memory. */
sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
char * const *argv, char * const *env)
{
+ struct avr_sim_state *state = AVR_SIM_STATE (sd);
SIM_CPU *cpu = STATE_CPU (sd, 0);
SIM_ADDR addr;
sim_pc_set (cpu, addr);
if (abfd != NULL)
- sd->avr_pc22 = (bfd_get_mach (abfd) >= bfd_mach_avr6);
+ state->avr_pc22 = (bfd_get_mach (abfd) >= bfd_mach_avr6);
return SIM_RC_OK;
}
#ifndef SIM_MAIN_H
#define SIM_MAIN_H
+#define SIM_HAVE_COMMON_SIM_STATE
+
#include "sim-basics.h"
#include "sim-base.h"
sim_cpu_base base;
};
-struct sim_state {
- sim_cpu *cpu[MAX_NR_PROCESSORS];
-
+struct avr_sim_state {
/* If true, the pc needs more than 2 bytes. */
int avr_pc22;
-
- sim_state_base base;
};
+#define AVR_SIM_STATE(sd) ((struct avr_sim_state *) STATE_ARCH_DATA (sd))
+
#endif