diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_DYNAMIC/cfg/chconf.h b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_DYNAMIC/cfg/chconf.h index bb68563a0..33599cb21 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_DYNAMIC/cfg/chconf.h +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_DYNAMIC/cfg/chconf.h @@ -805,6 +805,10 @@ /* Port-specific settings (override port settings defaulted in chcore.h). */ /*===========================================================================*/ +#define PORT_USE_SYSCALL TRUE + +#define PORT_SWITCHED_REGIONS_NUMBER 2 + #endif /* CHCONF_H */ /** @} */ diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_STATIC/cfg/chconf.h b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_STATIC/cfg/chconf.h index bb68563a0..d54e1af95 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_STATIC/cfg/chconf.h +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST_STATIC/cfg/chconf.h @@ -805,6 +805,8 @@ /* Port-specific settings (override port settings defaulted in chcore.h). */ /*===========================================================================*/ +#define PORT_USE_SYSCALL TRUE + #endif /* CHCONF_H */ /** @} */ diff --git a/os/common/ports/ARMv7-M/chcore.c b/os/common/ports/ARMv7-M/chcore.c index dfa060e46..2a55387e7 100644 --- a/os/common/ports/ARMv7-M/chcore.c +++ b/os/common/ports/ARMv7-M/chcore.c @@ -58,13 +58,13 @@ __attribute__((noinline)) void port_syslock_noinline(void) { port_lock(); - _stats_start_measure_crit_thd(); - _dbg_check_lock(); + __stats_start_measure_crit_thd(); + __dbg_check_lock(); } uint32_t port_get_s_psp(void) { - return (uint32_t)currp->ctx.syscall.psp; + return (uint32_t)__sch_get_currthread()->ctx.syscall.psp; } __attribute__((weak)) @@ -144,7 +144,7 @@ void SVC_Handler(void) { struct port_extctx *newctxp; /* Supervisor PSP from the thread context structure.*/ - s_psp = (uint32_t)currp->ctx.syscall.psp; + s_psp = (uint32_t)__sch_get_currthread()->ctx.syscall.psp; /* Pushing the port_linkctx into the supervisor stack.*/ s_psp -= sizeof (struct port_linkctx); @@ -334,7 +334,7 @@ void __port_irq_epilogue(void) { __set_CONTROL(control & ~1U); /* Switching to S-PSP taking it from the thread context.*/ - s_psp = (uint32_t)currp->ctx.syscall.psp; + s_psp = (uint32_t)__sch_get_currthread()->ctx.syscall.psp; /* Pushing the middle context for returning to the original frame and mode.*/ diff --git a/os/rt/include/chmtx.h b/os/rt/include/chmtx.h index 6030d4317..8fc3d60cd 100644 --- a/os/rt/include/chmtx.h +++ b/os/rt/include/chmtx.h @@ -92,6 +92,12 @@ struct ch_mutex { */ #define MUTEX_DECL(name) mutex_t name = __MUTEX_DATA(name) +#if CH_CFG_USE_MESSAGES_PRIORITY == TRUE +#define __ch_msg_insert(tp, qp) ch_sch_prio_insert(&tp->hdr.queue, qp) +#else +#define __ch_msg_insert(tp, qp) ch_queue_insert(&tp->hdr.queue, qp) +#endif + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ diff --git a/os/rt/src/chmsg.c b/os/rt/src/chmsg.c index a3e712428..a6f496f04 100644 --- a/os/rt/src/chmsg.c +++ b/os/rt/src/chmsg.c @@ -63,12 +63,6 @@ /* Module local functions. */ /*===========================================================================*/ -#if CH_CFG_USE_MESSAGES_PRIORITY == TRUE -#define msg_insert(tp, qp) ch_sch_prio_insert(&tp->hdr.queue, qp) -#else -#define msg_insert(tp, qp) ch_queue_insert(&tp->hdr.queue, qp) -#endif - /*===========================================================================*/ /* Module exported functions. */ /*===========================================================================*/ @@ -91,7 +85,7 @@ msg_t chMsgSend(thread_t *tp, msg_t msg) { chSysLock(); currtp->u.sentmsg = msg; - msg_insert(currtp, &tp->msgqueue); + __ch_msg_insert(currtp, &tp->msgqueue); if (tp->state == CH_STATE_WTMSG) { (void) chSchReadyI(tp); } diff --git a/os/sb/host/sbhost.c b/os/sb/host/sbhost.c index af6d3b038..83d37b3c3 100644 --- a/os/sb/host/sbhost.c +++ b/os/sb/host/sbhost.c @@ -163,7 +163,7 @@ void sbStart(sb_class_t *sbcp, const sb_config_t *config) { msg_t sbSendMessageTimeout(sb_class_t *sbcp, msg_t msg, sysinterval_t timeout) { - thread_t *ctp = currp; + thread_t *ctp = __sch_get_currthread(); chDbgCheck(sbcp != NULL); @@ -171,7 +171,7 @@ msg_t sbSendMessageTimeout(sb_class_t *sbcp, /* Sending the message.*/ ctp->u.sentmsg = msg; - __msg_insert(ctp, &sbcp->tp->msgqueue); + __ch_msg_insert(ctp, &sbcp->tp->msgqueue); if (sbcp->tp->state == CH_STATE_WTMSG) { (void) chSchReadyI(sbcp->tp); }