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