VRQs code.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15620 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
ca1ea99f64
commit
faef5bdb31
|
@ -100,7 +100,7 @@ __sandbox: .long 0xFE9154C0
|
|||
.long 32
|
||||
.long __crt0_entry
|
||||
.long __crt0_exit
|
||||
.long 0
|
||||
.long __crt0_vfq
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
|
@ -119,6 +119,14 @@ environ:
|
|||
|
||||
.text
|
||||
|
||||
/* Default VFQ handler.*/
|
||||
.align 2
|
||||
.thumb_func
|
||||
.weak __crt0_vfq
|
||||
__crt0_vfq:
|
||||
ldr r0, =0xFFFFFFFF
|
||||
/* Falls into __crt0_exit.*/
|
||||
|
||||
/* Default exit method, calling OS exit().*/
|
||||
.align 2
|
||||
.thumb_func
|
||||
|
|
|
@ -76,10 +76,14 @@ typedef struct {
|
|||
* @brief Exit vector.
|
||||
*/
|
||||
uint32_t hdr_exit;
|
||||
/**
|
||||
* @brief VFQ vector.
|
||||
*/
|
||||
uint32_t hdr_vfq;
|
||||
/**
|
||||
* @brief Used-defined parameters, defaulted to zero.
|
||||
*/
|
||||
uint32_t user[3];
|
||||
uint32_t user[2];
|
||||
} sb_header_t;
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "sb.h"
|
||||
|
||||
#if (SB_CFG_ENABLE_VRQ == TRUE) || defined(__DOXYGEN__)
|
||||
|
@ -53,6 +55,53 @@
|
|||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Activates VRQs on the specified sandbox.
|
||||
*
|
||||
* @param[in] sbp pointer to a @p sb_class_t structure
|
||||
* @param[in] vmask mask of VRQs to be activated
|
||||
* @return The operation status.
|
||||
* @retval false if the activation has succeeded.
|
||||
* @retval true in case of sandbox stack overflow.
|
||||
*/
|
||||
bool sbVRQSignalMaskI(sb_class_t *sbp, sb_vrqmask_t vmask) {
|
||||
struct port_extctx *ectxp;
|
||||
const sb_header_t *sbhp;
|
||||
|
||||
/* This IRQ could have preempted the sandbox itself or some other thread,
|
||||
handling is different.*/
|
||||
if (sbp->tp->state == CH_STATE_CURRENT) {
|
||||
/* Sandbox case, getting the current exception frame.*/
|
||||
ectxp = (struct port_extctx *)__get_PSP() - 1;
|
||||
|
||||
/* Checking if the new frame is within the sandbox else failure.*/
|
||||
if (!sb_is_valid_write_range(sbp,
|
||||
(void *)ectxp,
|
||||
sizeof (struct port_extctx))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ectxp = sbp->tp->ctx.sp - 1;
|
||||
|
||||
/* Checking if the new frame is within the sandbox else failure.*/
|
||||
if (!sb_is_valid_write_range(sbp,
|
||||
(void *)ectxp,
|
||||
sizeof (struct port_extctx))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Preventing leakage of information, clearing all register values, those
|
||||
would come from outside the sandbox.*/
|
||||
memset((void *)ectxp, 0, sizeof (struct port_extctx));
|
||||
}
|
||||
|
||||
/* Header location.*/
|
||||
sbhp = (const sb_header_t *)(void *)sbp->config->regions[sbp->config->code_region].area.base;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* SB_CFG_ENABLE_VRQ == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -62,7 +62,7 @@ typedef uint32_t sb_vrqmask_t;
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void sbVRQPendI(sb_class_t *sbp, sb_vrqmask_t vmask);
|
||||
bool sbVRQSignalMaskI(sb_class_t *sbp, sb_vrqmask_t vmask);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue