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