• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision15620 (tree)
Time2022-05-06 13:30:21
Authorgdisirio

Log Message

VRQs code.

Change Summary

Incremental Difference

--- trunk/os/sb/common/sbhdr.h (revision 15619)
+++ trunk/os/sb/common/sbhdr.h (revision 15620)
@@ -77,9 +77,13 @@
7777 */
7878 uint32_t hdr_exit;
7979 /**
80+ * @brief VFQ vector.
81+ */
82+ uint32_t hdr_vfq;
83+ /**
8084 * @brief Used-defined parameters, defaulted to zero.
8185 */
82- uint32_t user[3];
86+ uint32_t user[2];
8387 } sb_header_t;
8488
8589 /*===========================================================================*/
--- trunk/os/sb/host/sbvrq.c (revision 15619)
+++ trunk/os/sb/host/sbvrq.c (revision 15620)
@@ -25,6 +25,8 @@
2525 * @{
2626 */
2727
28+#include <string.h>
29+
2830 #include "sb.h"
2931
3032 #if (SB_CFG_ENABLE_VRQ == TRUE) || defined(__DOXYGEN__)
@@ -53,6 +55,53 @@
5355 /* Module exported functions. */
5456 /*===========================================================================*/
5557
58+/**
59+ * @brief Activates VRQs on the specified sandbox.
60+ *
61+ * @param[in] sbp pointer to a @p sb_class_t structure
62+ * @param[in] vmask mask of VRQs to be activated
63+ * @return The operation status.
64+ * @retval false if the activation has succeeded.
65+ * @retval true in case of sandbox stack overflow.
66+ */
67+bool sbVRQSignalMaskI(sb_class_t *sbp, sb_vrqmask_t vmask) {
68+ struct port_extctx *ectxp;
69+ const sb_header_t *sbhp;
70+
71+ /* This IRQ could have preempted the sandbox itself or some other thread,
72+ handling is different.*/
73+ if (sbp->tp->state == CH_STATE_CURRENT) {
74+ /* Sandbox case, getting the current exception frame.*/
75+ ectxp = (struct port_extctx *)__get_PSP() - 1;
76+
77+ /* Checking if the new frame is within the sandbox else failure.*/
78+ if (!sb_is_valid_write_range(sbp,
79+ (void *)ectxp,
80+ sizeof (struct port_extctx))) {
81+ return true;
82+ }
83+ }
84+ else {
85+ ectxp = sbp->tp->ctx.sp - 1;
86+
87+ /* Checking if the new frame is within the sandbox else failure.*/
88+ if (!sb_is_valid_write_range(sbp,
89+ (void *)ectxp,
90+ sizeof (struct port_extctx))) {
91+ return true;
92+ }
93+
94+ /* Preventing leakage of information, clearing all register values, those
95+ would come from outside the sandbox.*/
96+ memset((void *)ectxp, 0, sizeof (struct port_extctx));
97+ }
98+
99+ /* Header location.*/
100+ sbhp = (const sb_header_t *)(void *)sbp->config->regions[sbp->config->code_region].area.base;
101+
102+ return false;
103+}
104+
56105 #endif /* SB_CFG_ENABLE_VRQ == TRUE */
57106
58107 /** @} */
--- trunk/os/sb/host/sbvrq.h (revision 15619)
+++ trunk/os/sb/host/sbvrq.h (revision 15620)
@@ -62,7 +62,7 @@
6262 #ifdef __cplusplus
6363 extern "C" {
6464 #endif
65- void sbVRQPendI(sb_class_t *sbp, sb_vrqmask_t vmask);
65+ bool sbVRQSignalMaskI(sb_class_t *sbp, sb_vrqmask_t vmask);
6666 #ifdef __cplusplus
6767 }
6868 #endif
Show on old repository browser