diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
commit | f70a290e8a889caa905ab7650c696f2bb299be1a (patch) | |
tree | 56f0886d839499e9f522f189999024b3e86f9be2 /include/litmus/ftdev.h | |
parent | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (diff) | |
parent | 7ef4a793a624c6e66c16ca1051847f75161f5bec (diff) |
Merge branch 'wip-nested-locking' into tegra-nested-lockingwip-nested-locking
Conflicts:
Makefile
include/linux/fs.h
Diffstat (limited to 'include/litmus/ftdev.h')
-rw-r--r-- | include/litmus/ftdev.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/litmus/ftdev.h b/include/litmus/ftdev.h new file mode 100644 index 00000000000..0b959874dd7 --- /dev/null +++ b/include/litmus/ftdev.h | |||
@@ -0,0 +1,55 @@ | |||
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 | |||
12 | struct ftdev; | ||
13 | |||
14 | /* return 0 if buffer can be opened, otherwise -$REASON */ | ||
15 | typedef int (*ftdev_can_open_t)(struct ftdev* dev, unsigned int buf_no); | ||
16 | /* return 0 on success, otherwise -$REASON */ | ||
17 | typedef int (*ftdev_alloc_t)(struct ftdev* dev, unsigned int buf_no); | ||
18 | typedef void (*ftdev_free_t)(struct ftdev* dev, unsigned int buf_no); | ||
19 | /* Let devices handle writes from userspace. No synchronization provided. */ | ||
20 | typedef ssize_t (*ftdev_write_t)(struct ft_buffer* buf, size_t len, const char __user *from); | ||
21 | |||
22 | struct ftdev_event; | ||
23 | |||
24 | struct ftdev_minor { | ||
25 | struct ft_buffer* buf; | ||
26 | unsigned int readers; | ||
27 | struct mutex lock; | ||
28 | /* FIXME: filter for authorized events */ | ||
29 | struct ftdev_event* events; | ||
30 | struct device* device; | ||
31 | struct ftdev* ftdev; | ||
32 | }; | ||
33 | |||
34 | struct ftdev { | ||
35 | dev_t major; | ||
36 | struct cdev cdev; | ||
37 | struct class* class; | ||
38 | const char* name; | ||
39 | struct ftdev_minor* minor; | ||
40 | unsigned int minor_cnt; | ||
41 | ftdev_alloc_t alloc; | ||
42 | ftdev_free_t free; | ||
43 | ftdev_can_open_t can_open; | ||
44 | ftdev_write_t write; | ||
45 | }; | ||
46 | |||
47 | struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size); | ||
48 | void free_ft_buffer(struct ft_buffer* buf); | ||
49 | |||
50 | int ftdev_init( struct ftdev* ftdev, struct module* owner, | ||
51 | const int minor_cnt, const char* name); | ||
52 | void ftdev_exit(struct ftdev* ftdev); | ||
53 | int register_ftdev(struct ftdev* ftdev); | ||
54 | |||
55 | #endif | ||