diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-06-23 06:00:35 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2014-06-02 15:31:30 -0400 |
commit | 9ef9be8fed9471eaabd10dd1ba25514729ec1408 (patch) | |
tree | f8a1ab4e100712b6a70675099577ba99da12c35d /include | |
parent | f6a4781b8e50885daab00457e1b393f7792a0960 (diff) |
Feather-Trace: add generic ftdev device driver
This patch adds the ftdev device driver, which is used to export
samples collected with Feather-Trace to userspace.
Diffstat (limited to 'include')
-rw-r--r-- | include/litmus/ftdev.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/litmus/ftdev.h b/include/litmus/ftdev.h new file mode 100644 index 000000000000..a566b0b6ae05 --- /dev/null +++ b/include/litmus/ftdev.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef _LITMUS_FTDEV_H_ | ||
2 | #define _LITMUS_FTDEV_H_ | ||
3 | |||
4 | #include <litmus/feather_trace.h> | ||
5 | #include <litmus/feather_buffer.h> | ||
6 | #include <linux/mutex.h> | ||
7 | #include <linux/cdev.h> | ||
8 | |||
9 | #define FTDEV_ENABLE_CMD 0 | ||
10 | #define FTDEV_DISABLE_CMD 1 | ||
11 | #define FTDEV_CALIBRATE 0x1410 | ||
12 | |||
13 | struct ftdev; | ||
14 | |||
15 | /* return 0 if buffer can be opened, otherwise -$REASON */ | ||
16 | typedef int (*ftdev_can_open_t)(struct ftdev* dev, unsigned int buf_no); | ||
17 | /* return 0 on success, otherwise -$REASON */ | ||
18 | typedef int (*ftdev_alloc_t)(struct ftdev* dev, unsigned int buf_no); | ||
19 | typedef void (*ftdev_free_t)(struct ftdev* dev, unsigned int buf_no); | ||
20 | typedef long (*ftdev_calibrate_t)(struct ftdev* dev, unsigned int buf_no, unsigned long user_arg); | ||
21 | /* Let devices handle writes from userspace. No synchronization provided. */ | ||
22 | typedef ssize_t (*ftdev_write_t)(struct ft_buffer* buf, size_t len, const char __user *from); | ||
23 | |||
24 | struct ftdev_event; | ||
25 | |||
26 | struct ftdev_minor { | ||
27 | struct ft_buffer* buf; | ||
28 | unsigned int readers; | ||
29 | struct mutex lock; | ||
30 | /* FIXME: filter for authorized events */ | ||
31 | struct ftdev_event* events; | ||
32 | struct device* device; | ||
33 | struct ftdev* ftdev; | ||
34 | }; | ||
35 | |||
36 | struct ftdev { | ||
37 | dev_t major; | ||
38 | struct cdev cdev; | ||
39 | struct class* class; | ||
40 | const char* name; | ||
41 | struct ftdev_minor* minor; | ||
42 | unsigned int minor_cnt; | ||
43 | ftdev_alloc_t alloc; | ||
44 | ftdev_free_t free; | ||
45 | ftdev_can_open_t can_open; | ||
46 | ftdev_write_t write; | ||
47 | ftdev_calibrate_t calibrate; | ||
48 | }; | ||
49 | |||
50 | struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size); | ||
51 | void free_ft_buffer(struct ft_buffer* buf); | ||
52 | |||
53 | int ftdev_init( struct ftdev* ftdev, struct module* owner, | ||
54 | const int minor_cnt, const char* name); | ||
55 | void ftdev_exit(struct ftdev* ftdev); | ||
56 | int register_ftdev(struct ftdev* ftdev); | ||
57 | |||
58 | #endif | ||