diff --git a/os/sb/host/sbapi.c b/os/sb/host/sbapi.c index 2d92079f1..909288d41 100644 --- a/os/sb/host/sbapi.c +++ b/os/sb/host/sbapi.c @@ -159,9 +159,9 @@ uint32_t sb_api_wait_all_timeout(struct port_extctx *ctxp) { uint32_t sb_api_broadcast_flags(struct port_extctx *ctxp) { #if CH_CFG_USE_EVENTS == TRUE + sb_class_t *sbcp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; - chEvtBroadcastFlags((event_source_t *)ctxp->r0, - (eventflags_t)ctxp->r1); + chEvtBroadcastFlags(&sbcp->es, (eventflags_t)ctxp->r0); return SB_ERR_NOERROR; #else return SB_ERR_NOT_IMPLEMENTED; diff --git a/os/sb/host/sbhost.c b/os/sb/host/sbhost.c index c78193a47..f1854e10b 100644 --- a/os/sb/host/sbhost.c +++ b/os/sb/host/sbhost.c @@ -144,7 +144,7 @@ void sbObjectInit(sb_class_t *sbcp) { sbcp->msg_tp = NULL; #endif #if CH_CFG_USE_EVENTS == TRUE - chEvtObjectInit(sbcp->esp); + chEvtObjectInit(&sbcp->es); #endif } diff --git a/os/sb/host/sbhost.h b/os/sb/host/sbhost.h index 8252d2ca6..594b286e1 100644 --- a/os/sb/host/sbhost.h +++ b/os/sb/host/sbhost.h @@ -110,7 +110,7 @@ typedef struct { thread_t *msg_tp; #endif #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__) - event_source_t *esp; + event_source_t es; #endif } sb_class_t; @@ -950,6 +950,24 @@ extern "C" { /* Module inline functions. */ /*===========================================================================*/ +#if (CH_CFG_USE_WAITEXIT == TRUE) || defined(__DOXYGEN__) +/** + * @brief Blocks the execution of the invoking thread until the sandbox + * thread terminates then the exit code is returned. + * @pre The configuration option @p CH_CFG_USE_WAITEXIT must be enabled in + * order to use this function. + * + * @param[in] sbcp pointer to the sandbox object + * @return The exit code from the terminated thread. + * + * @api + */ +static inline msg_t sbWait(sb_class_t *sbcp) { + + return chThdWait(sbcp->tp); +} +#endif /* CH_CFG_USE_WAITEXIT == TRUE */ + #if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__) /** * @brief Sends a message to a sandboxed thread. @@ -1004,7 +1022,7 @@ static inline void sbEvtSignal(sb_class_t *sbcp, eventmask_t events) { */ static inline event_source_t *sbGetEventSourceX(sb_class_t *sbcp) { - return sbcp->esp; + return &sbcp->es; } #endif /* CH_CFG_USE_EVENTS == TRUE */