Text file
src/syscall/asm_linux_amd64.s
1 // Copyright 2009 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 #include "funcdata.h"
7
8 //
9 // System calls for AMD64, Linux
10 //
11
12 #define SYS_gettimeofday 96
13
14 // func Syscall(trap int64, a1, a2, a3 uintptr) (r1, r2, err uintptr);
15 // Trap # in AX, args in DI SI DX R10 R8 R9, return in AX DX
16 // Note that this differs from "standard" ABI convention, which
17 // would pass 4th arg in CX, not R10.
18
19 TEXT ·Syscall(SB),NOSPLIT,$0-56
20 CALL runtime·entersyscall(SB)
21 MOVQ a1+8(FP), DI
22 MOVQ a2+16(FP), SI
23 MOVQ a3+24(FP), DX
24 MOVQ trap+0(FP), AX // syscall entry
25 SYSCALL
26 CMPQ AX, $0xfffffffffffff001
27 JLS ok
28 MOVQ $-1, r1+32(FP)
29 MOVQ $0, r2+40(FP)
30 NEGQ AX
31 MOVQ AX, err+48(FP)
32 CALL runtime·exitsyscall(SB)
33 RET
34 ok:
35 MOVQ AX, r1+32(FP)
36 MOVQ DX, r2+40(FP)
37 MOVQ $0, err+48(FP)
38 CALL runtime·exitsyscall(SB)
39 RET
40
41 // func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
42 TEXT ·Syscall6(SB),NOSPLIT,$0-80
43 CALL runtime·entersyscall(SB)
44 MOVQ a1+8(FP), DI
45 MOVQ a2+16(FP), SI
46 MOVQ a3+24(FP), DX
47 MOVQ a4+32(FP), R10
48 MOVQ a5+40(FP), R8
49 MOVQ a6+48(FP), R9
50 MOVQ trap+0(FP), AX // syscall entry
51 SYSCALL
52 CMPQ AX, $0xfffffffffffff001
53 JLS ok6
54 MOVQ $-1, r1+56(FP)
55 MOVQ $0, r2+64(FP)
56 NEGQ AX
57 MOVQ AX, err+72(FP)
58 CALL runtime·exitsyscall(SB)
59 RET
60 ok6:
61 MOVQ AX, r1+56(FP)
62 MOVQ DX, r2+64(FP)
63 MOVQ $0, err+72(FP)
64 CALL runtime·exitsyscall(SB)
65 RET
66
67 // func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
68 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
69 MOVQ a1+8(FP), DI
70 MOVQ a2+16(FP), SI
71 MOVQ a3+24(FP), DX
72 MOVQ trap+0(FP), AX // syscall entry
73 SYSCALL
74 CMPQ AX, $0xfffffffffffff001
75 JLS ok1
76 MOVQ $-1, r1+32(FP)
77 MOVQ $0, r2+40(FP)
78 NEGQ AX
79 MOVQ AX, err+48(FP)
80 RET
81 ok1:
82 MOVQ AX, r1+32(FP)
83 MOVQ DX, r2+40(FP)
84 MOVQ $0, err+48(FP)
85 RET
86
87 // func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
88 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
89 MOVQ a1+8(FP), DI
90 MOVQ a2+16(FP), SI
91 MOVQ a3+24(FP), DX
92 MOVQ a4+32(FP), R10
93 MOVQ a5+40(FP), R8
94 MOVQ a6+48(FP), R9
95 MOVQ trap+0(FP), AX // syscall entry
96 SYSCALL
97 CMPQ AX, $0xfffffffffffff001
98 JLS ok2
99 MOVQ $-1, r1+56(FP)
100 MOVQ $0, r2+64(FP)
101 NEGQ AX
102 MOVQ AX, err+72(FP)
103 RET
104 ok2:
105 MOVQ AX, r1+56(FP)
106 MOVQ DX, r2+64(FP)
107 MOVQ $0, err+72(FP)
108 RET
109
110 // func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
111 TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-32
112 MOVQ a1+8(FP), DI
113 MOVQ $0, SI
114 MOVQ $0, DX
115 MOVQ $0, R10
116 MOVQ $0, R8
117 MOVQ $0, R9
118 MOVQ trap+0(FP), AX // syscall entry
119 POPQ R12 // preserve return address
120 SYSCALL
121 PUSHQ R12
122 CMPQ AX, $0xfffffffffffff001
123 JLS ok2
124 MOVQ $-1, r1+16(FP)
125 NEGQ AX
126 MOVQ AX, err+24(FP)
127 RET
128 ok2:
129 MOVQ AX, r1+16(FP)
130 MOVQ $0, err+24(FP)
131 RET
132
133 // func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr)
134 TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-48
135 MOVQ a1+8(FP), DI
136 MOVQ a2+16(FP), SI
137 MOVQ a3+24(FP), DX
138 MOVQ trap+0(FP), AX // syscall entry
139 SYSCALL
140 MOVQ AX, r1+32(FP)
141 MOVQ DX, r2+40(FP)
142 RET
143
144 // func gettimeofday(tv *Timeval) (err uintptr)
145 TEXT ·gettimeofday(SB),NOSPLIT,$0-16
146 MOVQ tv+0(FP), DI
147 MOVQ $0, SI
148 MOVQ runtime·vdsoGettimeofdaySym(SB), AX
149 TESTQ AX, AX
150 JZ fallback
151 CALL AX
152 ret:
153 CMPQ AX, $0xfffffffffffff001
154 JLS ok7
155 NEGQ AX
156 MOVQ AX, err+8(FP)
157 RET
158 fallback:
159 MOVL $SYS_gettimeofday, AX
160 SYSCALL
161 JMP ret
162 ok7:
163 MOVQ $0, err+8(FP)
164 RET
165
View as plain text