git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15743 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2022-08-30 12:51:54 +00:00
parent 2bb5f3c1c6
commit 0b506373ea
5 changed files with 47 additions and 22 deletions

View File

@ -26,6 +26,10 @@
#include "startup_defs.h" #include "startup_defs.h"
/* Sandbox objects.*/
sb_class_t sbx1, sbx2;
/*===========================================================================*/ /*===========================================================================*/
/* VHAL-related. */ /* VHAL-related. */
/*===========================================================================*/ /*===========================================================================*/
@ -45,7 +49,11 @@ static vio_gpio_units_t gpio_units1 = {
static vio_uart_units_t uart_units1 = { static vio_uart_units_t uart_units1 = {
.n = 1U, .n = 1U,
.units = { .units = {
[0] = {&LPSIOD1} [0] = {
.siop = &LPSIOD1,
.vrqsb = &sbx1,
.vrqn = 8
}
} }
}; };
@ -162,9 +170,6 @@ static const char *sbx2_envp[] = {
NULL NULL
}; };
/* Sandbox objects.*/
sb_class_t sbx1, sbx2;
static THD_WORKING_AREA(waUnprivileged1, 512); static THD_WORKING_AREA(waUnprivileged1, 512);
static THD_WORKING_AREA(waUnprivileged2, 512); static THD_WORKING_AREA(waUnprivileged2, 512);

View File

@ -432,10 +432,20 @@ msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg) {
* @notapi * @notapi
*/ */
void sio_lld_serve_interrupt(SIODriver *siop) { void sio_lld_serve_interrupt(SIODriver *siop) {
sioevents_t events;
/* The callback is simply invoked. Letting the driver on the host side __syscall2rr(201, SB_VUART_GCEVT, siop->nvuart);
decide how to manipulate IRQ sources.*/ osalDbgAssert((msg_t)r0 == HAL_RET_SUCCESS, "unexpected failure");
__sio_callback(siop);
/* Only processing enabled events.*/
events = (sioevents_t)r1;
/* Processing events, if any.*/
if (events != (sioevents_t)0) {
/* The callback is finally invoked.*/
__sio_callback(siop);
}
} }
#endif /* HAL_USE_SIO == TRUE */ #endif /* HAL_USE_SIO == TRUE */

View File

@ -36,10 +36,6 @@
#include "sbsysc.h" #include "sbsysc.h"
#include "sbconf.h" #include "sbconf.h"
#if (SB_CFG_ENABLE_VIO == TRUE) || defined (__DOXYGEN__)
#include "sbvio.h"
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Module constants. */ /* Module constants. */
/*===========================================================================*/ /*===========================================================================*/
@ -172,11 +168,25 @@
/* Module data structures and types. */ /* Module data structures and types. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Type of a sandbox object.
*/
typedef struct sb_class sb_class_t;
/** /**
* @brief Type of a mask of Virtual IRQs. * @brief Type of a mask of Virtual IRQs.
*/ */
typedef uint32_t sb_vrqmask_t; typedef uint32_t sb_vrqmask_t;
#if (SB_CFG_ENABLE_VRQ == TRUE) || defined (__DOXYGEN__)
#include "sbvrq.h"
#endif
#if (SB_CFG_ENABLE_VIO == TRUE) || defined (__DOXYGEN__)
#include "sbvio.h"
#endif
/** /**
* @brief Type of a sandbox manager global structure. * @brief Type of a sandbox manager global structure.
*/ */
@ -262,9 +272,9 @@ typedef struct {
} sb_config_t; } sb_config_t;
/** /**
* @brief Type of a sandbox object. * @brief Structure representing a sandbox object.
*/ */
typedef struct { struct sb_class {
/** /**
* @brief Pointer to the sandbox configuration data. * @brief Pointer to the sandbox configuration data.
*/ */
@ -317,7 +327,7 @@ typedef struct {
*/ */
sb_ioblock_t io; sb_ioblock_t io;
#endif #endif
} sb_class_t; };
/*===========================================================================*/ /*===========================================================================*/
/* Module macros. */ /* Module macros. */
@ -339,10 +349,6 @@ extern "C" {
/* Module inline functions. */ /* Module inline functions. */
/*===========================================================================*/ /*===========================================================================*/
#if (SB_CFG_ENABLE_VRQ == TRUE) || defined (__DOXYGEN__)
#include "sbvrq.h"
#endif
#include "sbelf.h" #include "sbelf.h"
#include "sbposix.h" #include "sbposix.h"
#include "sbapi.h" #include "sbapi.h"

View File

@ -50,9 +50,9 @@
/*===========================================================================*/ /*===========================================================================*/
static void vuart_cb(SIODriver *siop) { static void vuart_cb(SIODriver *siop) {
sb_class_t *sbp = (sb_class_t *)siop->arg; const vio_uart_unit_t *unitp = (const vio_uart_unit_t *)siop->arg;
sbVRQTriggerFromISR(sbp, 1U << SB_CFG_ALARM_VRQ); sbVRQTriggerFromISR(unitp->vrqsb, 1U << unitp->vrqn);
} }
/*===========================================================================*/ /*===========================================================================*/
@ -86,12 +86,14 @@ void sb_api_vio_uart(struct port_extctx *ectxp) {
return; return;
} }
/* Specified VUART configuration.*/
confp = &sbp->config->vioconf->uartconfs->cfgs[conf]; confp = &sbp->config->vioconf->uartconfs->cfgs[conf];
/* Associating this virtual UART to the SIO driver.*/
unitp->siop->arg = (void *)unitp;
msg = sioStart(unitp->siop, confp->siocfgp); msg = sioStart(unitp->siop, confp->siocfgp);
if (msg == HAL_RET_SUCCESS) { if (msg == HAL_RET_SUCCESS) {
/* Associating this SIO to the sandbox.*/
unitp->siop->arg = (sb_class_t *)sbp;
/* Starting with disabled events, enabling the callback.*/ /* Starting with disabled events, enabling the callback.*/
sioWriteEnableFlags(unitp->siop, SIO_FL_NONE); sioWriteEnableFlags(unitp->siop, SIO_FL_NONE);

View File

@ -56,6 +56,8 @@
*/ */
typedef struct vio_uart_unit { typedef struct vio_uart_unit {
SIODriver *siop; SIODriver *siop;
sb_class_t *vrqsb;
unsigned vrqn;
} vio_uart_unit_t; } vio_uart_unit_t;
/** /**