5#include <RTE_Components.h>
6#include CMSIS_device_header
34_Static_assert(
sizeof(
ExceptionFrame) % 8 == 0,
"The size of ExceptionFrame structure is not divisible by 8!");
44 uint32_t fpu_regs[16];
49_Static_assert(
sizeof(
ExceptionFrameFP) % 8 == 0,
"The size of ExceptionFrameFP structure is not divisible by 8!");
52#define EXCEPTION_FRAME_ENTRIES (sizeof(ExceptionFrame) / sizeof(uint32_t))
54#define EXCEPTION_FRAME_FP_ENTRIES (sizeof(ExceptionFrameFP) / sizeof(uint32_t))
56#define ALWAYS_INLINE __STATIC_FORCEINLINE
64#if defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__)
70 "POP {R0, R1, R2, R3}\n\t"
86 "POP {R0, R1, R2, R3}\n\t"
102#define SAVE_CONTEXT() \
104 ".syntax unified\n\t" \
107 "STMEA r0!, {r4 - r7}\n\t" \
113 "STMEA r0!, {r4 - r7}\n\t" \
116 : : : "r0", "r4", "r5", "r6", "r7", "memory" \
129#define LOAD_CONTEXT() \
131 ".syntax unified\n\t" \
133 "LDMFD r0!, {r4 - r7}\n\t" \
138 "LDMFD r0!, {r4 - r7}\n\t" \
140 : : : "r0", "r4", "r5", "r6", "r7", "memory" \
232 ".syntax unified\n\t"
246 ".syntax unified\n\t"
262#if defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__)
268 ".syntax unified\n\t"
269 "LDR R0, =0xFFFFFFF9\n\t"
271 "LDR R0, =0x01000000\n\t"
284 :
"r" (continue_here)
294 ".syntax unified\n\t"
295 "MOV R0, #0x01000000\n\t"
298 "MOV LR, #0xFFFFFFF9\n\t"
309 :
"r" (continue_here)
317#if defined(__ARM_ARCH_8M_BASE__) || defined(__ARM_ARCH_8M_MAIN__)
318 return (return_addr & EXC_RETURN_FTYPE) == 0;
319#elif defined(__ARM_ARCH_6M__)
322 return return_addr == EXC_RETURN_THREAD_PSP_FPU;
328#if defined(__ARM_ARCH_8M_BASE__) || defined(__ARM_ARCH_8M_MAIN__)
329 return (return_addr & (EXC_RETURN_MODE | EXC_RETURN_SPSEL)) == (EXC_RETURN_MODE | EXC_RETURN_SPSEL);
330#elif defined(__ARM_ARCH_6M__)
331 return return_addr == EXC_RETURN_THREAD_PSP;
333 return return_addr == EXC_RETURN_THREAD_PSP || return_addr == EXC_RETURN_THREAD_PSP_FPU;
uint32_t * get_exception_arg_addr(ExceptionFrame *frame, unsigned argno, bool fp_active)
Retrieve address of n-th argument from exception frame.
Definition cortex.c:47
static void set_exception_pc_lr(ExceptionFrame *frame, void *pc, void(*lr)(void))
Configure PC and LR register values in exception frame.
Definition cortex.h:188
static unsigned get_exception_argument(ExceptionFrame *frame, unsigned argno, bool fp_active)
Retrieve value of exception frame function call argument.
Definition cortex.h:162
ALWAYS_INLINE void __set_LR(void *lr)
Set value of process LR.
Definition cortex.h:243
static bool cortex_is_thread_psp_used(uint32_t return_addr)
Definition cortex.h:326
static void set_exception_argument(ExceptionFrame *frame, unsigned argno, unsigned value, bool fp_active)
Set value of exception frame function call argument.
Definition cortex.h:175
#define ALWAYS_INLINE
Definition cortex.h:56
static bool cortex_is_fpu_used(uint32_t return_addr)
Definition cortex.h:315
ALWAYS_INLINE void __ISR_return()
Perform same actions as normal ISR return does.
Definition cortex.h:83
ExceptionFrame * shim_exception_frame(ExceptionFrame *frame, unsigned args, bool fp_active)
Creates space for additional arguments under exception frame.
Definition cortex.c:319
ALWAYS_INLINE void * __get_LR(void)
Get value of process LR.
Definition cortex.h:228
ExceptionFrame * pop_exception_frame(ExceptionFrame *frame, unsigned args, bool fp_active)
Remove exception frame from thread's stack.
Definition cortex.c:341
ALWAYS_INLINE void __forge_shutdown_exception_frame(void(*continue_here)(void))
Forges shutdown exception frame.
Definition cortex.h:291
ExceptionFrame * push_exception_frame(ExceptionFrame *frame, unsigned args, bool fp_active)
Duplicate exception frame on thread's stack.
Definition cortex.c:286
Exception frame with FPU context saved.
Definition cortex.h:38
uint32_t xpsr
Definition cortex.h:43
void * pc
Definition cortex.h:42
uint32_t r12
Definition cortex.h:40
uint32_t fpscr
Definition cortex.h:45
uint32_t __spacer
Definition cortex.h:46
Full RISC-V trap context frame.
Definition exception_frame.h:176
void(* lr)(void)
Definition cortex.h:25
void * pc
Definition cortex.h:26
uint32_t xpsr
Definition cortex.h:27
uint32_t r12
Definition cortex.h:24