diff --git a/kernel/Kconfig b/kernel/Kconfig index d0c16a622b3..03e586bbc46 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -138,6 +138,14 @@ config ISR_STACK_SIZE This option specifies the size of the stack used by interrupt service routines (ISRs), and during kernel initialization. +config THREAD_STACK_INFO + bool + prompt "Thread stack info" + default n + help + This option allows each thread to store the thread stack info into + the k_thread data structure. + config THREAD_CUSTOM_DATA bool prompt "Thread custom data" diff --git a/kernel/include/kernel_structs.h b/kernel/include/kernel_structs.h index 02bfc4526be..6263b8d612f 100644 --- a/kernel/include/kernel_structs.h +++ b/kernel/include/kernel_structs.h @@ -65,6 +65,16 @@ struct __thread_entry { }; #endif +#if defined(CONFIG_THREAD_STACK_INFO) +/* Contains the stack information of a thread */ +struct _thread_stack_info { + /* Stack Start */ + u32_t start; + /* Stack Size */ + u32_t size; +}; +#endif /* CONFIG_THREAD_STACK_INFO */ + /* can be used for creating 'dummy' threads, e.g. for pending on objects */ struct _thread_base { @@ -148,6 +158,11 @@ struct k_thread { int errno_var; #endif +#if defined(CONFIG_THREAD_STACK_INFO) + /* Stack Info */ + struct _thread_stack_info stack_info; +#endif /* CONFIG_THREAD_STACK_INFO */ + /* arch-specifics: must always be at the end */ struct _thread_arch arch; }; @@ -265,6 +280,11 @@ static ALWAYS_INLINE struct k_thread *_new_thread_init(char *pStack, thread->custom_data = NULL; #endif +#if defined(CONFIG_THREAD_STACK_INFO) + thread->stack_info.start = (u32_t)pStack; + thread->stack_info.size = (u32_t)stackSize; +#endif /* CONFIG_THREAD_STACK_INFO */ + return thread; }