diff --git a/os/rt/include/chobjects.h b/os/rt/include/chobjects.h index 0b0de0720..6a1004a4c 100644 --- a/os/rt/include/chobjects.h +++ b/os/rt/include/chobjects.h @@ -199,6 +199,11 @@ struct ch_thread { * dynamic threading. */ stkalign_t *wabase; + /** + * @brief Working area end address. + * @note It is the 1st address after the working area. + */ + stkalign_t *waend; #endif /** * @brief Current thread state. diff --git a/os/rt/src/chinstances.c b/os/rt/src/chinstances.c index dd5af8cb1..eff561d2d 100644 --- a/os/rt/src/chinstances.c +++ b/os/rt/src/chinstances.c @@ -154,6 +154,7 @@ void chInstanceObjectInit(os_instance_t *oip, #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) oip->rlist.current->wabase = oicp->mainthread_base; + oip->rlist.current->waend = oicp->mainthread_end; #endif /* Setting up the caller as current thread.*/ diff --git a/os/rt/src/chsys.c b/os/rt/src/chsys.c index 468c06ad3..91da0b1dc 100644 --- a/os/rt/src/chsys.c +++ b/os/rt/src/chsys.c @@ -57,7 +57,7 @@ static CH_SYS_CORE0_MEMORY THD_WORKING_AREA(ch_c0_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE); #endif -#if CH_DBG_ENABLE_STACK_CHECK == TRUE +#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) extern stkalign_t __main_thread_stack_base__, __main_thread_stack_end__; #endif @@ -66,12 +66,9 @@ extern stkalign_t __main_thread_stack_base__, __main_thread_stack_end__; */ const os_instance_config_t ch_core0_cfg = { .name = "c0", -#if CH_DBG_ENABLE_STACK_CHECK == TRUE +#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) .mainthread_base = &__main_thread_stack_base__, .mainthread_end = &__main_thread_stack_end__, -#elif CH_CFG_USE_DYNAMIC == TRUE - .mainthread_base = NULL, - .mainthread_end = NULL, #endif #if CH_CFG_NO_IDLE_THREAD == FALSE .idlethread_base = THD_WORKING_AREA_BASE(ch_c0_idle_thread_wa), @@ -102,12 +99,9 @@ extern stkalign_t __c1_main_thread_stack_base__, __c1_main_thread_stack_end__; */ const os_instance_config_t ch_core1_cfg = { .name = "c1", -#if CH_DBG_ENABLE_STACK_CHECK == TRUE +#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) .mainthread_base = &__c1_main_thread_stack_base__, .mainthread_end = &__c1_main_thread_stack_end__, -#elif CH_CFG_USE_DYNAMIC == TRUE - .mainthread_base = NULL, - .mainthread_end = NULL, #endif #if CH_CFG_NO_IDLE_THREAD == FALSE .idlethread_base = THD_WORKING_AREA_BASE(ch_c1_idle_thread_wa), diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c index 04b3e639e..ff7121d02 100644 --- a/os/rt/src/chthreads.c +++ b/os/rt/src/chthreads.c @@ -190,6 +190,7 @@ thread_t *chThdCreateSuspendedI(const thread_descriptor_t *tdp) { #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) /* Stack boundary.*/ tp->wabase = tdp->wbase; + tp->waend = tdp->wend; #endif /* Setting up the port-dependent part of the working area.*/ @@ -359,6 +360,7 @@ thread_t *chThdCreateStatic(void *wsp, size_t size, #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) /* Stack boundary.*/ tp->wabase = (stkalign_t *)wsp; + tp->waend = (stkalign_t *)wsp + (size / sizeof (stkalign_t)); #endif /* Setting up the port-dependent part of the working area.*/ diff --git a/readme.txt b/readme.txt index 025d4f4bb..a34a7fe7b 100644 --- a/readme.txt +++ b/readme.txt @@ -74,6 +74,8 @@ ***************************************************************************** *** Next *** +- NEW: Added a "waend" field to the thread structure in RT for debug + convenience. - NEW: Removed obsolete sandbox code from ARMv7-M port. Now ARMv7-M-ALT is the official port for use with sandboxes. - NEW: Reworked HAL MAC driver, now with callback support.