#include "sim-assert.h"
#include "bfd.h"
-static void model_set (SIM_DESC, sim_cpu *, const MODEL *);
+static void model_set (sim_cpu *, const MODEL *);
static DECLARE_OPTION_HANDLER (model_option_handler);
const MODEL *model = sim_model_lookup (arg);
if (! model)
{
- sim_io_eprintf (sd, "unknown model `%s'", arg);
+ sim_io_eprintf (sd, "unknown model `%s'\n", arg);
return SIM_RC_FAIL;
}
sim_model_set (sd, cpu, model);
/* Subroutine of sim_model_set to set the model for one cpu. */
static void
-model_set (SIM_DESC sd, sim_cpu *cpu, const MODEL *model)
+model_set (sim_cpu *cpu, const MODEL *model)
{
CPU_MACH (cpu) = MODEL_MACH (model);
CPU_MODEL (cpu) = model;
for (c = 0; c < MAX_NR_PROCESSORS; ++c)
if (STATE_CPU (sd, c))
- model_set (sd, STATE_CPU (sd, c), model);
+ model_set (STATE_CPU (sd, c), model);
}
else
{
- model_set (sd, cpu, model);
+ model_set (cpu, model);
}
}
return NULL;
}
+/* Look up a machine via its bfd name.
+ Result is pointer to MACH entry or NULL if not found. */
+
+const MACH *
+sim_mach_lookup_bfd_name (const char *name)
+{
+ const MACH **machp;
+
+ for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+ {
+ if (strcmp (MACH_BFD_NAME (*machp), name) == 0)
+ return *machp;
+ }
+ return NULL;
+}
+
/* Initialize model support. */
static SIM_RC
{
/* Use the default model for the selected machine.
The default model is the first one in the list. */
- const MACH *mach = sim_mach_lookup (STATE_ARCHITECTURE (sd)->printable_name);
+ const MACH *mach = sim_mach_lookup_bfd_name (STATE_ARCHITECTURE (sd)->printable_name);
+
+ if (mach == NULL)
+ {
+ sim_io_eprintf (sd, "unsupported machine `%s'\n",
+ STATE_ARCHITECTURE (sd)->printable_name);
+ return SIM_RC_FAIL;
+ }
sim_model_set (sd, NULL, MACH_MODELS (mach));
}
else