...
Run Format

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	$0, R10
    23	MOVQ	$0, R8
    24	MOVQ	$0, R9
    25	MOVQ	trap+0(FP), AX	// syscall entry
    26	SYSCALL
    27	CMPQ	AX, $0xfffffffffffff001
    28	JLS	ok
    29	MOVQ	$-1, r1+32(FP)
    30	MOVQ	$0, r2+40(FP)
    31	NEGQ	AX
    32	MOVQ	AX, err+48(FP)
    33	CALL	runtime·exitsyscall(SB)
    34	RET
    35ok:
    36	MOVQ	AX, r1+32(FP)
    37	MOVQ	DX, r2+40(FP)
    38	MOVQ	$0, err+48(FP)
    39	CALL	runtime·exitsyscall(SB)
    40	RET
    41
    42// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
    43TEXT ·Syscall6(SB),NOSPLIT,$0-80
    44	CALL	runtime·entersyscall(SB)
    45	MOVQ	a1+8(FP), DI
    46	MOVQ	a2+16(FP), SI
    47	MOVQ	a3+24(FP), DX
    48	MOVQ	a4+32(FP), R10
    49	MOVQ	a5+40(FP), R8
    50	MOVQ	a6+48(FP), R9
    51	MOVQ	trap+0(FP), AX	// syscall entry
    52	SYSCALL
    53	CMPQ	AX, $0xfffffffffffff001
    54	JLS	ok6
    55	MOVQ	$-1, r1+56(FP)
    56	MOVQ	$0, r2+64(FP)
    57	NEGQ	AX
    58	MOVQ	AX, err+72(FP)
    59	CALL	runtime·exitsyscall(SB)
    60	RET
    61ok6:
    62	MOVQ	AX, r1+56(FP)
    63	MOVQ	DX, r2+64(FP)
    64	MOVQ	$0, err+72(FP)
    65	CALL	runtime·exitsyscall(SB)
    66	RET
    67
    68// func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
    69TEXT ·RawSyscall(SB),NOSPLIT,$0-56
    70	MOVQ	a1+8(FP), DI
    71	MOVQ	a2+16(FP), SI
    72	MOVQ	a3+24(FP), DX
    73	MOVQ	$0, R10
    74	MOVQ	$0, R8
    75	MOVQ	$0, R9
    76	MOVQ	trap+0(FP), AX	// syscall entry
    77	SYSCALL
    78	CMPQ	AX, $0xfffffffffffff001
    79	JLS	ok1
    80	MOVQ	$-1, r1+32(FP)
    81	MOVQ	$0, r2+40(FP)
    82	NEGQ	AX
    83	MOVQ	AX, err+48(FP)
    84	RET
    85ok1:
    86	MOVQ	AX, r1+32(FP)
    87	MOVQ	DX, r2+40(FP)
    88	MOVQ	$0, err+48(FP)
    89	RET
    90
    91// func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
    92TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
    93	MOVQ	a1+8(FP), DI
    94	MOVQ	a2+16(FP), SI
    95	MOVQ	a3+24(FP), DX
    96	MOVQ	a4+32(FP), R10
    97	MOVQ	a5+40(FP), R8
    98	MOVQ	a6+48(FP), R9
    99	MOVQ	trap+0(FP), AX	// syscall entry
   100	SYSCALL
   101	CMPQ	AX, $0xfffffffffffff001
   102	JLS	ok2
   103	MOVQ	$-1, r1+56(FP)
   104	MOVQ	$0, r2+64(FP)
   105	NEGQ	AX
   106	MOVQ	AX, err+72(FP)
   107	RET
   108ok2:
   109	MOVQ	AX, r1+56(FP)
   110	MOVQ	DX, r2+64(FP)
   111	MOVQ	$0, err+72(FP)
   112	RET
   113
   114// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
   115TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-32
   116	MOVQ	a1+8(FP), DI
   117	MOVQ	$0, SI
   118	MOVQ	$0, DX
   119	MOVQ	$0, R10
   120	MOVQ	$0, R8
   121	MOVQ	$0, R9
   122	MOVQ	trap+0(FP), AX	// syscall entry
   123	POPQ	R12 // preserve return address
   124	SYSCALL
   125	PUSHQ	R12
   126	CMPQ	AX, $0xfffffffffffff001
   127	JLS	ok2
   128	MOVQ	$-1, r1+16(FP)
   129	NEGQ	AX
   130	MOVQ	AX, err+24(FP)
   131	RET
   132ok2:
   133	MOVQ	AX, r1+16(FP)
   134	MOVQ	$0, err+24(FP)
   135	RET
   136
   137// func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr)
   138TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-48
   139	MOVQ	a1+8(FP), DI
   140	MOVQ	a2+16(FP), SI
   141	MOVQ	a3+24(FP), DX
   142	MOVQ	$0, R10
   143	MOVQ	$0, R8
   144	MOVQ	$0, R9
   145	MOVQ	trap+0(FP), AX	// syscall entry
   146	SYSCALL
   147	MOVQ	AX, r1+32(FP)
   148	MOVQ	DX, r2+40(FP)
   149	RET
   150
   151// func gettimeofday(tv *Timeval) (err uintptr)
   152TEXT ·gettimeofday(SB),NOSPLIT,$0-16
   153	MOVQ	tv+0(FP), DI
   154	MOVQ	$0, SI
   155	MOVQ	runtime·vdsoGettimeofdaySym(SB), AX
   156	CALL	AX
   157
   158	CMPQ	AX, $0xfffffffffffff001
   159	JLS	ok7
   160	NEGQ	AX
   161	MOVQ	AX, err+8(FP)
   162	RET
   163ok7:
   164	MOVQ	$0, err+8(FP)
   165	RET

View as plain text