00001
00022 #ifndef _XENO_NUCLEUS_REGISTRY_H
00023 #define _XENO_NUCLEUS_REGISTRY_H
00024
00025 #include <nucleus/types.h>
00026
00027 #define XNOBJECT_SELF XN_NO_HANDLE
00028
00029 #if defined(__KERNEL__) && defined(CONFIG_PROC_FS) && defined(CONFIG_XENO_OPT_REGISTRY)
00030 #define CONFIG_XENO_EXPORT_REGISTRY 1
00031 #endif
00032
00033 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00034
00035 #include <nucleus/synch.h>
00036 #include <nucleus/thread.h>
00037
00038 struct xnpnode;
00039
00040 typedef struct xnobject {
00041
00042 xnholder_t link;
00043 #define link2xnobj(laddr) \
00044 ((xnobject_t *)(((char *)laddr) - (int)(&((xnobject_t *)0)->link)))
00045
00046 void *objaddr;
00047
00048 const char *key;
00049
00050 xnsynch_t safesynch;
00051
00052 u_long safelock;
00053
00054 u_long cstamp;
00055
00056 #if defined(CONFIG_PROC_FS) && defined(__KERNEL__)
00057
00058 struct xnpnode *pnode;
00059
00060 struct proc_dir_entry *proc;
00061
00062 #endif
00063
00064 } xnobject_t;
00065
00066 typedef struct xnobjhash {
00067
00068 xnobject_t *object;
00069
00070 struct xnobjhash *next;
00071
00072 } xnobjhash_t;
00073
00074 #ifdef __cplusplus
00075 extern "C" {
00076 #endif
00077
00078 int xnregistry_init(void);
00079
00080 void xnregistry_cleanup(void);
00081
00082 #if defined(CONFIG_PROC_FS) && defined(__KERNEL__)
00083
00084 #include <linux/proc_fs.h>
00085
00086 #define XNOBJECT_PROC_RESERVED1 ((struct proc_dir_entry *)1)
00087 #define XNOBJECT_PROC_RESERVED2 ((struct proc_dir_entry *)2)
00088
00089 typedef ssize_t link_proc_t(char *buf,
00090 int count,
00091 void *data);
00092 typedef struct xnptree {
00093
00094 struct proc_dir_entry *dir;
00095 const char *name;
00096 int entries;
00097
00098 } xnptree_t;
00099
00100 typedef struct xnpnode {
00101
00102 struct proc_dir_entry *dir;
00103 const char *type;
00104 int entries;
00105 read_proc_t *read_proc;
00106 write_proc_t *write_proc;
00107 link_proc_t *link_proc;
00108 xnptree_t *root;
00109
00110 } xnpnode_t;
00111
00112 #else
00113
00114 typedef struct xnpnode {
00115
00116 const char *type;
00117
00118 } xnpnode_t;
00119
00120 #endif
00121
00122
00123
00124 int xnregistry_enter(const char *key,
00125 void *objaddr,
00126 xnhandle_t *phandle,
00127 xnpnode_t *pnode);
00128
00129 int xnregistry_bind(const char *key,
00130 xnticks_t timeout,
00131 xnhandle_t *phandle);
00132
00133 int xnregistry_remove(xnhandle_t handle);
00134
00135 int xnregistry_remove_safe(xnhandle_t handle,
00136 xnticks_t timeout);
00137
00138 void *xnregistry_get(xnhandle_t handle);
00139
00140 void *xnregistry_fetch(xnhandle_t handle);
00141
00142 u_long xnregistry_put(xnhandle_t handle);
00143
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147
00148 #endif
00149
00150 #endif