Black Lives Matter. Support the Equal Justice Initiative.

Text file src/syscall/asm_unix_amd64.s

Documentation: syscall

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

View as plain text