aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-11 16:54:35 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-11 16:54:35 +0000
commitd094e348c5d1a3785289c69c5185bbaca1257de8 (patch)
tree982d1606d57103c8ee2d38e9a11d161a65716640 /os/kernel
parentc762926b68f6a6c7f1e71b8acf9b1dd29d6e481f (diff)
downloadChibiOS-d094e348c5d1a3785289c69c5185bbaca1257de8.tar.gz
ChibiOS-d094e348c5d1a3785289c69c5185bbaca1257de8.tar.bz2
ChibiOS-d094e348c5d1a3785289c69c5185bbaca1257de8.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4266 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel')
-rw-r--r--os/kernel/include/chqueues.h40
-rw-r--r--os/kernel/src/chqueues.c10
2 files changed, 38 insertions, 12 deletions
diff --git a/os/kernel/include/chqueues.h b/os/kernel/include/chqueues.h
index b15cd70b0..b16a19609 100644
--- a/os/kernel/include/chqueues.h
+++ b/os/kernel/include/chqueues.h
@@ -68,6 +68,7 @@ struct GenericQueue {
uint8_t *q_wrptr; /**< @brief Write pointer. */
uint8_t *q_rdptr; /**< @brief Read pointer. */
qnotify_t q_notify; /**< @brief Data notification callback. */
+ void *q_link; /**< @brief Application defined field. */
};
/**
@@ -95,6 +96,17 @@ struct GenericQueue {
* @iclass
*/
#define chQSpaceI(qp) ((qp)->q_counter)
+
+/**
+ * @brief Returns the queue application-defined link.
+ * @note This function can be called in any context.
+ *
+ * @param[in] qp pointer to a @p GenericQueue structure.
+ * @return The application-defined link.
+ *
+ * @special
+ */
+#define chQGetLink(qp) ((qp)->q_link)
/** @} */
/**
@@ -185,15 +197,17 @@ typedef GenericQueue InputQueue;
* @param[in] buffer pointer to the queue buffer area
* @param[in] size size of the queue buffer area
* @param[in] inotify input notification callback pointer
+ * @param[in] link application defined pointer
*/
-#define _INPUTQUEUE_DATA(name, buffer, size, inotify) { \
+#define _INPUTQUEUE_DATA(name, buffer, size, inotify, link) { \
_THREADSQUEUE_DATA(name), \
0, \
(uint8_t *)(buffer), \
(uint8_t *)(buffer) + (size), \
(uint8_t *)(buffer), \
(uint8_t *)(buffer), \
- inotify \
+ (inotify), \
+ (link) \
}
/**
@@ -205,9 +219,10 @@ typedef GenericQueue InputQueue;
* @param[in] buffer pointer to the queue buffer area
* @param[in] size size of the queue buffer area
* @param[in] inotify input notification callback pointer
+ * @param[in] link application defined pointer
*/
-#define INPUTQUEUE_DECL(name, buffer, size, inotify) \
- InputQueue name = _INPUTQUEUE_DATA(name, buffer, size, inotify)
+#define INPUTQUEUE_DECL(name, buffer, size, inotify, link) \
+ InputQueue name = _INPUTQUEUE_DATA(name, buffer, size, inotify, link)
/**
* @extends GenericQueue
@@ -299,15 +314,17 @@ typedef GenericQueue OutputQueue;
* @param[in] buffer pointer to the queue buffer area
* @param[in] size size of the queue buffer area
* @param[in] onotify output notification callback pointer
+ * @param[in] link application defined pointer
*/
-#define _OUTPUTQUEUE_DATA(name, buffer, size, onotify) { \
+#define _OUTPUTQUEUE_DATA(name, buffer, size, onotify, link) { \
_THREADSQUEUE_DATA(name), \
(size), \
(uint8_t *)(buffer), \
(uint8_t *)(buffer) + (size), \
(uint8_t *)(buffer), \
(uint8_t *)(buffer), \
- onotify \
+ (onotify), \
+ (link) \
}
/**
@@ -319,21 +336,24 @@ typedef GenericQueue OutputQueue;
* @param[in] buffer pointer to the queue buffer area
* @param[in] size size of the queue buffer area
* @param[in] onotify output notification callback pointer
+ * @param[in] link application defined pointer
*/
-#define OUTPUTQUEUE_DECL(name, buffer, size, onotify) \
- OutputQueue name = _OUTPUTQUEUE_DATA(name, buffer, size, onotify)
+#define OUTPUTQUEUE_DECL(name, buffer, size, onotify, link) \
+ OutputQueue name = _OUTPUTQUEUE_DATA(name, buffer, size, onotify, link)
#ifdef __cplusplus
extern "C" {
#endif
- void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy);
+ void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy,
+ void *link);
void chIQResetI(InputQueue *iqp);
msg_t chIQPutI(InputQueue *iqp, uint8_t b);
msg_t chIQGetTimeout(InputQueue *iqp, systime_t time);
size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
size_t n, systime_t time);
- void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy);
+ void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy,
+ void *link);
void chOQResetI(OutputQueue *oqp);
msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time);
msg_t chOQGetI(OutputQueue *oqp);
diff --git a/os/kernel/src/chqueues.c b/os/kernel/src/chqueues.c
index adb5dd807..79bf409cb 100644
--- a/os/kernel/src/chqueues.c
+++ b/os/kernel/src/chqueues.c
@@ -83,16 +83,19 @@ static msg_t qwait(GenericQueue *qp, systime_t time) {
* @param[in] size size of the queue buffer
* @param[in] infy pointer to a callback function that is invoked when
* data is read from the queue. The value can be @p NULL.
+ * @param[in] link application defined pointer
*
* @init
*/
-void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy) {
+void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy,
+ void *link) {
queue_init(&iqp->q_waiting);
iqp->q_counter = 0;
iqp->q_buffer = iqp->q_rdptr = iqp->q_wrptr = bp;
iqp->q_top = bp + size;
iqp->q_notify = infy;
+ iqp->q_link = link;
}
/**
@@ -260,16 +263,19 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
* @param[in] size size of the queue buffer
* @param[in] onfy pointer to a callback function that is invoked when
* data is written to the queue. The value can be @p NULL.
+ * @param[in] link application defined pointer
*
* @init
*/
-void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy) {
+void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy,
+ void *link) {
queue_init(&oqp->q_waiting);
oqp->q_counter = size;
oqp->q_buffer = oqp->q_rdptr = oqp->q_wrptr = bp;
oqp->q_top = bp + size;
oqp->q_notify = onfy;
+ oqp->q_link = link;
}
/**