VRQs code.
@@ -77,9 +77,13 @@ | ||
77 | 77 | */ |
78 | 78 | uint32_t hdr_exit; |
79 | 79 | /** |
80 | + * @brief VFQ vector. | |
81 | + */ | |
82 | + uint32_t hdr_vfq; | |
83 | + /** | |
80 | 84 | * @brief Used-defined parameters, defaulted to zero. |
81 | 85 | */ |
82 | - uint32_t user[3]; | |
86 | + uint32_t user[2]; | |
83 | 87 | } sb_header_t; |
84 | 88 | |
85 | 89 | /*===========================================================================*/ |
@@ -25,6 +25,8 @@ | ||
25 | 25 | * @{ |
26 | 26 | */ |
27 | 27 | |
28 | +#include <string.h> | |
29 | + | |
28 | 30 | #include "sb.h" |
29 | 31 | |
30 | 32 | #if (SB_CFG_ENABLE_VRQ == TRUE) || defined(__DOXYGEN__) |
@@ -53,6 +55,53 @@ | ||
53 | 55 | /* Module exported functions. */ |
54 | 56 | /*===========================================================================*/ |
55 | 57 | |
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 | + | |
56 | 105 | #endif /* SB_CFG_ENABLE_VRQ == TRUE */ |
57 | 106 | |
58 | 107 | /** @} */ |
@@ -62,7 +62,7 @@ | ||
62 | 62 | #ifdef __cplusplus |
63 | 63 | extern "C" { |
64 | 64 | #endif |
65 | - void sbVRQPendI(sb_class_t *sbp, sb_vrqmask_t vmask); | |
65 | + bool sbVRQSignalMaskI(sb_class_t *sbp, sb_vrqmask_t vmask); | |
66 | 66 | #ifdef __cplusplus |
67 | 67 | } |
68 | 68 | #endif |