static SIM_RC sim_model_init (SIM_DESC sd) { SIM_CPU *cpu; /* If both cpu model and state architecture are set, ensure they're compatible. If only one is set, set the other. If neither are set, use the default model. STATE_ARCHITECTURE is the bfd_arch_info data for the selected "mach" (bfd terminology). */ /* Only check cpu 0. STATE_ARCHITECTURE is for that one only. */ /* ??? At present this only supports homogeneous multiprocessors. */ cpu = STATE_CPU (sd, 0); if (! STATE_ARCHITECTURE (sd) && ! CPU_MACH (cpu)) { /* Set the default model. */ const MODEL *model = sim_model_lookup (WITH_DEFAULT_MODEL); sim_model_set (sd, NULL, model); } if (STATE_ARCHITECTURE (sd) && CPU_MACH (cpu)) { if (strcmp (STATE_ARCHITECTURE (sd)->printable_name, MACH_BFD_NAME (CPU_MACH (cpu))) != 0) { sim_io_eprintf (sd, "invalid model `%s' for `%s'\n", MODEL_NAME (CPU_MODEL (cpu)), STATE_ARCHITECTURE (sd)->printable_name); return SIM_RC_FAIL; } } else if (STATE_ARCHITECTURE (sd)) { /* Use the default model for the selected machine. The default model is the first one in the list. */ 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 { STATE_ARCHITECTURE (sd) = bfd_scan_arch (MACH_BFD_NAME (CPU_MACH (cpu))); } return SIM_RC_OK; }
static SIM_RC model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt, char *arg, int is_command) { switch (opt) { case OPTION_MODEL : { const MODEL *model = sim_model_lookup (arg); if (! model) { sim_io_eprintf (sd, "unknown model `%s'", arg); return SIM_RC_FAIL; } sim_model_set (sd, cpu, model); break; } } return SIM_RC_OK; }
static SIM_RC model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt, char *arg, int is_command) { switch (opt) { case OPTION_MODEL : { const MODEL *model = sim_model_lookup (arg); if (! model) { sim_io_eprintf (sd, "unknown model `%s'\n", arg); return SIM_RC_FAIL; } sim_model_set (sd, cpu, model); break; } case OPTION_MODEL_INFO : { const MACH **machp; const MODEL *model; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { sim_io_printf (sd, "Models for architecture `%s':\n", MACH_NAME (*machp)); for (model = MACH_MODELS (*machp); MODEL_NAME (model) != NULL; ++model) sim_io_printf (sd, " %s", MODEL_NAME (model)); sim_io_printf (sd, "\n"); } break; } } return SIM_RC_OK; }