git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13760 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2020-07-14 09:41:33 +00:00
parent 7ec444ada9
commit 9f4fea9677
3 changed files with 104 additions and 57 deletions

View File

@ -105,7 +105,7 @@ include $(CHIBIOS)/os/hal/boards/ST_NUCLEO144_L552ZE/board.mk
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v8m-ml.mk
include $(CHIBIOS)/os/common/ports/ARMv8-M-ML/compilers/GCC/mk/port.mk
# Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).

View File

@ -322,7 +322,7 @@ struct port_extctx {
uint32_t lr_thd;
uint32_t pc;
uint32_t xpsr;
#if CORTEX_USE_FPU
#if (CORTEX_USE_FPU == TRUE) || defined(__DOXYGEN__)
uint32_t s0;
uint32_t s1;
uint32_t s2;
@ -341,7 +341,7 @@ struct port_extctx {
uint32_t s15;
uint32_t fpscr;
uint32_t reserved;
#endif /* CORTEX_USE_FPU */
#endif /* CORTEX_USE_FPU == TRUE */
};
/**
@ -350,7 +350,10 @@ struct port_extctx {
* switch.
*/
struct port_intctx {
#if CORTEX_USE_FPU
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
uint32_t splim;
#endif
#if (CORTEX_USE_FPU == TRUE) || defined(__DOXYGEN__)
uint32_t s16;
uint32_t s17;
uint32_t s18;
@ -367,7 +370,7 @@ struct port_intctx {
uint32_t s29;
uint32_t s30;
uint32_t s31;
#endif /* CORTEX_USE_FPU */
#endif /* CORTEX_USE_FPU == TRUE */
uint32_t r4;
uint32_t r5;
uint32_t r6;
@ -407,6 +410,31 @@ struct port_context {
#define PORT_IRQ_IS_VALID_KERNEL_PRIORITY(n) \
(((n) >= CORTEX_MAX_KERNEL_PRIORITY) && ((n) < CORTEX_PRIORITY_LEVELS))
/**
* @brief Initialization of stack check part of thread context.
*/
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
#define PORT_SETUP_CONTEXT_SPLIM(tp, wbase) \
(tp)->ctx.sp->splim = (uint32_t)(wbase)
#else
#define PORT_SETUP_CONTEXT_SPLIM(tp, wbase)
#endif
/**
* @brief Initialization of FPU part of thread context.
*/
#if (CORTEX_USE_FPU == TRUE) || defined(__DOXYGEN__)
#define PORT_SETUP_CONTEXT_FPU(tp) \
(tp)->ctx.sp->fpscr = (uint32_t)0
#else
#define PORT_SETUP_CONTEXT_FPU(tp)
#endif
/**
* @brief Initialization of MPU part of thread context.
*/
#define PORT_SETUP_CONTEXT_MPU(tp)
/**
* @brief Platform dependent part of the @p chThdCreateI() API.
* @details This code usually setup the context switching frame represented
@ -418,6 +446,9 @@ struct port_context {
(tp)->ctx.sp->r4 = (uint32_t)(pf); \
(tp)->ctx.sp->r5 = (uint32_t)(arg); \
(tp)->ctx.sp->lr = (uint32_t)__port_thread_start; \
PORT_SETUP_CONTEXT_SPLIM(tp, wbase); \
PORT_SETUP_CONTEXT_FPU(tp); \
PORT_SETUP_CONTEXT_MPU(tp); \
} while (0)
/**

View File

@ -89,8 +89,24 @@ __port_switch:
/* Saving FPU context.*/
vpush {s16-s31}
#endif
#if CH_DBG_ENABLE_STACK_CHECK
/* Saving stack limit register.*/
mrs r3, PSPLIM
push {r3}
movs r3, #0
msr PSPLIM, r3 /* Temporarily disabling stack check.*/
#endif
/* Switching stacks.*/
str sp, [r1, #CONTEXT_OFFSET]
ldr sp, [r0, #CONTEXT_OFFSET]
#if CH_DBG_ENABLE_STACK_CHECK
pop {r3}
msr PSPLIM, r3
#endif
#if CORTEX_USE_FPU
/* Restoring FPU context.*/
vpop {s16-s31}
@ -142,7 +158,7 @@ __port_switch_from_isr:
#endif
bl chSchDoPreemption
#if CH_DBG_SYSTEM_STATE_CHECK
bl _dbg_check_unlock
bl __dbg_check_unlock
#endif
#if CH_DBG_STATISTICS
bl __stats_stop_measure_crit_thd