1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
6 // System calls and other sys.stuff for riscv64, Linux
15 #define SYS_clock_gettime 113
18 #define SYS_connect 203
19 #define SYS_epoll_create1 20
20 #define SYS_epoll_ctl 21
21 #define SYS_epoll_pwait 22
23 #define SYS_exit_group 94
24 #define SYS_faccessat 48
27 #define SYS_getpid 172
28 #define SYS_getrlimit 163
29 #define SYS_gettid 178
30 #define SYS_gettimeofday 169
32 #define SYS_madvise 233
33 #define SYS_mincore 232
35 #define SYS_munmap 215
36 #define SYS_nanosleep 101
39 #define SYS_pselect6 72
41 #define SYS_rt_sigaction 134
42 #define SYS_rt_sigprocmask 135
43 #define SYS_rt_sigreturn 139
44 #define SYS_sched_getaffinity 123
45 #define SYS_sched_yield 124
46 #define SYS_setitimer 103
47 #define SYS_sigaltstack 132
48 #define SYS_socket 198
49 #define SYS_tgkill 131
53 // func exit(code int32)
54 TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4
56 MOV $SYS_exit_group, A7
60 // func exitThread(wait *uint32)
61 TEXT runtime·exitThread(SB),NOSPLIT|NOFRAME,$0-8
63 // We're done using the stack.
67 MOV $0, A0 // exit code
72 // func open(name *byte, mode, perm int32) int32
73 TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20
86 // func closefd(fd int32) int32
87 TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12
97 // func write1(fd uintptr, p unsafe.Pointer, n int32) int32
98 TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28
107 // func read(fd int32, p unsafe.Pointer, n int32) int32
108 TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28
117 // func pipe() (r, w int32, errno int32)
118 TEXT runtime·pipe(SB),NOSPLIT|NOFRAME,$0-12
126 // func pipe2(flags int32) (r, w int32, errno int32)
127 TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
132 MOVW A0, errno+16(FP)
135 // func getrlimit(kind int32, limit unsafe.Pointer) int32
136 TEXT runtime·getrlimit(SB),NOSPLIT|NOFRAME,$0-20
139 MOV $SYS_getrlimit, A7
144 // func usleep(usec uint32)
145 TEXT runtime·usleep(SB),NOSPLIT,$24-4
156 MOV $SYS_nanosleep, A7
160 // func gettid() uint32
161 TEXT runtime·gettid(SB),NOSPLIT,$0-4
167 // func raise(sig uint32)
168 TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0
171 // arg 1 tid - already in A0
172 MOVW sig+0(FP), A1 // arg 2
177 // func raiseproc(sig uint32)
178 TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
181 // arg 1 pid - already in A0
182 MOVW sig+0(FP), A1 // arg 2
188 TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
194 // func tgkill(tgid, tid, sig int)
195 TEXT ·tgkill(SB),NOSPLIT|NOFRAME,$0-24
203 // func setitimer(mode int32, new, old *itimerval)
204 TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
208 MOV $SYS_setitimer, A7
212 // func mincore(addr unsafe.Pointer, n uintptr, dst *byte) int32
213 TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28
222 // func walltime() (sec int64, nsec int32)
223 TEXT runtime·walltime(SB),NOSPLIT,$24-12
224 MOV $0, A0 // CLOCK_REALTIME
226 MOV $SYS_clock_gettime, A7
229 MOV 16(X2), T1 // nsec
234 // func nanotime1() int64
235 TEXT runtime·nanotime1(SB),NOSPLIT,$24-8
236 MOV $1, A0 // CLOCK_MONOTONIC
238 MOV $SYS_clock_gettime, A7
241 MOV 16(X2), T1 // nsec
242 // sec is in T0, nsec in T1
250 // func rtsigprocmask(how int32, new, old *sigset, size int32)
251 TEXT runtime·rtsigprocmask(SB),NOSPLIT|NOFRAME,$0-28
256 MOV $SYS_rt_sigprocmask, A7
263 // func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32
264 TEXT runtime·rt_sigaction(SB),NOSPLIT|NOFRAME,$0-36
269 MOV $SYS_rt_sigaction, A7
274 // func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
275 TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
283 // func sigtramp(signo, ureg, ctxt unsafe.Pointer)
284 TEXT runtime·sigtramp(SB),NOSPLIT,$64
289 // this might be called in external code context,
290 // where g is not set.
291 MOVBU runtime·iscgo(SB), A0
293 CALL runtime·load_g(SB)
295 MOV $runtime·sigtrampgo(SB), A0
299 // func cgoSigtramp()
300 TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0
301 MOV $runtime·sigtramp(SB), T1
304 // func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (p unsafe.Pointer, err int)
305 TEXT runtime·mmap(SB),NOSPLIT|NOFRAME,$0
309 MOVW flags+20(FP), A3
325 // func munmap(addr unsafe.Pointer, n uintptr)
326 TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0
336 // func madvise(addr unsafe.Pointer, n uintptr, flags int32)
337 TEXT runtime·madvise(SB),NOSPLIT|NOFRAME,$0
340 MOVW flags+16(FP), A2
346 // func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32
347 TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0
359 // func clone(flags int32, stk, mp, gp, fn unsafe.Pointer) int32
360 TEXT runtime·clone(SB),NOSPLIT|NOFRAME,$0
364 // Copy mp, gp, fn off parent stack for use by child.
378 // In parent, return.
380 MOVW ZERO, ret+40(FP)
384 // In child, on new stack.
391 // Initialize m->procid to Linux tid
395 MOV -24(X2), T2 // fn
404 // In child, set up new stack
412 // It shouldn't return. If it does, exit this thread.
416 JMP -3(PC) // keep exiting
418 // func sigaltstack(new, old *stackt)
419 TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0
422 MOV $SYS_sigaltstack, A7
430 TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0
431 MOV $SYS_sched_yield, A7
435 // func sched_getaffinity(pid, len uintptr, buf *uintptr) int32
436 TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0
440 MOV $SYS_sched_getaffinity, A7
445 // func epollcreate(size int32) int32
446 TEXT runtime·epollcreate(SB),NOSPLIT|NOFRAME,$0
448 MOV $SYS_epoll_create1, A7
453 // func epollcreate1(flags int32) int32
454 TEXT runtime·epollcreate1(SB),NOSPLIT|NOFRAME,$0
456 MOV $SYS_epoll_create1, A7
461 // func epollctl(epfd, op, fd int32, ev *epollevent) int32
462 TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
467 MOV $SYS_epoll_ctl, A7
472 // func epollwait(epfd int32, ev *epollevent, nev, timeout int32) int32
473 TEXT runtime·epollwait(SB),NOSPLIT|NOFRAME,$0
477 MOVW timeout+20(FP), A3
479 MOV $SYS_epoll_pwait, A7
484 // func closeonexec(int32)
485 TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
486 MOVW fd+0(FP), A0 // fd
487 MOV $2, A1 // F_SETFD
488 MOV $1, A2 // FD_CLOEXEC
493 // func runtime·setNonblock(int32 fd)
494 TEXT runtime·setNonblock(SB),NOSPLIT|NOFRAME,$0-4
495 MOVW fd+0(FP), A0 // fd
496 MOV $3, A1 // F_GETFL
500 MOV $0x800, A2 // O_NONBLOCK
502 MOVW fd+0(FP), A0 // fd
503 MOV $4, A1 // F_SETFL
508 // func sbrk0() uintptr
509 TEXT runtime·sbrk0(SB),NOSPLIT,$0-8
510 // Implemented as brk(NULL).