include/nucleus/registry.h

Go to the documentation of this file.
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 /* __KERNEL__ && CONFIG_PROC_FS && CONFIG_XENO_OPT_REGISTRY */
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;    /* !< Hash key. */
00049 
00050     xnsynch_t safesynch; /* !< Safe synchronization object. */
00051 
00052     u_long safelock;     /* !< Safe lock count. */
00053 
00054     u_long cstamp;      /* !< Creation stamp. */
00055 
00056 #if defined(CONFIG_PROC_FS) && defined(__KERNEL__)
00057 
00058     struct xnpnode *pnode; /* !< /proc information class. */
00059 
00060     struct proc_dir_entry *proc; /* !< /proc entry. */
00061 
00062 #endif /* CONFIG_PROC_FS && __KERNEL__ */
00063 
00064 } xnobject_t;
00065 
00066 typedef struct xnobjhash {
00067 
00068     xnobject_t *object;
00069 
00070     struct xnobjhash *next;     /* !< Next in h-table */
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 /* !(CONFIG_PROC_FS && __KERNEL__) */
00113 
00114 typedef struct xnpnode { /* Placeholder. */
00115 
00116     const char *type;
00117 
00118 } xnpnode_t;
00119 
00120 #endif /* CONFIG_PROC_FS && __KERNEL__ */
00121 
00122 /* Public interface. */
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 /* __KERNEL__ || __XENO_SIM__ */
00149 
00150 #endif /* !_XENO_NUCLEUS_REGISTRY_H */

Generated on Mon Dec 25 13:57:10 2006 for Xenomai API by  doxygen 1.4.6