Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
FMC TDC 1ns 5cha - Software
Commits
3c0d2649
Commit
3c0d2649
authored
Sep 13, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: use vmalloc to store data in the driver
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
174062cc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
10 deletions
+51
-10
ft-zio.c
kernel/ft-zio.c
+1
-0
fmctdc-lib.c
lib/fmctdc-lib.c
+34
-6
fmctdc-lib.h
lib/fmctdc-lib.h
+7
-1
fmc-tdc-tstamp.c
tools/fmc-tdc-tstamp.c
+1
-1
fmctdc-ut.c
unittest/fmctdc-ut.c
+8
-2
No files found.
kernel/ft-zio.c
View file @
3c0d2649
...
...
@@ -491,6 +491,7 @@ static struct zio_cset ft_cset[] = {
static
struct
zio_device
ft_tmpl
=
{
.
owner
=
THIS_MODULE
,
.
preferred_trigger
=
FT_ZIO_TRIG_TYPE_NAME
,
.
preferred_buffer
=
"vmalloc"
,
.
s_op
=
&
ft_zio_sysfs_ops
,
.
cset
=
ft_cset
,
.
n_cset
=
ARRAY_SIZE
(
ft_cset
),
...
...
lib/fmctdc-lib.c
View file @
3c0d2649
...
...
@@ -38,13 +38,20 @@ static int ft_nboards; /**< number of available boards */
static
char
*
names
[]
=
{
"seconds"
,
"coarse"
};
/**< names used to retrive
time-stamps from sysfs */
static
const
char
*
fmctdc_error_string
[]
=
{
[
FMCTDC_ERR_VMALLOC
-
__FMCTDC_ERR_MIN
]
=
"Missing ZIO vmalloc support"
,
};
/**
* It returns the error message associated to the given error code
* @param[in] err error code
*/
char
*
fmctdc_strerror
(
int
err
)
c
onst
c
har
*
fmctdc_strerror
(
int
err
)
{
return
strerror
(
err
);
if
(
err
<
__FMCTDC_ERR_MIN
||
err
>
__FMCTDC_ERR_MAX
)
return
strerror
(
err
);
return
fmctdc_error_string
[
err
-
__FMCTDC_ERR_MIN
];
}
...
...
@@ -227,6 +234,14 @@ found:
b
->
fdcc
[
i
]
=
open
(
path
,
O_RDONLY
);
if
(
b
->
fdcc
[
i
]
<
0
)
goto
error
;
snprintf
(
path
,
sizeof
(
path
),
"%s/ft-ch%d/chan0/buffer/max-buffer-kb"
,
b
->
sysbase
,
i
+
1
);
if
(
access
(
path
,
R_OK
|
W_OK
))
{
errno
=
FMCTDC_ERR_VMALLOC
;
goto
error
;
}
}
return
(
void
*
)
b
;
...
...
@@ -526,12 +541,15 @@ int fmctdc_get_buffer_len(struct fmctdc_board *userb, unsigned int channel)
return
-
1
;
}
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/chan0/buffer/max-buffer-
len
"
,
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/chan0/buffer/max-buffer-
kb
"
,
channel
+
1
);
ret
=
fmctdc_sysfs_get
(
b
,
attr
,
&
val
);
if
(
ret
)
return
ret
;
val
=
(
val
*
1024
)
/
sizeof
(
struct
ft_hw_timestamp
);
return
val
;
}
...
...
@@ -539,9 +557,14 @@ int fmctdc_get_buffer_len(struct fmctdc_board *userb, unsigned int channel)
* The function set the buffer length
* @param[in] userb TDC board instance token
* @param[in] channel to use
* @param[in] length maximum number of timestamps to store
* @param[in] length maximum number of timestamps to store
(min: 64)
* @return 0 on success, otherwise a negative errno code is set
* appropriately
*
* Internally, the buffer allocates memory in chunks of minimun 1KiB. This
* means, for example, that if you ask for 65 timestamp the buffer will
* allocate space for 128. This because 64 timestamps fit in 1KiB, to store
* 65 we need 2KiB (128 timestamps)
*/
int
fmctdc_set_buffer_len
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
unsigned
int
length
)
...
...
@@ -554,10 +577,15 @@ int fmctdc_set_buffer_len(struct fmctdc_board *userb, unsigned int channel,
errno
=
EINVAL
;
return
-
1
;
}
if
(
length
<
64
)
{
errno
=
EINVAL
;
return
-
1
;
}
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/chan0/buffer/max-buffer-len"
,
channel
+
1
);
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/chan0/buffer/max-buffer-kb"
,
channel
+
1
);
val
=
length
;
val
=
((
length
*
sizeof
(
struct
ft_hw_timestamp
))
/
1024
)
+
1
;
return
fmctdc_sysfs_set
(
b
,
attr
,
&
val
);
}
...
...
lib/fmctdc-lib.h
View file @
3c0d2649
...
...
@@ -17,6 +17,12 @@ extern "C" {
#include <stdint.h>
#define __FMCTDC_ERR_MIN 4096
enum
fmctdc_error_numbers
{
FMCTDC_ERR_VMALLOC
=
__FMCTDC_ERR_MIN
,
__FMCTDC_ERR_MAX
,
};
/**
* Enumeration for all TDC channels
*/
...
...
@@ -99,7 +105,7 @@ struct fmctdc_time {
* Set of library utilities
* @{
*/
extern
char
*
fmctdc_strerror
(
int
err
);
extern
c
onst
c
har
*
fmctdc_strerror
(
int
err
);
extern
int
fmctdc_init
(
void
);
extern
void
fmctdc_exit
(
void
);
/**@}*/
...
...
tools/fmc-tdc-tstamp.c
View file @
3c0d2649
...
...
@@ -251,7 +251,7 @@ int main(int argc, char **argv)
struct
fmctdc_time
*
ts
;
int
channels
[
FMCTDC_NUM_CHANNELS
];
int
chan_count
=
0
,
i
,
n
,
ch
,
fd
,
n_ts
,
ret
,
n_boards
;
int
nblock
=
0
,
buflen
=
16
;
int
nblock
=
0
,
buflen
=
5000000
;
enum
fmctdc_buffer_mode
bufmode
=
FMCTDC_BUFFER_FIFO
;
int
n_samples
=
-
1
;
unsigned
int
n_show
=
1
;
...
...
unittest/fmctdc-ut.c
View file @
3c0d2649
...
...
@@ -199,10 +199,16 @@ static void fmctdc_param_test6(struct m_test *m_test)
for
(
i
=
0
;
i
<
FMCTDC_NUM_CHANNELS
;
++
i
)
{
for
(
len
=
1
;
len
<
64
;
len
<<=
1
)
{
err
=
fmctdc_set_buffer_len
(
tdc
,
i
,
len
);
m_assert_int_eq
(
-
1
,
err
);
}
for
(
len
=
64
;
len
<
(
64
<<
20
);
len
<<=
1
)
{
err
=
fmctdc_set_buffer_len
(
tdc
,
i
,
len
);
m_assert_int_eq
(
0
,
err
);
ret
=
fmctdc_get_buffer_len
(
tdc
,
i
);
m_assert_int_
eq
(
len
,
ret
);
m_assert_int_
le
(
len
,
ret
);
}
}
}
...
...
@@ -247,7 +253,7 @@ static void fmctdc_op_test_setup(struct m_test *m_test)
ret
=
fmctdc_channel_status_get
(
tdc
,
i
);
m_assert_int_eq
(
FMCTDC_STATUS_DISABLE
,
ret
);
err
=
fmctdc_set_buffer_len
(
tdc
,
i
,
1
6
);
err
=
fmctdc_set_buffer_len
(
tdc
,
i
,
1
000000
);
m_assert_int_eq
(
0
,
err
);
err
=
fmctdc_ts_mode_set
(
tdc
,
i
,
FMCTDC_TS_MODE_POST
);
m_assert_int_eq
(
0
,
err
);
...
...
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