aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel/src')
-rw-r--r--os/kernel/src/chevents.c2
-rw-r--r--os/kernel/src/chheap.c2
-rw-r--r--os/kernel/src/chmboxes.c1
-rw-r--r--os/kernel/src/chmempools.c38
-rw-r--r--os/kernel/src/chmtx.c6
-rw-r--r--os/kernel/src/chthreads.c2
6 files changed, 41 insertions, 10 deletions
diff --git a/os/kernel/src/chevents.c b/os/kernel/src/chevents.c
index 6749255e8..2b3247543 100644
--- a/os/kernel/src/chevents.c
+++ b/os/kernel/src/chevents.c
@@ -376,7 +376,7 @@ eventmask_t chEvtWaitAll(eventmask_t mask) {
* This means that Event Listeners with a lower event identifier have
* an higher priority.
*
- * @param[in] mask mask of the event flagss that the function should wait
+ * @param[in] mask mask of the event flags that the function should wait
* for, @p ALL_EVENTS enables all the events
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
diff --git a/os/kernel/src/chheap.c b/os/kernel/src/chheap.c
index f84276779..1e7f99dce 100644
--- a/os/kernel/src/chheap.c
+++ b/os/kernel/src/chheap.c
@@ -31,7 +31,7 @@
* are guaranteed to be thread safe.<br>
* By enabling the @p CH_USE_MALLOC_HEAP option the heap manager
* will use the runtime-provided @p malloc() and @p free() as
- * backend for the heap APIs instead of the system provided
+ * back end for the heap APIs instead of the system provided
* allocator.
* @pre In order to use the heap APIs the @p CH_USE_HEAP option must
* be enabled in @p chconf.h.
diff --git a/os/kernel/src/chmboxes.c b/os/kernel/src/chmboxes.c
index 86f88dce7..163f93f20 100644
--- a/os/kernel/src/chmboxes.c
+++ b/os/kernel/src/chmboxes.c
@@ -364,6 +364,7 @@ msg_t chMBFetchI(Mailbox *mbp, msg_t *msgp) {
if (chSemGetCounterI(&mbp->mb_fullsem) <= 0)
return RDY_TIMEOUT;
+ chSemFastWaitI(&mbp->mb_fullsem);
*msgp = *mbp->mb_rdptr++;
if (mbp->mb_rdptr >= mbp->mb_top)
mbp->mb_rdptr = mbp->mb_buffer;
diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c
index 6d1f7e866..8ef5cc403 100644
--- a/os/kernel/src/chmempools.c
+++ b/os/kernel/src/chmempools.c
@@ -61,7 +61,33 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) {
}
/**
+ * @brief Loads a memory pool with an array of static objects.
+ * @pre The memory pool must be already been initialized.
+ * @pre The array elements must be of the right size for the specified
+ * memory pool.
+ * @post The memory pool contains the elements of the input array.
+ *
+ * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] p pointer to the array first element
+ * @param[in] n number of elements in the array
+ *
+ * @api
+ */
+void chPoolLoadArray(MemoryPool *mp, void *p, size_t n) {
+
+ chDbgCheck((mp != NULL) && MEM_IS_ALIGNED(p) && (n != 0),
+ "chPoolLoadArray");
+
+ while (n) {
+ chPoolAdd(mp, p);
+ p = (void *)(((uint8_t *)p) + mp->mp_object_size);
+ n--;
+ }
+}
+
+/**
* @brief Allocates an object from a memory pool.
+ * @pre The memory pool must be already been initialized.
*
* @param[in] mp pointer to a @p MemoryPool structure
* @return The pointer to the allocated object.
@@ -84,6 +110,7 @@ void *chPoolAllocI(MemoryPool *mp) {
/**
* @brief Allocates an object from a memory pool.
+ * @pre The memory pool must be already been initialized.
*
* @param[in] mp pointer to a @p MemoryPool structure
* @return The pointer to the allocated object.
@@ -101,14 +128,15 @@ void *chPoolAlloc(MemoryPool *mp) {
}
/**
- * @brief Releases (or adds) an object into (to) a memory pool.
+ * @brief Releases an object into a memory pool.
+ * @pre The memory pool must be already been initialized.
* @pre The freed object must be of the right size for the specified
* memory pool.
* @pre The freed object must be memory aligned to the size of
* @p stkalign_t type.
*
* @param[in] mp pointer to a @p MemoryPool structure
- * @param[in] objp the pointer to the object to be released or added
+ * @param[in] objp the pointer to the object to be released
*
* @iclass
*/
@@ -124,14 +152,15 @@ void chPoolFreeI(MemoryPool *mp, void *objp) {
}
/**
- * @brief Releases (or adds) an object into (to) a memory pool.
+ * @brief Releases an object into a memory pool.
+ * @pre The memory pool must be already been initialized.
* @pre The freed object must be of the right size for the specified
* memory pool.
* @pre The freed object must be memory aligned to the size of
* @p stkalign_t type.
*
* @param[in] mp pointer to a @p MemoryPool structure
- * @param[in] objp the pointer to the object to be released or added
+ * @param[in] objp the pointer to the object to be released
*
* @api
*/
@@ -141,6 +170,7 @@ void chPoolFree(MemoryPool *mp, void *objp) {
chPoolFreeI(mp, objp);
chSysUnlock();
}
+
#endif /* CH_USE_MEMPOOLS */
/** @} */
diff --git a/os/kernel/src/chmtx.c b/os/kernel/src/chmtx.c
index 975a63094..20a4700fe 100644
--- a/os/kernel/src/chmtx.c
+++ b/os/kernel/src/chmtx.c
@@ -117,14 +117,14 @@ void chMtxLockS(Mutex *mp) {
chDbgCheckClassS();
chDbgCheck(mp != NULL, "chMtxLockS");
- /* Ia the mutex already locked? */
+ /* Is the mutex already locked? */
if (mp->m_owner != NULL) {
/* Priority inheritance protocol; explores the thread-mutex dependencies
boosting the priority of all the affected threads to equal the priority
of the running thread requesting the mutex.*/
Thread *tp = mp->m_owner;
/* Does the running thread have higher priority than the mutex
- ownning thread? */
+ owning thread? */
while (tp->p_prio < ctp->p_prio) {
/* Make priority of thread tp match the running thread's priority.*/
tp->p_prio = ctp->p_prio;
@@ -258,7 +258,7 @@ Mutex *chMtxUnlock(void) {
chDbgAssert(ctp->p_mtxlist->m_owner == ctp,
"chMtxUnlock(), #2",
"ownership failure");
- /* Removes the top Mutex from the Threads's owned mutexes list and matk it
+ /* Removes the top Mutex from the Thread's owned mutexes list and matk it
as not owned.*/
ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index eccf466d0..0be671c16 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -149,7 +149,7 @@ void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v) {
*/
Thread *chThdCreateI(void *wsp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) {
- /* Thread structure is layed out in the lower part of the thread workspace */
+ /* Thread structure is layed out in the lower part of the thread workspace.*/
Thread *tp = wsp;
chDbgCheckClassI();