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
bcf8a856
Commit
bcf8a856
authored
Dec 05, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arch-wrs: allocate all structures in shared memory
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
d93b31c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
20 deletions
+42
-20
ppsi-wrs.h
arch-wrs/include/ppsi-wrs.h
+1
-0
main-loop.c
arch-wrs/main-loop.c
+5
-0
wrs-startup.c
arch-wrs/wrs-startup.c
+36
-20
No files found.
arch-wrs/include/ppsi-wrs.h
View file @
bcf8a856
...
...
@@ -10,6 +10,7 @@
# define BUILT_WITH_WHITERABBIT 0
#endif
#define WRS_PPSI_SHMEM_VERSION 1
/*
* These are the functions provided by the various wrs files
...
...
arch-wrs/main-loop.c
View file @
bcf8a856
...
...
@@ -33,6 +33,11 @@ static int run_all_state_machines(struct pp_globals *ppg)
/* FIXME: we should save this pointer in the ppi itself */
p
=
pp_wrs_lookup_port
(
ppi
->
iface_name
);
if
(
!
p
)
{
fprintf
(
stderr
,
"ppsi: can't find %s in shmem
\n
"
,
ppi
->
iface_name
);
continue
;
}
WR_DSPOR
(
ppi
)
->
linkUP
=
(
p
->
state
!=
HAL_PORT_STATE_LINK_DOWN
&&
...
...
arch-wrs/wrs-startup.c
View file @
bcf8a856
...
...
@@ -24,6 +24,7 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#include <libwr/shmem.h>
#if BUILT_WITH_WHITERABBIT
# define WRSW_HAL_RETRIES 1000
...
...
@@ -53,19 +54,24 @@ static struct wr_operations wrs_wr_operations = {
.
enable_timing_output
=
wrs_enable_timing_output
,
};
/* ppg and fields */
static
struct
pp_globals
ppg_static
;
static
DSDefault
defaultDS
;
static
DSCurrent
currentDS
;
static
DSParent
parentDS
;
static
DSTimeProperties
timePropertiesDS
;
static
struct
pp_servo
servo
;
struct
minipc_ch
*
hal_ch
;
struct
minipc_ch
*
ppsi_ch
;
struct
hal_port_state
*
hal_ports
;
int
hal_nports
;
/*
* we need to call calloc, to reset all stuff that used to be static,
* but we'd better have a simple prototype, compatilble with wrs_shm_alloc()
*/
void
*
local_malloc
(
void
*
headptr
,
size_t
size
)
{
void
*
retval
=
malloc
(
size
);
if
(
retval
)
memset
(
retval
,
0
,
size
);
return
retval
;
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
pp_globals
*
ppg
;
...
...
@@ -74,8 +80,9 @@ int main(int argc, char **argv)
unsigned
long
seed
;
struct
timex
t
;
int
i
,
hal_retries
;
struct
wrs_shm_head
*
hal_head
;
struct
wrs_shm_head
*
hal_head
,
*
ppsi_head
;
struct
hal_shmem_header
*
h
;
void
*
(
*
alloc_fn
)(
void
*
headptr
,
size_t
size
)
=
local_malloc
;
setbuf
(
stdout
,
NULL
);
...
...
@@ -117,20 +124,30 @@ int main(int argc, char **argv)
exit
(
1
);
}
wrs_init_ipcserver
(
ppsi_ch
);
ppsi_head
=
wrs_shm_get
(
wrs_shm_ptp
,
"ppsi"
,
WRS_SHM_WRITE
);
if
(
!
ppsi_head
)
{
fprintf
(
stderr
,
"Fatal: could not create shmem: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
alloc_fn
=
wrs_shm_alloc
;
ppsi_head
->
version
=
WRS_PPSI_SHMEM_VERSION
;
}
ppg
=
&
ppg_static
;
ppg
->
defaultDS
=
&
defaultDS
;
ppg
->
currentDS
=
&
currentDS
;
ppg
->
parentDS
=
&
parentDS
;
ppg
->
timePropertiesDS
=
&
timePropertiesDS
;
ppg
->
servo
=
&
servo
;
ppg
=
alloc_fn
(
ppsi_head
,
sizeof
(
*
ppg
));
ppg
->
defaultDS
=
alloc_fn
(
ppsi_head
,
sizeof
(
*
ppg
->
defaultDS
));
ppg
->
currentDS
=
alloc_fn
(
ppsi_head
,
sizeof
(
*
ppg
->
currentDS
));
ppg
->
parentDS
=
alloc_fn
(
ppsi_head
,
sizeof
(
*
ppg
->
parentDS
));
ppg
->
timePropertiesDS
=
alloc_fn
(
ppsi_head
,
sizeof
(
*
ppg
->
timePropertiesDS
));
ppg
->
servo
=
alloc_fn
(
ppsi_head
,
sizeof
(
*
ppg
->
servo
));
ppg
->
rt_opts
=
&
__pp_default_rt_opts
;
/* We are hosted, so we can allocate */
ppg
->
max_links
=
PP_MAX_LINKS
;
ppg
->
arch_data
=
calloc
(
1
,
sizeof
(
struct
unix_arch_data
));
ppg
->
pp_instances
=
calloc
(
ppg
->
max_links
,
sizeof
(
struct
pp_instance
));
ppg
->
arch_data
=
malloc
(
sizeof
(
struct
unix_arch_data
));
ppg
->
pp_instances
=
alloc_fn
(
ppsi_head
,
ppg
->
max_links
*
sizeof
(
*
ppi
));
if
((
!
ppg
->
arch_data
)
||
(
!
ppg
->
pp_instances
))
{
fprintf
(
stderr
,
"ppsi: out of memory
\n
"
);
...
...
@@ -146,7 +163,7 @@ int main(int argc, char **argv)
* exactly after stbcnt. It's a bad hack, but it works
*/
p
=
(
int
*
)(
&
t
.
stbcnt
)
+
1
;
timePropertiesDS
.
currentUtcOffset
=
*
p
;
ppg
->
timePropertiesDS
->
currentUtcOffset
=
*
p
;
}
if
(
pp_parse_cmdline
(
ppg
,
argc
,
argv
)
!=
0
)
...
...
@@ -192,7 +209,6 @@ int main(int argc, char **argv)
ppi
->
n_ops
=
&
DEFAULT_NET_OPS
;
ppi
->
t_ops
=
&
DEFAULT_TIME_OPS
;
ppi
->
portDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
portDS
));
ppi
->
__tx_buffer
=
malloc
(
PP_MAX_FRAME_LENGTH
);
ppi
->
__rx_buffer
=
malloc
(
PP_MAX_FRAME_LENGTH
);
...
...
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