aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/kernel/include/chsys.h7
-rw-r--r--os/kernel/include/chthreads.h4
-rw-r--r--os/kernel/src/chsys.c3
-rw-r--r--os/kernel/src/chthreads.c8
-rw-r--r--os/kernel/templates/chconf.h46
5 files changed, 52 insertions, 16 deletions
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h
index 2f94c5209..22396f41f 100644
--- a/os/kernel/include/chsys.h
+++ b/os/kernel/include/chsys.h
@@ -45,7 +45,14 @@
* error in the application code that triggers an assertion while
* in debug mode.
*/
+#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
#define chSysHalt() port_halt()
+#else
+#define chSysHalt() { \
+ SYSTEM_HALT_HOOK(); \
+ port_halt(); \
+}
+#endif
/**
* @brief Performs a context switch.
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h
index 1e659b768..9748166b9 100644
--- a/os/kernel/include/chthreads.h
+++ b/os/kernel/include/chthreads.h
@@ -160,8 +160,10 @@ struct Thread {
*/
void *p_mpool;
#endif
+#if defined(THREAD_EXT_FIELDS_HOOK)
/* Extra fields defined in chconf.h.*/
- THREAD_EXT_FIELDS
+ THREAD_EXT_FIELDS_HOOK
+#endif
};
/** @brief Thread state: Ready to run, waiting on the ready list.*/
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index d34e7e73a..22860b317 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -117,6 +117,9 @@ void chSysTimerHandlerI(void) {
currp->p_time++;
#endif
chVTDoTickI();
+#if defined(SYSTEM_TICK_EVENT_HOOK)
+ SYSTEM_TICK_EVENT_HOOK();
+#endif
}
#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index 3f2f88899..ae38dc11a 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -94,7 +94,9 @@ Thread *init_thread(Thread *tp, tprio_t prio) {
#if CH_USE_EVENTS
tp->p_epending = 0;
#endif
- THREAD_EXT_INIT(tp);
+#if defined(THREAD_EXT_EXIT_HOOK)
+ THREAD_EXT_INIT_HOOK(tp);
+#endif
return tp;
}
@@ -357,7 +359,9 @@ void chThdExit(msg_t msg) {
chSysLock();
tp->p_u.exitcode = msg;
- THREAD_EXT_EXIT(tp);
+#if defined(THREAD_EXT_EXIT_HOOK)
+ THREAD_EXT_EXIT_HOOK(tp);
+#endif
#if CH_USE_WAITEXIT
while (notempty(&tp->p_waiting))
chSchReadyI(list_remove(&tp->p_waiting));
diff --git a/os/kernel/templates/chconf.h b/os/kernel/templates/chconf.h
index 6522e0b3b..8f2c4b3e3 100644
--- a/os/kernel/templates/chconf.h
+++ b/os/kernel/templates/chconf.h
@@ -434,11 +434,9 @@
* @brief Threads descriptor structure hook.
* @details User fields added to the end of the @p Thread structure.
*/
-#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
-#define THREAD_EXT_FIELDS \
-struct { \
- /* Add threads custom fields here.*/ \
-};
+#if !defined(THREAD_EXT_FIELDS_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_FIELDS_HOOK \
+ /* Add threads custom fields here.*/
#endif
/**
@@ -448,9 +446,9 @@ struct { \
* @note It is invoked from within @p chThdInit() and implicitily from all
* the threads creation APIs.
*/
-#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
-#define THREAD_EXT_INIT(tp) { \
- /* Add threads initialization code here.*/ \
+#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_INIT_HOOK(tp) { \
+ /* Add threads initialization code here.*/ \
}
#endif
@@ -462,9 +460,9 @@ struct { \
* @note It is also invoked when the threads simply return in order to
* terminate.
*/
-#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
-#define THREAD_EXT_EXIT(tp) { \
- /* Add threads finalization code here.*/ \
+#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_EXIT_HOOK(tp) { \
+ /* Add threads finalization code here.*/ \
}
#endif
@@ -473,8 +471,30 @@ struct { \
* @details This hook is continuously invoked by the idle thread loop.
*/
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
-#define IDLE_LOOP_HOOK() { \
- /* Idle loop code here.*/ \
+#define IDLE_LOOP_HOOK() { \
+ /* Idle loop code here.*/ \
+}
+#endif
+
+/**
+ * @brief System tick event hook.
+ * @details This hook is invoked in the system tick handler immediately
+ * after processing the virtual timers queue.
+ */
+#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
+#define SYSTEM_TICK_EVENT_HOOK() { \
+ /* System tick event code here.*/ \
+}
+#endif
+
+/**
+ * @brief System halt hook.
+ * @details This hook is invoked in case to a system halting error before
+ * the system is halted.
+ */
+#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
+#define SYSTEM_HALT_HOOK() { \
+ /* System halt code here.*/ \
}
#endif