@ -62,7 +62,7 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
{
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 ) ;
@ -76,7 +76,14 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
{
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 ) ) ;
@ -138,12 +145,15 @@ sim_model_set (SIM_DESC sd, sim_cpu *cpu, const SIM_MODEL *model)
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 )
{
@ -158,11 +168,14 @@ sim_model_lookup (const char *name)
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 ;
@ -174,11 +187,14 @@ sim_mach_lookup (const char *name)
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 ;
@ -209,7 +225,7 @@ sim_model_init (SIM_DESC sd)
& & ! 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 ) ;
}
@ -230,7 +246,8 @@ sim_model_init (SIM_DESC sd)
{
/* 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 )
{
@ -247,12 +264,3 @@ sim_model_init (SIM_DESC sd)
return SIM_RC_OK ;
}
# 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