github.com/slayercat/go@v0.0.0-20170428012452-c51559813f61/src/syscall/asm_plan9_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  #include "textflag.h"
     6  #include "funcdata.h"
     7  
     8  //
     9  // System call support for Plan 9
    10  //
    11  
    12  //func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err string)
    13  //func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err string)
    14  //func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
    15  //func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
    16  
    17  TEXT	·Syscall(SB),NOSPLIT,$0-64
    18  	CALL	runtime·entersyscall(SB)
    19  	MOVQ	trap+0(FP), BP	// syscall entry
    20  	// slide args down on top of system call number
    21  	LEAQ	a1+8(FP), SI
    22  	LEAQ	trap+0(FP), DI
    23  	CLD
    24  	MOVSQ
    25  	MOVSQ
    26  	MOVSQ
    27  	SYSCALL
    28  	MOVQ	AX, r1+32(FP)
    29  	MOVQ	$0, r2+40(FP)
    30  	CMPL	AX, $-1
    31  	JNE	ok3
    32  
    33  	SUBQ	$16, SP
    34  	CALL	runtime·errstr(SB)
    35  	MOVQ	SP, SI
    36  	ADDQ	$16, SP
    37  	JMP	copyresult3
    38  	
    39  ok3:
    40  	LEAQ	runtime·emptystring(SB), SI	
    41  	
    42  copyresult3:
    43  	LEAQ	err+48(FP), DI
    44  
    45  	CLD
    46  	MOVSQ
    47  	MOVSQ
    48  
    49  	CALL	runtime·exitsyscall(SB)
    50  	RET
    51  
    52  TEXT	·Syscall6(SB),NOSPLIT,$0-88
    53  	CALL	runtime·entersyscall(SB)
    54  	MOVQ	trap+0(FP), BP	// syscall entry
    55  	// slide args down on top of system call number
    56  	LEAQ	a1+8(FP), SI
    57  	LEAQ	trap+0(FP), DI
    58  	CLD
    59  	MOVSQ
    60  	MOVSQ
    61  	MOVSQ
    62  	MOVSQ
    63  	MOVSQ
    64  	MOVSQ
    65  	SYSCALL
    66  	MOVQ	AX, r1+56(FP)
    67  	MOVQ	$0, r2+64(FP)
    68  	CMPL	AX, $-1
    69  	JNE	ok4
    70  	
    71  	SUBQ	$16, SP
    72  	CALL	runtime·errstr(SB)
    73  	MOVQ	SP, SI
    74  	ADDQ	$16, SP
    75  	JMP	copyresult4
    76  	
    77  ok4:
    78  	LEAQ	runtime·emptystring(SB), SI
    79  	
    80  copyresult4:
    81  	LEAQ	err+72(FP), DI
    82  
    83  	CLD
    84  	MOVSQ
    85  	MOVSQ
    86  
    87  	CALL	runtime·exitsyscall(SB)
    88  	RET
    89  
    90  TEXT ·RawSyscall(SB),NOSPLIT,$0-56
    91  	MOVQ	trap+0(FP), BP	// syscall entry
    92  	// slide args down on top of system call number
    93  	LEAQ	a1+8(FP), SI
    94  	LEAQ	trap+0(FP), DI
    95  	CLD
    96  	MOVSQ
    97  	MOVSQ
    98  	MOVSQ
    99  	SYSCALL
   100  	MOVQ	AX, r1+32(FP)
   101  	MOVQ	AX, r2+40(FP)
   102  	MOVQ	AX, err+48(FP)
   103  	RET
   104  
   105  TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
   106  	MOVQ	trap+0(FP), BP	// syscall entry
   107  	// slide args down on top of system call number
   108  	LEAQ	a1+8(FP), SI
   109  	LEAQ	trap+0(FP), DI
   110  	CLD
   111  	MOVSQ
   112  	MOVSQ
   113  	MOVSQ
   114  	MOVSQ
   115  	MOVSQ
   116  	MOVSQ
   117  	SYSCALL
   118  	MOVQ	AX, r1+56(FP)
   119  	MOVQ	AX, r2+64(FP)
   120  	MOVQ	AX, err+72(FP)
   121  	RET
   122  
   123  #define SYS_SEEK 39	/* from zsysnum_plan9_amd64.go */
   124  
   125  //func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
   126  TEXT ·seek(SB),NOSPLIT,$0-56
   127  	LEAQ	newoffset+32(FP), AX
   128  	MOVQ	AX, placeholder+0(FP)
   129  	
   130  	MOVQ	$SYS_SEEK, BP	// syscall entry
   131  	SYSCALL
   132  	
   133  	CMPL	AX, $-1
   134  	JNE	ok6
   135  	MOVQ	$-1, newoffset+32(FP)
   136  	
   137  	SUBQ	$16, SP
   138  	CALL	syscall·errstr(SB)
   139  	MOVQ	SP, SI
   140  	ADDQ	$16, SP	
   141  	JMP	copyresult6
   142  	
   143  ok6:
   144  	LEAQ	runtime·emptystring(SB), SI
   145  	
   146  copyresult6:
   147  	LEAQ	err+40(FP), DI
   148  
   149  	CLD
   150  	MOVSQ
   151  	MOVSQ
   152  	RET
   153  
   154  //func exit(code int)
   155  // Import runtime·exit for cleanly exiting.
   156  TEXT ·exit(SB),NOSPLIT,$8-8
   157  	NO_LOCAL_POINTERS
   158  	MOVQ	code+0(FP), AX
   159  	MOVQ	AX, 0(SP)
   160  	CALL	runtime·exit(SB)
   161  	RET