queue.h

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

Generated on Mon Dec 13 09:49:49 2004 for RTAI API by  doxygen 1.3.9.1