Skip to content

Commit 3adefa8

Browse files
committed
soc: nordic: vpr: align ESF_SW_IRQ_SIZEOF when new exception debug is used
There is new exception debugging mechanism for RISC-V which needs additional member in arch_esf structure. VPRs handle stacking partially in hw so exact position of some stack members needs to be at the end of arch_esf, so explicit padding is needed. Aligned also ESF_SW_IRQ_SIZEOF when exception debug is used. Added generation of __struct_soc_esf_SIZEOF which helps when calculating offsets. Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
1 parent 869881e commit 3adefa8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

arch/riscv/core/offsets/offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ GEN_OFFSET_STRUCT(arch_esf, soc_context);
127127
#endif
128128
#if defined(CONFIG_RISCV_SOC_OFFSETS)
129129
GEN_SOC_OFFSET_SYMS();
130+
GEN_ABSOLUTE_SYM(__struct_soc_esf_SIZEOF, sizeof(struct soc_esf));
130131
#endif
131132

132133
GEN_ABSOLUTE_SYM(__struct_arch_esf_SIZEOF, sizeof(struct arch_esf));

soc/nordic/common/vpr/soc_isr_stacking.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
#define VPR_CPU DT_INST(0, nordic_vpr)
1616

1717
#ifdef CONFIG_EXCEPTION_DEBUG
18-
#define ESF_CSF _callee_saved_t *csf
18+
/*
19+
* Explicit padding is needed for VPRs, because they use hardware stacking on part of arch_esf and
20+
* ESF_SW_IRQ_SIZEOF needs to be calculated accordingly.
21+
*/
22+
#define ESF_CSF \
23+
_callee_saved_t *csf; \
24+
unsigned long padding1; \
25+
unsigned long padding2; \
26+
unsigned long padding3;
1927
#else
2028
#define ESF_CSF
2129
#endif /* CONFIG_EXCEPTION_DEBUG */
@@ -90,10 +98,13 @@
9098

9199
/*
92100
* Size of the SW managed part of the ESF in case of interrupt
93-
* sizeof(__padding) + ... + sizeof(soc_context)
101+
* sizeof(s0) + sizeof(mstatus) + sizeof(soc_context) +...+ sizeof(ESF_CSF)
94102
*/
95-
#define ESF_SW_IRQ_SIZEOF (0x10)
96-
103+
#ifdef CONFIG_EXCEPTION_DEBUG
104+
#define ESF_SW_IRQ_SIZEOF (0x8 + __struct_soc_esf_SIZEOF + 0x10)
105+
#else
106+
#define ESF_SW_IRQ_SIZEOF (0x8 + __struct_soc_esf_SIZEOF)
107+
#endif
97108
/*
98109
* VPR needs aligned(8) SP when doing HW stacking, if this condition is not fulfilled it will move
99110
* SP by additional 4 bytes when HW stacking is done. This will be indicated by LSB bit in stacked

0 commit comments

Comments
 (0)