New API added to pools and fifos.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12100 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
4a78d17518
commit
7d47d8cf46
|
@ -163,7 +163,6 @@ extern "C" {
|
|||
sysinterval_t timeout);
|
||||
void *chGuardedPoolAllocTimeout(guarded_memory_pool_t *gmp,
|
||||
sysinterval_t timeout);
|
||||
void chGuardedPoolFreeI(guarded_memory_pool_t *gmp, void *objp);
|
||||
void chGuardedPoolFree(guarded_memory_pool_t *gmp, void *objp);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
|
@ -251,6 +250,64 @@ static inline void chGuardedPoolObjectInit(guarded_memory_pool_t *gmp,
|
|||
chGuardedPoolObjectInitAligned(gmp, size, PORT_NATURAL_ALIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Allocates an object from a guarded memory pool.
|
||||
* @pre The guarded memory pool must be already been initialized.
|
||||
*
|
||||
* @param[in] gmp pointer to a @p guarded_memory_pool_t structure
|
||||
* @return The pointer to the allocated object.
|
||||
* @retval NULL if the pool is empty.
|
||||
*
|
||||
* @iclass
|
||||
*/
|
||||
static inline void *chGuardedPoolAllocI(guarded_memory_pool_t *gmp) {
|
||||
void *p;
|
||||
|
||||
p = chPoolAllocI(&gmp->pool);
|
||||
if (p != NULL) {
|
||||
chSemFastWaitI(&gmp->sem);
|
||||
chDbgAssert(chSemGetCounterI(&gmp->sem) >= (cnt_t)0,
|
||||
"semaphore out of sync");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases an object into a guarded memory pool.
|
||||
* @pre The guarded memory pool must already be initialized.
|
||||
* @pre The freed object must be of the right size for the specified
|
||||
* guarded memory pool.
|
||||
* @pre The added object must be properly aligned.
|
||||
*
|
||||
* @param[in] gmp pointer to a @p guarded_memory_pool_t structure
|
||||
* @param[in] objp the pointer to the object to be released
|
||||
*
|
||||
* @iclass
|
||||
*/
|
||||
static inline void chGuardedPoolFreeI(guarded_memory_pool_t *gmp, void *objp) {
|
||||
|
||||
chPoolFreeI(&gmp->pool, objp);
|
||||
chSemSignalI(&gmp->sem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases an object into a guarded memory pool.
|
||||
* @pre The guarded memory pool must already be initialized.
|
||||
* @pre The freed object must be of the right size for the specified
|
||||
* guarded memory pool.
|
||||
* @pre The added object must be properly aligned.
|
||||
*
|
||||
* @param[in] gmp pointer to a @p guarded_memory_pool_t structure
|
||||
* @param[in] objp the pointer to the object to be released
|
||||
*
|
||||
* @sclass
|
||||
*/
|
||||
static inline void chGuardedPoolFreeS(guarded_memory_pool_t *gmp, void *objp) {
|
||||
|
||||
chGuardedPoolFreeI(gmp, objp);
|
||||
chSchRescheduleS();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds an object to a guarded memory pool.
|
||||
* @pre The guarded memory pool must be already been initialized.
|
||||
|
@ -290,25 +347,22 @@ static inline void chGuardedPoolAddI(guarded_memory_pool_t *gmp, void *objp) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Allocates an object from a guarded memory pool.
|
||||
* @brief Adds an object to a guarded memory pool.
|
||||
* @pre The guarded memory pool must be already been initialized.
|
||||
* @pre The added object must be of the right size for the specified
|
||||
* guarded memory pool.
|
||||
* @pre The added object must be properly aligned.
|
||||
* @note This function is just an alias for @p chGuardedPoolFreeI() and
|
||||
* has been added for clarity.
|
||||
*
|
||||
* @param[in] gmp pointer to a @p guarded_memory_pool_t structure
|
||||
* @return The pointer to the allocated object.
|
||||
* @retval NULL if the pool is empty.
|
||||
* @param[in] objp the pointer to the object to be added
|
||||
*
|
||||
* @iclass
|
||||
* @sclass
|
||||
*/
|
||||
static inline void *chGuardedPoolAllocI(guarded_memory_pool_t *gmp) {
|
||||
void *p;
|
||||
static inline void chGuardedPoolAddS(guarded_memory_pool_t *gmp, void *objp) {
|
||||
|
||||
p = chPoolAllocI(&gmp->pool);
|
||||
if (p != NULL) {
|
||||
chSemFastWaitI(&gmp->sem);
|
||||
chDbgAssert(chSemGetCounterI(&gmp->sem) >= (cnt_t)0,
|
||||
"semaphore out of sync");
|
||||
}
|
||||
return p;
|
||||
chGuardedPoolFreeS(gmp, objp);
|
||||
}
|
||||
#endif /* CH_CFG_USE_SEMAPHORES == TRUE */
|
||||
|
||||
|
|
|
@ -204,6 +204,20 @@ static inline void chFifoReturnObjectI(objects_fifo_t *ofp,
|
|||
chGuardedPoolFreeI(&ofp->free, objp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases a fetched object.
|
||||
*
|
||||
* @param[in] ofp pointer to a @p objects_fifo_t structure
|
||||
* @param[in] objp pointer to the object to be released
|
||||
*
|
||||
* @sclass
|
||||
*/
|
||||
static inline void chFifoReturnObjectS(objects_fifo_t *ofp,
|
||||
void *objp) {
|
||||
|
||||
chGuardedPoolFreeS(&ofp->free, objp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases a fetched object.
|
||||
*
|
||||
|
@ -269,6 +283,57 @@ static inline void chFifoSendObject(objects_fifo_t *ofp, void *objp) {
|
|||
chDbgAssert(msg == MSG_OK, "post failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Posts an high priority object.
|
||||
* @note By design the object can be always immediately posted.
|
||||
*
|
||||
* @param[in] ofp pointer to a @p objects_fifo_t structure
|
||||
* @param[in] objp pointer to the object to be posted
|
||||
*
|
||||
* @iclass
|
||||
*/
|
||||
static inline void chFifoSendObjectAheadI(objects_fifo_t *ofp,
|
||||
void *objp) {
|
||||
msg_t msg;
|
||||
|
||||
msg = chMBPostAheadI(&ofp->mbx, (msg_t)objp);
|
||||
chDbgAssert(msg == MSG_OK, "post failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Posts an high priority object.
|
||||
* @note By design the object can be always immediately posted.
|
||||
*
|
||||
* @param[in] ofp pointer to a @p objects_fifo_t structure
|
||||
* @param[in] objp pointer to the object to be posted
|
||||
*
|
||||
* @sclass
|
||||
*/
|
||||
static inline void chFifoSendObjectAheadS(objects_fifo_t *ofp,
|
||||
void *objp) {
|
||||
msg_t msg;
|
||||
|
||||
msg = chMBPostAheadTimeoutS(&ofp->mbx, (msg_t)objp, TIME_IMMEDIATE);
|
||||
chDbgAssert(msg == MSG_OK, "post failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Posts an high priority object.
|
||||
* @note By design the object can be always immediately posted.
|
||||
*
|
||||
* @param[in] ofp pointer to a @p objects_fifo_t structure
|
||||
* @param[in] objp pointer to the object to be released
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
static inline void chFifoSendObjectAhead(objects_fifo_t *ofp, void *objp) {
|
||||
|
||||
msg_t msg;
|
||||
|
||||
msg = chMBPostAheadTimeout(&ofp->mbx, (msg_t)objp, TIME_IMMEDIATE);
|
||||
chDbgAssert(msg == MSG_OK, "post failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetches an object.
|
||||
*
|
||||
|
|
|
@ -305,24 +305,6 @@ void *chGuardedPoolAllocTimeout(guarded_memory_pool_t *gmp,
|
|||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases an object into a guarded memory pool.
|
||||
* @pre The guarded memory pool must already be initialized.
|
||||
* @pre The freed object must be of the right size for the specified
|
||||
* guarded memory pool.
|
||||
* @pre The added object must be properly aligned.
|
||||
*
|
||||
* @param[in] gmp pointer to a @p guarded_memory_pool_t structure
|
||||
* @param[in] objp the pointer to the object to be released
|
||||
*
|
||||
* @iclass
|
||||
*/
|
||||
void chGuardedPoolFreeI(guarded_memory_pool_t *gmp, void *objp) {
|
||||
|
||||
chPoolFreeI(&gmp->pool, objp);
|
||||
chSemSignalI(&gmp->sem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases an object into a guarded memory pool.
|
||||
* @pre The guarded memory pool must already be initialized.
|
||||
|
|
|
@ -91,6 +91,11 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** Next ***
|
||||
- NEW: Added new functions to objects fifos: chFifoReturnObjectS(),
|
||||
chFifoSendObjectAheadI(), chFifoSendObjectAheadS() and
|
||||
chFifoSendObjectAhead().
|
||||
- NEW: Added new functions to guarded pools: chGuardedPoolFreeS() and
|
||||
chGuardedPoolAddS().
|
||||
- NEW: Added initializer sections for flash0...flash7 memory areas in
|
||||
GCC Cortex-M linker scripts.
|
||||
- NEW: Added support for oversampling in STM32 ADCv3 driver.
|
||||
|
|
Loading…
Reference in New Issue