Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
c2c1231b
Commit
c2c1231b
authored
Nov 27, 2013
by
Pietro Fezzardi
Committed by
Alessandro Rubini
Mar 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arch-sim: initialization code for master and slave
parent
16b4b4e3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
171 additions
and
2 deletions
+171
-2
Makefile
arch-sim/Makefile
+2
-2
main-loop.c
arch-sim/main-loop.c
+13
-0
ppsi-sim.h
arch-sim/ppsi-sim.h
+6
-0
sim-startup.c
arch-sim/sim-startup.c
+150
-0
No files found.
arch-sim/Makefile
View file @
c2c1231b
...
...
@@ -7,11 +7,11 @@ CFLAGS += -Itools
OBJ-y
+=
$A
/sim-startup.o
\
$A
/main-loop.o
\
$A
/sim-io.o
\
lib/cmdline.o
\
lib/conf.o
\
lib/div64.o
# lib/dump-funcs.o \
# lib/conf.o \
# lib/libc-functions.o \
# lib/cmdline.o \
# Support only "sim" time operations
TIME
:=
sim
...
...
arch-sim/main-loop.c
View file @
c2c1231b
/*
* Copyright (C) 2013 CERN (ww.cern.ch)
* Author: Pietro Fezzardi (pietrofezzardi@gmail.com)
*
* Released to the public domain
*/
#include <ppsi/ppsi.h>
#include "ppsi-sim.h"
void
sim_main_loop
(
struct
pp_globals
*
ppg
)
{
return
;
}
arch-sim/ppsi-sim.h
View file @
c2c1231b
...
...
@@ -59,11 +59,17 @@ struct sim_ppi_arch_data {
DSCurrent
*
currentDS
;
DSParent
*
parentDS
;
DSTimeProperties
*
timePropertiesDS
;
/* other pp_instance, used in net ops */
struct
pp_instance
*
other_ppi
;
};
/* symbolic names to address master and slave in ppg->pp_instances */
#define SIM_SLAVE 1
#define SIM_MASTER 0
static
inline
struct
sim_ppi_arch_data
*
SIM_PPI_ARCH
(
struct
pp_instance
*
ppi
)
{
return
(
struct
sim_ppi_arch_data
*
)(
ppi
->
arch_data
);
}
extern
int
sim_set_global_DS
(
struct
pp_instance
*
ppi
);
extern
void
sim_main_loop
(
struct
pp_globals
*
ppg
);
arch-sim/sim-startup.c
View file @
c2c1231b
/*
* Copyright (C) 2013 CERN (www.cern.ch)
* Author: Pietro Fezzardi (pietrofezzardi@gmail.com)
*
* Released to the public domain
*/
#include <stdio.h>
#include <ppsi/ppsi.h>
#include "ppsi-sim.h"
static
struct
pp_runtime_opts
sim_master_rt_opts
=
{
.
clock_quality
=
{
.
clockClass
=
PP_CLASS_WR_GM_LOCKED
,
.
clockAccuracy
=
PP_DEFAULT_CLOCK_ACCURACY
,
.
offsetScaledLogVariance
=
PP_DEFAULT_CLOCK_VARIANCE
,
},
.
inbound_latency
=
{
0
,
PP_DEFAULT_INBOUND_LATENCY
},
.
outbound_latency
=
{
0
,
PP_DEFAULT_OUTBOUND_LATENCY
},
.
max_rst
=
PP_DEFAULT_MAX_RESET
,
.
max_dly
=
PP_DEFAULT_MAX_DELAY
,
.
no_adjust
=
PP_DEFAULT_NO_ADJUST
,
.
no_rst_clk
=
PP_DEFAULT_NO_RESET_CLOCK
,
.
ap
=
PP_DEFAULT_AP
,
.
ai
=
PP_DEFAULT_AI
,
.
s
=
PP_DEFAULT_DELAY_S
,
.
announce_intvl
=
PP_DEFAULT_ANNOUNCE_INTERVAL
,
.
sync_intvl
=
PP_DEFAULT_SYNC_INTERVAL
,
.
prio1
=
PP_DEFAULT_PRIORITY1
,
.
prio2
=
PP_DEFAULT_PRIORITY2
,
.
domain_number
=
PP_DEFAULT_DOMAIN_NUMBER
,
.
ttl
=
PP_DEFAULT_TTL
,
};
/*
* In arch-sim we use two pp_instaces in the same pp_globals to represent
* two different machines. This means *completely differnt* machines, with
* their own Data Sets. Given we can't put more all the different Data Sets
* in the same ppg, we stored them in the ppi->arch_data of every istance.
* This function is used to set the inner Data Sets pointer of the ppg to
* point to the Data Sets related to the pp_instange passed as argument
*/
int
sim_set_global_DS
(
struct
pp_instance
*
ppi
)
{
struct
sim_ppi_arch_data
*
data
=
SIM_PPI_ARCH
(
ppi
);
ppi
->
glbs
->
defaultDS
=
data
->
defaultDS
;
ppi
->
glbs
->
currentDS
=
data
->
currentDS
;
ppi
->
glbs
->
parentDS
=
data
->
parentDS
;
ppi
->
glbs
->
timePropertiesDS
=
data
->
timePropertiesDS
;
ppi
->
glbs
->
servo
=
data
->
servo
;
ppi
->
glbs
->
rt_opts
=
data
->
rt_opts
;
return
0
;
}
static
int
sim_ppi_init
(
struct
pp_instance
*
ppi
,
int
which_ppi
)
{
struct
sim_ppi_arch_data
*
data
;
ppi
->
arch_data
=
calloc
(
1
,
sizeof
(
struct
sim_ppi_arch_data
));
ppi
->
portDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
portDS
));
if
((
!
ppi
->
arch_data
)
||
(
!
ppi
->
portDS
))
return
-
1
;
data
=
SIM_PPI_ARCH
(
ppi
);
data
->
defaultDS
=
calloc
(
1
,
sizeof
(
*
data
->
defaultDS
));
data
->
currentDS
=
calloc
(
1
,
sizeof
(
*
data
->
currentDS
));
data
->
parentDS
=
calloc
(
1
,
sizeof
(
*
data
->
parentDS
));
data
->
timePropertiesDS
=
calloc
(
1
,
sizeof
(
*
data
->
timePropertiesDS
));
data
->
servo
=
calloc
(
1
,
sizeof
(
*
data
->
servo
));
if
((
!
data
->
defaultDS
)
||
(
!
data
->
currentDS
)
||
(
!
data
->
parentDS
)
||
(
!
data
->
timePropertiesDS
)
||
(
!
data
->
servo
))
return
-
1
;
if
(
which_ppi
==
SIM_MASTER
)
data
->
rt_opts
=
&
sim_master_rt_opts
;
else
data
->
rt_opts
=
&
__pp_default_rt_opts
;
data
->
other_ppi
=
&
ppi
->
glbs
->
pp_instances
[
-
(
which_ppi
-
1
)];
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
pp_globals
*
ppg
;
struct
pp_instance
*
ppi_master
,
*
ppi_slave
;
struct
pp_instance
*
ppi
;
int
i
;
setbuf
(
stdout
,
NULL
);
pp_printf
(
"PPSi. Commit %s, built on "
__DATE__
"
\n
"
,
PPSI_VERSION
);
ppg
=
calloc
(
1
,
sizeof
(
struct
pp_globals
));
ppg
->
max_links
=
2
;
// master and slave, nothing else
ppg
->
arch_data
=
calloc
(
1
,
sizeof
(
struct
sim_ppg_arch_data
));
ppg
->
pp_instances
=
calloc
(
ppg
->
max_links
,
sizeof
(
struct
pp_instance
));
if
((
!
ppg
->
arch_data
)
||
(
!
ppg
->
pp_instances
))
return
-
1
;
/* Alloc data stuctures inside the pp_instances */
for
(
i
=
0
;
i
<
ppg
->
max_links
;
i
++
)
{
ppi
=
&
ppg
->
pp_instances
[
i
];
ppi
->
glbs
=
ppg
;
// must be done before using sim_set_global_DS
if
(
sim_ppi_init
(
ppi
,
i
))
return
-
1
;
}
ppi_slave
=
&
ppg
->
pp_instances
[
SIM_SLAVE
];
ppi_master
=
&
ppg
->
pp_instances
[
SIM_MASTER
];
sim_set_global_DS
(
ppi_slave
);
if
(
pp_parse_cmdline
(
ppg
,
argc
,
argv
)
!=
0
)
return
-
1
;
/* If no item has been parsed, provide default file or string */
if
(
ppg
->
cfg
.
cfg_items
==
0
)
pp_config_file
(
ppg
,
0
,
PP_DEFAULT_CONFIGFILE
);
if
(
ppg
->
cfg
.
cfg_items
==
0
)
pp_config_string
(
ppg
,
strdup
(
"port SIM_SLAVE; iface 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
++
)
{
ppi
=
&
ppg
->
pp_instances
[
i
];
ppi
->
iface_name
=
ppi
->
cfg
.
iface_name
;
if
(
ppi
->
cfg
.
proto
==
PPSI_PROTO_RAW
)
pp_printf
(
"Warning: simulator doesn't support raw "
"ethernet. Using UDP
\n
"
);
ppi
->
ethernet_mode
=
0
;
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_MASTER
)
{
ppi
->
master_only
=
1
;
ppi
->
slave_only
=
0
;
}
else
if
(
ppi
->
cfg
.
role
==
PPSI_ROLE_SLAVE
)
{
ppi
->
master_only
=
0
;
ppi
->
slave_only
=
1
;
}
ppi
->
t_ops
=
&
DEFAULT_TIME_OPS
;
//ppi->n_ops = &DEFAULT_NET_OPS;
}
sim_set_global_DS
(
ppi_master
);
pp_init_globals
(
ppg
,
&
sim_master_rt_opts
);
sim_set_global_DS
(
ppi_slave
);
pp_init_globals
(
ppg
,
&
__pp_default_rt_opts
);
sim_main_loop
(
ppg
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment