From 7b51712449ffa10f260f60e6968257230fe63f15 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 9 Aug 2013 13:43:56 +0000 Subject: Updated queues. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6112 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chqueues.h | 373 +++++++++++++++++++++++++------------------ os/kernel/src/chqueues.c | 80 ++++++---- 2 files changed, 269 insertions(+), 184 deletions(-) (limited to 'os/kernel') diff --git a/os/kernel/include/chqueues.h b/os/kernel/include/chqueues.h index 8449442c3..c050285ac 100644 --- a/os/kernel/include/chqueues.h +++ b/os/kernel/include/chqueues.h @@ -31,6 +31,10 @@ #if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + /** * @name Queue functions returned status value * @{ @@ -42,13 +46,25 @@ #define Q_FULL -4 /**< @brief Queue full, */ /** @} */ +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + /** * @brief Type of a generic I/O queue structure. */ -typedef struct GenericQueue GenericQueue; +typedef struct io_queue io_queue_t; /** @brief Queue notification callback type.*/ -typedef void (*qnotify_t)(GenericQueue *qp); +typedef void (*qnotify_t)(io_queue_t *qp); /** * @brief Generic I/O queue structure. @@ -59,7 +75,7 @@ typedef void (*qnotify_t)(GenericQueue *qp); * lock zone (see I-Locked and S-Locked states in * @ref system_states) and is non-blocking. */ -struct GenericQueue { +struct io_queue { threads_queue_t q_waiting; /**< @brief Queue of waiting threads. */ size_t q_counter; /**< @brief Resources counter. */ uint8_t *q_buffer; /**< @brief Pointer to the queue buffer.*/ @@ -71,6 +87,108 @@ struct GenericQueue { void *q_link; /**< @brief Application defined field. */ }; +/** + * @extends io_queue_t + * + * @brief Type of an input queue structure. + * @details This structure represents a generic asymmetrical input queue. + * Writing to the queue is non-blocking and can be performed from + * interrupt handlers or from within a kernel lock zone (see + * I-Locked and S-Locked states in @ref system_states). + * Reading the queue can be a blocking operation and is supposed to + * be performed by a system thread. + */ +typedef io_queue_t input_queue_t; + +/** + * @extends io_queue_t + * + * @brief Type of an output queue structure. + * @details This structure represents a generic asymmetrical output queue. + * Reading from the queue is non-blocking and can be performed from + * interrupt handlers or from within a kernel lock zone (see + * I-Locked and S-Locked states in @ref system_states). + * Writing the queue can be a blocking operation and is supposed to + * be performed by a system thread. + */ +typedef io_queue_t output_queue_t; + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/** + * @brief Data part of a static input queue initializer. + * @details This macro should be used when statically initializing an + * input queue that is part of a bigger structure. + * + * @param[in] name the name of the input queue variable + * @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, link) { \ + _threads_queue_t_DATA(name), \ + 0, \ + (uint8_t *)(buffer), \ + (uint8_t *)(buffer) + (size), \ + (uint8_t *)(buffer), \ + (uint8_t *)(buffer), \ + (inotify), \ + (link) \ +} + +/** + * @brief Static input queue initializer. + * @details Statically initialized input queues require no explicit + * initialization using @p chIQInit(). + * + * @param[in] name the name of the input queue variable + * @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, link) \ + input_queue_t name = _INPUTQUEUE_DATA(name, buffer, size, inotify, link) + +/** + * @brief Data part of a static output queue initializer. + * @details This macro should be used when statically initializing an + * output queue that is part of a bigger structure. + * + * @param[in] name the name of the output queue variable + * @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, link) { \ + _threads_queue_t_DATA(name), \ + (size), \ + (uint8_t *)(buffer), \ + (uint8_t *)(buffer) + (size), \ + (uint8_t *)(buffer), \ + (uint8_t *)(buffer), \ + (onotify), \ + (link) \ +} + +/** + * @brief Static output queue initializer. + * @details Statically initialized output queues require no explicit + * initialization using @p chOQInit(). + * + * @param[in] name the name of the output queue variable + * @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, link) \ + output_queue_t name = _OUTPUTQUEUE_DATA(name, buffer, size, onotify, link) + /** * @name Macro Functions * @{ @@ -78,7 +196,7 @@ struct GenericQueue { /** * @brief Returns the queue's buffer size. * - * @param[in] qp pointer to a @p GenericQueue structure. + * @param[in] qp pointer to a @p io_queue_t structure. * @return The buffer size. * * @iclass @@ -90,7 +208,7 @@ struct GenericQueue { * @details Returns the used space if used on an input queue or the empty * space if used on an output queue. * - * @param[in] qp pointer to a @p GenericQueue structure. + * @param[in] qp pointer to a @p io_queue_t structure. * @return The buffer space. * * @iclass @@ -99,79 +217,110 @@ struct GenericQueue { /** * @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. + * @param[in] qp pointer to a @p io_queue_t structure. * @return The application-defined link. * - * @special + * @xclass */ -#define chQGetLink(qp) ((qp)->q_link) +#define chQGetLinkX(qp) ((qp)->q_link) /** @} */ -/** - * @extends GenericQueue - * - * @brief Type of an input queue structure. - * @details This structure represents a generic asymmetrical input queue. - * Writing to the queue is non-blocking and can be performed from - * interrupt handlers or from within a kernel lock zone (see - * I-Locked and S-Locked states in @ref system_states). - * Reading the queue can be a blocking operation and is supposed to - * be performed by a system thread. - */ -typedef GenericQueue InputQueue; +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void chIQObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size, + qnotify_t infy, void *link); + void chIQResetI(input_queue_t *iqp); + msg_t chIQPutI(input_queue_t *iqp, uint8_t b); + msg_t chIQGetTimeout(input_queue_t *iqp, systime_t time); + size_t chIQReadTimeout(input_queue_t *iqp, uint8_t *bp, + size_t n, systime_t time); + + void chOQObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, + qnotify_t onfy, void *link); + void chOQResetI(output_queue_t *oqp); + msg_t chOQPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time); + msg_t chOQGetI(output_queue_t *oqp); + size_t chOQWriteTimeout(output_queue_t *oqp, const uint8_t *bp, + size_t n, systime_t time); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ -/** - * @name Macro Functions - * @{ - */ /** * @brief Returns the filled space into an input queue. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @return The number of full bytes in the queue. * @retval 0 if the queue is empty. * * @iclass */ -#define chIQGetFullI(iqp) chQSpaceI(iqp) +static inline size_t chIQGetFullI(input_queue_t *iqp) { + + chDbgCheckClassI(); + + return (size_t)chQSpaceI(iqp); +} /** * @brief Returns the empty space into an input queue. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @return The number of empty bytes in the queue. * @retval 0 if the queue is full. * * @iclass */ -#define chIQGetEmptyI(iqp) (chQSizeI(iqp) - chQSpaceI(iqp)) +static inline size_t chIQGetEmptyI(input_queue_t *iqp) { + + chDbgCheckClassI(); + + return (size_t)(chQSizeI(iqp) - chQSpaceI(iqp)); +} /** * @brief Evaluates to @p true if the specified input queue is empty. * - * @param[in] iqp pointer to an @p InputQueue structure. + * @param[in] iqp pointer to an @p input_queue_t structure. * @return The queue status. * @retval false if the queue is not empty. * @retval true if the queue is empty. * * @iclass */ -#define chIQIsEmptyI(iqp) ((bool_t)(chQSpaceI(iqp) <= 0)) +static inline bool chIQIsEmptyI(input_queue_t *iqp) { + + chDbgCheckClassI(); + + return (bool)(chQSpaceI(iqp) <= 0); +} /** * @brief Evaluates to @p true if the specified input queue is full. * - * @param[in] iqp pointer to an @p InputQueue structure. + * @param[in] iqp pointer to an @p input_queue_t structure. * @return The queue status. * @retval false if the queue is not full. * @retval true if the queue is full. * * @iclass */ -#define chIQIsFullI(iqp) ((bool_t)(((iqp)->q_wrptr == (iqp)->q_rdptr) && \ - ((iqp)->q_counter != 0))) +static inline bool chIQIsFullI(input_queue_t *iqp) { + + chDbgCheckClassI(); + + return (bool)((iqp->q_wrptr == iqp->q_rdptr) && (iqp->q_counter != 0)); +} /** * @brief Input queue read. @@ -179,114 +328,82 @@ typedef GenericQueue InputQueue; * is empty then the calling thread is suspended until a byte arrives * in the queue. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @return A byte value from the queue. * @retval Q_RESET if the queue has been reset. * * @api */ -#define chIQGet(iqp) chIQGetTimeout(iqp, TIME_INFINITE) -/** @} */ +static inline msg_t chIQGet(input_queue_t *iqp) { -/** - * @brief Data part of a static input queue initializer. - * @details This macro should be used when statically initializing an - * input queue that is part of a bigger structure. - * - * @param[in] name the name of the input queue variable - * @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, link) { \ - _threads_queue_t_DATA(name), \ - 0, \ - (uint8_t *)(buffer), \ - (uint8_t *)(buffer) + (size), \ - (uint8_t *)(buffer), \ - (uint8_t *)(buffer), \ - (inotify), \ - (link) \ + return chIQGetTimeout(iqp, TIME_INFINITE); } -/** - * @brief Static input queue initializer. - * @details Statically initialized input queues require no explicit - * initialization using @p chIQInit(). - * - * @param[in] name the name of the input queue variable - * @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, link) \ - InputQueue name = _INPUTQUEUE_DATA(name, buffer, size, inotify, link) - -/** - * @extends GenericQueue - * - * @brief Type of an output queue structure. - * @details This structure represents a generic asymmetrical output queue. - * Reading from the queue is non-blocking and can be performed from - * interrupt handlers or from within a kernel lock zone (see - * I-Locked and S-Locked states in @ref system_states). - * Writing the queue can be a blocking operation and is supposed to - * be performed by a system thread. - */ -typedef GenericQueue OutputQueue; - -/** - * @name Macro Functions - * @{ - */ /** * @brief Returns the filled space into an output queue. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @return The number of full bytes in the queue. * @retval 0 if the queue is empty. * * @iclass */ -#define chOQGetFullI(oqp) (chQSizeI(oqp) - chQSpaceI(oqp)) +static inline size_t chOQGetFullI(output_queue_t *oqp) { + + chDbgCheckClassI(); + + return (size_t)(chQSizeI(oqp) - chQSpaceI(oqp)); +} /** * @brief Returns the empty space into an output queue. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @return The number of empty bytes in the queue. * @retval 0 if the queue is full. * * @iclass */ -#define chOQGetEmptyI(oqp) chQSpaceI(oqp) +static inline size_t chOQGetEmptyI(output_queue_t *oqp) { + + chDbgCheckClassI(); + + return (size_t)chQSpaceI(oqp); +} /** * @brief Evaluates to @p true if the specified output queue is empty. * - * @param[in] oqp pointer to an @p OutputQueue structure. + * @param[in] oqp pointer to an @p output_queue_t structure. * @return The queue status. * @retval false if the queue is not empty. * @retval true if the queue is empty. * * @iclass */ -#define chOQIsEmptyI(oqp) ((bool_t)(((oqp)->q_wrptr == (oqp)->q_rdptr) && \ - ((oqp)->q_counter != 0))) +static inline bool chOQIsEmptyI(output_queue_t *oqp) { + + chDbgCheckClassI(); + + return (bool)((oqp->q_wrptr == oqp->q_rdptr) && (oqp->q_counter != 0)); +} /** * @brief Evaluates to @p true if the specified output queue is full. * - * @param[in] oqp pointer to an @p OutputQueue structure. + * @param[in] oqp pointer to an @p output_queue_t structure. * @return The queue status. * @retval false if the queue is not full. * @retval true if the queue is full. * * @iclass */ -#define chOQIsFullI(oqp) ((bool_t)(chQSpaceI(oqp) <= 0)) +static inline bool chOQIsFullI(output_queue_t *oqp) { + + chDbgCheckClassI(); + + return (bool)(chQSpaceI(oqp) <= 0); +} /** * @brief Output queue write. @@ -294,7 +411,7 @@ typedef GenericQueue OutputQueue; * is full then the calling thread is suspended until there is space * in the queue. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @param[in] b the byte value to be written in the queue * @return The operation status. * @retval Q_OK if the operation succeeded. @@ -302,66 +419,10 @@ typedef GenericQueue OutputQueue; * * @api */ -#define chOQPut(oqp, b) chOQPutTimeout(oqp, b, TIME_INFINITE) - /** @} */ - -/** - * @brief Data part of a static output queue initializer. - * @details This macro should be used when statically initializing an - * output queue that is part of a bigger structure. - * - * @param[in] name the name of the output queue variable - * @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, link) { \ - _threads_queue_t_DATA(name), \ - (size), \ - (uint8_t *)(buffer), \ - (uint8_t *)(buffer) + (size), \ - (uint8_t *)(buffer), \ - (uint8_t *)(buffer), \ - (onotify), \ - (link) \ -} - -/** - * @brief Static output queue initializer. - * @details Statically initialized output queues require no explicit - * initialization using @p chOQInit(). - * - * @param[in] name the name of the output queue variable - * @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, 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 *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); +static inline msg_t chOQPut(output_queue_t *oqp, uint8_t b) { - 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); - size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp, - size_t n, systime_t time); -#ifdef __cplusplus + return chOQPutTimeout(oqp, b, TIME_INFINITE); } -#endif #endif /* CH_CFG_USE_QUEUES */ diff --git a/os/kernel/src/chqueues.c b/os/kernel/src/chqueues.c index f7e587228..7cbc63f50 100644 --- a/os/kernel/src/chqueues.c +++ b/os/kernel/src/chqueues.c @@ -45,10 +45,30 @@ #if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) +/*===========================================================================*/ +/* Module local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local functions. */ +/*===========================================================================*/ + /** * @brief Puts the invoking thread into the queue's threads queue. * - * @param[out] qp pointer to an @p GenericQueue structure + * @param[out] qp pointer to an @p io_queue_t structure * @param[in] time the number of ticks before the operation timeouts, * the following special values are allowed: * - @a TIME_IMMEDIATE immediate timeout. @@ -60,7 +80,7 @@ * @retval Q_RESET if the queue has been reset. * @retval Q_TIMEOUT if the queue operation timed out. */ -static msg_t qwait(GenericQueue *qp, systime_t time) { +static msg_t qwait(io_queue_t *qp, systime_t time) { if (TIME_IMMEDIATE == time) return Q_TIMEOUT; @@ -69,6 +89,10 @@ static msg_t qwait(GenericQueue *qp, systime_t time) { return chSchGoSleepTimeoutS(CH_STATE_WTQUEUE, time); } +/*===========================================================================*/ +/* Module exported functions. */ +/*===========================================================================*/ + /** * @brief Initializes an input queue. * @details A Semaphore is internally initialized and works as a counter of @@ -76,7 +100,7 @@ static msg_t qwait(GenericQueue *qp, systime_t time) { * @note The callback is invoked from within the S-Locked system state, * see @ref system_states. * - * @param[out] iqp pointer to an @p InputQueue structure + * @param[out] iqp pointer to an @p input_queue_t structure * @param[in] bp pointer to a memory area allocated as queue buffer * @param[in] size size of the queue buffer * @param[in] infy pointer to a callback function that is invoked when @@ -85,8 +109,8 @@ static msg_t qwait(GenericQueue *qp, systime_t time) { * * @init */ -void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy, - void *link) { +void chIQObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size, + qnotify_t infy, void *link) { queue_init(&iqp->q_waiting); iqp->q_counter = 0; @@ -103,11 +127,11 @@ void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy, * @note A reset operation can be used by a low level driver in order to * obtain immediate attention from the high level layers. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * * @iclass */ -void chIQResetI(InputQueue *iqp) { +void chIQResetI(input_queue_t *iqp) { chDbgCheckClassI(); @@ -121,7 +145,7 @@ void chIQResetI(InputQueue *iqp) { * @brief Input queue write. * @details A byte value is written into the low end of an input queue. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @param[in] b the byte value to be written in the queue * @return The operation status. * @retval Q_OK if the operation has been completed with success. @@ -130,7 +154,7 @@ void chIQResetI(InputQueue *iqp) { * * @iclass */ -msg_t chIQPutI(InputQueue *iqp, uint8_t b) { +msg_t chIQPutI(input_queue_t *iqp, uint8_t b) { chDbgCheckClassI(); @@ -156,7 +180,7 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) { * @note The callback is invoked before reading the character from the * buffer or before entering the state @p CH_STATE_WTQUEUE. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @param[in] time the number of ticks before the operation timeouts, * the following special values are allowed: * - @a TIME_IMMEDIATE immediate timeout. @@ -168,7 +192,7 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) { * * @api */ -msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { +msg_t chIQGetTimeout(input_queue_t *iqp, systime_t time) { uint8_t b; chSysLock(); @@ -177,7 +201,7 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { while (chIQIsEmptyI(iqp)) { msg_t msg; - if ((msg = qwait((GenericQueue *)iqp, time)) < Q_OK) { + if ((msg = qwait((io_queue_t *)iqp, time)) < Q_OK) { chSysUnlock(); return msg; } @@ -203,7 +227,7 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { * @note The callback is invoked before reading each character from the * buffer or before entering the state @p CH_STATE_WTQUEUE. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @param[out] bp pointer to the data buffer * @param[in] n the maximum amount of data to be transferred, the * value 0 is reserved @@ -216,7 +240,7 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { * * @api */ -size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, +size_t chIQReadTimeout(input_queue_t *iqp, uint8_t *bp, size_t n, systime_t time) { qnotify_t nfy = iqp->q_notify; size_t r = 0; @@ -229,7 +253,7 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, nfy(iqp); while (chIQIsEmptyI(iqp)) { - if (qwait((GenericQueue *)iqp, time) != Q_OK) { + if (qwait((io_queue_t *)iqp, time) != Q_OK) { chSysUnlock(); return r; } @@ -256,7 +280,7 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, * @note The callback is invoked from within the S-Locked system state, * see @ref system_states. * - * @param[out] oqp pointer to an @p OutputQueue structure + * @param[out] oqp pointer to an @p output_queue_t structure * @param[in] bp pointer to a memory area allocated as queue buffer * @param[in] size size of the queue buffer * @param[in] onfy pointer to a callback function that is invoked when @@ -265,8 +289,8 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, * * @init */ -void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy, - void *link) { +void chOQObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, + qnotify_t onfy, void *link) { queue_init(&oqp->q_waiting); oqp->q_counter = size; @@ -283,11 +307,11 @@ void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy, * @note A reset operation can be used by a low level driver in order to * obtain immediate attention from the high level layers. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * * @iclass */ -void chOQResetI(OutputQueue *oqp) { +void chOQResetI(output_queue_t *oqp) { chDbgCheckClassI(); @@ -305,7 +329,7 @@ void chOQResetI(OutputQueue *oqp) { * @note The callback is invoked after writing the character into the * buffer. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @param[in] b the byte value to be written in the queue * @param[in] time the number of ticks before the operation timeouts, * the following special values are allowed: @@ -319,13 +343,13 @@ void chOQResetI(OutputQueue *oqp) { * * @api */ -msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) { +msg_t chOQPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time) { chSysLock(); while (chOQIsFullI(oqp)) { msg_t msg; - if ((msg = qwait((GenericQueue *)oqp, time)) < Q_OK) { + if ((msg = qwait((io_queue_t *)oqp, time)) < Q_OK) { chSysUnlock(); return msg; } @@ -347,13 +371,13 @@ msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) { * @brief Output queue read. * @details A byte value is read from the low end of an output queue. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @return The byte value from the queue. * @retval Q_EMPTY if the queue is empty. * * @iclass */ -msg_t chOQGetI(OutputQueue *oqp) { +msg_t chOQGetI(output_queue_t *oqp) { uint8_t b; chDbgCheckClassI(); @@ -383,7 +407,7 @@ msg_t chOQGetI(OutputQueue *oqp) { * @note The callback is invoked after writing each character into the * buffer. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @param[out] bp pointer to the data buffer * @param[in] n the maximum amount of data to be transferred, the * value 0 is reserved @@ -396,7 +420,7 @@ msg_t chOQGetI(OutputQueue *oqp) { * * @api */ -size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp, +size_t chOQWriteTimeout(output_queue_t *oqp, const uint8_t *bp, size_t n, systime_t time) { qnotify_t nfy = oqp->q_notify; size_t w = 0; @@ -406,7 +430,7 @@ size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp, chSysLock(); while (true) { while (chOQIsFullI(oqp)) { - if (qwait((GenericQueue *)oqp, time) != Q_OK) { + if (qwait((io_queue_t *)oqp, time) != Q_OK) { chSysUnlock(); return w; } -- cgit v1.2.3