aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 5a3facf8e..3f426cbb8 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -207,7 +207,8 @@ CHIBISRC = $(STARTUPSRC) \
207 $(PLATFORMSRC) \ 207 $(PLATFORMSRC) \
208 $(BOARDSRC) \ 208 $(BOARDSRC) \
209 $(STREAMSSRC) \ 209 $(STREAMSSRC) \
210 $(CHIBIOS)/os/various/syscalls.c 210 $(CHIBIOS)/os/various/syscalls.c \
211 $(PLATFORM_COMMON_DIR)/syscall-fallbacks.c
211 212
212# Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise. 213# Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise.
213QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM) 214QUANTUM_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