cortexm_common: Fix isr_stack_usage

Refactor and add multiply by word size to get the usage in number of
bytes instead of in number of words.

Verified implementation by manual memory inspection in GDB.
This commit is contained in:
Joakim Nohlgård 2016-06-20 14:33:17 +02:00
parent 4c91121372
commit cb19a4c709

View File

@ -259,8 +259,12 @@ int thread_arch_isr_stack_usage(void)
{
uint32_t *ptr = &_sstack;
while (*(ptr++) == STACK_CANARY_WORD) {}
return (ISR_STACKSIZE - (ptr - &_sstack));
while(((*ptr) == STACK_CANARY_WORD) && (ptr < &_estack)) {
++ptr;
}
ptrdiff_t num_used_words = &_estack - ptr;
return num_used_words * sizeof(*ptr);
}
__attribute__((naked)) void NORETURN thread_arch_start_threading(void)