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 // TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
      6 // so that go vet can check that they are correct.
      7 
      8 #include "textflag.h"
      9 #include "funcdata.h"
     10 
     11 //
     12 // System call support for 386, FreeBSD
     13 //
     14 
     15 // func Syscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32);
     16 // func Syscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32);
     17 // Trap # in AX, args on stack above caller pc.
     18 
     19 TEXT	Syscall(SB),NOSPLIT,$0-28
     20 	CALL	runtimeentersyscall(SB)
     21 	MOVL	4(SP), AX	// syscall entry
     22 	// slide args down on top of system call number
     23 	LEAL		8(SP), SI
     24 	LEAL		4(SP), DI
     25 	CLD
     26 	MOVSL
     27 	MOVSL
     28 	MOVSL
     29 	INT	$0x80
     30 	JAE	ok
     31 	MOVL	$-1, 20(SP)	// r1
     32 	MOVL	$-1, 24(SP)	// r2
     33 	MOVL	AX, 28(SP)		// errno
     34 	CALL	runtimeexitsyscall(SB)
     35 	RET
     36 ok:
     37 	MOVL	AX, 20(SP)	// r1
     38 	MOVL	DX, 24(SP)	// r2
     39 	MOVL	$0, 28(SP)	// errno
     40 	CALL	runtimeexitsyscall(SB)
     41 	RET
     42 
     43 TEXT	Syscall6(SB),NOSPLIT,$0-40
     44 	CALL	runtimeentersyscall(SB)
     45 	MOVL	4(SP), AX	// syscall entry
     46 	// slide args down on top of system call number
     47 	LEAL		8(SP), SI
     48 	LEAL		4(SP), DI
     49 	CLD
     50 	MOVSL
     51 	MOVSL
     52 	MOVSL
     53 	MOVSL
     54 	MOVSL
     55 	MOVSL
     56 	INT	$0x80
     57 	JAE	ok6
     58 	MOVL	$-1, 32(SP)	// r1
     59 	MOVL	$-1, 36(SP)	// r2
     60 	MOVL	AX, 40(SP)		// errno
     61 	CALL	runtimeexitsyscall(SB)
     62 	RET
     63 ok6:
     64 	MOVL	AX, 32(SP)	// r1
     65 	MOVL	DX, 36(SP)	// r2
     66 	MOVL	$0, 40(SP)	// errno
     67 	CALL	runtimeexitsyscall(SB)
     68 	RET
     69 
     70 TEXT	Syscall9(SB),NOSPLIT,$0-52
     71 	CALL	runtimeentersyscall(SB)
     72 	MOVL	4(SP), AX	// syscall entry
     73 	// slide args down on top of system call number
     74 	LEAL		8(SP), SI
     75 	LEAL		4(SP), DI
     76 	CLD
     77 	MOVSL
     78 	MOVSL
     79 	MOVSL
     80 	MOVSL
     81 	MOVSL
     82 	MOVSL
     83 	MOVSL
     84 	MOVSL
     85 	MOVSL
     86 	INT	$0x80
     87 	JAE	ok9
     88 	MOVL	$-1, 44(SP)	// r1
     89 	MOVL	$-1, 48(SP)	// r2
     90 	MOVL	AX, 52(SP)		// errno
     91 	CALL	runtimeexitsyscall(SB)
     92 	RET
     93 ok9:
     94 	MOVL	AX, 44(SP)	// r1
     95 	MOVL	DX, 48(SP)	// r2
     96 	MOVL	$0, 52(SP)	// errno
     97 	CALL	runtimeexitsyscall(SB)
     98 	RET
     99 
    100 TEXT RawSyscall(SB),NOSPLIT,$0-28
    101 	MOVL	4(SP), AX	// syscall entry
    102 	// slide args down on top of system call number
    103 	LEAL		8(SP), SI
    104 	LEAL		4(SP), DI
    105 	CLD
    106 	MOVSL
    107 	MOVSL
    108 	MOVSL
    109 	INT	$0x80
    110 	JAE	ok1
    111 	MOVL	$-1, 20(SP)	// r1
    112 	MOVL	$-1, 24(SP)	// r2
    113 	MOVL	AX, 28(SP)		// errno
    114 	RET
    115 ok1:
    116 	MOVL	AX, 20(SP)	// r1
    117 	MOVL	DX, 24(SP)	// r2
    118 	MOVL	$0, 28(SP)	// errno
    119 	RET
    120 
    121 TEXT	RawSyscall6(SB),NOSPLIT,$0-40
    122 	MOVL	4(SP), AX	// syscall entry
    123 	// slide args down on top of system call number
    124 	LEAL		8(SP), SI
    125 	LEAL		4(SP), DI
    126 	CLD
    127 	MOVSL
    128 	MOVSL
    129 	MOVSL
    130 	MOVSL
    131 	MOVSL
    132 	MOVSL
    133 	INT	$0x80
    134 	JAE	ok2
    135 	MOVL	$-1, 32(SP)	// r1
    136 	MOVL	$-1, 36(SP)	// r2
    137 	MOVL	AX, 40(SP)		// errno
    138 	RET
    139 ok2:
    140 	MOVL	AX, 32(SP)	// r1
    141 	MOVL	DX, 36(SP)	// r2
    142 	MOVL	$0, 40(SP)	// errno
    143 	RET
    144