arch: k210: Fix stack coloring for the idle thread stack

Summary:
- I noticed that stack coloring for the idle thread stacks does
  not work due to the recent changes
- This commit fixes this issue

Impact:
- k210 only

Testing:
- Tested with both maix-bit (dev board) and QEMU

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2021-06-12 07:32:25 +09:00 committed by Xiang Xiao
parent fd46d7a74f
commit bafac8b560
5 changed files with 40 additions and 12 deletions

View File

@ -29,7 +29,7 @@ CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c riscv_fault.c
CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_fault.c
CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c
CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c
CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c

View File

@ -30,6 +30,7 @@
#include <nuttx/userspace.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "k210.h"
@ -44,6 +45,28 @@
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_allocate_heap
*
* Description:
* This function will be called to dynamically set aside the heap region.
*
* For the kernel build (CONFIG_BUILD_PROTECTED=y) with both kernel- and
* user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the
* size of the unprotected, user-space heap.
*
* If a protected kernel-space heap is provided, the kernel heap must be
* allocated (and protected) by an analogous up_allocate_kheap().
*
****************************************************************************/
void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
{
board_autoled_on(LED_HEAPALLOCATE);
*heap_start = (FAR void *)K210_HEAP_START;
*heap_size = CONFIG_RAM_END - K210_HEAP_START;
}
/****************************************************************************
* Name: up_allocate_kheap
*

View File

@ -112,6 +112,17 @@ void k210_cpu_boot(int cpu)
showprogress('b');
DPRINTF("CPU%d Started\n", this_cpu());
#ifdef CONFIG_STACK_COLORATION
FAR struct tcb_s *tcb = this_task();
/* If stack debug is enabled, then fill the stack with a
* recognizable value that we can use later to test for high
* water marks.
*/
riscv_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size);
#endif
/* TODO: Setup FPU */
/* Clear machine software interrupt for CPU(cpu) */

View File

@ -51,9 +51,9 @@ extern uintptr_t *_default_stack_limit;
#define K210_IDLESTACK1_TOP (K210_IDLESTACK1_BASE + CONFIG_IDLETHREAD_STACKSIZE)
#if defined(CONFIG_SMP) && (CONFIG_SMP_NCPUS > 1)
#define K210_IDLESTACK_TOP (K210_IDLESTACK1_TOP)
#define K210_HEAP_START (K210_IDLESTACK1_TOP)
#else
#define K210_IDLESTACK_TOP (K210_IDLESTACK0_TOP)
#define K210_HEAP_START (K210_IDLESTACK0_TOP)
#endif
#endif /* _ARCH_RISCV_SRC_K210_K210_MEMORYMAP_H */

View File

@ -48,17 +48,11 @@
* Public Data
****************************************************************************/
/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
* linker script. _ebss lies at the end of the BSS region. The idle task
* stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
* The IDLE thread is the thread that the system boots on and, eventually,
* becomes the IDLE, do nothing task that runs only when there is nothing
* else to run. The heap continues from there until the end of memory.
* g_idle_topstack is a read-only variable the provides this computed
* address.
/* NOTE: g_idle_topstack needs to point the top of the idle stack
* for CPU0 and this value is used in up_initial_state()
*/
uintptr_t g_idle_topstack = K210_IDLESTACK_TOP;
uintptr_t g_idle_topstack = K210_IDLESTACK0_TOP;
volatile bool g_serial_ok = false;
extern void k210_cpu_boot(uint32_t);