From 464676510bfb4b5b0f6950a19072e88258636a60 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Thu, 16 Jun 2016 13:18:49 -0700 Subject: [PATCH] nios2: crt0: init interrupt stack as well CONFIG_INIT_STACKS should initialize all stack regions with 0xaa. Make sure the initial interrupt stack gets this as well. Take care not to exceed the bounds of the array if it is not 4-byte aligned. Change-Id: Ib23329ac84a5a8515272be2944f948e8faba65b3 Signed-off-by: Andrew Boie --- arch/nios2/core/crt0.S | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/nios2/core/crt0.S b/arch/nios2/core/crt0.S index 2ee23a2f785..1842c53f2b2 100644 --- a/arch/nios2/core/crt0.S +++ b/arch/nios2/core/crt0.S @@ -62,6 +62,25 @@ SECTION_FUNC(TEXT, __text_start) * ZEP-275 */ +#ifdef CONFIG_INIT_STACKS + /* Pre-populate all bytes in _interrupt_stack with 0xAA */ + movhi r1, %hi(_interrupt_stack) + ori r1, r1, %lo(_interrupt_stack) + movhi r2, %hi(CONFIG_ISR_STACK_SIZE) + ori r2, r2, %lo(CONFIG_ISR_STACK_SIZE) + subi r2, r2, 3 + /* Put constant 0xaaaaaaaa in r3 */ + movhi r3, 0xaaaa + ori r3, r3, 0xaaaa +1: + /* Loop through the _interrupt_stack treating it as an array of + * uint32_t, setting each element to r3 */ + stw r3, (r1) + subi r2, r2, 4 + addi r1, r1, 4 + blt r0, r2, 1b +#endif + /* Set up the initial stack pointer to the interrupt stack, safe * to use this as the CPU boots up with interrupts disabled and we * don't turn them on until much later, when the kernel is on