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 <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-06-16 13:18:49 -07:00 committed by Inaky Perez-Gonzalez
parent 9ac955a762
commit 464676510b

View file

@ -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