Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKito Cheng <kito@andestech.com>2017-07-27 11:45:47 +0300
committerJeff Johnston <jjohnstn@redhat.com>2017-08-17 21:51:05 +0300
commitc496cbb6bdbe7d5a81aff83fbaafa2c92336a544 (patch)
treeed04d1b91bb7d73f84c2113d6a7ab301111908e4 /libgloss/riscv/machine/syscall.h
parent7040b2de0883e8346af9c976cd711cf75307e854 (diff)
Add RISC-V port for libglossnewlib-snapshot-20170818
Contributor list: - Andrew Waterman <andrew@sifive.com> - Palmer Dabbelt <palmer@dabbelt.com> - Kito Cheng <kito.cheng@gmail.com> - Alex Suykov <alex.suykov@gmail.com>
Diffstat (limited to 'libgloss/riscv/machine/syscall.h')
-rw-r--r--libgloss/riscv/machine/syscall.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/libgloss/riscv/machine/syscall.h b/libgloss/riscv/machine/syscall.h
new file mode 100644
index 000000000..424bd906a
--- /dev/null
+++ b/libgloss/riscv/machine/syscall.h
@@ -0,0 +1,82 @@
+/* Copyright (c) 2017 SiFive Inc. All rights reserved.
+
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the BSD License. This program is distributed in the hope that
+ it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
+ including the implied warranties of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. A copy of this license is available at
+ http://www.opensource.org/licenses.
+*/
+
+#ifndef _MACHINE_SYSCALL_H
+#define _MACHINE_SYSCALL_H
+
+#define SYS_getcwd 17
+#define SYS_dup 23
+#define SYS_fcntl 25
+#define SYS_faccessat 48
+#define SYS_chdir 49
+#define SYS_openat 56
+#define SYS_close 57
+#define SYS_getdents 61
+#define SYS_lseek 62
+#define SYS_read 63
+#define SYS_write 64
+#define SYS_writev 66
+#define SYS_pread 67
+#define SYS_pwrite 68
+#define SYS_fstatat 79
+#define SYS_fstat 80
+#define SYS_exit 93
+#define SYS_exit_group 94
+#define SYS_kill 129
+#define SYS_rt_sigaction 134
+#define SYS_times 153
+#define SYS_uname 160
+#define SYS_gettimeofday 169
+#define SYS_getpid 172
+#define SYS_getuid 174
+#define SYS_geteuid 175
+#define SYS_getgid 176
+#define SYS_getegid 177
+#define SYS_brk 214
+#define SYS_munmap 215
+#define SYS_mremap 216
+#define SYS_mmap 222
+#define SYS_open 1024
+#define SYS_link 1025
+#define SYS_unlink 1026
+#define SYS_mkdir 1030
+#define SYS_access 1033
+#define SYS_stat 1038
+#define SYS_lstat 1039
+#define SYS_time 1062
+#define SYS_getmainvars 2011
+
+extern long __syscall_error(long);
+
+static inline long
+__internal_syscall(long n, long _a0, long _a1, long _a2, long _a3)
+{
+ register long a0 asm("a0") = _a0;
+ register long a1 asm("a1") = _a1;
+ register long a2 asm("a2") = _a2;
+ register long a3 asm("a3") = _a3;
+
+#ifdef __riscv_32e
+ register long syscall_id asm("t0") = n;
+#else
+ register long syscall_id asm("a7") = n;
+#endif
+
+ asm volatile ("scall"
+ : "+r"(a0) : "r"(a1), "r"(a2), "r"(a3), "r"(syscall_id));
+
+ if (a0 < 0)
+ return __syscall_error (a0);
+ else
+ return a0;
+}
+
+#endif