Fixed a problem in SB VRQs preemption.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15636 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2022-05-26 13:13:43 +00:00
parent ae718c401a
commit 6003c5b30b
2 changed files with 9 additions and 7 deletions

View File

@ -23,6 +23,8 @@ void __crt0_vrq(int vrqn) {
(void)vrqn;
printf("#1 Hello World (%u)!!\r\n", (unsigned)0);
__sb_vrq_return();
}
@ -38,12 +40,13 @@ int main(void) {
while (true) {
}
#endif
__sb_vrq_seten(2);
__sb_vrq_setwt(2);
__sb_vrq_seten(1);
// __sb_vrq_setwt(1);
sbSetAlarm(sbTimeMS2I(300), true);
while (true) {
msg_t msg = sbMsgWait();
printf("#1 Hello World (%u)!!\r\n", (unsigned)msg);
// printf("#1 Hello World (%u)!!\r\n", (unsigned)msg);
// sbFileWrite(1U, (const uint8_t *)"#1 Hello World!!\r\n", 15U);
sbMsgReply(msg);
// sbSleepMilliseconds(500);

View File

@ -188,7 +188,7 @@ void sbVRQTriggerFromISR(sb_class_t *sbp, sb_vrqmask_t vmask) {
if ((sbp->tp->state == CH_STATE_CURRENT)) {
/* Sandbox case, getting the current exception frame.*/
if ((__get_CONTROL() & 1U) == 0U) {
/* If preempted in privileged mode then getting the store U_PSP
/* If preempted in privileged mode then getting the stored U_PSP
value.*/
ectxp = (struct port_extctx *)sbp->tp->ctx.syscall.u_psp;
}
@ -213,9 +213,8 @@ void sbVRQTriggerFromISR(sb_class_t *sbp, sb_vrqmask_t vmask) {
}
}
else {
/* Other thread case, getting the pointer from the context switch
structure.*/
ectxp = sbp->tp->ctx.sp;
/* Getting the stored U_PSP value.*/
ectxp = (struct port_extctx *)sbp->tp->ctx.syscall.u_psp;
newctxp = ectxp - 1;
/* Checking if the new frame is within the sandbox else failure.*/