diff options
Diffstat (limited to 'os/kernel')
-rw-r--r-- | os/kernel/include/chdebug.h | 8 | ||||
-rw-r--r-- | os/kernel/include/chschd.h | 4 | ||||
-rw-r--r-- | os/kernel/include/chthreads.h | 30 | ||||
-rw-r--r-- | os/kernel/src/chsys.c | 6 | ||||
-rw-r--r-- | os/kernel/src/chthreads.c | 3 |
5 files changed, 35 insertions, 16 deletions
diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h index 2fb3b2385..b2edf176e 100644 --- a/os/kernel/include/chdebug.h +++ b/os/kernel/include/chdebug.h @@ -90,13 +90,15 @@ typedef struct { *
* @api
*/
+#if !defined(chDbgCheck)
#define chDbgCheck(c, func) { \
if (!(c)) \
- chDbgPanic(__QUOTE_THIS(func)"(), line "__QUOTE_THIS(__LINE__)); \
+ chDbgPanic(__QUOTE_THIS(func)"()"); \
}
+#endif /* !defined(chDbgCheck) */
#else /* !CH_DBG_ENABLE_CHECKS */
#define chDbgCheck(c, func) { \
- (void)(c), (void)__QUOTE_THIS(func)"(), line "__QUOTE_THIS(__LINE__); \
+ (void)(c), (void)__QUOTE_THIS(func)"()"; \
}
#endif /* !CH_DBG_ENABLE_CHECKS */
@@ -118,10 +120,12 @@ typedef struct { *
* @api
*/
+#if !defined(chDbgAssert)
#define chDbgAssert(c, m, r) { \
if (!(c)) \
chDbgPanic(m); \
}
+#endif /* !defined(chDbgAssert) */
#else /* !CH_DBG_ENABLE_ASSERTS */
#define chDbgAssert(c, m, r) {(void)(c);}
#endif /* !CH_DBG_ENABLE_ASSERTS */
diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index e154da863..cd545a05e 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -76,12 +76,12 @@ typedef struct { initialized to zero. */
struct context r_ctx; /**< @brief Not used, present because
offsets. */
-#if CH_USE_REGISTRY
+#if CH_USE_REGISTRY || defined(__DOXYGEN__)
Thread *r_newer; /**< @brief Newer registry element. */
Thread *r_older; /**< @brief Older registry element. */
#endif
/* End of the fields shared with the Thread structure.*/
-#if CH_TIME_QUANTUM > 0
+#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
cnt_t r_preempt; /**< @brief Round robin counter. */
#endif
Thread *r_current; /**< @brief The currently running
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index e0f1b3e95..b02960bd4 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -44,17 +44,23 @@ struct Thread { /* End of the fields shared with the ThreadsQueue structure. */
tprio_t p_prio; /**< @brief Thread priority. */
struct context p_ctx; /**< @brief Processor context. */
-#if CH_USE_REGISTRY
+#if CH_USE_REGISTRY || defined(__DOXYGEN__)
Thread *p_newer; /**< @brief Newer registry element. */
Thread *p_older; /**< @brief Older registry element. */
#endif
/* End of the fields shared with the ReadyList structure. */
-#if CH_USE_REGISTRY
+#if CH_USE_REGISTRY || defined(__DOXYGEN__)
/**
* @brief Thread name or @p NULL.
*/
const char *p_name;
#endif
+#if CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__)
+ /**
+ * @brief Thread stack boundary.
+ */
+ stkalign_t *p_stklimit;
+#endif
/**
* @brief Current thread state.
*/
@@ -63,19 +69,19 @@ struct Thread { * @brief Various thread flags.
*/
tmode_t p_flags;
-#if CH_USE_DYNAMIC
+#if CH_USE_DYNAMIC || defined(__DOXYGEN__)
/**
* @brief References to this thread.
*/
trefs_t p_refs;
#endif
-#if CH_USE_NESTED_LOCKS
+#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
/**
* @brief Number of nested locks.
*/
cnt_t p_locks;
#endif
-#if CH_DBG_THREADS_PROFILING
+#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
/**
* @brief Thread consumed time in ticks.
* @note This field can overflow.
@@ -109,22 +115,22 @@ struct Thread { * states.
*/
void *wtobjp;
-#if CH_USE_EVENTS
+#if CH_USE_EVENTS || defined(__DOXYGEN__)
/**
* @brief Enabled events mask.
- * @note This field is only valied while the thread is in the
+ * @note This field is only valid while the thread is in the
* @p THD_STATE_WTOREVT or @p THD_STATE_WTANDEVT states.
*/
eventmask_t ewmask;
#endif
} p_u;
-#if CH_USE_WAITEXIT
+#if CH_USE_WAITEXIT || defined(__DOXYGEN__)
/**
* @brief Termination waiting list.
*/
ThreadsList p_waiting;
#endif
-#if CH_USE_MESSAGES
+#if CH_USE_MESSAGES || defined(__DOXYGEN__)
/**
* @brief Messages queue.
*/
@@ -134,13 +140,13 @@ struct Thread { */
msg_t p_msg;
#endif
-#if CH_USE_EVENTS
+#if CH_USE_EVENTS || defined(__DOXYGEN__)
/**
* @brief Pending events mask.
*/
eventmask_t p_epending;
#endif
-#if CH_USE_MUTEXES
+#if CH_USE_MUTEXES || defined(__DOXYGEN__)
/**
* @brief List of the mutexes owned by this thread.
* @note The list is terminated by a @p NULL in this field.
@@ -151,7 +157,7 @@ struct Thread { */
tprio_t p_realprio;
#endif
-#if CH_USE_DYNAMIC && CH_USE_MEMPOOLS
+#if (CH_USE_DYNAMIC && CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
/**
* @brief Memory Pool where the thread workspace is returned.
*/
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c index 8d9ce4905..4c8cd708d 100644 --- a/os/kernel/src/chsys.c +++ b/os/kernel/src/chsys.c @@ -77,6 +77,9 @@ void _idle_thread(void *p) { */
void chSysInit(void) {
static Thread mainthread;
+#if CH_DBG_ENABLE_STACK_CHECK
+ extern stkalign_t __main_thread_stack_base__;
+#endif
port_init();
_scheduler_init();
@@ -94,6 +97,9 @@ void chSysInit(void) { /* Now this instructions flow becomes the main thread.*/
setcurrp(_thread_init(&mainthread, NORMALPRIO));
currp->p_state = THD_STATE_CURRENT;
+#if CH_DBG_ENABLE_STACK_CHECK
+ currp->p_stklimit = &__main_thread_stack_base__;
+#endif
chSysEnable();
chRegSetThreadName("main");
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index b68263a7b..182de7673 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -99,6 +99,9 @@ Thread *_thread_init(Thread *tp, tprio_t prio) { #if CH_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);
#endif
|