diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2009-12-17 21:24:47 -0500 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-29 17:12:00 -0400 |
commit | cf3f4bd8db320f3f487d66bdec924e926f004787 (patch) | |
tree | 541206678cd3b2d58911a1f71ea0c4276af9643c /include/litmus/ftdev.h | |
parent | 4b38febbd59fd33542a343991262119eb9860f5e (diff) |
[ported from 2008.3] Add Feather-Trace device file support
Diffstat (limited to 'include/litmus/ftdev.h')
-rw-r--r-- | include/litmus/ftdev.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/litmus/ftdev.h b/include/litmus/ftdev.h new file mode 100644 index 000000000000..7697b4616699 --- /dev/null +++ b/include/litmus/ftdev.h | |||
@@ -0,0 +1,49 @@ | |||
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 MAX_FTDEV_MINORS NR_CPUS | ||
10 | |||
11 | #define FTDEV_ENABLE_CMD 0 | ||
12 | #define FTDEV_DISABLE_CMD 1 | ||
13 | |||
14 | struct ftdev; | ||
15 | |||
16 | /* return 0 if buffer can be opened, otherwise -$REASON */ | ||
17 | typedef int (*ftdev_can_open_t)(struct ftdev* dev, unsigned int buf_no); | ||
18 | /* return 0 on success, otherwise -$REASON */ | ||
19 | typedef int (*ftdev_alloc_t)(struct ftdev* dev, unsigned int buf_no); | ||
20 | typedef void (*ftdev_free_t)(struct ftdev* dev, unsigned int buf_no); | ||
21 | |||
22 | |||
23 | struct ftdev_event; | ||
24 | |||
25 | struct ftdev_minor { | ||
26 | struct ft_buffer* buf; | ||
27 | unsigned int readers; | ||
28 | struct mutex lock; | ||
29 | /* FIXME: filter for authorized events */ | ||
30 | struct ftdev_event* events; | ||
31 | }; | ||
32 | |||
33 | struct ftdev { | ||
34 | struct cdev cdev; | ||
35 | /* FIXME: don't waste memory, allocate dynamically */ | ||
36 | struct ftdev_minor minor[MAX_FTDEV_MINORS]; | ||
37 | unsigned int minor_cnt; | ||
38 | ftdev_alloc_t alloc; | ||
39 | ftdev_free_t free; | ||
40 | ftdev_can_open_t can_open; | ||
41 | }; | ||
42 | |||
43 | struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size); | ||
44 | void free_ft_buffer(struct ft_buffer* buf); | ||
45 | |||
46 | void ftdev_init(struct ftdev* ftdev, struct module* owner); | ||
47 | int register_ftdev(struct ftdev* ftdev, const char* name, int major); | ||
48 | |||
49 | #endif | ||