• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revisión15634 (tree)
Tiempo2022-05-24 18:44:53
Autorgdisirio

Log Message

Added sandbox alarms API.

Cambiar Resumen

Diferencia incremental

--- trunk/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_DYNAMIC/cfg/sbconf.h (revision 15633)
+++ trunk/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_DYNAMIC/cfg/sbconf.h (revision 15634)
@@ -46,6 +46,13 @@
4646 #endif
4747
4848 /**
49+ * @brief Virtual IRQ to be used for alarm.
50+ */
51+#if !defined(SB_CFG_ALARM_VRQ) || defined(__DOXYGEN__)
52+#define SB_CFG_ALARM_VRQ 0
53+#endif
54+
55+/**
4956 * @brief Enables Posix API in sandboxes using VFS.
5057 */
5158 #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__)
--- trunk/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_STATIC/cfg/sbconf.h (revision 15633)
+++ trunk/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_STATIC/cfg/sbconf.h (revision 15634)
@@ -46,6 +46,13 @@
4646 #endif
4747
4848 /**
49+ * @brief Virtual IRQ to be used for alarm.
50+ */
51+#if !defined(SB_CFG_ALARM_VRQ) || defined(__DOXYGEN__)
52+#define SB_CFG_ALARM_VRQ 0
53+#endif
54+
55+/**
4956 * @brief Enables Posix API in sandboxes using VFS.
5057 */
5158 #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__)
--- trunk/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/cfg/sbconf.h (revision 15633)
+++ trunk/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/cfg/sbconf.h (revision 15634)
@@ -46,6 +46,13 @@
4646 #endif
4747
4848 /**
49+ * @brief Virtual IRQ to be used for alarm.
50+ */
51+#if !defined(SB_CFG_ALARM_VRQ) || defined(__DOXYGEN__)
52+#define SB_CFG_ALARM_VRQ 0
53+#endif
54+
55+/**
4956 * @brief Enables Posix API in sandboxes using VFS.
5057 */
5158 #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__)
--- trunk/demos/STM32/RT-STM32L4R9-DISCOVERY-SB_HOST_STATIC/cfg/sbconf.h (revision 15633)
+++ trunk/demos/STM32/RT-STM32L4R9-DISCOVERY-SB_HOST_STATIC/cfg/sbconf.h (revision 15634)
@@ -46,6 +46,13 @@
4646 #endif
4747
4848 /**
49+ * @brief Virtual IRQ to be used for alarm.
50+ */
51+#if !defined(SB_CFG_ALARM_VRQ) || defined(__DOXYGEN__)
52+#define SB_CFG_ALARM_VRQ 0
53+#endif
54+
55+/**
4956 * @brief Enables Posix API in sandboxes using VFS.
5057 */
5158 #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__)
--- trunk/os/sb/common/sbsysc.h (revision 15633)
+++ trunk/os/sb/common/sbsysc.h (revision 15634)
@@ -49,6 +49,8 @@
4949 #define SB_SYSC_EVENT_WAIT_ALL 10
5050 #define SB_SYSC_EVENT_BROADCAST 11
5151 #define SB_SYSC_LOADELF 12
52+#define SB_SYSC_VRQ_SET_ALARM 245
53+#define SB_SYSC_VRQ_RESET_ALARM 246
5254 #define SB_SYSC_VRQ_WAIT 247
5355 #define SB_SYSC_VRQ_SETWT 248
5456 #define SB_SYSC_VRQ_CLRWT 249
--- trunk/os/sb/host/sb.h (revision 15633)
+++ trunk/os/sb/host/sb.h (revision 15634)
@@ -100,6 +100,10 @@
100100 #error "SB_CFG_ENABLE_VRQ not defined in sbconf.h"
101101 #endif
102102
103+#if !defined(SB_CFG_ALARM_VRQ) || defined(__DOXYGEN__)
104+#error "SB_CFG_ALARM_VRQ not defined in sbconf.h"
105+#endif
106+
103107 #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__)
104108 #error "SB_CFG_ENABLE_VFS not defined in sbconf.h"
105109 #endif
@@ -152,6 +156,10 @@
152156 #error "SB_CFG_NUM_REGIONS not matching PORT_SWITCHED_REGIONS_NUMBER"
153157 #endif
154158
159+#if (SB_CFG_ALARM_VRQ < 0) || (SB_CFG_ALARM_VRQ > 31)
160+#error "invalid SB_CFG_ALARM_VRQ value"
161+#endif
162+
155163 /*===========================================================================*/
156164 /* Module data structures and types. */
157165 /*===========================================================================*/
@@ -255,6 +263,10 @@
255263 * @brief Pointer to the image header.
256264 */
257265 const sb_header_t *sbhp;
266+ /**
267+ * @brief Virtual timer used for alarms.
268+ */
269+ virtual_timer_t alarm_vt;
258270 #if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
259271 /**
260272 * @brief Thread sending a message to the sandbox.
--- trunk/os/sb/host/sbapi.c (revision 15633)
+++ trunk/os/sb/host/sbapi.c (revision 15634)
@@ -76,6 +76,8 @@
7676 * @{
7777 */
7878 #if (SB_CFG_ENABLE_VRQ == TRUE) || defined(__DOXYGEN__)
79+#define SB_SVC245_HANDLER sb_api_vrq_set_alarm
80+#define SB_SVC246_HANDLER sb_api_vrq_reset_alarm
7981 #define SB_SVC247_HANDLER sb_api_vrq_wait
8082 #define SB_SVC248_HANDLER sb_api_vrq_setwt
8183 #define SB_SVC249_HANDLER sb_api_vrq_clrwt
--- trunk/os/sb/host/sbvrq.c (revision 15633)
+++ trunk/os/sb/host/sbvrq.c (revision 15634)
@@ -101,6 +101,14 @@
101101 }
102102 }
103103
104+static void delay_cb(virtual_timer_t *vtp, void *arg) {
105+ sb_class_t *sbp = (sb_class_t *)arg;
106+
107+ (void)vtp;
108+
109+ sbVRQTriggerFromISR(sbp, 1U << SB_CFG_ALARM_VRQ);
110+}
111+
104112 /*===========================================================================*/
105113 /* Module exported functions. */
106114 /*===========================================================================*/
@@ -235,6 +243,31 @@
235243 return;
236244 }
237245
246+void sb_api_vrq_set_alarm(struct port_extctx *ectxp) {
247+ sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
248+ sysinterval_t interval = (sysinterval_t )ectxp->r0;
249+ bool continuous = (bool)ectxp->r1;
250+
251+ if (continuous) {
252+ chVTSetContinuous(&sbp->alarm_vt, interval, delay_cb, (void *)sbp);
253+ }
254+ else {
255+ chVTSet(&sbp->alarm_vt, interval, delay_cb, (void *)sbp);
256+ }
257+
258+ ectxp->r0 = CH_RET_SUCCESS;
259+}
260+
261+void sb_api_vrq_reset_alarm(struct port_extctx *ectxp) {
262+ sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
263+
264+ (void)ectxp;
265+
266+ chVTReset(&sbp->alarm_vt);
267+
268+ ectxp->r0 = CH_RET_SUCCESS;
269+}
270+
238271 void sb_api_vrq_wait(struct port_extctx *ectxp) {
239272 sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
240273 sb_vrqmask_t active_mask;
@@ -249,6 +282,8 @@
249282 }
250283
251284 chSysUnlock();
285+
286+ ectxp->r0 = CH_RET_SUCCESS;
252287 }
253288
254289 void sb_api_vrq_setwt(struct port_extctx *ectxp) {
--- trunk/os/sb/host/sbvrq.h (revision 15633)
+++ trunk/os/sb/host/sbvrq.h (revision 15634)
@@ -66,6 +66,8 @@
6666 #endif
6767 void sbVRQTriggerS(sb_class_t *sbp, sb_vrqmask_t vmask);
6868 void sbVRQTriggerFromISR(sb_class_t *sbp, sb_vrqmask_t vmask);
69+ void sb_api_vrq_set_alarm(struct port_extctx *ectxp);
70+ void sb_api_vrq_reset_alarm(struct port_extctx *ectxp);
6971 void sb_api_vrq_wait(struct port_extctx *ectxp);
7072 void sb_api_vrq_setwt(struct port_extctx *ectxp);
7173 void sb_api_vrq_clrwt(struct port_extctx *ectxp);
Show on old repository browser