kernel: interrupt/idle stacks/threads as array

The set of interrupt stacks is now expressed as an array. We
also define the idle threads and their associated stacks this
way. This allows for iteration in cases where we have multiple
CPUs.

There is now a centralized declaration in kernel_internal.h.

On uniprocessor systems, z_interrupt_stacks has one element
and can be used in the same way as _interrupt_stack.

The IRQ stack for CPU 0 is now set in init.c instead of in
arch code.

The extern definition of the main thread stack is now removed,
this doesn't need to be in a header.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-03-12 15:37:29 -07:00 committed by Andrew Boie
commit 80a0d9d16b
29 changed files with 110 additions and 165 deletions

View file

@ -131,7 +131,8 @@ static void shell_stack_dump(const struct k_thread *thread, void *user_data)
size, unused, size - unused, size, pcnt);
}
extern K_THREAD_STACK_DEFINE(_interrupt_stack, CONFIG_ISR_STACK_SIZE);
extern K_THREAD_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
CONFIG_ISR_STACK_SIZE);
static int cmd_kernel_stacks(const struct shell *shell,
size_t argc, char **argv)
@ -144,26 +145,27 @@ static int cmd_kernel_stacks(const struct shell *shell,
k_thread_foreach(shell_stack_dump, (void *)shell);
/* Placeholder logic for interrupt stack until we have better
* kernel support, including dumping all IRQ stacks for SMP systems
* and hooks to dump arch-specific exception-related stack buffers.
*
* For now, dump data for the first IRQ stack defined in init.c
* kernel support, including dumping arch-specific exception-related
* stack buffers.
*/
buf = Z_THREAD_STACK_BUFFER(_interrupt_stack);
size = K_THREAD_STACK_SIZEOF(_interrupt_stack);
for (int i = 0; i < CONFIG_MP_NUM_CPUS; i++) {
buf = Z_THREAD_STACK_BUFFER(z_interrupt_stacks[i]);
size = K_THREAD_STACK_SIZEOF(z_interrupt_stacks[i]);
for (size_t i = 0; i < K_THREAD_STACK_SIZEOF(_interrupt_stack); i++) {
if (buf[i] == 0xAAU) {
unused++;
} else {
break;
for (size_t i = 0; i < size; i++) {
if (buf[i] == 0xAAU) {
unused++;
} else {
break;
}
}
}
shell_print(shell,
"%p IRQ 0 (real size %zu):\tunused %zu\tusage %zu / %zu (%zu %%)",
_interrupt_stack, size, unused, size - unused, size,
((size - unused) * 100U) / size);
shell_print(shell,
"%p IRQ %02d (real size %zu):\tunused %zu\tusage %zu / %zu (%zu %%)",
&z_interrupt_stacks[i], i, size, unused,
size - unused, size,
((size - unused) * 100U) / size);
}
return 0;
}