diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2009-12-17 21:33:26 -0500 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-29 17:16:27 -0400 |
commit | fa3c94fc9cd1619fe0dd6081a1a980c09ef3e119 (patch) | |
tree | 2e389b77431e55e8b81f4f256b93f23137dd4e2f /include/litmus | |
parent | f5936ecf0cff0b94419b6768efba3e15622beeb6 (diff) |
[ported from 2008.3] Add File Descriptor Attached Shared Objects (FDSO) infrastructure
Diffstat (limited to 'include/litmus')
-rw-r--r-- | include/litmus/fdso.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/litmus/fdso.h b/include/litmus/fdso.h new file mode 100644 index 000000000000..286e10f86de0 --- /dev/null +++ b/include/litmus/fdso.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* fdso.h - file descriptor attached shared objects | ||
2 | * | ||
3 | * (c) 2007 B. Brandenburg, LITMUS^RT project | ||
4 | */ | ||
5 | |||
6 | #ifndef _LINUX_FDSO_H_ | ||
7 | #define _LINUX_FDSO_H_ | ||
8 | |||
9 | #include <linux/list.h> | ||
10 | #include <asm/atomic.h> | ||
11 | |||
12 | #include <linux/fs.h> | ||
13 | |||
14 | #define MAX_OBJECT_DESCRIPTORS 32 | ||
15 | |||
16 | typedef enum { | ||
17 | MIN_OBJ_TYPE = 0, | ||
18 | |||
19 | FMLP_SEM = 0, | ||
20 | SRP_SEM = 1, | ||
21 | |||
22 | MAX_OBJ_TYPE = 1 | ||
23 | } obj_type_t; | ||
24 | |||
25 | struct inode_obj_id { | ||
26 | struct list_head list; | ||
27 | atomic_t count; | ||
28 | struct inode* inode; | ||
29 | |||
30 | obj_type_t type; | ||
31 | void* obj; | ||
32 | unsigned int id; | ||
33 | }; | ||
34 | |||
35 | |||
36 | struct od_table_entry { | ||
37 | unsigned int used; | ||
38 | |||
39 | struct inode_obj_id* obj; | ||
40 | void* extra; | ||
41 | }; | ||
42 | |||
43 | struct fdso_ops { | ||
44 | void* (*create) (void); | ||
45 | void (*destroy)(void*); | ||
46 | int (*open) (struct od_table_entry*, void* __user); | ||
47 | int (*close) (struct od_table_entry*); | ||
48 | }; | ||
49 | |||
50 | /* translate a userspace supplied od into the raw table entry | ||
51 | * returns NULL if od is invalid | ||
52 | */ | ||
53 | struct od_table_entry* __od_lookup(int od); | ||
54 | |||
55 | /* translate a userspace supplied od into the associated object | ||
56 | * returns NULL if od is invalid | ||
57 | */ | ||
58 | static inline void* od_lookup(int od, obj_type_t type) | ||
59 | { | ||
60 | struct od_table_entry* e = __od_lookup(od); | ||
61 | return e && e->obj->type == type ? e->obj->obj : NULL; | ||
62 | } | ||
63 | |||
64 | #define lookup_fmlp_sem(od)((struct pi_semaphore*) od_lookup(od, FMLP_SEM)) | ||
65 | #define lookup_srp_sem(od) ((struct srp_semaphore*) od_lookup(od, SRP_SEM)) | ||
66 | #define lookup_ics(od) ((struct ics*) od_lookup(od, ICS_ID)) | ||
67 | |||
68 | |||
69 | #endif | ||