Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Mock Turtle
Commits
f16bb67c
Commit
f16bb67c
authored
Mar 13, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrtd:tools: various fixes of types and variable usage
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
5f73158e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
wrtd-boot.c
applications/wrtd/tools/wrtd-boot.c
+21
-12
No files found.
applications/wrtd/tools/wrtd-boot.c
View file @
f16bb67c
...
...
@@ -14,6 +14,8 @@
#include <libwrnc.h>
#include <libwrtd.h>
#define WRTD_BOOT_WR_FMC_OFFSET 0x2
enum
wrtb_boot_tdc_offset_type
{
OFFSET_ZERO
,
OFFSET_USER
,
...
...
@@ -46,25 +48,27 @@ static inline char *stroffset(enum wrtb_boot_tdc_offset_type type) {
*/
static
int
partial_offset_get
(
unsigned
int
dev_id
,
unsigned
int
channel
,
uint64
_t
*
offset
,
int32
_t
*
offset
,
enum
wrtb_boot_tdc_offset_type
type
)
{
char
path
[
255
];
FILE
*
f
;
int
ret
;
uint32_t
val
;
if
(
type
==
OFFSET_WR
)
sprintf
(
path
,
"/sys/bus/zio/devices/tdc-1n5c-%04x/%s"
,
dev_id
,
stroffset
(
type
));
dev_id
-
WRTD_BOOT_WR_FMC_OFFSET
,
stroffset
(
type
));
else
sprintf
(
path
,
"/sys/bus/zio/devices/tdc-1n5c-%04x/ft-ch%d/%s"
,
dev_id
,
channel
+
1
,
stroffset
(
type
));
dev_id
-
WRTD_BOOT_WR_FMC_OFFSET
,
channel
+
1
,
stroffset
(
type
));
f
=
fopen
(
path
,
"r"
);
if
(
!
f
)
return
-
1
;
ret
=
fscanf
(
f
,
"%"
SCN
x64
,
offset
);
ret
=
fscanf
(
f
,
"%"
SCN
u32
,
&
val
);
if
(
ret
!=
1
)
{
fclose
(
f
);
if
(
!
errno
)
...
...
@@ -74,6 +78,7 @@ static int partial_offset_get(unsigned int dev_id,
fclose
(
f
);
*
offset
=
(
int32_t
)
val
;
return
0
;
}
...
...
@@ -81,31 +86,35 @@ static int partial_offset_get(unsigned int dev_id,
/**
* It compute the final time stamp (as it is done on the fmc-tdc driver)
*/
static
int
offset_get
(
unsigned
int
dev_id
,
unsigned
int
channel
,
uint64
_t
*
offset
)
static
int
offset_get
(
unsigned
int
dev_id
,
unsigned
int
channel
,
int32
_t
*
offset
)
{
uint64
_t
tmp
;
int32
_t
tmp
;
int
err
;
fprintf
(
stdout
,
"Building timestamp offset
\n
"
);
/* Get zero offset */
err
=
partial_offset_get
(
dev_id
,
channel
,
&
tmp
,
OFFSET_ZERO
);
if
(
err
)
return
-
1
;
*
offset
=
tmp
;
fprintf
(
stdout
,
" zero offset : %"
PRI
u64
"
\n
"
,
tmp
);
fprintf
(
stdout
,
" zero offset : %"
PRI
i32
"
\n
"
,
tmp
);
/* Get White Rabbit offset */
err
=
partial_offset_get
(
dev_id
,
channel
,
&
tmp
,
OFFSET_WR
);
if
(
err
)
return
-
1
;
*
offset
-=
tmp
;
fprintf
(
stdout
,
"
user offset : %"
PRIu64
"
\n
"
,
tmp
);
fprintf
(
stdout
,
"
wr offset : %"
PRIi32
"
\n
"
,
tmp
);
err
=
partial_offset_get
(
dev_id
,
channel
,
offset
,
OFFSET_USER
);
/* Get user offset */
err
=
partial_offset_get
(
dev_id
,
channel
,
&
tmp
,
OFFSET_USER
);
if
(
err
)
return
-
1
;
*
offset
+=
tmp
;
fprintf
(
stdout
,
" wr offset : %"
PRIu64
"
\n
"
,
tmp
);
fprintf
(
stdout
,
"final offset : %"
PRIu64
"
\n
"
,
*
offset
);
fprintf
(
stdout
,
" user offset : %"
PRIi32
"
\n
"
,
tmp
);
fprintf
(
stdout
,
"final offset : %"
PRIi32
"
\n
"
,
*
offset
);
return
0
;
}
...
...
@@ -118,7 +127,7 @@ int main(int argc, char *argv[])
struct
wrtd_node
*
wrtd
;
struct
wrnc_dev
*
wrnc
;
unsigned
long
timeout
=
180
;
uint64
_t
offset
;
int32
_t
offset
;
atexit
(
wrtd_exit
);
...
...
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