diff options
Diffstat (limited to 'include/litmus/fdso.h')
| -rw-r--r-- | include/litmus/fdso.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/include/litmus/fdso.h b/include/litmus/fdso.h new file mode 100644 index 00000000000..85a649e2722 --- /dev/null +++ b/include/litmus/fdso.h | |||
| @@ -0,0 +1,81 @@ | |||
| 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 | #include <linux/slab.h> | ||
| 14 | |||
| 15 | #define MAX_OBJECT_DESCRIPTORS 32 | ||
| 16 | |||
| 17 | typedef unsigned int resource_mask_t; | ||
| 18 | |||
| 19 | typedef enum { | ||
| 20 | MIN_OBJ_TYPE = 0, | ||
| 21 | |||
| 22 | FMLP_SEM = 0, | ||
| 23 | SRP_SEM = 1, | ||
| 24 | |||
| 25 | MPCP_SEM = 2, | ||
| 26 | MPCP_VS_SEM = 3, | ||
| 27 | DPCP_SEM = 4, | ||
| 28 | |||
| 29 | PCP_SEM = 5, | ||
| 30 | |||
| 31 | DGL_SEM = 6, | ||
| 32 | |||
| 33 | MAX_OBJ_TYPE = 6 | ||
| 34 | } obj_type_t; | ||
| 35 | |||
| 36 | struct inode_obj_id { | ||
| 37 | struct list_head list; | ||
| 38 | atomic_t count; | ||
| 39 | struct inode* inode; | ||
| 40 | |||
| 41 | obj_type_t type; | ||
| 42 | void* obj; | ||
| 43 | unsigned int id; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct fdso_ops; | ||
| 47 | |||
| 48 | struct od_table_entry { | ||
| 49 | unsigned int used; | ||
| 50 | |||
| 51 | struct inode_obj_id* obj; | ||
| 52 | const struct fdso_ops* class; | ||
| 53 | }; | ||
| 54 | |||
| 55 | struct fdso_ops { | ||
| 56 | int (*create)(void** obj_ref, obj_type_t type, void* __user); | ||
| 57 | void (*destroy)(obj_type_t type, void*); | ||
| 58 | int (*open) (struct od_table_entry*, void* __user); | ||
| 59 | int (*close) (struct od_table_entry*); | ||
| 60 | }; | ||
| 61 | |||
| 62 | /* translate a userspace supplied od into the raw table entry | ||
| 63 | * returns NULL if od is invalid | ||
| 64 | */ | ||
| 65 | struct od_table_entry* get_entry_for_od(int od); | ||
| 66 | |||
| 67 | /* translate a userspace supplied od into the associated object | ||
| 68 | * returns NULL if od is invalid | ||
| 69 | */ | ||
| 70 | static inline void* od_lookup(int od, obj_type_t type) | ||
| 71 | { | ||
| 72 | struct od_table_entry* e = get_entry_for_od(od); | ||
| 73 | return e && e->obj->type == type ? e->obj->obj : NULL; | ||
| 74 | } | ||
| 75 | |||
| 76 | #define lookup_fmlp_sem(od)((struct fmlp_semaphore*) od_lookup(od, FMLP_SEM)) | ||
| 77 | #define lookup_srp_sem(od) ((struct srp_semaphore*) od_lookup(od, SRP_SEM)) | ||
| 78 | #define lookup_ics(od) ((struct ics*) od_lookup(od, ICS_ID)) | ||
| 79 | |||
| 80 | |||
| 81 | #endif | ||
