@ -38,7 +38,7 @@ extern device_factory_t* ns16550_factory;
sim_t : : sim_t ( const cfg_t * cfg , bool halted ,
sim_t : : sim_t ( const cfg_t * cfg , bool halted ,
std : : vector < std : : pair < reg_t , abstract_mem_t * > > mems ,
std : : vector < std : : pair < reg_t , abstract_mem_t * > > mems ,
std : : vector < device_factory_t * > plugin_device_factories ,
const std : : vector < device_factory_sargs_t > & plugin_device_factories ,
const std : : vector < std : : string > & args ,
const std : : vector < std : : string > & args ,
const debug_module_config_t & dm_config ,
const debug_module_config_t & dm_config ,
const char * log_path ,
const char * log_path ,
@ -115,10 +115,10 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
// that's not bus-accessible), but it should handle the normal use cases. In
// that's not bus-accessible), but it should handle the normal use cases. In
// particular, the default device tree configuration that you get without
// particular, the default device tree configuration that you get without
// setting the dtb_file argument has one.
// setting the dtb_file argument has one.
std : : vector < const device_factory_t * > device_factories = {
std : : vector < device_factory_sargs_t > device_factories = {
clint_factory , // clint must be element 0
{ clint_factory , { } } , // clint must be element 0
plic_factory , // plic must be element 1
{ plic_factory , { } } , // plic must be element 1
ns16550_factory } ;
{ ns16550_factory , { } } } ;
device_factories . insert ( device_factories . end ( ) ,
device_factories . insert ( device_factories . end ( ) ,
plugin_device_factories . begin ( ) ,
plugin_device_factories . begin ( ) ,
plugin_device_factories . end ( ) ) ;
plugin_device_factories . end ( ) ) ;
@ -136,8 +136,11 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
} else {
} else {
std : : pair < reg_t , reg_t > initrd_bounds = cfg - > initrd_bounds ;
std : : pair < reg_t , reg_t > initrd_bounds = cfg - > initrd_bounds ;
std : : string device_nodes ;
std : : string device_nodes ;
for ( const device_factory_t * factory : device_factories )
for ( const device_factory_sargs_t & factory_sargs : device_factories ) {
device_nodes . append ( factory - > generate_dts ( this ) ) ;
const device_factory_t * factory = factory_sargs . first ;
const std : : vector < std : : string > & sargs = factory_sargs . second ;
device_nodes . append ( factory - > generate_dts ( this , sargs ) ) ;
}
dts = make_dts ( INSNS_PER_RTC_TICK , CPU_HZ ,
dts = make_dts ( INSNS_PER_RTC_TICK , CPU_HZ ,
initrd_bounds . first , initrd_bounds . second ,
initrd_bounds . first , initrd_bounds . second ,
cfg - > bootargs , cfg - > pmpregions , cfg - > pmpgranularity ,
cfg - > bootargs , cfg - > pmpregions , cfg - > pmpgranularity ,
@ -160,9 +163,10 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
void * fdt = ( void * ) dtb . c_str ( ) ;
void * fdt = ( void * ) dtb . c_str ( ) ;
for ( size_t i = 0 ; i < device_factories . size ( ) ; i + + ) {
for ( size_t i = 0 ; i < device_factories . size ( ) ; i + + ) {
const device_factory_t * factory = device_factories [ i ] ;
const device_factory_t * factory = device_factories [ i ] . first ;
const std : : vector < std : : string > & sargs = device_factories [ i ] . second ;
reg_t device_base = 0 ;
reg_t device_base = 0 ;
abstract_device_t * device = factory - > parse_from_fdt ( fdt , this , & device_base ) ;
abstract_device_t * device = factory - > parse_from_fdt ( fdt , this , & device_base , sargs ) ;
if ( device ) {
if ( device ) {
assert ( device_base ) ;
assert ( device_base ) ;
std : : shared_ptr < abstract_device_t > dev_ptr ( device ) ;
std : : shared_ptr < abstract_device_t > dev_ptr ( device ) ;