Text file src/syscall/asm_plan9_386.s

     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 386, 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  #define SYS_ERRSTR 41	/* from zsysnum_plan9.go */
    18  
    19  // Trap # in AX, args on stack above caller pc.
    20  TEXT	·Syscall(SB),NOSPLIT,$148-32
    21  	NO_LOCAL_POINTERS
    22  	CALL	runtime·entersyscall(SB)
    23  	MOVL	trap+0(FP), AX	// syscall entry
    24  	// copy args down
    25  	LEAL	a1+4(FP), SI
    26  	LEAL	sysargs-144(SP), DI
    27  	CLD
    28  	MOVSL
    29  	MOVSL
    30  	MOVSL
    31  	INT	$64
    32  	MOVL	AX, r1+16(FP)
    33  	MOVL	$0, r2+20(FP)
    34  	CMPL	AX, $-1
    35  	JNE	ok3
    36  
    37  	LEAL	errbuf-128(SP), AX
    38  	MOVL	AX, sysargs-144(SP)
    39  	MOVL	$128, sysargs1-140(SP)
    40  	MOVL	$SYS_ERRSTR, AX
    41  	INT	$64
    42  	CALL	runtime·exitsyscall(SB)
    43  	MOVL	sysargs-144(SP), AX
    44  	MOVL	AX, errbuf-148(SP)
    45  	CALL	runtime·gostring(SB)
    46  	LEAL	str-144(SP), SI
    47  	JMP	copyresult3
    48  
    49  ok3:
    50  	CALL	runtime·exitsyscall(SB)
    51  	LEAL	·emptystring(SB), SI
    52  
    53  copyresult3:
    54  	LEAL	err+24(FP), DI
    55  
    56  	CLD
    57  	MOVSL
    58  	MOVSL
    59  
    60  	RET
    61  
    62  TEXT	·Syscall6(SB),NOSPLIT,$148-44
    63  	NO_LOCAL_POINTERS
    64  	CALL	runtime·entersyscall(SB)
    65  	MOVL	trap+0(FP), AX	// syscall entry
    66  	// copy args down
    67  	LEAL	a1+4(FP), SI
    68  	LEAL	sysargs-144(SP), DI
    69  	CLD
    70  	MOVSL
    71  	MOVSL
    72  	MOVSL
    73  	MOVSL
    74  	MOVSL
    75  	MOVSL
    76  	INT	$64
    77  	MOVL	AX, r1+28(FP)
    78  	MOVL	$0, r2+32(FP)
    79  	CMPL	AX, $-1
    80  	JNE	ok4
    81  
    82  	LEAL	errbuf-128(SP), AX
    83  	MOVL	AX, sysargs-144(SP)
    84  	MOVL	$128, sysargs1-140(SP)
    85  	MOVL	$SYS_ERRSTR, AX
    86  	INT	$64
    87  	CALL	runtime·exitsyscall(SB)
    88  	MOVL	sysargs-144(SP), AX
    89  	MOVL	AX, errbuf-148(SP)
    90  	CALL	runtime·gostring(SB)
    91  	LEAL	str-144(SP), SI
    92  	JMP	copyresult4
    93  
    94  ok4:
    95  	CALL	runtime·exitsyscall(SB)
    96  	LEAL	·emptystring(SB), SI
    97  
    98  copyresult4:
    99  	LEAL	err+36(FP), DI
   100  
   101  	CLD
   102  	MOVSL
   103  	MOVSL
   104  
   105  	RET
   106  
   107  TEXT ·RawSyscall(SB),NOSPLIT,$0-28
   108  	MOVL	trap+0(FP), AX	// syscall entry
   109  	// slide args down on top of system call number
   110  	LEAL	a1+4(FP), SI
   111  	LEAL	trap+0(FP), DI
   112  	CLD
   113  	MOVSL
   114  	MOVSL
   115  	MOVSL
   116  	INT	$64
   117  	MOVL	AX, r1+16(FP)
   118  	MOVL	AX, r2+20(FP)
   119  	MOVL	AX, err+24(FP)
   120  	RET
   121  
   122  TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
   123  	MOVL	trap+0(FP), AX	// syscall entry
   124  	// slide args down on top of system call number
   125  	LEAL	a1+4(FP), SI
   126  	LEAL	trap+0(FP), DI
   127  	CLD
   128  	MOVSL
   129  	MOVSL
   130  	MOVSL
   131  	MOVSL
   132  	MOVSL
   133  	MOVSL
   134  	INT	$64
   135  	MOVL	AX, r1+28(FP)
   136  	MOVL	AX, r2+32(FP)
   137  	MOVL	AX, err+36(FP)
   138  	RET
   139  
   140  #define SYS_SEEK 39	/* from zsysnum_plan9.go */
   141  
   142  //func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
   143  TEXT ·seek(SB),NOSPLIT,$24-36
   144  	NO_LOCAL_POINTERS
   145  	LEAL	newoffset+20(FP), AX
   146  	MOVL	AX, placeholder+0(FP)
   147  
   148  	// copy args down
   149  	LEAL	placeholder+0(FP), SI
   150  	LEAL	sysargs-20(SP), DI
   151  	CLD
   152  	MOVSL
   153  	MOVSL
   154  	MOVSL
   155  	MOVSL
   156  	MOVSL
   157  	MOVL	$SYS_SEEK, AX	// syscall entry
   158  	INT	$64
   159  
   160  	CMPL	AX, $-1
   161  	JNE	ok6
   162  	MOVL	AX, newoffset_lo+20(FP)
   163  	MOVL	AX, newoffset_hi+24(FP)
   164  
   165  	CALL	syscall·errstr(SB)
   166  	MOVL	SP, SI
   167  	JMP	copyresult6
   168  
   169  ok6:
   170  	LEAL	·emptystring(SB), SI
   171  
   172  copyresult6:
   173  	LEAL	err+28(FP), DI
   174  
   175  	CLD
   176  	MOVSL
   177  	MOVSL
   178  	RET
   179  

View as plain text