From 075ff711f1c9cf031fa4708c6b704f120d9a509d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Aug 2011 09:00:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3192 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chsys.c | 6 ++++++ os/kernel/src/chthreads.c | 3 +++ 2 files changed, 9 insertions(+) (limited to 'os/kernel/src') 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 -- cgit v1.2.3