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(ln)          container_of(ln, rt_queue_msg_t, link)
00109 
00110 } rt_queue_msg_t;
00111 
00112 #ifdef __cplusplus
00113 extern "C" {
00114 #endif
00115 
00116 int __native_queue_pkg_init(void);
00117 
00118 void __native_queue_pkg_cleanup(void);
00119 
00120 #ifdef __cplusplus
00121 }
00122 #endif
00123 
00124 #else /* !(__KERNEL__ || __XENO_SIM__) */
00125 
00126 typedef RT_QUEUE_PLACEHOLDER RT_QUEUE;
00127 
00128 #ifdef __cplusplus
00129 extern "C" {
00130 #endif
00131 
00132 int rt_queue_bind(RT_QUEUE *q,
00133                   const char *name,
00134                   RTIME timeout);
00135 
00136 int rt_queue_unbind(RT_QUEUE *q);
00137 
00138 #ifdef __cplusplus
00139 }
00140 #endif
00141 
00142 #endif /* __KERNEL__ || __XENO_SIM__ */
00143 
00144 #ifdef __cplusplus
00145 extern "C" {
00146 #endif
00147 
00148 /* Public interface. */
00149 
00150 int rt_queue_create(RT_QUEUE *q,
00151                     const char *name,
00152                     size_t poolsize,
00153                     size_t qlimit,
00154                     int mode);
00155 
00156 int rt_queue_delete(RT_QUEUE *q);
00157 
00158 void *rt_queue_alloc(RT_QUEUE *q,
00159                      size_t size);
00160 
00161 int rt_queue_free(RT_QUEUE *q,
00162                   void *buf);
00163 
00164 int rt_queue_send(RT_QUEUE *q,
00165                   void *buf,
00166                   size_t size,
00167                   int mode);
00168 
00169 int rt_queue_write(RT_QUEUE *q,
00170                    const void *buf,
00171                    size_t size,
00172                    int mode);
00173 
00174 ssize_t rt_queue_receive(RT_QUEUE *q,
00175                          void **bufp,
00176                          RTIME timeout);
00177 
00178 static inline ssize_t __deprecated_call__ rt_queue_recv(RT_QUEUE *q,
00179                                                         void **bufp,
00180                                                         RTIME timeout)
00181 {
00182     return rt_queue_receive(q,bufp,timeout);
00183 }
00184 
00185 ssize_t rt_queue_read(RT_QUEUE *q,
00186                       void *bufp,
00187                       size_t size,
00188                       RTIME timeout);
00189 
00190 int rt_queue_inquire(RT_QUEUE *q,
00191                      RT_QUEUE_INFO *info);
00192 
00193 #ifdef __cplusplus
00194 }
00195 #endif
00196 
00197 #endif /* !_XENO_QUEUE_H */

Generated on Sun Dec 9 10:37:17 2007 for Xenomai API by  doxygen 1.5.3