Syscall and VRQ return paths improved.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15780 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2022-09-10 13:56:17 +00:00
parent 4d0df2442b
commit 8d3f1beaff
2 changed files with 17 additions and 14 deletions

View File

@ -1216,19 +1216,11 @@ void __sb_abort(msg_t msg) {
chSysHalt("zombies"); chSysHalt("zombies");
} }
void __port_do_syscall_entry(struct port_extctx *ectxpxx, void __port_do_syscall_entry(struct port_extctx *ectxp,
uint32_t n) { uint32_t n) {
extern void __sb_dispatch_syscall(struct port_extctx *ctxp, uint32_t n); extern void __sb_dispatch_syscall(struct port_extctx *ctxp, uint32_t n);
thread_t *tp = __sch_get_currthread(); thread_t *tp = __sch_get_currthread();
struct port_extctx *ectxp, *newctxp; struct port_extctx *newctxp;
uint32_t u_psp;
(void)ectxpxx;
/* Caller context in unprivileged memory.*/
u_psp = __get_PSP();
ectxp = (struct port_extctx *)u_psp;
__port_syscall_set_u_psp(tp, u_psp);
/* Return context for change in privileged mode.*/ /* Return context for change in privileged mode.*/
newctxp = ((struct port_extctx *)__port_syscall_get_s_psp(tp)) - 1; newctxp = ((struct port_extctx *)__port_syscall_get_s_psp(tp)) - 1;
@ -1242,6 +1234,9 @@ void __port_do_syscall_entry(struct port_extctx *ectxpxx,
newctxp->fpscr = FPU->FPDSCR; newctxp->fpscr = FPU->FPDSCR;
#endif #endif
/* Caller context in unprivileged memory.*/
__port_syscall_set_u_psp(tp, (uint32_t)ectxp);
/* Switching PSP to the privileged mode PSP.*/ /* Switching PSP to the privileged mode PSP.*/
__set_PSP((uint32_t)newctxp); __set_PSP((uint32_t)newctxp);
} }

View File

@ -371,15 +371,23 @@ void sb_api_vrq_getisr(struct port_extctx *ectxp) {
void sb_api_vrq_return(struct port_extctx *ectxp) { void sb_api_vrq_return(struct port_extctx *ectxp) {
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
sb_vrqmask_t active_mask;
/* Returning from VRQ, enabling VRQs globally again.*/
sbp->vrq_isr = 0U;
/* Discarding the return current context, returning on the previous one. /* Discarding the return current context, returning on the previous one.
TODO: Check for overflows????*/ TODO: Check for overflows????*/
ectxp++; ectxp++;
__sb_vrq_check_pending(sbp, ectxp); active_mask = sbp->vrq_wtmask & sbp->vrq_enmask;
if (active_mask != 0U) {
sbp->vrq_isr = 0U;
/* Creating a return context.*/
vrq_pushctx2(ectxp, sbp, active_mask);
}
else {
sbp->vrq_isr = 0U;
__set_PSP((uint32_t)ectxp);
}
} }
/** /**