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