aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/litmus/ftdev.h58
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
13struct ftdev;
14
15/* return 0 if buffer can be opened, otherwise -$REASON */
16typedef int (*ftdev_can_open_t)(struct ftdev* dev, unsigned int buf_no);
17/* return 0 on success, otherwise -$REASON */
18typedef int (*ftdev_alloc_t)(struct ftdev* dev, unsigned int buf_no);
19typedef void (*ftdev_free_t)(struct ftdev* dev, unsigned int buf_no);
20typedef 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. */
22typedef ssize_t (*ftdev_write_t)(struct ft_buffer* buf, size_t len, const char __user *from);
23
24struct ftdev_event;
25
26struct 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
36struct 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
50struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size);
51void free_ft_buffer(struct ft_buffer* buf);
52
53int ftdev_init( struct ftdev* ftdev, struct module* owner,
54 const int minor_cnt, const char* name);
55void ftdev_exit(struct ftdev* ftdev);
56int register_ftdev(struct ftdev* ftdev);
57
58#endif