• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision12991 (tree)
Zeit2019-09-15 16:03:12
Autorgdisirio

Log Message

New files.

Ändern Zusammenfassung

Diff

--- trunk/os/sb/host/sb.h (nonexistent)
+++ trunk/os/sb/host/sb.h (revision 12991)
@@ -0,0 +1,130 @@
1+/*
2+ ChibiOS - Copyright (C) 2006..2019 Giovanni Di Sirio.
3+
4+ This file is part of ChibiOS.
5+
6+ ChibiOS is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
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/sb.h
22+ * @brief ARM sandbox macros and structures.
23+ *
24+ * @addtogroup ARM_SANDBOX
25+ * @{
26+ */
27+
28+#ifndef SB_H
29+#define SB_H
30+
31+#include "sberr.h"
32+#include "sbhost.h"
33+#include "sbapi.h"
34+#include "sbposix.h"
35+
36+/*===========================================================================*/
37+/* Module constants. */
38+/*===========================================================================*/
39+
40+/**
41+ * @brief ChibiOS/SB identification macro.
42+ */
43+#define _CHIBIOS_SB_
44+
45+/**
46+ * @brief Stable release flag.
47+ */
48+#define CH_SB_STABLE 0
49+
50+/**
51+ * @name ChibiOS/SE version identification
52+ * @{
53+ */
54+/**
55+ * @brief Safety Extensions version string.
56+ */
57+#define CH_SB_VERSION "1.0.0"
58+
59+/**
60+ * @brief Safety Extensions version major number.
61+ */
62+#define CH_SB_MAJOR 1
63+
64+/**
65+ * @brief Safety Extensions version minor number.
66+ */
67+#define CH_SB_MINOR 0
68+
69+/**
70+ * @brief Safety Extensions version patch number.
71+ */
72+#define CH_SB_PATCH 0
73+/** @} */
74+
75+/*===========================================================================*/
76+/* Module pre-compile time settings. */
77+/*===========================================================================*/
78+
79+/*===========================================================================*/
80+/* Derived constants and error checks. */
81+/*===========================================================================*/
82+
83+/* License checks.*/
84+#if !defined(CH_CUSTOMER_LIC_SB) || !defined(CH_LICENSE_FEATURES)
85+#error "malformed chlicense.h"
86+#endif
87+
88+#if CH_CUSTOMER_LIC_SB == FALSE
89+#error "ChibiOS/SB not licensed"
90+#endif
91+
92+#if CH_CFG_ST_RESOLUTION != 32
93+#error "SandBox requires CH_CFG_ST_RESOLUTION == 32"
94+#endif
95+
96+#if CH_CFG_INTERVALS_SIZE != 32
97+#error "SandBox requires CH_CFG_INTERVALS_SIZE == 32"
98+#endif
99+
100+#if PORT_USE_SYSCALL == FALSE
101+#error "SandBox requires PORT_USE_SYSCALL == TRUE"
102+#endif
103+
104+/*===========================================================================*/
105+/* Module data structures and types. */
106+/*===========================================================================*/
107+
108+/*===========================================================================*/
109+/* Module macros. */
110+/*===========================================================================*/
111+
112+/*===========================================================================*/
113+/* External declarations. */
114+/*===========================================================================*/
115+
116+#ifdef __cplusplus
117+extern "C" {
118+#endif
119+
120+#ifdef __cplusplus
121+}
122+#endif
123+
124+/*===========================================================================*/
125+/* Module inline functions. */
126+/*===========================================================================*/
127+
128+#endif /* SBHOST_H */
129+
130+/** @} */
--- trunk/os/sb/host/sbposix.c (nonexistent)
+++ trunk/os/sb/host/sbposix.c (revision 12991)
@@ -0,0 +1,128 @@
1+/*
2+ ChibiOS - Copyright (C) 2006..2019 Giovanni Di Sirio.
3+
4+ This file is part of ChibiOS.
5+
6+ ChibiOS is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
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/sbposix.c
22+ * @brief ARM sandbox host Posix API code.
23+ *
24+ * @addtogroup ARM_SANDBOX_HOSTAPI
25+ * @{
26+ */
27+
28+#include "ch.h"
29+#include "sb.h"
30+
31+/*===========================================================================*/
32+/* Module local definitions. */
33+/*===========================================================================*/
34+
35+/*===========================================================================*/
36+/* Module exported variables. */
37+/*===========================================================================*/
38+
39+/*===========================================================================*/
40+/* Module local types. */
41+/*===========================================================================*/
42+
43+/*===========================================================================*/
44+/* Module local variables. */
45+/*===========================================================================*/
46+
47+/*===========================================================================*/
48+/* Module local functions. */
49+/*===========================================================================*/
50+
51+/*===========================================================================*/
52+/* Module exported functions. */
53+/*===========================================================================*/
54+
55+uint32_t sb_posix_open(const char *pathname, uint32_t flags) {
56+
57+ (void)pathname;
58+ (void)flags;
59+
60+ return SB_ERR_ENOENT;
61+}
62+
63+uint32_t sb_posix_close(uint32_t fd) {
64+
65+ if ((fd == 0U) || (fd == 1U) || (fd == 2U)) {
66+
67+ return SB_ERR_NOERROR;
68+ }
69+
70+ return SB_ERR_EBADFD;
71+}
72+
73+uint32_t sb_posix_read(uint32_t fd, uint8_t *buf, size_t count) {
74+
75+ if (fd == 0U) {
76+ sb_class_t *sbcp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
77+ SandboxStream *ssp = sbcp->config->stdin_stream;
78+
79+ if ((count == 0U) || (ssp == NULL)) {
80+ return 0U;
81+ }
82+
83+ return (uint32_t)ssp->vmt->read((void *)ssp, buf, count);
84+ }
85+
86+ return SB_ERR_EBADFD;
87+}
88+
89+uint32_t sb_posix_write(uint32_t fd, const uint8_t *buf, size_t count) {
90+ sb_class_t *sbcp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
91+
92+ if (fd == 1U) {
93+ SandboxStream *ssp = sbcp->config->stdout_stream;
94+
95+ if ((count == 0U) || (ssp == NULL)) {
96+ return 0U;
97+ }
98+
99+ return (uint32_t)ssp->vmt->write((void *)ssp, buf, count);
100+ }
101+
102+ if (fd == 2U) {
103+ SandboxStream *ssp = sbcp->config->stderr_stream;
104+
105+ if ((count == 0U) || (ssp == NULL)) {
106+ return 0U;
107+ }
108+
109+ return (uint32_t)ssp->vmt->write((void *)ssp, buf, count);
110+ }
111+
112+ return SB_ERR_EBADFD;
113+}
114+
115+uint32_t sb_posix_lseek(uint32_t fd, uint32_t offset, uint32_t whence) {
116+
117+ (void)offset;
118+ (void)whence;
119+
120+ if ((fd == 0U) || (fd == 1U) || (fd == 2U)) {
121+
122+ return SB_ERR_ESPIPE;
123+ }
124+
125+ return SB_ERR_EBADFD;
126+}
127+
128+/** @} */
--- trunk/os/sb/host/sbposix.h (nonexistent)
+++ trunk/os/sb/host/sbposix.h (revision 12991)
@@ -0,0 +1,84 @@
1+/*
2+ ChibiOS - Copyright (C) 2006..2019 Giovanni Di Sirio.
3+
4+ This file is part of ChibiOS.
5+
6+ ChibiOS is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
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/sbposix.h
22+ * @brief ARM sandbox host Posix API macros and structures.
23+ *
24+ * @addtogroup ARM_SANDBOX_POSIX
25+ * @{
26+ */
27+
28+#ifndef SBPOSIX_H
29+#define SBPOSIX_H
30+
31+/*===========================================================================*/
32+/* Module constants. */
33+/*===========================================================================*/
34+
35+/**
36+ * @name Posix-like function codes
37+ * @{
38+ */
39+#define SB_POSIX_OPEN 1
40+#define SB_POSIX_CLOSE 2
41+#define SB_POSIX_READ 3
42+#define SB_POSIX_WRITE 4
43+#define SB_POSIX_LSEEK 5
44+/** @} */
45+
46+/*===========================================================================*/
47+/* Module pre-compile time settings. */
48+/*===========================================================================*/
49+
50+/*===========================================================================*/
51+/* Derived constants and error checks. */
52+/*===========================================================================*/
53+
54+/*===========================================================================*/
55+/* Module data structures and types. */
56+/*===========================================================================*/
57+
58+/*===========================================================================*/
59+/* Module macros. */
60+/*===========================================================================*/
61+
62+/*===========================================================================*/
63+/* External declarations. */
64+/*===========================================================================*/
65+
66+#ifdef __cplusplus
67+extern "C" {
68+#endif
69+ uint32_t sb_posix_open(const char *pathname, uint32_t flags);
70+ uint32_t sb_posix_close(uint32_t fd);
71+ uint32_t sb_posix_read(uint32_t fd, uint8_t *buf, size_t count);
72+ uint32_t sb_posix_write(uint32_t fd, const uint8_t *buf, size_t count);
73+ uint32_t sb_posix_lseek(uint32_t fd, uint32_t offset, uint32_t whence);
74+#ifdef __cplusplus
75+}
76+#endif
77+
78+/*===========================================================================*/
79+/* Module inline functions. */
80+/*===========================================================================*/
81+
82+#endif /* SBPOSIX_H */
83+
84+/** @} */
Show on old repository browser