aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel/src')
-rw-r--r--os/kernel/src/chcond.c14
-rw-r--r--os/kernel/src/chdynamic.c28
-rw-r--r--os/kernel/src/chevents.c14
-rw-r--r--os/kernel/src/chheap.c12
-rw-r--r--os/kernel/src/chlists.c4
-rw-r--r--os/kernel/src/chmboxes.c6
-rw-r--r--os/kernel/src/chmemcore.c12
-rw-r--r--os/kernel/src/chmempools.c6
-rw-r--r--os/kernel/src/chmsg.c10
-rw-r--r--os/kernel/src/chmtx.c18
-rw-r--r--os/kernel/src/chqueues.c6
-rw-r--r--os/kernel/src/chregistry.c16
-rw-r--r--os/kernel/src/chschd.c30
-rw-r--r--os/kernel/src/chsem.c14
-rw-r--r--os/kernel/src/chsys.c28
-rw-r--r--os/kernel/src/chthreads.c44
16 files changed, 129 insertions, 133 deletions
diff --git a/os/kernel/src/chcond.c b/os/kernel/src/chcond.c
index d4d845512..8486705e6 100644
--- a/os/kernel/src/chcond.c
+++ b/os/kernel/src/chcond.c
@@ -33,14 +33,14 @@
* The condition variable is a synchronization object meant to be
* used inside a zone protected by a mutex. Mutexes and condition
* variables together can implement a Monitor construct.
- * @pre In order to use the condition variable APIs the @p CH_USE_CONDVARS
+ * @pre In order to use the condition variable APIs the @p CH_CFG_USE_CONDVARS
* option must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_CONDVARS || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@@ -218,14 +218,14 @@ msg_t chCondWaitS(condition_variable_t *cp) {
return msg;
}
-#if CH_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__)
+#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__)
/**
* @brief Waits on the condition variable releasing the mutex lock.
* @details Releases the currently owned mutex, waits on the condition
* variable, and finally acquires the mutex again. All the sequence
* is performed atomically.
* @pre The invoking thread <b>must</b> have at least one owned mutex.
- * @pre The configuration option @p CH_USE_CONDVARS_TIMEOUT must be enabled
+ * @pre The configuration option @p CH_CFG_USE_CONDVARS_TIMEOUT must be enabled
* in order to use this function.
* @post Exiting the function because a timeout does not re-acquire the
* mutex, the mutex ownership is lost.
@@ -262,7 +262,7 @@ msg_t chCondWaitTimeout(condition_variable_t *cp, systime_t time) {
* variable, and finally acquires the mutex again. All the sequence
* is performed atomically.
* @pre The invoking thread <b>must</b> have at least one owned mutex.
- * @pre The configuration option @p CH_USE_CONDVARS_TIMEOUT must be enabled
+ * @pre The configuration option @p CH_CFG_USE_CONDVARS_TIMEOUT must be enabled
* in order to use this function.
* @post Exiting the function because a timeout does not re-acquire the
* mutex, the mutex ownership is lost.
@@ -302,8 +302,8 @@ msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time) {
chMtxLockS(mp);
return msg;
}
-#endif /* CH_USE_CONDVARS_TIMEOUT */
+#endif /* CH_CFG_USE_CONDVARS_TIMEOUT */
-#endif /* CH_USE_CONDVARS */
+#endif /* CH_CFG_USE_CONDVARS */
/** @} */
diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c
index 21c81fc24..cab5556f3 100644
--- a/os/kernel/src/chdynamic.c
+++ b/os/kernel/src/chdynamic.c
@@ -29,7 +29,7 @@
#include "ch.h"
-#if CH_USE_DYNAMIC || defined(__DOXYGEN__)
+#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@@ -57,7 +57,7 @@
/**
* @brief Adds a reference to a thread object.
- * @pre The configuration option @p CH_USE_DYNAMIC must be enabled in order
+ * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order
* to use this function.
*
* @param[in] tp pointer to the thread
@@ -80,7 +80,7 @@ thread_t *chThdAddRef(thread_t *tp) {
* @details If the references counter reaches zero <b>and</b> the thread
* is in the @p THD_STATE_FINAL state then the thread's memory is
* returned to the proper allocator.
- * @pre The configuration option @p CH_USE_DYNAMIC must be enabled in order
+ * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order
* to use this function.
* @note Static threads are not affected.
*
@@ -101,17 +101,17 @@ void chThdRelease(thread_t *tp) {
allocator. Of course static threads are not affected.*/
if ((refs == 0) && (tp->p_state == THD_STATE_FINAL)) {
switch (tp->p_flags & THD_MEM_MODE_MASK) {
-#if CH_USE_HEAP
+#if CH_CFG_USE_HEAP
case THD_MEM_MODE_HEAP:
-#if CH_USE_REGISTRY
+#if CH_CFG_USE_REGISTRY
REG_REMOVE(tp);
#endif
chHeapFree(tp);
break;
#endif
-#if CH_USE_MEMPOOLS
+#if CH_CFG_USE_MEMPOOLS
case THD_MEM_MODE_MEMPOOL:
-#if CH_USE_REGISTRY
+#if CH_CFG_USE_REGISTRY
REG_REMOVE(tp);
#endif
chPoolFree(tp->p_mpool, tp);
@@ -121,10 +121,10 @@ void chThdRelease(thread_t *tp) {
}
}
-#if CH_USE_HEAP || defined(__DOXYGEN__)
+#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
/**
* @brief Creates a new thread allocating the memory from the heap.
- * @pre The configuration options @p CH_USE_DYNAMIC and @p CH_USE_HEAP
+ * @pre The configuration options @p CH_CFG_USE_DYNAMIC and @p CH_CFG_USE_HEAP
* must be enabled in order to use this function.
* @note A thread can terminate by calling @p chThdExit() or by simply
* returning from its main function.
@@ -169,13 +169,13 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
chSysUnlock();
return tp;
}
-#endif /* CH_USE_HEAP */
+#endif /* CH_CFG_USE_HEAP */
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
/**
* @brief Creates a new thread allocating the memory from the specified
* memory pool.
- * @pre The configuration options @p CH_USE_DYNAMIC and @p CH_USE_MEMPOOLS
+ * @pre The configuration options @p CH_CFG_USE_DYNAMIC and @p CH_CFG_USE_MEMPOOLS
* must be enabled in order to use this function.
* @note A thread can terminate by calling @p chThdExit() or by simply
* returning from its main function.
@@ -221,8 +221,8 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
chSysUnlock();
return tp;
}
-#endif /* CH_USE_MEMPOOLS */
+#endif /* CH_CFG_USE_MEMPOOLS */
-#endif /* CH_USE_DYNAMIC */
+#endif /* CH_CFG_USE_DYNAMIC */
/** @} */
diff --git a/os/kernel/src/chevents.c b/os/kernel/src/chevents.c
index 1206b61fe..f48a3ec9a 100644
--- a/os/kernel/src/chevents.c
+++ b/os/kernel/src/chevents.c
@@ -51,7 +51,7 @@
* An unlimited number of Event Sources can exists in a system and
* each thread can be listening on an unlimited number of
* them.
- * @pre In order to use the Events APIs the @p CH_USE_EVENTS option must be
+ * @pre In order to use the Events APIs the @p CH_CFG_USE_EVENTS option must be
* enabled in @p chconf.h.
* @post Enabling events requires 1-4 (depending on the architecture)
* extra bytes in the @p thread_t structure.
@@ -60,7 +60,7 @@
#include "ch.h"
-#if CH_USE_EVENTS || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@@ -350,7 +350,7 @@ void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask) {
}
}
-#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
+#if CH_CFG_OPTIMIZE_SPEED || !CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
/**
* @brief Waits for exactly one of the specified events.
* @details The function waits for one event among those specified in
@@ -438,9 +438,9 @@ eventmask_t chEvtWaitAll(eventmask_t mask) {
chSysUnlock();
return mask;
}
-#endif /* CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT */
+#endif /* CH_CFG_OPTIMIZE_SPEED || !CH_CFG_USE_EVENTS_TIMEOUT */
-#if CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
+#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
/**
* @brief Waits for exactly one of the specified events.
* @details The function waits for one event among those specified in
@@ -568,8 +568,8 @@ eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) {
chSysUnlock();
return mask;
}
-#endif /* CH_USE_EVENTS_TIMEOUT */
+#endif /* CH_CFG_USE_EVENTS_TIMEOUT */
-#endif /* CH_USE_EVENTS */
+#endif /* CH_CFG_USE_EVENTS */
/** @} */
diff --git a/os/kernel/src/chheap.c b/os/kernel/src/chheap.c
index b41817123..c2732376e 100644
--- a/os/kernel/src/chheap.c
+++ b/os/kernel/src/chheap.c
@@ -29,14 +29,14 @@
* are functionally equivalent to the usual @p malloc() and @p free()
* library functions. The main difference is that the OS heap APIs
* are guaranteed to be thread safe.<br>
- * @pre In order to use the heap APIs the @p CH_USE_HEAP option must
+ * @pre In order to use the heap APIs the @p CH_CFG_USE_HEAP option must
* be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_HEAP || defined(__DOXYGEN__)
+#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@@ -45,7 +45,7 @@
/*
* Defaults on the best synchronization mechanism available.
*/
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
#define H_LOCK(h) chMtxLock(&(h)->h_mtx)
#define H_UNLOCK(h) chMtxUnlock()
#else
@@ -87,7 +87,7 @@ void _heap_init(void) {
default_heap.h_provider = chCoreAlloc;
default_heap.h_free.h.u.next = (union heap_header *)NULL;
default_heap.h_free.h.size = 0;
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
chMtxObjectInit(&default_heap.h_mtx);
#else
chSemObjectInit(&default_heap.h_sem, 1);
@@ -115,7 +115,7 @@ void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size) {
heapp->h_free.h.size = 0;
hp->h.u.next = NULL;
hp->h.size = size - sizeof(union heap_header);
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
chMtxObjectInit(&heapp->h_mtx);
#else
chSemObjectInit(&heapp->h_sem, 1);
@@ -273,6 +273,6 @@ size_t chHeapStatus(memory_heap_t *heapp, size_t *sizep) {
return n;
}
-#endif /* CH_USE_HEAP */
+#endif /* CH_CFG_USE_HEAP */
/** @} */
diff --git a/os/kernel/src/chlists.c b/os/kernel/src/chlists.c
index 241067ab4..0f492db5f 100644
--- a/os/kernel/src/chlists.c
+++ b/os/kernel/src/chlists.c
@@ -54,7 +54,7 @@
/* Module exported functions. */
/*===========================================================================*/
-#if !CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
+#if !CH_CFG_OPTIMIZE_SPEED || defined(__DOXYGEN__)
/**
* @brief Inserts a thread into a priority ordered queue.
* @note The insertion is done by scanning the list from the highest
@@ -175,6 +175,6 @@ thread_t *list_remove(threads_list_t *tlp) {
tlp->p_next = tp->p_next;
return tp;
}
-#endif /* CH_OPTIMIZE_SPEED */
+#endif /* CH_CFG_OPTIMIZE_SPEED */
/** @} */
diff --git a/os/kernel/src/chmboxes.c b/os/kernel/src/chmboxes.c
index b1a4fb963..2a6e6fae8 100644
--- a/os/kernel/src/chmboxes.c
+++ b/os/kernel/src/chmboxes.c
@@ -45,14 +45,14 @@
* example) from the posting side and free it on the fetching side.
* Another approach is to set a "done" flag into the structure pointed
* by the message.
- * @pre In order to use the mailboxes APIs the @p CH_USE_MAILBOXES option
+ * @pre In order to use the mailboxes APIs the @p CH_CFG_USE_MAILBOXES option
* must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_MAILBOXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -393,6 +393,6 @@ msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp) {
chSemSignalI(&mbp->mb_emptysem);
return RDY_OK;
}
-#endif /* CH_USE_MAILBOXES */
+#endif /* CH_CFG_USE_MAILBOXES */
/** @} */
diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c
index 76f415743..d5e7ed79c 100644
--- a/os/kernel/src/chmemcore.c
+++ b/os/kernel/src/chmemcore.c
@@ -39,14 +39,14 @@
* This allocator, alone, is also useful for very simple
* applications that just require a simple way to get memory
* blocks.
- * @pre In order to use the core memory manager APIs the @p CH_USE_MEMCORE
+ * @pre In order to use the core memory manager APIs the @p CH_CFG_USE_MEMCORE
* option must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_MEMCORE || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMCORE || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -77,17 +77,17 @@ static uint8_t *endmem;
* @notapi
*/
void _core_init(void) {
-#if CH_MEMCORE_SIZE == 0
+#if CH_CFG_MEMCORE_SIZE == 0
extern uint8_t __heap_base__[];
extern uint8_t __heap_end__[];
nextmem = (uint8_t *)MEM_ALIGN_NEXT(__heap_base__);
endmem = (uint8_t *)MEM_ALIGN_PREV(__heap_end__);
#else
- static stkalign_t buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
+ static stkalign_t buffer[MEM_ALIGN_NEXT(CH_CFG_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
nextmem = (uint8_t *)&buffer[0];
- endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
+ endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_CFG_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
#endif
}
@@ -148,6 +148,6 @@ size_t chCoreStatus(void) {
return (size_t)(endmem - nextmem);
}
-#endif /* CH_USE_MEMCORE */
+#endif /* CH_CFG_USE_MEMCORE */
/** @} */
diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c
index 44557235b..6d84b557e 100644
--- a/os/kernel/src/chmempools.c
+++ b/os/kernel/src/chmempools.c
@@ -31,14 +31,14 @@
* Memory Pools do not enforce any alignment constraint on the
* contained object however the objects must be properly aligned
* to contain a pointer to void.
- * @pre In order to use the memory pools APIs the @p CH_USE_MEMPOOLS option
+ * @pre In order to use the memory pools APIs the @p CH_CFG_USE_MEMPOOLS option
* must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -189,6 +189,6 @@ void chPoolFree(memory_pool_t *mp, void *objp) {
chSysUnlock();
}
-#endif /* CH_USE_MEMPOOLS */
+#endif /* CH_CFG_USE_MEMPOOLS */
/** @} */
diff --git a/os/kernel/src/chmsg.c b/os/kernel/src/chmsg.c
index b53f91979..535143b7c 100644
--- a/os/kernel/src/chmsg.c
+++ b/os/kernel/src/chmsg.c
@@ -36,8 +36,8 @@
* architectures function pointers can be larger that @p msg_t.<br>
* Messages are usually processed in FIFO order but it is possible to
* process them in priority order by enabling the
- * @p CH_USE_MESSAGES_PRIORITY option in @p chconf.h.<br>
- * @pre In order to use the message APIs the @p CH_USE_MESSAGES option
+ * @p CH_CFG_USE_MESSAGES_PRIORITY option in @p chconf.h.<br>
+ * @pre In order to use the message APIs the @p CH_CFG_USE_MESSAGES option
* must be enabled in @p chconf.h.
* @post Enabling messages requires 6-12 (depending on the architecture)
* extra bytes in the @p thread_t structure.
@@ -46,7 +46,7 @@
#include "ch.h"
-#if CH_USE_MESSAGES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -64,7 +64,7 @@
/* Module local functions. */
/*===========================================================================*/
-#if CH_USE_MESSAGES_PRIORITY
+#if CH_CFG_USE_MESSAGES_PRIORITY
#define msg_insert(tp, qp) prio_insert(tp, qp)
#else
#define msg_insert(tp, qp) queue_insert(tp, qp)
@@ -147,6 +147,6 @@ void chMsgRelease(thread_t *tp, msg_t msg) {
chSysUnlock();
}
-#endif /* CH_USE_MESSAGES */
+#endif /* CH_CFG_USE_MESSAGES */
/** @} */
diff --git a/os/kernel/src/chmtx.c b/os/kernel/src/chmtx.c
index ec191b53d..be9c6dd78 100644
--- a/os/kernel/src/chmtx.c
+++ b/os/kernel/src/chmtx.c
@@ -58,7 +58,7 @@
* The mechanism works with any number of nested mutexes and any
* number of involved threads. The algorithm complexity (worst case)
* is N with N equal to the number of nested mutexes.
- * @pre In order to use the mutex APIs the @p CH_USE_MUTEXES option
+ * @pre In order to use the mutex APIs the @p CH_CFG_USE_MUTEXES option
* must be enabled in @p chconf.h.
* @post Enabling mutexes requires 5-12 (depending on the architecture)
* extra bytes in the @p thread_t structure.
@@ -67,7 +67,7 @@
#include "ch.h"
-#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -158,16 +158,16 @@ void chMtxLockS(mutex_t *mp) {
(threads_queue_t *)tp->p_u.wtobjp);
tp = ((mutex_t *)tp->p_u.wtobjp)->m_owner;
continue;
-#if CH_USE_CONDVARS | \
- (CH_USE_SEMAPHORES && CH_USE_SEMAPHORES_PRIORITY) | \
- (CH_USE_MESSAGES && CH_USE_MESSAGES_PRIORITY)
-#if CH_USE_CONDVARS
+#if CH_CFG_USE_CONDVARS | \
+ (CH_CFG_USE_SEMAPHORES && CH_CFG_USE_SEMAPHORES_PRIORITY) | \
+ (CH_CFG_USE_MESSAGES && CH_CFG_USE_MESSAGES_PRIORITY)
+#if CH_CFG_USE_CONDVARS
case THD_STATE_WTCOND:
#endif
-#if CH_USE_SEMAPHORES && CH_USE_SEMAPHORES_PRIORITY
+#if CH_CFG_USE_SEMAPHORES && CH_CFG_USE_SEMAPHORES_PRIORITY
case THD_STATE_WTSEM:
#endif
-#if CH_USE_MESSAGES && CH_USE_MESSAGES_PRIORITY
+#if CH_CFG_USE_MESSAGES && CH_CFG_USE_MESSAGES_PRIORITY
case THD_STATE_SNDMSGQ:
#endif
/* Re-enqueues tp with its new priority on the queue.*/
@@ -423,6 +423,6 @@ void chMtxUnlockAll(void) {
chSysUnlock();
}
-#endif /* CH_USE_MUTEXES */
+#endif /* CH_CFG_USE_MUTEXES */
/** @} */
diff --git a/os/kernel/src/chqueues.c b/os/kernel/src/chqueues.c
index 7115d77b6..fcaa2895f 100644
--- a/os/kernel/src/chqueues.c
+++ b/os/kernel/src/chqueues.c
@@ -36,14 +36,14 @@
* are implemented by pairing an input queue and an output queue
* together.
* .
- * @pre In order to use the I/O queues the @p CH_USE_QUEUES option must
+ * @pre In order to use the I/O queues the @p CH_CFG_USE_QUEUES option must
* be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_QUEUES || defined(__DOXYGEN__)
+#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
/**
* @brief Puts the invoking thread into the queue's threads queue.
@@ -426,6 +426,6 @@ size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp,
chSysLock();
}
}
-#endif /* CH_USE_QUEUES */
+#endif /* CH_CFG_USE_QUEUES */
/** @} */
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c
index 832ef0ce9..b43341edd 100644
--- a/os/kernel/src/chregistry.c
+++ b/os/kernel/src/chregistry.c
@@ -42,13 +42,13 @@
* terminating threads can pulse an event source and an event handler
* can perform a scansion of the registry in order to recover the
* memory.
- * @pre In order to use the threads registry the @p CH_USE_REGISTRY option
+ * @pre In order to use the threads registry the @p CH_CFG_USE_REGISTRY option
* must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_REGISTRY || defined(__DOXYGEN__)
+#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -98,12 +98,12 @@ ROMCONST chdebug_t ch_debug = {
#endif
(uint8_t)_offsetof(thread_t, p_state),
(uint8_t)_offsetof(thread_t, p_flags),
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
(uint8_t)_offsetof(thread_t, p_refs),
#else
(uint8_t)0,
#endif
-#if CH_TIME_QUANTUM > 0
+#if CH_CFG_TIME_QUANTUM > 0
(uint8_t)_offsetof(thread_t, p_preempt),
#else
(uint8_t)0,
@@ -132,7 +132,7 @@ thread_t *chRegFirstThread(void) {
chSysLock();
tp = rlist.r_newer;
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
tp->p_refs++;
#endif
chSysUnlock();
@@ -157,7 +157,7 @@ thread_t *chRegNextThread(thread_t *tp) {
ntp = tp->p_newer;
if (ntp == (thread_t *)&rlist)
ntp = NULL;
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
else {
chDbgAssert(ntp->p_refs < 255, "chRegNextThread(), #1",
"too many references");
@@ -165,12 +165,12 @@ thread_t *chRegNextThread(thread_t *tp) {
}
#endif
chSysUnlock();
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
chThdRelease(tp);
#endif
return ntp;
}
-#endif /* CH_USE_REGISTRY */
+#endif /* CH_CFG_USE_REGISTRY */
/** @} */
diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c
index 4592f4806..c360777ef 100644
--- a/os/kernel/src/chschd.c
+++ b/os/kernel/src/chschd.c
@@ -67,7 +67,7 @@ void _scheduler_init(void) {
queue_init(&rlist.r_queue);
rlist.r_prio = NOPRIO;
-#if CH_USE_REGISTRY
+#if CH_CFG_USE_REGISTRY
rlist.r_newer = rlist.r_older = (thread_t *)&rlist;
#endif
}
@@ -126,10 +126,10 @@ void chSchGoSleepS(tstate_t newstate) {
chDbgCheckClassS();
(otp = currp)->p_state = newstate;
-#if CH_TIME_QUANTUM > 0
+#if CH_CFG_TIME_QUANTUM > 0
/* The thread is renouncing its remaining time slices so it will have a new
time quantum when it will wakeup.*/
- otp->p_preempt = CH_TIME_QUANTUM;
+ otp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
setcurrp(queue_fifo_remove(&rlist.r_queue));
currp->p_state = THD_STATE_CURRENT;
@@ -149,17 +149,17 @@ static void wakeup(void *p) {
another thread with higher priority.*/
chSysUnlockFromIsr();
return;
-#if CH_USE_SEMAPHORES || CH_USE_QUEUES || \
- (CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT)
-#if CH_USE_SEMAPHORES
+#if CH_CFG_USE_SEMAPHORES || CH_CFG_USE_QUEUES || \
+ (CH_CFG_USE_CONDVARS && CH_CFG_USE_CONDVARS_TIMEOUT)
+#if CH_CFG_USE_SEMAPHORES
case THD_STATE_WTSEM:
chSemFastSignalI((semaphore_t *)tp->p_u.wtobjp);
/* Falls into, intentional. */
#endif
-#if CH_USE_QUEUES
+#if CH_CFG_USE_QUEUES
case THD_STATE_WTQUEUE:
#endif
-#if CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT
+#if CH_CFG_USE_CONDVARS && CH_CFG_USE_CONDVARS_TIMEOUT
case THD_STATE_WTCOND:
#endif
/* States requiring dequeuing.*/
@@ -276,7 +276,7 @@ void chSchRescheduleS(void) {
bool chSchIsPreemptionRequired(void) {
tprio_t p1 = firstprio(&rlist.r_queue);
tprio_t p2 = currp->p_prio;
-#if CH_TIME_QUANTUM > 0
+#if CH_CFG_TIME_QUANTUM > 0
/* If the running thread has not reached its time quantum, reschedule only
if the first thread on the ready queue has a higher priority.
Otherwise, if the running thread has used up its time quantum, reschedule
@@ -306,8 +306,8 @@ void chSchDoRescheduleBehind(void) {
/* Picks the first thread from the ready queue and makes it current.*/
setcurrp(queue_fifo_remove(&rlist.r_queue));
currp->p_state = THD_STATE_CURRENT;
-#if CH_TIME_QUANTUM > 0
- otp->p_preempt = CH_TIME_QUANTUM;
+#if CH_CFG_TIME_QUANTUM > 0
+ otp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
chSchReadyI(otp);
chSysSwitch(currp, otp);
@@ -355,8 +355,8 @@ void chSchDoRescheduleAhead(void) {
*/
void chSchDoReschedule(void) {
-#if CH_TIME_QUANTUM > 0
- /* If CH_TIME_QUANTUM is enabled then there are two different scenarios to
+#if CH_CFG_TIME_QUANTUM > 0
+ /* If CH_CFG_TIME_QUANTUM is enabled then there are two different scenarios to
handle on preemption: time quantum elapsed or not.*/
if (currp->p_preempt == 0) {
/* The thread consumed its time quantum so it is enqueued behind threads
@@ -368,11 +368,11 @@ void chSchDoReschedule(void) {
threads with equal priority and does not acquire a new time quantum.*/
chSchDoRescheduleAhead();
}
-#else /* !(CH_TIME_QUANTUM > 0) */
+#else /* !(CH_CFG_TIME_QUANTUM > 0) */
/* If the round-robin mechanism is disabled then the thread goes always
ahead of its peers.*/
chSchDoRescheduleAhead();
-#endif /* !(CH_TIME_QUANTUM > 0) */
+#endif /* !(CH_CFG_TIME_QUANTUM > 0) */
}
/** @} */
diff --git a/os/kernel/src/chsem.c b/os/kernel/src/chsem.c
index 554c02246..bcf222230 100644
--- a/os/kernel/src/chsem.c
+++ b/os/kernel/src/chsem.c
@@ -51,15 +51,15 @@
* also have other uses, queues guards and counters for example.<br>
* Semaphores usually use a FIFO queuing strategy but it is possible
* to make them order threads by priority by enabling
- * @p CH_USE_SEMAPHORES_PRIORITY in @p chconf.h.
- * @pre In order to use the semaphore APIs the @p CH_USE_SEMAPHORES
+ * @p CH_CFG_USE_SEMAPHORES_PRIORITY in @p chconf.h.
+ * @pre In order to use the semaphore APIs the @p CH_CFG_USE_SEMAPHORES
* option must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
-#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
+#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module exported variables. */
@@ -77,7 +77,7 @@
/* Module local functions. */
/*===========================================================================*/
-#if CH_USE_SEMAPHORES_PRIORITY
+#if CH_CFG_USE_SEMAPHORES_PRIORITY
#define sem_insert(tp, qp) prio_insert(tp, qp)
#else
#define sem_insert(tp, qp) queue_insert(tp, qp)
@@ -360,11 +360,8 @@ void chSemAddCounterI(semaphore_t *sp, cnt_t n) {
}
}
-#if CH_USE_SEMSW
/**
* @brief Performs atomic signal and wait operations on two semaphores.
- * @pre The configuration option @p CH_USE_SEMSW must be enabled in order
- * to use this function.
*
* @param[in] sps pointer to a @p semaphore_t structure to be signaled
* @param[in] spw pointer to a @p semaphore_t structure to wait on
@@ -406,8 +403,7 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
chSysUnlock();
return msg;
}
-#endif /* CH_USE_SEMSW */
-#endif /* CH_USE_SEMAPHORES */
+#endif /* CH_CFG_USE_SEMAPHORES */
/** @} */
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index b3d99a7d9..97f01f933 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -47,18 +47,18 @@
/* Module local variables. */
/*===========================================================================*/
-#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
+#if !CH_CFG_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
* @brief Idle thread working area.
*/
static WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
-#endif /* CH_NO_IDLE_THREAD */
+#endif /* CH_CFG_NO_IDLE_THREAD */
/*===========================================================================*/
/* Module local functions. */
/*===========================================================================*/
-#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
+#if !CH_CFG_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
* @brief This function implements the idle thread infinite loop.
* @details The function puts the processor in the lowest power mode capable
@@ -75,10 +75,10 @@ static void _idle_thread(void *p) {
chRegSetThreadName("idle");
while (true) {
port_wait_for_interrupt();
- IDLE_LOOP_HOOK();
+ CH_CFG_IDLE_LOOP_HOOK();
}
}
-#endif /* CH_NO_IDLE_THREAD */
+#endif /* CH_CFG_NO_IDLE_THREAD */
/*===========================================================================*/
/* Module exported functions. */
@@ -105,10 +105,10 @@ void chSysInit(void) {
port_init();
_scheduler_init();
_vt_init();
-#if CH_USE_MEMCORE
+#if CH_CFG_USE_MEMCORE
_core_init();
#endif
-#if CH_USE_HEAP
+#if CH_CFG_USE_HEAP
_heap_init();
#endif
#if CH_DBG_ENABLE_TRACE
@@ -129,7 +129,7 @@ void chSysInit(void) {
active, else the parameter is ignored.*/
chRegSetThreadName((const char *)&ch_debug);
-#if !CH_NO_IDLE_THREAD
+#if !CH_CFG_NO_IDLE_THREAD
/* This thread has the lowest priority in the system, its role is just to
serve interrupts in its context while keeping the lowest energy saving
mode compatible with the system status.*/
@@ -152,8 +152,8 @@ void chSysHalt(void) {
chSysDisable();
-#if defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
- SYSTEM_HALT_HOOK();
+#if defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
+ CH_CFG_SYSTEM_HALT_HOOK();
#endif
/* Harmless infinite loop.*/
@@ -167,7 +167,7 @@ void chSysHalt(void) {
* and preempts it when the quantum is used up. Increments system
* time and manages the timers.
* @note The frequency of the timer determines the system tick granularity
- * and, together with the @p CH_TIME_QUANTUM macro, the round robin
+ * and, together with the @p CH_CFG_TIME_QUANTUM macro, the round robin
* interval.
*
* @iclass
@@ -176,7 +176,7 @@ void chSysTimerHandlerI(void) {
chDbgCheckClassI();
-#if CH_TIME_QUANTUM > 0
+#if CH_CFG_TIME_QUANTUM > 0
/* Running thread has not used up quantum yet? */
if (currp->p_preempt > 0)
/* Decrement remaining quantum.*/
@@ -186,8 +186,8 @@ void chSysTimerHandlerI(void) {
currp->p_time++;
#endif
chVTDoTickI();
-#if defined(SYSTEM_TICK_EVENT_HOOK)
- SYSTEM_TICK_EVENT_HOOK();
+#if defined(CH_CFG_SYSTEM_TICK_HOOK)
+ CH_CFG_SYSTEM_TICK_HOOK();
#endif
}
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index 47f53e10d..17eeb763b 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -49,7 +49,7 @@
* .
* The threads subsystem is implicitly included in kernel however
* some of its part may be excluded by disabling them in @p chconf.h,
- * see the @p CH_USE_WAITEXIT and @p CH_USE_DYNAMIC configuration
+ * see the @p CH_CFG_USE_WAITEXIT and @p CH_CFG_USE_DYNAMIC configuration
* options.
* @{
*/
@@ -95,37 +95,37 @@ thread_t *_thread_init(thread_t *tp, tprio_t prio) {
tp->p_prio = prio;
tp->p_state = THD_STATE_SUSPENDED;
tp->p_flags = THD_MEM_MODE_STATIC;
-#if CH_TIME_QUANTUM > 0
- tp->p_preempt = CH_TIME_QUANTUM;
+#if CH_CFG_TIME_QUANTUM > 0
+ tp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
-#if CH_USE_MUTEXES
+#if CH_CFG_USE_MUTEXES
tp->p_realprio = prio;
tp->p_mtxlist = NULL;
#endif
-#if CH_USE_EVENTS
+#if CH_CFG_USE_EVENTS
tp->p_epending = 0;
#endif
#if CH_DBG_THREADS_PROFILING
tp->p_time = 0;
#endif
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
tp->p_refs = 1;
#endif
-#if CH_USE_REGISTRY
+#if CH_CFG_USE_REGISTRY
tp->p_name = NULL;
REG_INSERT(tp);
#endif
-#if CH_USE_WAITEXIT
+#if CH_CFG_USE_WAITEXIT
list_init(&tp->p_waiting);
#endif
-#if CH_USE_MESSAGES
+#if CH_CFG_USE_MESSAGES
queue_init(&tp->p_msgqueue);
#endif
#if CH_DBG_ENABLE_STACK_CHECK
tp->p_stklimit = (stkalign_t *)(tp + 1);
#endif
-#if defined(THREAD_EXT_INIT_HOOK)
- THREAD_EXT_INIT_HOOK(tp);
+#if defined(CH_CFG_THREAD_INIT_HOOK)
+ CH_CFG_THREAD_INIT_HOOK(tp);
#endif
return tp;
}
@@ -238,7 +238,7 @@ tprio_t chThdSetPriority(tprio_t newprio) {
chDbgCheck(newprio <= HIGHPRIO, "chThdSetPriority");
chSysLock();
-#if CH_USE_MUTEXES
+#if CH_CFG_USE_MUTEXES
oldprio = currp->p_realprio;
if ((currp->p_prio == currp->p_realprio) || (newprio > currp->p_prio))
currp->p_prio = newprio;
@@ -385,14 +385,14 @@ void chThdExitS(msg_t msg) {
thread_t *tp = currp;
tp->p_u.exitcode = msg;
-#if defined(THREAD_EXT_EXIT_HOOK)
- THREAD_EXT_EXIT_HOOK(tp);
+#if defined(CH_CFG_THREAD_EXIT_HOOK)
+ CH_CFG_THREAD_EXIT_HOOK(tp);
#endif
-#if CH_USE_WAITEXIT
+#if CH_CFG_USE_WAITEXIT
while (list_notempty(&tp->p_waiting))
chSchReadyI(list_remove(&tp->p_waiting));
#endif
-#if CH_USE_REGISTRY
+#if CH_CFG_USE_REGISTRY
/* Static threads are immediately removed from the registry because
there is no memory to recover.*/
if ((tp->p_flags & THD_MEM_MODE_MASK) == THD_MEM_MODE_STATIC)
@@ -403,7 +403,7 @@ void chThdExitS(msg_t msg) {
chDbgAssert(false, "chThdExitS(), #1", "zombies apocalypse");
}
-#if CH_USE_WAITEXIT || defined(__DOXYGEN__)
+#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__)
/**
* @brief Blocks the execution of the invoking thread until the specified
* thread terminates then the exit code is returned.
@@ -421,13 +421,13 @@ void chThdExitS(msg_t msg) {
* - If the thread was spawned by @p chThdCreateFromMemoryPool()
* then the working area is returned to the owning memory pool.
* .
- * @pre The configuration option @p CH_USE_WAITEXIT must be enabled in
+ * @pre The configuration option @p CH_CFG_USE_WAITEXIT must be enabled in
* order to use this function.
* @post Enabling @p chThdWait() requires 2-4 (depending on the
* architecture) extra bytes in the @p thread_t structure.
* @post After invoking @p chThdWait() the thread pointer becomes invalid
* and must not be used as parameter for further system calls.
- * @note If @p CH_USE_DYNAMIC is not specified this function just waits for
+ * @note If @p CH_CFG_USE_DYNAMIC is not specified this function just waits for
* the thread termination, no memory allocators are involved.
*
* @param[in] tp pointer to the thread
@@ -442,7 +442,7 @@ msg_t chThdWait(thread_t *tp) {
chSysLock();
chDbgAssert(tp != currp, "chThdWait(), #1", "waiting self");
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
chDbgAssert(tp->p_refs > 0, "chThdWait(), #2", "not referenced");
#endif
if (tp->p_state != THD_STATE_FINAL) {
@@ -451,11 +451,11 @@ msg_t chThdWait(thread_t *tp) {
}
msg = tp->p_u.exitcode;
chSysUnlock();
-#if CH_USE_DYNAMIC
+#if CH_CFG_USE_DYNAMIC
chThdRelease(tp);
#endif
return msg;
}
-#endif /* CH_USE_WAITEXIT */
+#endif /* CH_CFG_USE_WAITEXIT */
/** @} */