Enabled MPU stack check.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14865 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
102016ca2e
commit
f68cb0f52c
|
@ -55,19 +55,38 @@
|
|||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if (PORT_ENABLE_GUARD_PAGES == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Setting up MPU region for the current thread.
|
||||
*/
|
||||
void __port_set_region(void) {
|
||||
|
||||
mpuSetRegionAddress(PORT_USE_GUARD_MPU_REGION,
|
||||
chThdGetSelfX()->wabase);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Tail ISR context switch code.
|
||||
*
|
||||
* @return The threads pointers encoded in a single 64 bits value.
|
||||
*/
|
||||
uint64_t port_schedule_next(void) {
|
||||
uint64_t __port_schedule_next(void) {
|
||||
|
||||
/* Note, not an error, we are outside the ISR already.*/
|
||||
chSysLock();
|
||||
|
||||
if (likely(chSchIsPreemptionRequired())) {
|
||||
return ((uint64_t)(uint32_t)chThdGetSelfX() << 32) |
|
||||
((uint64_t)(uint32_t)chSchSelectFirst() << 0);
|
||||
thread_t *otp, *ntp;
|
||||
|
||||
otp = chThdGetSelfX();
|
||||
ntp = chSchSelectFirst();
|
||||
|
||||
#if PORT_ENABLE_GUARD_PAGES == TRUE
|
||||
mpuSetRegionAddress(PORT_USE_GUARD_MPU_REGION, ntp->wabase);
|
||||
#endif
|
||||
|
||||
return ((uint64_t)(uint32_t)otp << 32) | ((uint64_t)(uint32_t)ntp << 0);
|
||||
}
|
||||
|
||||
chSysUnlock();
|
||||
|
@ -118,7 +137,7 @@ void port_init(os_instance_t *oip) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if PORT_USE_SYSCALL == TRUE
|
||||
#if (PORT_ENABLE_GUARD_PAGES == TRUE) || (PORT_USE_SYSCALL == TRUE)
|
||||
/* MPU is enabled.*/
|
||||
mpuEnable(MPU_CTRL_PRIVDEFENA);
|
||||
#endif
|
||||
|
|
|
@ -214,6 +214,10 @@
|
|||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if (CH_DBG_ENABLE_STACK_CHECK == FALSE) && (PORT_ENABLE_GUARD_PAGES == TRUE)
|
||||
#error "PORT_ENABLE_GUARD_PAGES requires CH_DBG_ENABLE_STACK_CHECK"
|
||||
#endif
|
||||
|
||||
#if (PORT_SWITCHED_REGIONS_NUMBER < 0) || (PORT_SWITCHED_REGIONS_NUMBER > 4)
|
||||
#error "invalid PORT_SWITCHED_REGIONS_NUMBER value"
|
||||
#endif
|
||||
|
@ -707,7 +711,7 @@ struct port_context {
|
|||
#if PORT_ENABLE_GUARD_PAGES == FALSE
|
||||
#define port_switch(ntp, otp) do { \
|
||||
struct port_intctx *r13 = (struct port_intctx *)__get_PSP(); \
|
||||
if ((stkalign_t *)(r13 - 1) < (otp)->wabase) { \
|
||||
if ((stkalign_t *)(void *)(r13 - 1) < (otp)->wabase) { \
|
||||
chSysHalt("stack overflow"); \
|
||||
} \
|
||||
__port_switch(ntp, otp); \
|
||||
|
|
|
@ -243,7 +243,7 @@ PendSV_Handler:
|
|||
mrs r3, BASEPRI
|
||||
push {r3, lr}
|
||||
|
||||
bl port_schedule_next
|
||||
bl __port_schedule_next
|
||||
cmp r0, #0
|
||||
it eq
|
||||
popeq {r3, pc}
|
||||
|
@ -293,6 +293,9 @@ PendSV_Handler:
|
|||
.thumb_func
|
||||
.globl __port_thread_start
|
||||
__port_thread_start:
|
||||
#if PORT_ENABLE_GUARD_PAGES
|
||||
bl __port_set_region
|
||||
#endif
|
||||
#if CH_DBG_SYSTEM_STATE_CHECK
|
||||
bl __dbg_check_unlock
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue