From 4c7b7f38ba237508f2953bc37d2aff482909f369 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 25 Jul 2014 08:36:08 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7078 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/nil/include/nil.h | 7 +++++++ os/nil/src/nil.c | 11 +++-------- os/nil/templates/nilconf.h | 8 ++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'os') diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h index d6a7945d7..83d4208d2 100644 --- a/os/nil/include/nil.h +++ b/os/nil/include/nil.h @@ -181,6 +181,13 @@ typedef struct nil_thread thread_t; #define NIL_CFG_ENABLE_STACK_CHECK FALSE #endif +/** + * @brief System initialization hook. + */ +#if !defined(NIL_CFG_SYSTEM_INIT_HOOK) || defined(__DOXYGEN__) +#define NIL_CFG_SYSTEM_INIT_HOOK() {} +#endif + /** * @brief Threads descriptor structure extension. * @details User fields added to the end of the @p thread_t structure. diff --git a/os/nil/src/nil.c b/os/nil/src/nil.c index d7afe3b87..90e4b8379 100644 --- a/os/nil/src/nil.c +++ b/os/nil/src/nil.c @@ -75,6 +75,9 @@ void chSysInit(void) { /* Port layer initialization.*/ port_init(); + /* System initialization hook.*/ + NIL_CFG_SYSTEM_INIT_HOOK(); + /* Iterates through the list of defined threads.*/ tp = &nil.threads[0]; tcp = nil_thd_configs; @@ -87,9 +90,7 @@ void chSysInit(void) { PORT_SETUP_CONTEXT(tp, tcp->wend, tcp->funcp, tcp->arg); /* Initialization hook.*/ -#if defined(NIL_CFG_THREAD_EXT_INIT_HOOK) NIL_CFG_THREAD_EXT_INIT_HOOK(tp); -#endif tp++, tcp++; } @@ -129,9 +130,7 @@ void chSysHalt(const char *reason) { (void)reason; #endif -#if defined(NIL_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) NIL_CFG_SYSTEM_HALT_HOOK(reason); -#endif /* Harmless infinite loop.*/ while (true) @@ -300,11 +299,9 @@ void chSchRescheduleS(void) { thread_t *otp = nil.current; nil.current = nil.next; -#if defined(NIL_CFG_IDLE_LEAVE_HOOK) if (otp == &nil.threads[NIL_CFG_NUM_THREADS]) { NIL_CFG_IDLE_LEAVE_HOOK(); } -#endif port_switch(nil.next, otp); } } @@ -376,11 +373,9 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) { /* Is this thread ready to execute?*/ if (NIL_THD_IS_READY(ntp)) { nil.current = nil.next = ntp; -#if defined(NIL_CFG_IDLE_ENTER_HOOK) if (ntp == &nil.threads[NIL_CFG_NUM_THREADS]) { NIL_CFG_IDLE_ENTER_HOOK(); } -#endif port_switch(ntp, otp); return nil.current->u1.msg; } diff --git a/os/nil/templates/nilconf.h b/os/nil/templates/nilconf.h index 97826e307..f95b082ee 100644 --- a/os/nil/templates/nilconf.h +++ b/os/nil/templates/nilconf.h @@ -117,6 +117,14 @@ */ /*===========================================================================*/ +/** + * @brief System initialization hook. + */ +#if !defined(NIL_CFG_SYSTEM_INIT_HOOK) || defined(__DOXYGEN__) +#define NIL_CFG_SYSTEM_INIT_HOOK() { \ +} +#endif + /** * @brief Threads descriptor structure extension. * @details User fields added to the end of the @p thread_t structure. -- cgit v1.2.3