summaryrefslogtreecommitdiffstats
path: root/bsps/m32c/m32cbsp/console/syscalls.S
diff options
context:
space:
mode:
Diffstat (limited to 'bsps/m32c/m32cbsp/console/syscalls.S')
-rw-r--r--bsps/m32c/m32cbsp/console/syscalls.S43
1 files changed, 43 insertions, 0 deletions
diff --git a/bsps/m32c/m32cbsp/console/syscalls.S b/bsps/m32c/m32cbsp/console/syscalls.S
new file mode 100644
index 0000000000..f4cabac940
--- /dev/null
+++ b/bsps/m32c/m32cbsp/console/syscalls.S
@@ -0,0 +1,43 @@
+/*
+ * System call support for simulator in gdb.
+ * Adapted from newlib 1.16.0.
+ */
+
+#define SYS_exit 1
+#define SYS_open 2
+#define SYS_close 3
+#define SYS_read 4
+#define SYS_write 5
+#define SYS_lseek 6
+#define SYS_unlink 7
+#define SYS_getpid 8
+#define SYS_kill 9
+#define SYS_fstat 10
+#define SYS_sbrk 11
+
+#define POUND #
+#define SYSCALL(N) mov.b POUND N,0x400
+
+#define S(n) _sys_##n: .global _sys_##n | SYSCALL(SYS_##n) | rts
+
+S(write)
+S(exit)
+S(sbrk)
+
+ .global _abort
+_abort:
+ /* This is for debuggers. The simulator stops here too. */
+ brk
+
+ /* Else, fall back on the simulator's "kill me" option. */
+#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
+ mov.w #42,r1
+#else
+ mov.w #42,r0
+#endif
+
+ SYSCALL(SYS_kill)
+
+ /* Else, exit. */
+ jmp.a __exit
+