Go to the documentation of this file.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 #include <nucleus/vfile.h>
00035
00036 struct xnpnode;
00037
00038 typedef struct xnobject {
00039 void *objaddr;
00040 const char *key;
00041 struct xnsynch safesynch;
00042 u_long safelock;
00043 u_long cstamp;
00044 #ifdef CONFIG_XENO_OPT_VFILE
00045 struct xnpnode *pnode;
00046 union {
00047 struct {
00048 struct xnvfile_rev_tag tag;
00049 struct xnvfile_snapshot file;
00050 } vfsnap;
00051 struct xnvfile_regular vfreg;
00052 struct xnvfile_link link;
00053 } vfile_u;
00054 struct xnvfile *vfilp;
00055 #endif
00056 struct xnobject *hnext;
00057 struct xnholder link;
00058 } xnobject_t;
00059
00060 #define link2xnobj(ln) container_of(ln, struct xnobject, link)
00061
00062 #ifdef __cplusplus
00063 extern "C" {
00064 #endif
00065
00066 int xnregistry_init(void);
00067
00068 void xnregistry_cleanup(void);
00069
00070 #ifdef CONFIG_XENO_OPT_VFILE
00071
00072 #define XNOBJECT_PNODE_RESERVED1 ((struct xnvfile *)1)
00073 #define XNOBJECT_PNODE_RESERVED2 ((struct xnvfile *)2)
00074
00075 struct xnptree {
00076 const char *dirname;
00077
00078 int entries;
00079 struct xnvfile_directory vdir;
00080 };
00081
00082 #define DEFINE_XNPTREE(__var, __name) \
00083 struct xnptree __var = { \
00084 .dirname = __name, \
00085 .entries = 0, \
00086 .vdir = xnvfile_nodir, \
00087 }
00088
00089 struct xnpnode_ops {
00090 int (*export)(struct xnobject *object, struct xnpnode *pnode);
00091 void (*unexport)(struct xnobject *object, struct xnpnode *pnode);
00092 void (*touch)(struct xnobject *object);
00093 };
00094
00095 struct xnpnode {
00096 const char *dirname;
00097 struct xnptree *root;
00098 struct xnpnode_ops *ops;
00099
00100 int entries;
00101 struct xnvfile_directory vdir;
00102 };
00103
00104 struct xnpnode_snapshot {
00105 struct xnpnode node;
00106 struct xnvfile_snapshot_template vfile;
00107 };
00108
00109 struct xnpnode_regular {
00110 struct xnpnode node;
00111 struct xnvfile_regular_template vfile;
00112 };
00113
00114 struct xnpnode_link {
00115 struct xnpnode node;
00116 char *(*target)(void *obj);
00117 };
00118
00119 #else
00120
00121 #define DEFINE_XNPTREE(__var, __name);
00122
00123
00124
00125 struct xnpnode {
00126 const char *dirname;
00127 };
00128
00129 struct xnpnode_snapshot {
00130 struct xnpnode node;
00131 };
00132
00133 struct xnpnode_regular {
00134 struct xnpnode node;
00135 };
00136
00137 struct xnpnode_link {
00138 struct xnpnode node;
00139 };
00140
00141 #endif
00142
00143 extern struct xnobject *registry_obj_slots;
00144
00145
00146
00147 extern struct xnobject *registry_obj_slots;
00148
00149 static inline struct xnobject *xnregistry_validate(xnhandle_t handle)
00150 {
00151 struct xnobject *object;
00152
00153
00154
00155
00156
00157 if (likely(handle && handle < CONFIG_XENO_OPT_REGISTRY_NRSLOTS)) {
00158 object = ®istry_obj_slots[handle];
00159 return object->objaddr ? object : NULL;
00160 }
00161
00162 return NULL;
00163 }
00164
00165 static inline void *xnregistry_lookup(xnhandle_t handle)
00166 {
00167 struct xnobject *object = xnregistry_validate(handle);
00168 return object ? object->objaddr : NULL;
00169 }
00170
00171 int xnregistry_enter(const char *key,
00172 void *objaddr,
00173 xnhandle_t *phandle,
00174 struct xnpnode *pnode);
00175
00176 int xnregistry_bind(const char *key,
00177 xnticks_t timeout,
00178 int timeout_mode,
00179 xnhandle_t *phandle);
00180
00181 int xnregistry_remove(xnhandle_t handle);
00182
00183 int xnregistry_remove_safe(xnhandle_t handle,
00184 xnticks_t timeout);
00185
00186 void *xnregistry_get(xnhandle_t handle);
00187
00188 void *xnregistry_fetch(xnhandle_t handle);
00189
00190 u_long xnregistry_put(xnhandle_t handle);
00191
00192 #ifdef __cplusplus
00193 }
00194 #endif
00195
00196 extern struct xnpnode_ops xnregistry_vfsnap_ops;
00197
00198 extern struct xnpnode_ops xnregistry_vlink_ops;
00199
00200 #endif
00201
00202 #endif