Xenomai API
2.5.6.1
|
00001 00024 #ifndef _XENO_NUCLEUS_REGISTRY_H 00025 #define _XENO_NUCLEUS_REGISTRY_H 00026 00027 #include <nucleus/types.h> 00028 00029 #define XNOBJECT_SELF XN_NO_HANDLE 00030 00031 #if defined(__KERNEL__) || defined(__XENO_SIM__) 00032 00033 #include <nucleus/synch.h> 00034 00035 struct xnpnode; 00036 00037 typedef struct xnobject { 00038 00039 xnholder_t link; 00040 00041 #define link2xnobj(ln) container_of(ln, xnobject_t, link) 00042 00043 void *objaddr; 00044 00045 const char *key; /* !< Hash key. */ 00046 00047 xnsynch_t safesynch; /* !< Safe synchronization object. */ 00048 00049 u_long safelock; /* !< Safe lock count. */ 00050 00051 u_long cstamp; /* !< Creation stamp. */ 00052 00053 struct xnobject *hnext; /* !< Next in h-table */ 00054 00055 #ifdef CONFIG_PROC_FS 00056 00057 struct xnpnode *pnode; /* !< /proc information class. */ 00058 00059 struct proc_dir_entry *proc; /* !< /proc entry. */ 00060 00061 #endif /* CONFIG_PROC_FS */ 00062 00063 } xnobject_t; 00064 00065 #ifdef __cplusplus 00066 extern "C" { 00067 #endif 00068 00069 int xnregistry_init(void); 00070 00071 void xnregistry_cleanup(void); 00072 00073 #ifdef CONFIG_PROC_FS 00074 00075 #include <linux/proc_fs.h> 00076 00077 #define XNOBJECT_PROC_RESERVED1 ((struct proc_dir_entry *)1) 00078 #define XNOBJECT_PROC_RESERVED2 ((struct proc_dir_entry *)2) 00079 00080 typedef ssize_t link_proc_t(char *buf, 00081 int count, 00082 void *data); 00083 typedef struct xnptree { 00084 00085 struct proc_dir_entry *dir; 00086 const char *name; 00087 int entries; 00088 00089 } xnptree_t; 00090 00091 typedef struct xnpnode { 00092 00093 struct proc_dir_entry *dir; 00094 const char *type; 00095 int entries; 00096 read_proc_t *read_proc; 00097 write_proc_t *write_proc; 00098 link_proc_t *link_proc; 00099 xnptree_t *root; 00100 00101 } xnpnode_t; 00102 00103 #else /* !CONFIG_PROC_FS */ 00104 00105 typedef struct xnpnode { /* Placeholder. */ 00106 00107 const char *type; 00108 00109 } xnpnode_t; 00110 00111 #endif /* !CONFIG_PROC_FS */ 00112 00113 extern struct xnobject *registry_obj_slots; 00114 00115 /* Public interface. */ 00116 00117 int xnregistry_enter(const char *key, 00118 void *objaddr, 00119 xnhandle_t *phandle, 00120 xnpnode_t *pnode); 00121 00122 int xnregistry_bind(const char *key, 00123 xnticks_t timeout, 00124 int timeout_mode, 00125 xnhandle_t *phandle); 00126 00127 int xnregistry_remove(xnhandle_t handle); 00128 00129 int xnregistry_remove_safe(xnhandle_t handle, 00130 xnticks_t timeout); 00131 00132 void *xnregistry_get(xnhandle_t handle); 00133 00134 void *xnregistry_fetch(xnhandle_t handle); 00135 00136 u_long xnregistry_put(xnhandle_t handle); 00137 00138 static inline struct xnobject *xnregistry_validate(xnhandle_t handle) 00139 { 00140 struct xnobject *object; 00141 /* 00142 * Careful: a removed object which is still in flight to be 00143 * unexported carries a NULL objaddr, so we have to check this 00144 * as well. 00145 */ 00146 if (likely(handle && handle < CONFIG_XENO_OPT_REGISTRY_NRSLOTS)) { 00147 object = ®istry_obj_slots[handle]; 00148 return object->objaddr ? object : NULL; 00149 } 00150 00151 return NULL; 00152 } 00153 00154 static inline void *xnregistry_lookup(xnhandle_t handle) 00155 { 00156 struct xnobject *object = xnregistry_validate(handle); 00157 return object ? object->objaddr : NULL; 00158 } 00159 00160 #ifdef __cplusplus 00161 } 00162 #endif 00163 00164 #endif /* __KERNEL__ || __XENO_SIM__ */ 00165 00166 #endif /* !_XENO_NUCLEUS_REGISTRY_H */