include/native/queue.h

Go to the documentation of this file.
00001 
00022 #ifndef _XENO_QUEUE_H
00023 #define _XENO_QUEUE_H
00024 
00025 #include <nucleus/synch.h>
00026 #include <nucleus/heap.h>
00027 #include <native/types.h>
00028 
00029 /* Creation flags. */
00030 #define Q_PRIO   XNSYNCH_PRIO   /* Pend by task priority order. */
00031 #define Q_FIFO   XNSYNCH_FIFO   /* Pend by FIFO order. */
00032 #define Q_DMA    0x100          /* Use memory suitable for DMA. */
00033 #define Q_SHARED 0x200          /* Use mappable shared memory. */
00034 
00035 #define Q_UNLIMITED 0           /* No size limit. */
00036 
00037 /* Operation flags. */
00038 #define Q_NORMAL     0x0
00039 #define Q_URGENT     0x1
00040 #define Q_BROADCAST  0x2
00041 
00042 typedef struct rt_queue_info {
00043 
00044     int nwaiters;               /* !< Number of pending tasks. */
00045 
00046     int nmessages;              /* !< Number of queued messages. */
00047 
00048     int mode;                   /* !< Creation mode. */
00049 
00050     size_t qlimit;              /* !< Queue limit. */
00051 
00052     size_t poolsize;            /* !< Size of pool memory (in bytes). */
00053 
00054     size_t usedmem;             /* !< Amount of pool memory used (in bytes). */
00055 
00056     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00057 
00058 } RT_QUEUE_INFO;
00059 
00060 typedef struct rt_queue_placeholder {
00061 
00062     xnhandle_t opaque;
00063 
00064     void *opaque2;
00065 
00066     caddr_t mapbase;
00067 
00068     size_t mapsize;
00069 
00070 } RT_QUEUE_PLACEHOLDER;
00071 
00072 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00073 
00074 #define XENO_QUEUE_MAGIC 0x55550707
00075 
00076 typedef struct rt_queue {
00077 
00078     unsigned magic;   /* !< Magic code - must be first */
00079 
00080     xnsynch_t synch_base; /* !< Base synchronization object. */
00081 
00082     xnqueue_t pendq;    /* !< Pending message queue. */
00083 
00084     xnheap_t bufpool;   /* !< Message buffer pool. */
00085 
00086     int mode;           /* !< Creation mode. */
00087 
00088     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00089 
00090     int qlimit;         /* !< Maximum queued elements. */
00091 
00092     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00093 
00094 #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE)
00095     pid_t cpid;                 /* !< Creator's pid. */
00096 #endif /* __KERNEL__ && CONFIG_XENO_OPT_PERVASIVE */
00097 
00098 } RT_QUEUE;
00099 
00100 typedef struct rt_queue_msg {
00101 
00102     size_t size;
00103 
00104     volatile unsigned refcount;
00105 
00106     xnholder_t link;
00107 
00108 #define link2rtmsg(laddr) \
00109 ((rt_queue_msg_t *)(((char *)laddr) - (int)(&((rt_queue_msg_t *)0)->link)))
00110 
00111 } rt_queue_msg_t;
00112 
00113 #ifdef __cplusplus
00114 extern "C" {
00115 #endif
00116 
00117 int __native_queue_pkg_init(void);
00118 
00119 void __native_queue_pkg_cleanup(void);
00120 
00121 #ifdef __cplusplus
00122 }
00123 #endif
00124 
00125 #else /* !(__KERNEL__ || __XENO_SIM__) */
00126 
00127 typedef RT_QUEUE_PLACEHOLDER RT_QUEUE;
00128 
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132 
00133 int rt_queue_bind(RT_QUEUE *q,
00134                   const char *name,
00135                   RTIME timeout);
00136 
00137 int rt_queue_unbind(RT_QUEUE *q);
00138 
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142 
00143 #endif /* __KERNEL__ || __XENO_SIM__ */
00144 
00145 #ifdef __cplusplus
00146 extern "C" {
00147 #endif
00148 
00149 /* Public interface. */
00150 
00151 int rt_queue_create(RT_QUEUE *q,
00152                     const char *name,
00153                     size_t poolsize,
00154                     size_t qlimit,
00155                     int mode);
00156 
00157 int rt_queue_delete(RT_QUEUE *q);
00158 
00159 void *rt_queue_alloc(RT_QUEUE *q,
00160                      size_t size);
00161 
00162 int rt_queue_free(RT_QUEUE *q,
00163                   void *buf);
00164 
00165 int rt_queue_send(RT_QUEUE *q,
00166                   void *buf,
00167                   size_t size,
00168                   int mode);
00169 
00170 int rt_queue_write(RT_QUEUE *q,
00171                    const void *buf,
00172                    size_t size,
00173                    int mode);
00174 
00175 ssize_t rt_queue_receive(RT_QUEUE *q,
00176                          void **bufp,
00177                          RTIME timeout);
00178 
00179 static inline ssize_t __deprecated_call__ rt_queue_recv(RT_QUEUE *q,
00180                                                         void **bufp,
00181                                                         RTIME timeout)
00182 {
00183     return rt_queue_receive(q,bufp,timeout);
00184 }
00185 
00186 ssize_t rt_queue_read(RT_QUEUE *q,
00187                       void *bufp,
00188                       size_t size,
00189                       RTIME timeout);
00190 
00191 int rt_queue_inquire(RT_QUEUE *q,
00192                      RT_QUEUE_INFO *info);
00193 
00194 #ifdef __cplusplus
00195 }
00196 #endif
00197 
00198 #endif /* !_XENO_QUEUE_H */

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