Preparation for SB Virtual IRQs. Removed some obsolete code from SBs.
@@ -39,6 +39,13 @@ | ||
39 | 39 | #endif |
40 | 40 | |
41 | 41 | /** |
42 | + * @brief Enables support for sandbox Virtual IRQs. | |
43 | + */ | |
44 | +#if !defined(SB_CFG_ENABLE_VRQ) || defined(__DOXYGEN__) | |
45 | +#define SB_CFG_ENABLE_VRQ TRUE | |
46 | +#endif | |
47 | + | |
48 | +/** | |
42 | 49 | * @brief Enables Posix API in sandboxes using VFS. |
43 | 50 | */ |
44 | 51 | #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__) |
@@ -39,6 +39,13 @@ | ||
39 | 39 | #endif |
40 | 40 | |
41 | 41 | /** |
42 | + * @brief Enables support for sandbox Virtual IRQs. | |
43 | + */ | |
44 | +#if !defined(SB_CFG_ENABLE_VRQ) || defined(__DOXYGEN__) | |
45 | +#define SB_CFG_ENABLE_VRQ TRUE | |
46 | +#endif | |
47 | + | |
48 | +/** | |
42 | 49 | * @brief Enables Posix API in sandboxes using VFS. |
43 | 50 | */ |
44 | 51 | #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__) |
@@ -39,6 +39,13 @@ | ||
39 | 39 | #endif |
40 | 40 | |
41 | 41 | /** |
42 | + * @brief Enables support for sandbox Virtual IRQs. | |
43 | + */ | |
44 | +#if !defined(SB_CFG_ENABLE_VRQ) || defined(__DOXYGEN__) | |
45 | +#define SB_CFG_ENABLE_VRQ TRUE | |
46 | +#endif | |
47 | + | |
48 | +/** | |
42 | 49 | * @brief Enables Posix API in sandboxes using VFS. |
43 | 50 | */ |
44 | 51 | #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__) |
@@ -39,6 +39,13 @@ | ||
39 | 39 | #endif |
40 | 40 | |
41 | 41 | /** |
42 | + * @brief Enables support for sandbox Virtual IRQs. | |
43 | + */ | |
44 | +#if !defined(SB_CFG_ENABLE_VRQ) || defined(__DOXYGEN__) | |
45 | +#define SB_CFG_ENABLE_VRQ TRUE | |
46 | +#endif | |
47 | + | |
48 | +/** | |
42 | 49 | * @brief Enables Posix API in sandboxes using VFS. |
43 | 50 | */ |
44 | 51 | #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__) |
@@ -94,6 +94,10 @@ | ||
94 | 94 | #error "SB_CFG_NUM_REGIONS not defined in sbconf.h" |
95 | 95 | #endif |
96 | 96 | |
97 | +#if !defined(SB_CFG_ENABLE_VRQ) || defined(__DOXYGEN__) | |
98 | +#error "SB_CFG_ENABLE_VRQ not defined in sbconf.h" | |
99 | +#endif | |
100 | + | |
97 | 101 | #if !defined(SB_CFG_ENABLE_VFS) || defined(__DOXYGEN__) |
98 | 102 | #error "SB_CFG_ENABLE_VFS not defined in sbconf.h" |
99 | 103 | #endif |
@@ -281,6 +285,7 @@ | ||
281 | 285 | /*===========================================================================*/ |
282 | 286 | |
283 | 287 | #include "sbsysc.h" |
288 | +#include "sbvrq.h" | |
284 | 289 | #include "sbelf.h" |
285 | 290 | #include "sbposix.h" |
286 | 291 | #include "sbapi.h" |
@@ -36,6 +36,20 @@ | ||
36 | 36 | /* Module local definitions. */ |
37 | 37 | /*===========================================================================*/ |
38 | 38 | |
39 | +static void sb_api_stdio(struct port_extctx *ectxp); | |
40 | +static void sb_api_exit(struct port_extctx *ctxp); | |
41 | +static void sb_api_get_systime(struct port_extctx *ctxp); | |
42 | +static void sb_api_get_frequency(struct port_extctx *ctxp); | |
43 | +static void sb_api_sleep(struct port_extctx *ctxp); | |
44 | +static void sb_api_sleep_until_windowed(struct port_extctx *ctxp); | |
45 | +static void sb_api_wait_message(struct port_extctx *ctxp); | |
46 | +static void sb_api_reply_message(struct port_extctx *ctxp); | |
47 | +static void sb_api_wait_one_timeout(struct port_extctx *ctxp); | |
48 | +static void sb_api_wait_any_timeout(struct port_extctx *ctxp); | |
49 | +static void sb_api_wait_all_timeout(struct port_extctx *ctxp); | |
50 | +static void sb_api_broadcast_flags(struct port_extctx *ctxp); | |
51 | +static void sb_api_loadelf(struct port_extctx *ectxp); | |
52 | + | |
39 | 53 | /** |
40 | 54 | * @name Standard API handlers |
41 | 55 | * @{ |
@@ -960,26 +974,8 @@ | ||
960 | 974 | #endif |
961 | 975 | } |
962 | 976 | |
963 | -/*===========================================================================*/ | |
964 | -/* Module exported functions. */ | |
965 | -/*===========================================================================*/ | |
966 | - | |
967 | -void __sb_abort(msg_t msg) { | |
968 | - | |
969 | - chSysUnlock(); | |
970 | - | |
971 | - sb_cleanup(); | |
972 | - | |
973 | - chSysLock(); | |
974 | -#if CH_CFG_USE_EVENTS == TRUE | |
975 | - chEvtBroadcastI(&sb.termination_es); | |
976 | -#endif | |
977 | - chThdExitS(msg); | |
978 | - chSysHalt("zombies"); | |
979 | -} | |
980 | - | |
981 | 977 | #if (SB_CFG_ENABLE_VFS == TRUE) || defined(__DOXYGEN__) |
982 | -void sb_api_stdio(struct port_extctx *ectxp) { | |
978 | +static void sb_api_stdio(struct port_extctx *ectxp) { | |
983 | 979 | |
984 | 980 | switch (ectxp->r0) { |
985 | 981 | case SB_POSIX_OPEN: |
@@ -1052,7 +1048,7 @@ | ||
1052 | 1048 | } |
1053 | 1049 | #endif /* SB_CFG_ENABLE_VFS == TRUE */ |
1054 | 1050 | |
1055 | -void sb_api_exit(struct port_extctx *ectxp) { | |
1051 | +static void sb_api_exit(struct port_extctx *ectxp) { | |
1056 | 1052 | |
1057 | 1053 | sb_cleanup(); |
1058 | 1054 |
@@ -1067,17 +1063,17 @@ | ||
1067 | 1063 | ectxp->r0 = CH_RET_ENOSYS; |
1068 | 1064 | } |
1069 | 1065 | |
1070 | -void sb_api_get_systime(struct port_extctx *ectxp) { | |
1066 | +static void sb_api_get_systime(struct port_extctx *ectxp) { | |
1071 | 1067 | |
1072 | 1068 | ectxp->r0 = (uint32_t)chVTGetSystemTimeX(); |
1073 | 1069 | } |
1074 | 1070 | |
1075 | -void sb_api_get_frequency(struct port_extctx *ectxp) { | |
1071 | +static void sb_api_get_frequency(struct port_extctx *ectxp) { | |
1076 | 1072 | |
1077 | 1073 | ectxp->r0 = (uint32_t)CH_CFG_ST_FREQUENCY; |
1078 | 1074 | } |
1079 | 1075 | |
1080 | -void sb_api_sleep(struct port_extctx *ectxp) { | |
1076 | +static void sb_api_sleep(struct port_extctx *ectxp) { | |
1081 | 1077 | sysinterval_t interval = (sysinterval_t )ectxp->r0; |
1082 | 1078 | |
1083 | 1079 | if (interval != TIME_IMMEDIATE) { |
@@ -1087,7 +1083,7 @@ | ||
1087 | 1083 | ectxp->r0 = CH_RET_SUCCESS; |
1088 | 1084 | } |
1089 | 1085 | |
1090 | -void sb_api_sleep_until_windowed(struct port_extctx *ectxp) { | |
1086 | +static void sb_api_sleep_until_windowed(struct port_extctx *ectxp) { | |
1091 | 1087 | |
1092 | 1088 | chThdSleepUntilWindowed((systime_t )ectxp->r0, (systime_t )ectxp->r1); |
1093 | 1089 |
@@ -1094,7 +1090,7 @@ | ||
1094 | 1090 | ectxp->r0 = CH_RET_SUCCESS; |
1095 | 1091 | } |
1096 | 1092 | |
1097 | -void sb_api_wait_message(struct port_extctx *ectxp) { | |
1093 | +static void sb_api_wait_message(struct port_extctx *ectxp) { | |
1098 | 1094 | #if CH_CFG_USE_MESSAGES == TRUE |
1099 | 1095 | sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; |
1100 | 1096 |
@@ -1117,7 +1113,7 @@ | ||
1117 | 1113 | #endif |
1118 | 1114 | } |
1119 | 1115 | |
1120 | -void sb_api_reply_message(struct port_extctx *ectxp) { | |
1116 | +static void sb_api_reply_message(struct port_extctx *ectxp) { | |
1121 | 1117 | #if CH_CFG_USE_MESSAGES == TRUE |
1122 | 1118 | sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; |
1123 | 1119 |
@@ -1139,7 +1135,7 @@ | ||
1139 | 1135 | #endif |
1140 | 1136 | } |
1141 | 1137 | |
1142 | -void sb_api_wait_one_timeout(struct port_extctx *ectxp) { | |
1138 | +static void sb_api_wait_one_timeout(struct port_extctx *ectxp) { | |
1143 | 1139 | #if CH_CFG_USE_EVENTS == TRUE |
1144 | 1140 | |
1145 | 1141 | ectxp->r0 = (uint32_t)chEvtWaitOneTimeout((eventmask_t )ectxp->r0, |
@@ -1149,7 +1145,7 @@ | ||
1149 | 1145 | #endif |
1150 | 1146 | } |
1151 | 1147 | |
1152 | -void sb_api_wait_any_timeout(struct port_extctx *ectxp) { | |
1148 | +static void sb_api_wait_any_timeout(struct port_extctx *ectxp) { | |
1153 | 1149 | #if CH_CFG_USE_EVENTS == TRUE |
1154 | 1150 | |
1155 | 1151 | ectxp->r0 = (uint32_t)chEvtWaitAnyTimeout((eventmask_t )ectxp->r0, |
@@ -1159,7 +1155,7 @@ | ||
1159 | 1155 | #endif |
1160 | 1156 | } |
1161 | 1157 | |
1162 | -void sb_api_wait_all_timeout(struct port_extctx *ectxp) { | |
1158 | +static void sb_api_wait_all_timeout(struct port_extctx *ectxp) { | |
1163 | 1159 | #if CH_CFG_USE_EVENTS == TRUE |
1164 | 1160 | |
1165 | 1161 | ectxp->r0 = (uint32_t)chEvtWaitAllTimeout((eventmask_t )ectxp->r0, |
@@ -1169,7 +1165,7 @@ | ||
1169 | 1165 | #endif |
1170 | 1166 | } |
1171 | 1167 | |
1172 | -void sb_api_broadcast_flags(struct port_extctx *ectxp) { | |
1168 | +static void sb_api_broadcast_flags(struct port_extctx *ectxp) { | |
1173 | 1169 | #if CH_CFG_USE_EVENTS == TRUE |
1174 | 1170 | sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; |
1175 | 1171 |
@@ -1180,7 +1176,7 @@ | ||
1180 | 1176 | #endif |
1181 | 1177 | } |
1182 | 1178 | |
1183 | -void sb_api_loadelf(struct port_extctx *ectxp) { | |
1179 | +static void sb_api_loadelf(struct port_extctx *ectxp) { | |
1184 | 1180 | #if (SB_CFG_ENABLE_VFS == TRUE) || defined(__DOXYGEN__) |
1185 | 1181 | sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; |
1186 | 1182 | const char *fname = (const char *)ectxp->r0; |
@@ -1202,4 +1198,22 @@ | ||
1202 | 1198 | #endif |
1203 | 1199 | } |
1204 | 1200 | |
1201 | +/*===========================================================================*/ | |
1202 | +/* Module exported functions. */ | |
1203 | +/*===========================================================================*/ | |
1204 | + | |
1205 | +void __sb_abort(msg_t msg) { | |
1206 | + | |
1207 | + chSysUnlock(); | |
1208 | + | |
1209 | + sb_cleanup(); | |
1210 | + | |
1211 | + chSysLock(); | |
1212 | +#if CH_CFG_USE_EVENTS == TRUE | |
1213 | + chEvtBroadcastI(&sb.termination_es); | |
1214 | +#endif | |
1215 | + chThdExitS(msg); | |
1216 | + chSysHalt("zombies"); | |
1217 | +} | |
1218 | + | |
1205 | 1219 | /** @} */ |
@@ -49,48 +49,6 @@ | ||
49 | 49 | */ |
50 | 50 | typedef void (*port_syscall_t)(struct port_extctx *ectx); |
51 | 51 | |
52 | -/** | |
53 | - * @brief Sandbox Stream interface methods. | |
54 | - * @note Is intentionally compatible with HAL streams but we have to | |
55 | - * duplicate is because we don't want dependencies with HAL in | |
56 | - * this subsystem. | |
57 | - */ | |
58 | -struct SandboxStreamVMT { | |
59 | - /** | |
60 | - * @brief Object instance offset. | |
61 | - */ | |
62 | - size_t instance_offset; | |
63 | - /** | |
64 | - * @brief Stream write buffer method. | |
65 | - */ | |
66 | - size_t (*write)(void *instance, const uint8_t *bp, size_t n); | |
67 | - /** | |
68 | - * @brief Stream read buffer method. | |
69 | - */ | |
70 | - size_t (*read)(void *instance, uint8_t *bp, size_t n); | |
71 | - /** | |
72 | - * @brief Channel put method, blocking. | |
73 | - */ | |
74 | - msg_t (*put)(void *instance, uint8_t b); | |
75 | - /** | |
76 | - * @brief Channel get method, blocking. | |
77 | - */ | |
78 | - msg_t (*get)(void *instance); | |
79 | -}; | |
80 | - | |
81 | -/** | |
82 | - * @brief Sandbox Stream class. | |
83 | - * @note Is intentionally compatible with HAL streams but we have to | |
84 | - * duplicate is because we don't want dependencies with HAL in | |
85 | - * this subsystem. | |
86 | - */ | |
87 | -typedef struct { | |
88 | - /** | |
89 | - * @brief Virtual Methods Table. | |
90 | - */ | |
91 | - const struct SandboxStreamVMT *vmt; | |
92 | -} SandboxStream; | |
93 | - | |
94 | 52 | /*===========================================================================*/ |
95 | 53 | /* Module macros. */ |
96 | 54 | /*===========================================================================*/ |
@@ -102,19 +60,7 @@ | ||
102 | 60 | #ifdef __cplusplus |
103 | 61 | extern "C" { |
104 | 62 | #endif |
105 | - void sb_api_stdio(struct port_extctx *ectxp); | |
106 | - void sb_api_exit(struct port_extctx *ctxp); | |
107 | - void sb_api_get_systime(struct port_extctx *ctxp); | |
108 | - void sb_api_get_frequency(struct port_extctx *ctxp); | |
109 | - void sb_api_sleep(struct port_extctx *ctxp); | |
110 | - void sb_api_sleep_until_windowed(struct port_extctx *ctxp); | |
111 | - void sb_api_wait_message(struct port_extctx *ctxp); | |
112 | - void sb_api_reply_message(struct port_extctx *ctxp); | |
113 | - void sb_api_wait_one_timeout(struct port_extctx *ctxp); | |
114 | - void sb_api_wait_any_timeout(struct port_extctx *ctxp); | |
115 | - void sb_api_wait_all_timeout(struct port_extctx *ctxp); | |
116 | - void sb_api_broadcast_flags(struct port_extctx *ctxp); | |
117 | - void sb_api_loadelf(struct port_extctx *ectxp); | |
63 | + | |
118 | 64 | #ifdef __cplusplus |
119 | 65 | } |
120 | 66 | #endif |
@@ -0,0 +1,58 @@ | ||
1 | +/* | |
2 | + ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014, | |
3 | + 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio. | |
4 | + | |
5 | + This file is part of ChibiOS. | |
6 | + | |
7 | + ChibiOS is free software; you can redistribute it and/or modify | |
8 | + it under the terms of the GNU General Public License as published by | |
9 | + the Free Software Foundation version 3 of the License. | |
10 | + | |
11 | + ChibiOS is distributed in the hope that it will be useful, | |
12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + GNU General Public License for more details. | |
15 | + | |
16 | + You should have received a copy of the GNU General Public License | |
17 | + along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | +*/ | |
19 | + | |
20 | +/** | |
21 | + * @file sb/host/sbvrq.c | |
22 | + * @brief ARM SandBox host Virtual IRQs code. | |
23 | + * | |
24 | + * @addtogroup ARM_SANDBOX_VRQ | |
25 | + * @{ | |
26 | + */ | |
27 | + | |
28 | +#include "sb.h" | |
29 | + | |
30 | +#if (SB_CFG_ENABLE_VRQ == TRUE) || defined(__DOXYGEN__) | |
31 | + | |
32 | +/*===========================================================================*/ | |
33 | +/* Module local definitions. */ | |
34 | +/*===========================================================================*/ | |
35 | + | |
36 | +/*===========================================================================*/ | |
37 | +/* Module exported variables. */ | |
38 | +/*===========================================================================*/ | |
39 | + | |
40 | +/*===========================================================================*/ | |
41 | +/* Module local types. */ | |
42 | +/*===========================================================================*/ | |
43 | + | |
44 | +/*===========================================================================*/ | |
45 | +/* Module local variables. */ | |
46 | +/*===========================================================================*/ | |
47 | + | |
48 | +/*===========================================================================*/ | |
49 | +/* Module local functions. */ | |
50 | +/*===========================================================================*/ | |
51 | + | |
52 | +/*===========================================================================*/ | |
53 | +/* Module exported functions. */ | |
54 | +/*===========================================================================*/ | |
55 | + | |
56 | +#endif /* SB_CFG_ENABLE_VRQ == TRUE */ | |
57 | + | |
58 | +/** @} */ |
@@ -0,0 +1,78 @@ | ||
1 | +/* | |
2 | + ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014, | |
3 | + 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio. | |
4 | + | |
5 | + This file is part of ChibiOS. | |
6 | + | |
7 | + ChibiOS is free software; you can redistribute it and/or modify | |
8 | + it under the terms of the GNU General Public License as published by | |
9 | + the Free Software Foundation version 3 of the License. | |
10 | + | |
11 | + ChibiOS is distributed in the hope that it will be useful, | |
12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + GNU General Public License for more details. | |
15 | + | |
16 | + You should have received a copy of the GNU General Public License | |
17 | + along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | +*/ | |
19 | + | |
20 | +/** | |
21 | + * @file sb/host/sbvrq.h | |
22 | + * @brief ARM SandBox host Virtual IRQs macros and structures. | |
23 | + * | |
24 | + * @addtogroup ARM_SANDBOX_HOSTAPI | |
25 | + * @{ | |
26 | + */ | |
27 | + | |
28 | +#ifndef SBVRQ_H | |
29 | +#define SBVRQ_H | |
30 | + | |
31 | +#if (SB_CFG_ENABLE_VRQ == TRUE) || defined(__DOXYGEN__) | |
32 | + | |
33 | +/*===========================================================================*/ | |
34 | +/* Module constants. */ | |
35 | +/*===========================================================================*/ | |
36 | + | |
37 | +/*===========================================================================*/ | |
38 | +/* Module pre-compile time settings. */ | |
39 | +/*===========================================================================*/ | |
40 | + | |
41 | +/*===========================================================================*/ | |
42 | +/* Derived constants and error checks. */ | |
43 | +/*===========================================================================*/ | |
44 | + | |
45 | +/*===========================================================================*/ | |
46 | +/* Module data structures and types. */ | |
47 | +/*===========================================================================*/ | |
48 | + | |
49 | +/** | |
50 | + * @brief Type of a mask of Virtual IRQs. | |
51 | + */ | |
52 | +typedef uint32_t sb_vrqmask_t; | |
53 | + | |
54 | +/*===========================================================================*/ | |
55 | +/* Module macros. */ | |
56 | +/*===========================================================================*/ | |
57 | + | |
58 | +/*===========================================================================*/ | |
59 | +/* External declarations. */ | |
60 | +/*===========================================================================*/ | |
61 | + | |
62 | +#ifdef __cplusplus | |
63 | +extern "C" { | |
64 | +#endif | |
65 | + void sbVRQPendI(sb_class_t *sbp, sb_vrqmask_t vmask); | |
66 | +#ifdef __cplusplus | |
67 | +} | |
68 | +#endif | |
69 | + | |
70 | +/*===========================================================================*/ | |
71 | +/* Module inline functions. */ | |
72 | +/*===========================================================================*/ | |
73 | + | |
74 | +#endif /* SB_CFG_ENABLE_VRQ == TRUE */ | |
75 | + | |
76 | +#endif /* SBVRQ_H */ | |
77 | + | |
78 | +/** @} */ |