Xenomai API
2.5.6.1
|
00001 #ifndef PSE51_REGISTRY_H 00002 #define PSE51_REGISTRY_H 00003 00004 #include <stdarg.h> 00005 #include <nucleus/queue.h> 00006 #include <nucleus/synch.h> 00007 #include <posix/posix.h> 00008 00009 #define PSE51_MAXNAME 64 00010 00011 /* A pse51_node_t is the holder to be added to each object which needs to be put 00012 in the registry. */ 00013 typedef struct pse51_node { 00014 unsigned magic; 00015 unsigned flags; /* PSE51_NODE_PARTIAL_INIT. */ 00016 unsigned refcount; 00017 /* pse51_unlink_t *dest_hook; */ 00018 00019 struct pse51_node *next; 00020 struct pse51_node **prev; 00021 char name[PSE51_MAXNAME]; 00022 } pse51_node_t; 00023 00024 int pse51_reg_pkg_init(unsigned objects_count, unsigned maxfds); 00025 00026 void pse51_reg_pkg_cleanup(void); 00027 00028 /* Get an existing node: oflags are POSIX open style flags. 00029 If 0 is returned and (*nodep) is NULL, then a new node should be added 00030 with node_add. */ 00031 int pse51_node_get(pse51_node_t **nodep, 00032 const char *name, 00033 unsigned long magic, 00034 long oflags); 00035 00036 /* bind a node. */ 00037 int pse51_node_add(pse51_node_t *node, const char *name, unsigned magic); 00038 00039 /* Any successful call to node_get or node_add need to be paired with a call 00040 node_put before a node may be unlinked. */ 00041 int pse51_node_put(pse51_node_t *node); 00042 00043 /* Remove the binding of a node to its name, if the node is still referenced, 00044 real destruction is deferred until the last call to node_put. */ 00045 int pse51_node_remove(pse51_node_t **nodep, const char *name, unsigned magic); 00046 00047 #define PSE51_NODE_REMOVED 1 00048 00049 #define pse51_node_ref_p(node) ((node)->refcount) 00050 00051 #define pse51_node_removed_p(node) \ 00052 ((node)->flags & PSE51_NODE_REMOVED && !pse51_node_ref_p(node)) 00053 00054 /* A pse51_desc_t is the structure associated with a descriptor. */ 00055 typedef struct pse51_desc { 00056 pse51_node_t *node; 00057 long flags; 00058 int fd; 00059 } pse51_desc_t; 00060 00061 int pse51_desc_create(pse51_desc_t **descp, pse51_node_t *node, long flags); 00062 00063 int pse51_desc_get(pse51_desc_t **descp, int fd, unsigned magic); 00064 00065 int pse51_desc_destroy(pse51_desc_t *desc); 00066 00067 #define pse51_desc_setflags(desc, fl) ((desc)->flags = (fl)) 00068 00069 #define pse51_desc_getflags(desc) ((desc)->flags) 00070 00071 #define pse51_desc_node(desc) ((desc)->node) 00072 00073 #define pse51_desc_fd(desc) ((desc)->fd) 00074 00075 #define PSE51_PERMS_MASK (O_RDONLY | O_WRONLY | O_RDWR) 00076 00077 00078 /* Associative lists, used for association of user-space to kernel-space 00079 objects. */ 00080 #ifdef CONFIG_XENO_OPT_PERVASIVE 00081 struct mm_struct; 00082 00083 DECLARE_EXTERN_XNLOCK(pse51_assoc_lock); 00084 00085 typedef xnqueue_t pse51_assocq_t; 00086 00087 typedef struct { 00088 u_long key; 00089 xnholder_t link; 00090 00091 #define link2assoc(laddr) \ 00092 ((pse51_assoc_t *)((unsigned long)(laddr) - offsetof(pse51_assoc_t, link))) 00093 00094 } pse51_assoc_t; 00095 00096 typedef struct { 00097 unsigned long kfd; 00098 pse51_assoc_t assoc; 00099 00100 #define assoc2ufd(laddr) \ 00101 ((pse51_ufd_t *)((unsigned long) (laddr) - offsetof(pse51_ufd_t, assoc))) 00102 } pse51_ufd_t; 00103 00104 #define pse51_assocq_init(q) (initq(q)) 00105 00106 #define pse51_assoc_key(assoc) ((assoc)->key) 00107 00108 void pse51_assocq_destroy(pse51_assocq_t *q, void (*destroy)(pse51_assoc_t *)); 00109 00110 int pse51_assoc_insert(pse51_assocq_t *q, 00111 pse51_assoc_t *assoc, 00112 u_long key); 00113 00114 pse51_assoc_t *pse51_assoc_lookup(pse51_assocq_t *q, 00115 u_long key); 00116 00117 pse51_assoc_t *pse51_assoc_remove(pse51_assocq_t *q, 00118 u_long key); 00119 #endif /* CONFIG_XENO_OPT_PERVASIVE */ 00120 00121 #endif /* PSE51_REGISTRY_H */