Text file
src/syscall/asm_linux_riscv64.s
1 // Copyright 2019 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.
4
5 #include "textflag.h"
6
7 //
8 // System calls for riscv64, Linux
9 //
10
11 // func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64)
12 TEXT ·Syscall(SB),NOSPLIT,$0-56
13 CALL runtime·entersyscall(SB)
14 MOV a1+8(FP), A0
15 MOV a2+16(FP), A1
16 MOV a3+24(FP), A2
17 MOV trap+0(FP), A7 // syscall entry
18 ECALL
19 MOV $-4096, T0
20 BLTU T0, A0, err
21 MOV A0, r1+32(FP) // r1
22 MOV A1, r2+40(FP) // r2
23 MOV ZERO, err+48(FP) // errno
24 CALL runtime·exitsyscall(SB)
25 RET
26 err:
27 MOV $-1, T0
28 MOV T0, r1+32(FP) // r1
29 MOV ZERO, r2+40(FP) // r2
30 SUB A0, ZERO, A0
31 MOV A0, err+48(FP) // errno
32 CALL runtime·exitsyscall(SB)
33 RET
34
35 // func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
36 TEXT ·Syscall6(SB),NOSPLIT,$0-80
37 CALL runtime·entersyscall(SB)
38 MOV a1+8(FP), A0
39 MOV a2+16(FP), A1
40 MOV a3+24(FP), A2
41 MOV a4+32(FP), A3
42 MOV a5+40(FP), A4
43 MOV a6+48(FP), A5
44 MOV trap+0(FP), A7 // syscall entry
45 ECALL
46 MOV $-4096, T0
47 BLTU T0, A0, err
48 MOV A0, r1+56(FP) // r1
49 MOV A1, r2+64(FP) // r2
50 MOV ZERO, err+72(FP) // errno
51 CALL runtime·exitsyscall(SB)
52 RET
53 err:
54 MOV $-1, T0
55 MOV T0, r1+56(FP) // r1
56 MOV ZERO, r2+64(FP) // r2
57 SUB A0, ZERO, A0
58 MOV A0, err+72(FP) // errno
59 CALL runtime·exitsyscall(SB)
60 RET
61
62 // func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
63 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
64 MOV a1+8(FP), A0
65 MOV a2+16(FP), A1
66 MOV a3+24(FP), A2
67 MOV trap+0(FP), A7 // syscall entry
68 ECALL
69 MOV $-4096, T0
70 BLTU T0, A0, err
71 MOV A0, r1+32(FP) // r1
72 MOV A1, r2+40(FP) // r2
73 MOV ZERO, err+48(FP) // errno
74 RET
75 err:
76 MOV $-1, T0
77 MOV T0, r1+32(FP) // r1
78 MOV ZERO, r2+40(FP) // r2
79 SUB A0, ZERO, A0
80 MOV A0, err+48(FP) // errno
81 RET
82
83 // func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
84 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
85 MOV a1+8(FP), A0
86 MOV a2+16(FP), A1
87 MOV a3+24(FP), A2
88 MOV a4+32(FP), A3
89 MOV a5+40(FP), A4
90 MOV a6+48(FP), A5
91 MOV trap+0(FP), A7 // syscall entry
92 ECALL
93 MOV $-4096, T0
94 BLTU T0, A0, err
95 MOV A0, r1+56(FP) // r1
96 MOV A1, r2+64(FP) // r2
97 MOV ZERO, err+72(FP) // errno
98 RET
99 err:
100 MOV $-1, T0
101 MOV T0, r1+56(FP) // r1
102 MOV ZERO, r2+64(FP) // r2
103 SUB A0, ZERO, A0
104 MOV A0, err+72(FP) // errno
105 RET
106
107 // func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
108 TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
109 MOV a1+8(FP), A0
110 MOV ZERO, A1
111 MOV ZERO, A2
112 MOV ZERO, A3
113 MOV ZERO, A4
114 MOV ZERO, A5
115 MOV trap+0(FP), A7 // syscall entry
116 ECALL
117 MOV $-4096, T0
118 BLTU T0, A0, err
119 MOV A0, r1+16(FP) // r1
120 MOV ZERO, err+24(FP) // errno
121 RET
122 err:
123 MOV $-1, T0
124 MOV T0, r1+16(FP) // r1
125 SUB A0, ZERO, A0
126 MOV A0, err+24(FP) // errno
127 RET
128
129 TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-48
130 MOV a1+8(FP), A0
131 MOV a2+16(FP), A1
132 MOV a3+24(FP), A2
133 MOV trap+0(FP), A7 // syscall entry
134 ECALL
135 MOV A0, r1+32(FP)
136 MOV A1, r2+40(FP)
137 RET
138
View as plain text