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_gettid 178
29 #define SYS_gettimeofday 169
31 #define SYS_madvise 233
32 #define SYS_mincore 232
34 #define SYS_munmap 215
35 #define SYS_nanosleep 101
38 #define SYS_pselect6 72
40 #define SYS_rt_sigaction 134
41 #define SYS_rt_sigprocmask 135
42 #define SYS_rt_sigreturn 139
43 #define SYS_sched_getaffinity 123
44 #define SYS_sched_yield 124
45 #define SYS_setitimer 103
46 #define SYS_sigaltstack 132
47 #define SYS_socket 198
48 #define SYS_tgkill 131
52 // func exit(code int32)
53 TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4
55 MOV $SYS_exit_group, A7
59 // func exitThread(wait *uint32)
60 TEXT runtime·exitThread(SB),NOSPLIT|NOFRAME,$0-8
62 // We're done using the stack.
66 MOV $0, A0 // exit code
71 // func open(name *byte, mode, perm int32) int32
72 TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20
85 // func closefd(fd int32) int32
86 TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12
96 // func write1(fd uintptr, p unsafe.Pointer, n int32) int32
97 TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28
106 // func read(fd int32, p unsafe.Pointer, n int32) int32
107 TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28
116 // func pipe() (r, w int32, errno int32)
117 TEXT runtime·pipe(SB),NOSPLIT|NOFRAME,$0-12
125 // func pipe2(flags int32) (r, w int32, errno int32)
126 TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
131 MOVW A0, errno+16(FP)
134 // func usleep(usec uint32)
135 TEXT runtime·usleep(SB),NOSPLIT,$24-4
146 MOV $SYS_nanosleep, A7
150 // func gettid() uint32
151 TEXT runtime·gettid(SB),NOSPLIT,$0-4
157 // func raise(sig uint32)
158 TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0
161 // arg 1 tid - already in A0
162 MOVW sig+0(FP), A1 // arg 2
167 // func raiseproc(sig uint32)
168 TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
171 // arg 1 pid - already in A0
172 MOVW sig+0(FP), A1 // arg 2
178 TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
184 // func tgkill(tgid, tid, sig int)
185 TEXT ·tgkill(SB),NOSPLIT|NOFRAME,$0-24
193 // func setitimer(mode int32, new, old *itimerval)
194 TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
198 MOV $SYS_setitimer, A7
202 // func mincore(addr unsafe.Pointer, n uintptr, dst *byte) int32
203 TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28
212 // func walltime() (sec int64, nsec int32)
213 TEXT runtime·walltime(SB),NOSPLIT,$24-12
214 MOV $0, A0 // CLOCK_REALTIME
216 MOV $SYS_clock_gettime, A7
219 MOV 16(X2), T1 // nsec
224 // func nanotime1() int64
225 TEXT runtime·nanotime1(SB),NOSPLIT,$24-8
226 MOV $1, A0 // CLOCK_MONOTONIC
228 MOV $SYS_clock_gettime, A7
231 MOV 16(X2), T1 // nsec
232 // sec is in T0, nsec in T1
240 // func rtsigprocmask(how int32, new, old *sigset, size int32)
241 TEXT runtime·rtsigprocmask(SB),NOSPLIT|NOFRAME,$0-28
246 MOV $SYS_rt_sigprocmask, A7
253 // func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32
254 TEXT runtime·rt_sigaction(SB),NOSPLIT|NOFRAME,$0-36
259 MOV $SYS_rt_sigaction, A7
264 // func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
265 TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
273 // func sigtramp(signo, ureg, ctxt unsafe.Pointer)
274 TEXT runtime·sigtramp(SB),NOSPLIT,$64
279 // this might be called in external code context,
280 // where g is not set.
281 MOVBU runtime·iscgo(SB), A0
283 CALL runtime·load_g(SB)
285 MOV $runtime·sigtrampgo(SB), A0
289 // func cgoSigtramp()
290 TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0
291 MOV $runtime·sigtramp(SB), T1
294 // func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (p unsafe.Pointer, err int)
295 TEXT runtime·mmap(SB),NOSPLIT|NOFRAME,$0
299 MOVW flags+20(FP), A3
315 // func munmap(addr unsafe.Pointer, n uintptr)
316 TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0
326 // func madvise(addr unsafe.Pointer, n uintptr, flags int32)
327 TEXT runtime·madvise(SB),NOSPLIT|NOFRAME,$0
330 MOVW flags+16(FP), A2
336 // func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32
337 TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0
349 // func clone(flags int32, stk, mp, gp, fn unsafe.Pointer) int32
350 TEXT runtime·clone(SB),NOSPLIT|NOFRAME,$0
354 // Copy mp, gp, fn off parent stack for use by child.
368 // In parent, return.
370 MOVW ZERO, ret+40(FP)
374 // In child, on new stack.
381 // Initialize m->procid to Linux tid
385 MOV -24(X2), T2 // fn
394 // In child, set up new stack
402 // It shouldn't return. If it does, exit this thread.
406 JMP -3(PC) // keep exiting
408 // func sigaltstack(new, old *stackt)
409 TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0
412 MOV $SYS_sigaltstack, A7
420 TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0
421 MOV $SYS_sched_yield, A7
425 // func sched_getaffinity(pid, len uintptr, buf *uintptr) int32
426 TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0
430 MOV $SYS_sched_getaffinity, A7
435 // func epollcreate(size int32) int32
436 TEXT runtime·epollcreate(SB),NOSPLIT|NOFRAME,$0
438 MOV $SYS_epoll_create1, A7
443 // func epollcreate1(flags int32) int32
444 TEXT runtime·epollcreate1(SB),NOSPLIT|NOFRAME,$0
446 MOV $SYS_epoll_create1, A7
451 // func epollctl(epfd, op, fd int32, ev *epollevent) int32
452 TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
457 MOV $SYS_epoll_ctl, A7
462 // func epollwait(epfd int32, ev *epollevent, nev, timeout int32) int32
463 TEXT runtime·epollwait(SB),NOSPLIT|NOFRAME,$0
467 MOVW timeout+20(FP), A3
469 MOV $SYS_epoll_pwait, A7
474 // func closeonexec(int32)
475 TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
476 MOVW fd+0(FP), A0 // fd
477 MOV $2, A1 // F_SETFD
478 MOV $1, A2 // FD_CLOEXEC
483 // func runtime·setNonblock(int32 fd)
484 TEXT runtime·setNonblock(SB),NOSPLIT|NOFRAME,$0-4
485 MOVW fd+0(FP), A0 // fd
486 MOV $3, A1 // F_GETFL
490 MOV $0x800, A2 // O_NONBLOCK
492 MOVW fd+0(FP), A0 // fd
493 MOV $4, A1 // F_SETFL
498 // func sbrk0() uintptr
499 TEXT runtime·sbrk0(SB),NOSPLIT,$0-8
500 // Implemented as brk(NULL).