aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-01-18 04:45:21 +1100
committerGitHub <noreply@github.com>2021-01-18 04:45:21 +1100
commite524e0a397efe3424cffe6e9d75be5dcf589b685 (patch)
tree243d95e4d327ffe87072d5bc90becd62262194ad
parentda40242dbc2b03437774a58bb7b8d35f4b59a2cd (diff)
downloadqmk_firmware-e524e0a397efe3424cffe6e9d75be5dcf589b685.tar.gz
qmk_firmware-e524e0a397efe3424cffe6e9d75be5dcf589b685.zip
Add syscall fallbacks to ChibiOS builds (#11573)
* Add fallback syscalls to ChibiOS builds that are present but able to be overridden as appropriate. * Modified location to be ChibiOS-specific.
-rw-r--r--tmk_core/chibios.mk3
-rw-r--r--tmk_core/common/chibios/syscall-fallbacks.c91
2 files changed, 93 insertions, 1 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 733f2d60f..e94e935eb 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -204,7 +204,8 @@ CHIBISRC = $(STARTUPSRC) \
204 $(PLATFORMSRC) \ 204 $(PLATFORMSRC) \
205 $(BOARDSRC) \ 205 $(BOARDSRC) \
206 $(STREAMSSRC) \ 206 $(STREAMSSRC) \
207 $(CHIBIOS)/os/various/syscalls.c 207 $(CHIBIOS)/os/various/syscalls.c \
208 $(PLATFORM_COMMON_DIR)/syscall-fallbacks.c
208 209
209# Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise. 210# Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise.
210QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM) 211QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM)
diff --git a/tmk_core/common/chibios/syscall-fallbacks.c b/tmk_core/common/chibios/syscall-fallbacks.c
new file mode 100644
index 000000000..5d232a755
--- /dev/null
+++ b/tmk_core/common/chibios/syscall-fallbacks.c
@@ -0,0 +1,91 @@
1/* Copyright 2021 Nick Brassel, QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <sys/stat.h>
18#include <sys/types.h>
19
20#pragma GCC diagnostic ignored "-Wmissing-prototypes"
21
22__attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) {
23 (void)r;
24 (void)file;
25 (void)ptr;
26 (void)len;
27 return -1;
28}
29
30__attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) {
31 (void)r;
32 (void)file;
33 (void)ptr;
34 (void)dir;
35 return 0;
36}
37
38__attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) {
39 (void)r;
40 (void)file;
41 (void)ptr;
42 return len;
43}
44
45__attribute__((weak, used)) int _close_r(struct _reent *r, int file) {
46 (void)r;
47 (void)file;
48 return 0;
49}
50
51__attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) {
52 (void)r;
53 (void)incr;
54 return (caddr_t)-1;
55}
56
57__attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) {
58 (void)r;
59 (void)file;
60 (void)st;
61 return 0;
62}
63
64__attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) {
65 (void)r;
66 (void)fd;
67 return 1;
68}
69
70__attribute__((weak, used)) void _fini(void) { return; }
71
72__attribute__((weak, used)) pid_t _getpid(void) { return 1; }
73
74__attribute__((weak, noreturn)) void _exit(int i) {
75 (void)i;
76 while (1)
77 ;
78}
79
80__attribute__((weak)) void _kill(void) {}
81
82__attribute__((weak)) void *__dso_handle;
83
84void __cxa_pure_virtual(void);
85
86__attribute__((weak)) void __cxa_pure_virtual() {
87 while (1)
88 ;
89}
90
91#pragma GCC diagnostic pop