Black Lives Matter. Support the Equal Justice Initiative.

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

View as plain text