+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * interp.c (sim_open): Set STATE_MACHS.
+ * machs.c (sim_machs): Rename to ...
+ (bfin_sim_machs): ... this.
+ * machs.h (bfin_sim_machs): New decl.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* machs.c (sim_machs): Mark const.
sizeof (struct bfin_board_data));
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = bfin_sim_machs;
current_alignment = STRICT_ALIGNMENT;
current_target_byte_order = BFD_ENDIAN_LITTLE;
bfin_prepare_run
};
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const bfin_sim_machs[] =
{
& bfin_mach,
NULL
void bfin_model_cpu_init (SIM_DESC, SIM_CPU *);
bu32 bfin_model_get_chipid (SIM_DESC);
bu32 bfin_model_get_dspid (SIM_DESC);
+extern const SIM_MACH * const bfin_sim_machs[];
#define BFIN_COREMMR_CEC_BASE 0xFFE02100
#define BFIN_COREMMR_CEC_SIZE (4 * 5)
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (bpf_sim_machs): ... this.
+ * sim-if.c (bpf_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const bpf_sim_machs[] =
{
#ifdef HAVE_CPU_BPFBF
& bpf_mach,
sim_state_free (sd);
}
+extern const SIM_MACH * const bpf_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
SIM_DESC sd = sim_state_alloc (kind, callback);
+ /* Set default options before parsing user options. */
+ STATE_MACHS (sd) = bpf_sim_machs;
+
if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
goto error;
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * cgen-defs.h (cgen_cpu_max_extra_bytes): Add SIM_DESC arg.
+ * cgen-utils.c (cgen_cpu_max_extra_bytes): Likewise. Change sim_machs
+ to STATE_MACHS.
+ * sim-base.h (struct sim_state): Add machs.
+ (STATE_MACHS): New define.
+ * sim-cpu.c (sim_cpu_alloc): Pass sd to cgen_cpu_max_extra_bytes.
+ * sim-model.c (model_option_handler): Pass sd to sim_model_lookup.
+ Change sim_machs to STATE_MACHS.
+ (sim_model_lookup): Add SIM_DESC arg. Change sim_machs to
+ STATE_MACHS.
+ (sim_mach_lookup): Likewiwse.
+ (sim_mach_lookup_bfd_name): Likewise.
+ (sim_model_init): Pass sd to sim_model_lookup and
+ sim_mach_lookup_bfd_name.
+ (sim_machs): Delete.
+ * sim-model.h (enum mach_attr): Delete.
+ (SIM_MODEL): Change num to int.
+ (sim_machs): Delete.
+ (sim_model_lookup): Add SIM_DESC arg.
+ (sim_mach_lookup): Likewise.
+ (sim_mach_lookup_bfd_name): Likewise.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* Make-common.in (Makefile): Replace $(arch) and pass more files to
/* Return the maximum number of extra bytes required for a sim_cpu struct. */
/* ??? Ok, yes, this is less pretty than it should be. Give me a better
language [or suggest a better way]. */
-extern int cgen_cpu_max_extra_bytes (void);
+extern int cgen_cpu_max_extra_bytes (SIM_DESC);
/* Target supplied routine to process an invalid instruction. */
extern SEM_PC sim_engine_invalid_insn (SIM_CPU *, IADDR, SEM_PC);
/* Return the maximum number of extra bytes required for a SIM_CPU struct. */
int
-cgen_cpu_max_extra_bytes (void)
+cgen_cpu_max_extra_bytes (SIM_DESC sd)
{
- int i;
+ const SIM_MACH * const *machp;
int extra = 0;
- for (i = 0; sim_machs[i] != 0; ++i)
+ SIM_ASSERT (STATE_MACHS (sd) != NULL);
+
+ for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
{
- int size = IMP_PROPS_SIM_CPU_SIZE (MACH_IMP_PROPS (sim_machs[i]));
+ int size = IMP_PROPS_SIM_CPU_SIZE (MACH_IMP_PROPS (*machp));
if (size > extra)
extra = size;
}
const char *target;
#define STATE_TARGET(sd) ((sd)->target)
+ /* List of machs available. */
+ const SIM_MACH * const *machs;
+#define STATE_MACHS(sd) ((sd)->machs)
+
/* In standalone simulator, this is the program's arguments passed
on the command line. */
char **prog_argv;
int extra_bytes = 0;
#ifdef CGEN_ARCH
- extra_bytes += cgen_cpu_max_extra_bytes ();
+ extra_bytes += cgen_cpu_max_extra_bytes (sd);
#endif
return zalloc (sizeof (sim_cpu) + extra_bytes);
{
case OPTION_MODEL :
{
- const SIM_MODEL *model = sim_model_lookup (arg);
+ const SIM_MODEL *model = sim_model_lookup (sd, arg);
if (! model)
{
sim_io_eprintf (sd, "unknown model `%s'\n", arg);
{
const SIM_MACH * const *machp;
const SIM_MODEL *model;
- for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+
+ if (STATE_MACHS (sd) == NULL)
+ {
+ sim_io_printf (sd, "This target does not support any models\n");
+ return SIM_RC_FAIL;
+ }
+
+ for (machp = STATE_MACHS(sd); *machp != NULL; ++machp)
{
sim_io_printf (sd, "Models for architecture `%s':\n",
MACH_NAME (*machp));
Result is pointer to MODEL entry or NULL if not found. */
const SIM_MODEL *
-sim_model_lookup (const char *name)
+sim_model_lookup (SIM_DESC sd, const char *name)
{
const SIM_MACH * const *machp;
const SIM_MODEL *model;
- for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+ if (STATE_MACHS (sd) == NULL)
+ return NULL;
+
+ for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
{
for (model = MACH_MODELS (*machp); MODEL_NAME (model) != NULL; ++model)
{
Result is pointer to MACH entry or NULL if not found. */
const SIM_MACH *
-sim_mach_lookup (const char *name)
+sim_mach_lookup (SIM_DESC sd, const char *name)
{
const SIM_MACH * const *machp;
- for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+ if (STATE_MACHS (sd) == NULL)
+ return NULL;
+
+ for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
{
if (strcmp (MACH_NAME (*machp), name) == 0)
return *machp;
Result is pointer to MACH entry or NULL if not found. */
const SIM_MACH *
-sim_mach_lookup_bfd_name (const char *name)
+sim_mach_lookup_bfd_name (SIM_DESC sd, const char *name)
{
const SIM_MACH * const *machp;
- for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+ if (STATE_MACHS (sd) == NULL)
+ return NULL;
+
+ for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
{
if (strcmp (MACH_BFD_NAME (*machp), name) == 0)
return *machp;
&& ! CPU_MACH (cpu))
{
/* Set the default model. */
- const SIM_MODEL *model = sim_model_lookup (WITH_DEFAULT_MODEL);
+ const SIM_MODEL *model = sim_model_lookup (sd, WITH_DEFAULT_MODEL);
SIM_ASSERT (model != NULL);
sim_model_set (sd, NULL, model);
}
{
/* Use the default model for the selected machine.
The default model is the first one in the list. */
- const SIM_MACH *mach = sim_mach_lookup_bfd_name (STATE_ARCHITECTURE (sd)->printable_name);
+ const SIM_MACH *mach =
+ sim_mach_lookup_bfd_name (sd, STATE_ARCHITECTURE (sd)->printable_name);
if (mach == NULL)
{
return SIM_RC_OK;
}
-\f
-#if !WITH_MODEL_P
-/* Set up basic model support. This is a stub for ports that do not define
- models. See sim-model.h for more details. */
-const SIM_MACH * const sim_machs[] =
-{
- NULL
-};
-#endif
#endif
#ifndef WITH_DEFAULT_MODEL
-/* Just a stub for ports that do not define models. */
-enum mach_attr { _MACH_NONE };
# define WITH_DEFAULT_MODEL NULL
# define WITH_MODEL_P 0
#else
/* This is the argument to bfd_scan_arch. */
const char *bfd_name;
#define MACH_BFD_NAME(m) ((m)->bfd_name)
- enum mach_attr num;
+ int num;
#define MACH_NUM(m) ((m)->num)
int word_bitsize;
#define MODEL_INIT(m) ((m)->init)
} SIM_MODEL;
-/* Tables of supported machines. */
-/* ??? In a simulator of multiple architectures, will need multiple copies of
- this. Have an `archs' array that contains a pointer to the machs array
- for each (which in turn has a pointer to the models array for each). */
-extern const SIM_MACH * const sim_machs[];
-
/* Model module handlers. */
extern MODULE_INSTALL_FN sim_model_install;
/* Support routines. */
extern void sim_model_set (SIM_DESC sd_, sim_cpu *cpu_, const SIM_MODEL *model_);
-extern const SIM_MODEL *sim_model_lookup (const char *name_);
-extern const SIM_MACH *sim_mach_lookup (const char *name_);
-extern const SIM_MACH *sim_mach_lookup_bfd_name (const char *bfd_name_);
+extern const SIM_MODEL *sim_model_lookup (SIM_DESC, const char *name_);
+extern const SIM_MACH *sim_mach_lookup (SIM_DESC, const char *name_);
+extern const SIM_MACH *sim_mach_lookup_bfd_name (SIM_DESC, const char *bfd_name_);
#endif /* SIM_MODEL_H */
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (cris_sim_machs): ... this.
+ * sim-if.c (cris_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (stamp-v10fcpu): Do not insert cgen-ops.h include.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const cris_sim_machs[] =
{
#ifdef HAVE_CPU_CRISV10F
& crisv10_mach,
return ok;
}
+extern const SIM_MACH * const cris_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
bfd_byte sp_init[4] = {0, 0, 0, 0};
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = cris_sim_machs;
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (frv_sim_machs): ... this.
+ * sim-if.c (frv_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const frv_sim_machs[] =
{
#ifdef HAVE_CPU_FRVBF
& frv_mach,
sim_state_free (sd);
}
+extern const SIM_MACH * const frv_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
SIM_DESC sd = sim_state_alloc (kind, callback);
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = frv_sim_machs;
current_alignment = STRICT_ALIGNMENT;
current_target_byte_order = BFD_ENDIAN_BIG;
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (iq2000_sim_machs): ... this.
+ * sim-if.c (iq2000_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const iq2000_sim_machs[] =
{
#ifdef HAVE_CPU_IQ2000BF
& iq2000_mach,
sim_state_free (sd);
}
+extern const SIM_MACH * const iq2000_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
SIM_DESC sd = sim_state_alloc (kind, callback);
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = iq2000_sim_machs;
current_alignment = STRICT_ALIGNMENT;
current_target_byte_order = BFD_ENDIAN_BIG;
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (lm32_sim_machs): ... this.
+ * sim-if.c (lm32_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const lm32_sim_machs[] =
{
#ifdef HAVE_CPU_LM32BF
& lm32_mach,
return (addr + 65536) & ~(0xffffUL);
}
+extern const SIM_MACH * const lm32_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
unsigned long base, limit;
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = lm32_sim_machs;
current_alignment = STRICT_ALIGNMENT;
current_target_byte_order = BFD_ENDIAN_BIG;
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (m32r_sim_machs): ... this.
+ * sim-if.c (m32r_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const m32r_sim_machs[] =
{
#ifdef HAVE_CPU_M32RBF
& m32r_mach,
sim_state_free (sd);
}
+extern const SIM_MACH * const m32r_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
int i;
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = m32r_sim_machs;
current_alignment = STRICT_ALIGNMENT;
current_target_byte_order = BFD_ENDIAN_BIG;
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * arch.c (sim_machs): Rename to ...
+ (or1k_sim_machs): ... this.
+ * sim-if.c (or1k_sim_machs): New decl.
+ (sim_open): Set STATE_MACH.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.
#include "sim-main.h"
#include "bfd.h"
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const or1k_sim_machs[] =
{
#ifdef HAVE_CPU_OR1K32BF
& or32_mach,
return SIM_RC_FAIL;
}
+extern const SIM_MACH * const or1k_sim_machs[];
+
/* Create an instance of the simulator. */
SIM_DESC
int i;
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = or1k_sim_machs;
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
+2021-06-30 Mike Frysinger <vapier@gentoo.org>
+
+ * interp.c (sim_open): Set STATE_MACHS.
+ (riscv_sim_machs): New decl.
+ * machs.c (sim_machs): Rename to ...
+ (riscv_sim_machs): ... this.
+
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* machs.c (sim_machs): Mark const.
sim_state_free (sd);
}
+extern const SIM_MACH * const riscv_sim_machs[];
+
SIM_DESC
sim_open (SIM_OPEN_KIND kind, host_callback *callback,
struct bfd *abfd, char * const *argv)
sizeof (struct riscv_sim_state));
/* Set default options before parsing user options. */
+ STATE_MACHS (sd) = riscv_sim_machs;
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
#endif
/* Order matters here. */
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const riscv_sim_machs[] =
{
#if WITH_TARGET_WORD_BITSIZE >= 128
&rv128i_mach,