From b1b6a741702a7ca1bf5b021f7f8504784a26aa19 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Tue, 26 Sep 2017 05:28:27 +1000 Subject: [PATCH] or1k: Use EXCEPTION_STACK_SIZE of 256bytes. or1k defines a 128 byte "red zone" after the stack that can not be touched by the exception handler. We also need 128 bytes to store the 32 registers. --- litex/soc/software/libbase/crt0-or1k.S | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/litex/soc/software/libbase/crt0-or1k.S b/litex/soc/software/libbase/crt0-or1k.S index 5db4142a..ff77910d 100644 --- a/litex/soc/software/libbase/crt0-or1k.S +++ b/litex/soc/software/libbase/crt0-or1k.S @@ -19,7 +19,18 @@ #include -#define EXCEPTION_STACK_SIZE (4*32) +/* + * OR1K Architecture has a 128 byte "red zone" after the stack that can not be + * touched by exception handlers. GCC uses this red zone for locals and + * temps without needing to change the stack pointer. + */ +#define OR1K_RED_ZONE_SIZE 128 + +/* + * We need 4 bytes (32 bits) * 32 registers space on the stack to save all the + * registers. + */ +#define EXCEPTION_STACK_SIZE ((4*32) + OR1K_RED_ZONE_SIZE) #define HANDLE_EXCEPTION ; \ l.addi r1, r1, -EXCEPTION_STACK_SIZE ; \ -- 2.30.2