Commit 17a47301 authored by Pietro Fezzardi's avatar Pietro Fezzardi Committed by Alessandro Rubini

arch-sim: added per-arch config options

startup is changed, because we need to set the initial time for the
master before we set the initial offset from master fo the slave.
In this way the diagnostics cannot be turned on to print out the
config for the master. This is not a problem, because the master
it's not meant to be configurable
parent 54eb55be
...@@ -7,6 +7,7 @@ CFLAGS += -Itools ...@@ -7,6 +7,7 @@ CFLAGS += -Itools
OBJ-y += $A/sim-startup.o \ OBJ-y += $A/sim-startup.o \
$A/main-loop.o \ $A/main-loop.o \
$A/sim-io.o \ $A/sim-io.o \
$A/sim-conf.o \
lib/cmdline.o \ lib/cmdline.o \
lib/conf.o \ lib/conf.o \
lib/div64.o lib/div64.o
......
/*
* Copyright (C) 2013 CERN (www.cern.ch)
* Author: Pietro Fezzardi (pietrofezzardi@gmail.com)
*
* Released according to GNU LGPL, version 2.1 or any later
*/
#include <ppsi/ppsi.h>
#include "ppsi-sim.h"
static int f_ppm_real(int lineno, struct pp_globals *ppg,
union pp_cfg_arg *arg)
{
struct pp_instance *ppi_slave;
/* master clock is supposed to be perfect. parameters about ppm are
* modifiable only for slave ppi */
ppi_slave = pp_sim_get_slave(ppg);
SIM_PPI_ARCH(ppi_slave)->time.freq_ppm_real = arg->i * 1000;
return 0;
}
static int f_ppm_servo(int lineno, struct pp_globals *ppg,
union pp_cfg_arg *arg)
{
struct pp_instance *ppi_slave;
/* master clock is supposed to be perfect. parameters about ppm are
* modifiable only for slave ppi */
ppi_slave = pp_sim_get_slave(ppg);
SIM_PPI_ARCH(ppi_slave)->time.freq_ppm_servo = arg->i * 1000;
return 0;
}
static int f_ofm(int lineno, struct pp_globals *ppg,
union pp_cfg_arg *arg)
{
struct pp_sim_time_instance *t_master, *t_slave;
t_master = &SIM_PPI_ARCH(pp_sim_get_master(ppg))->time;
t_slave = &SIM_PPI_ARCH(pp_sim_get_slave(ppg))->time;
t_slave->current_ns = t_master->current_ns + arg->ts.tv_nsec +
arg->ts.tv_sec * (long long)PP_NSEC_PER_SEC;
return 0;
}
static int f_init_time(int lineno, struct pp_globals *ppg,
union pp_cfg_arg *arg)
{
struct pp_sim_time_instance *t_inst;
t_inst = &SIM_PPI_ARCH(pp_sim_get_master(ppg))->time;
t_inst->current_ns = arg->ts.tv_nsec +
arg->ts.tv_sec * (long long)PP_NSEC_PER_SEC;
return 0;
}
struct pp_argline pp_arch_arglines[] = {
{f_ppm_real, "sim_ppm_real", ARG_INT},
{f_ppm_servo, "sim_init_ppm_servo", ARG_INT},
{f_ofm, "sim_init_ofm", ARG_TIME},
{f_init_time, "sim_init_master_time", ARG_TIME},
{}
};
...@@ -111,6 +111,22 @@ int main(int argc, char **argv) ...@@ -111,6 +111,22 @@ int main(int argc, char **argv)
ppi_slave = &ppg->pp_instances[SIM_SLAVE]; ppi_slave = &ppg->pp_instances[SIM_SLAVE];
ppi_master = &ppg->pp_instances[SIM_MASTER]; ppi_master = &ppg->pp_instances[SIM_MASTER];
/*
* Configure the master with standard configuration, only from default
* string. The master is not configurable, but there's no need to do
* it cause we are ok with a standard one. We just want to see the
* behaviour of the slave.
* NOTE: the master instance is initialized before parsing the command
* line, so the diagnostics cannot be enabled here. We cannot put the
* master config later because the initial time for the master is needed
* to set the initial offset for the slave
*/
sim_set_global_DS(ppi_master);
pp_config_string(ppg, strdup("port SIM_MASTER; iface MASTER;"
"proto udp; role master;"
"sim_init_master_time 10.0;"));
/* parse commandline for configuration options */
sim_set_global_DS(ppi_slave); sim_set_global_DS(ppi_slave);
if (pp_parse_cmdline(ppg, argc, argv) != 0) if (pp_parse_cmdline(ppg, argc, argv) != 0)
return -1; return -1;
...@@ -120,15 +136,6 @@ int main(int argc, char **argv) ...@@ -120,15 +136,6 @@ int main(int argc, char **argv)
if (ppg->cfg.cfg_items == 0) if (ppg->cfg.cfg_items == 0)
pp_config_string(ppg, strdup("port SIM_SLAVE; iface SLAVE;" pp_config_string(ppg, strdup("port SIM_SLAVE; iface SLAVE;"
"proto udp; role slave;")); "proto udp; role slave;"));
/*
* Configure the master with standard configuration, only from default
* string. The master is not configurable, but there's no need to do
* it cause we are ok with a standard one. We just want to see the
* behaviour of the slave
*/
sim_set_global_DS(ppi_master);
pp_config_string(ppg, strdup("port SIM_MASTER; iface MASTER;"
"proto udp; role master;"));
for (i = 0; i < ppg->nlinks; i++) { for (i = 0; i < ppg->nlinks; i++) {
ppi = &ppg->pp_instances[i]; ppi = &ppg->pp_instances[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment