Text file
src/syscall/asm_unix_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 //go:build dragonfly || freebsd || netbsd
6
7 #include "textflag.h"
8 #include "funcdata.h"
9
10 //
11 // System call support for AMD64 unixes
12 //
13
14 // func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64)
15 // func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64)
16 // Trap # in AX, args in DI SI DX, return in AX DX
17
18 TEXT ·Syscall(SB),NOSPLIT,$0-56
19 CALL runtime·entersyscall(SB)
20 MOVQ trap+0(FP), AX // syscall entry
21 MOVQ a1+8(FP), DI
22 MOVQ a2+16(FP), SI
23 MOVQ a3+24(FP), DX
24 SYSCALL
25 JCC ok
26 MOVQ $-1, r1+32(FP) // r1
27 MOVQ $0, r2+40(FP) // r2
28 MOVQ AX, err+48(FP) // errno
29 CALL runtime·exitsyscall(SB)
30 RET
31 ok:
32 MOVQ AX, r1+32(FP) // r1
33 MOVQ DX, r2+40(FP) // r2
34 MOVQ $0, err+48(FP) // errno
35 CALL runtime·exitsyscall(SB)
36 RET
37
38 TEXT ·Syscall6(SB),NOSPLIT,$0-80
39 CALL runtime·entersyscall(SB)
40 MOVQ trap+0(FP), AX // syscall entry
41 MOVQ a1+8(FP), DI
42 MOVQ a2+16(FP), SI
43 MOVQ a3+24(FP), DX
44 MOVQ a4+32(FP), R10
45 MOVQ a5+40(FP), R8
46 MOVQ a6+48(FP), R9
47 SYSCALL
48 JCC ok6
49 MOVQ $-1, r1+56(FP) // r1
50 MOVQ $0, r2+64(FP) // r2
51 MOVQ AX, err+72(FP) // errno
52 CALL runtime·exitsyscall(SB)
53 RET
54 ok6:
55 MOVQ AX, r1+56(FP) // r1
56 MOVQ DX, r2+64(FP) // r2
57 MOVQ $0, err+72(FP) // errno
58 CALL runtime·exitsyscall(SB)
59 RET
60
61 TEXT ·RawSyscall(SB),NOSPLIT,$0-56
62 MOVQ a1+8(FP), DI
63 MOVQ a2+16(FP), SI
64 MOVQ a3+24(FP), DX
65 MOVQ trap+0(FP), AX // syscall entry
66 SYSCALL
67 JCC ok1
68 MOVQ $-1, r1+32(FP) // r1
69 MOVQ $0, r2+40(FP) // r2
70 MOVQ AX, err+48(FP) // errno
71 RET
72 ok1:
73 MOVQ AX, r1+32(FP) // r1
74 MOVQ DX, r2+40(FP) // r2
75 MOVQ $0, err+48(FP) // errno
76 RET
77
78 TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
79 MOVQ a1+8(FP), DI
80 MOVQ a2+16(FP), SI
81 MOVQ a3+24(FP), DX
82 MOVQ a4+32(FP), R10
83 MOVQ a5+40(FP), R8
84 MOVQ a6+48(FP), R9
85 MOVQ trap+0(FP), AX // syscall entry
86 SYSCALL
87 JCC ok2
88 MOVQ $-1, r1+56(FP) // r1
89 MOVQ $0, r2+64(FP) // r2
90 MOVQ AX, err+72(FP) // errno
91 RET
92 ok2:
93 MOVQ AX, r1+56(FP) // r1
94 MOVQ DX, r2+64(FP) // r2
95 MOVQ $0, err+72(FP) // errno
96 RET
97
View as plain text