SPARC: optimized interrupt stack frame size

With this change we allocate stack space only for the registers we
actually store in the thread interrupt stack frame.

Furthermore, no function is called on with the interrupt context save
frame %sp so no full frame is needed here. ABI functions are called
later in the interrupt trap handler, but that is after the dedicated
interrupt stack has been installed.

This saves 96 bytes of stack space for each interrupted context.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
Martin Åberg 2020-11-30 12:19:24 +01:00 committed by Ioannis Glaropoulos
parent 3734465354
commit 356d37fb7f
2 changed files with 20 additions and 11 deletions

View file

@ -86,12 +86,12 @@ __sparc_trap_interrupt:
* task is restored.
*/
/* Allocate stack for isr context including ABI frame. */
/* Allocate stack for isr context. */
sub %fp, ISF_SIZE, %sp
/*
* %fp: %sp of interrupted task
* %sp: %sp of interrupted task - ISF_SIZE.
* (fits a full ABI frame + what we store here)
* (fits what we store here)
*
* Save the interrupted context.
*/

View file

@ -41,15 +41,24 @@
/* Interrupt stack frame */
#define ISF_PSR_OFFSET (STACK_FRAME_SIZE + 0x00)
#define ISF_PC_OFFSET (STACK_FRAME_SIZE + 0x04)
#define ISF_NPC_OFFSET (STACK_FRAME_SIZE + 0x08)
#define ISF_G1_OFFSET (STACK_FRAME_SIZE + 0x0c)
#define ISF_G2_OFFSET (STACK_FRAME_SIZE + 0x10)
#define ISF_G3_OFFSET (STACK_FRAME_SIZE + 0x14)
#define ISF_G4_OFFSET (STACK_FRAME_SIZE + 0x18)
#define ISF_Y_OFFSET (STACK_FRAME_SIZE + 0x1c)
#define ISF_PSR_OFFSET (0x40 + 0x00)
#define ISF_PC_OFFSET (0x40 + 0x04)
#define ISF_NPC_OFFSET (0x40 + 0x08)
#define ISF_G1_OFFSET (0x40 + 0x0c)
#define ISF_G2_OFFSET (0x40 + 0x10)
#define ISF_G3_OFFSET (0x40 + 0x14)
#define ISF_G4_OFFSET (0x40 + 0x18)
#define ISF_Y_OFFSET (0x40 + 0x1c)
#define ISF_SIZE (STACK_FRAME_SIZE + 0x20)
#if !defined(_FLAT)
#define ISF_SIZE (0x20)
#else
/*
* The flat ABI stores and loads "local" and "in" registers in the save area as
* part of function prologue and epilogue. So we allocate space for a new save
* area (0x40 byte) as part of the interrupt stack frame.
*/
#define ISF_SIZE (0x40 + 0x20)
#endif
#endif /* ZEPHYR_ARCH_SPARC_CORE_STACK_H_ */