github.com/letsencrypt/go@v0.0.0-20160714163537-4054769a31f6/src/syscall/asm_freebsd_amd64.s (about)

     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  // TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
     6  // so that go vet can check that they are correct.
     7  
     8  #include "textflag.h"
     9  #include "funcdata.h"
    10  
    11  //
    12  // System call support for AMD64, FreeBSD
    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  // func Syscall9(trap int64, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int64)
    18  // Trap # in AX, args in DI SI DX, return in AX DX
    19  
    20  TEXT	·Syscall(SB),NOSPLIT,$0-56
    21  	CALL	runtime·entersyscall(SB)
    22  	MOVQ	16(SP), DI
    23  	MOVQ	24(SP), SI
    24  	MOVQ	32(SP), DX
    25  	MOVQ	$0, R10
    26  	MOVQ	$0, R8
    27  	MOVQ	$0, R9
    28  	MOVQ	8(SP), AX	// syscall entry
    29  	SYSCALL
    30  	JCC	ok
    31  	MOVQ	$-1, 40(SP)	// r1
    32  	MOVQ	$0, 48(SP)	// r2
    33  	MOVQ	AX, 56(SP)  // errno
    34  	CALL	runtime·exitsyscall(SB)
    35  	RET
    36  ok:
    37  	MOVQ	AX, 40(SP)	// r1
    38  	MOVQ	DX, 48(SP)	// r2
    39  	MOVQ	$0, 56(SP)	// errno
    40  	CALL	runtime·exitsyscall(SB)
    41  	RET
    42  
    43  TEXT	·Syscall6(SB),NOSPLIT,$0-80
    44  	CALL	runtime·entersyscall(SB)
    45  	MOVQ	16(SP), DI
    46  	MOVQ	24(SP), SI
    47  	MOVQ	32(SP), DX
    48  	MOVQ	40(SP), R10
    49  	MOVQ	48(SP), R8
    50  	MOVQ	56(SP), R9
    51  	MOVQ	8(SP), AX	// syscall entry
    52  	SYSCALL
    53  	JCC	ok6
    54  	MOVQ	$-1, 64(SP)	// r1
    55  	MOVQ	$0, 72(SP)	// r2
    56  	MOVQ	AX, 80(SP)  // errno
    57  	CALL	runtime·exitsyscall(SB)
    58  	RET
    59  ok6:
    60  	MOVQ	AX, 64(SP)	// r1
    61  	MOVQ	DX, 72(SP)	// r2
    62  	MOVQ	$0, 80(SP)	// errno
    63  	CALL	runtime·exitsyscall(SB)
    64  	RET
    65  
    66  TEXT	·Syscall9(SB),NOSPLIT,$0-104
    67  	CALL	runtime·entersyscall(SB)
    68  	MOVQ	8(SP), AX
    69  	MOVQ	16(SP), DI
    70  	MOVQ	24(SP), SI
    71  	MOVQ	32(SP), DX
    72  	MOVQ	40(SP),	R10
    73  	MOVQ	48(SP), R8
    74  	MOVQ	56(SP), R9
    75  
    76  	// shift around the last three arguments so they're at the
    77  	// top of the stack when the syscall is called.
    78  	MOVQ	64(SP), R11 // arg 7
    79  	MOVQ	R11, 8(SP)
    80  	MOVQ	72(SP), R11 // arg 8
    81  	MOVQ	R11, 16(SP)
    82  	MOVQ	80(SP), R11 // arg 9
    83  	MOVQ	R11, 24(SP)
    84  
    85  	SYSCALL
    86  	JCC	ok9
    87  	MOVQ	$-1, 88(SP)	// r1
    88  	MOVQ	$0, 96(SP)	// r2
    89  	MOVQ	AX, 104(SP)  // errno
    90  	CALL	runtime·exitsyscall(SB)
    91  	RET
    92  ok9:
    93  	MOVQ	AX, 88(SP)	// r1
    94  	MOVQ	DX, 96(SP)	// r2
    95  	MOVQ	$0, 104(SP)	// errno
    96  	CALL	runtime·exitsyscall(SB)
    97  	RET
    98  
    99  TEXT ·RawSyscall(SB),NOSPLIT,$0-56
   100  	MOVQ	16(SP), DI
   101  	MOVQ	24(SP), SI
   102  	MOVQ	32(SP), DX
   103  	MOVQ	$0, R10
   104  	MOVQ	$0, R8
   105  	MOVQ	$0, R9
   106  	MOVQ	8(SP), AX	// syscall entry
   107  	SYSCALL
   108  	JCC	ok1
   109  	MOVQ	$-1, 40(SP)	// r1
   110  	MOVQ	$0, 48(SP)	// r2
   111  	MOVQ	AX, 56(SP)  // errno
   112  	RET
   113  ok1:
   114  	MOVQ	AX, 40(SP)	// r1
   115  	MOVQ	DX, 48(SP)	// r2
   116  	MOVQ	$0, 56(SP)	// errno
   117  	RET
   118  
   119  TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
   120  	MOVQ	16(SP), DI
   121  	MOVQ	24(SP), SI
   122  	MOVQ	32(SP), DX
   123  	MOVQ	40(SP), R10
   124  	MOVQ	48(SP), R8
   125  	MOVQ	56(SP), R9
   126  	MOVQ	8(SP), AX	// syscall entry
   127  	SYSCALL
   128  	JCC	ok2
   129  	MOVQ	$-1, 64(SP)	// r1
   130  	MOVQ	$0, 72(SP)	// r2
   131  	MOVQ	AX, 80(SP)  // errno
   132  	RET
   133  ok2:
   134  	MOVQ	AX, 64(SP)	// r1
   135  	MOVQ	DX, 72(SP)	// r2
   136  	MOVQ	$0, 80(SP)	// errno
   137  	RET