Home | History | Annotate | Download | only in syscall
      1 // Copyright 2016 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 
      7 //
      8 // System calls for s390x, Linux
      9 //
     10 
     11 // func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64)
     12 TEXT Syscall(SB),NOSPLIT,$0-56
     13 	BL	runtimeentersyscall(SB)
     14 	MOVD	a1+8(FP), R2
     15 	MOVD	a2+16(FP), R3
     16 	MOVD	a3+24(FP), R4
     17 	MOVD	$0, R5
     18 	MOVD	$0, R6
     19 	MOVD	$0, R7
     20 	MOVD	trap+0(FP), R1	// syscall entry
     21 	SYSCALL
     22 	MOVD	$0xfffffffffffff001, R8
     23 	CMPUBLT	R2, R8, ok
     24 	MOVD	$-1, r1+32(FP)
     25 	MOVD	$0, r2+40(FP)
     26 	NEG	R2, R2
     27 	MOVD	R2, err+48(FP)	// errno
     28 	BL	runtimeexitsyscall(SB)
     29 	RET
     30 ok:
     31 	MOVD	R2, r1+32(FP)
     32 	MOVD	R3, r2+40(FP)
     33 	MOVD	$0, err+48(FP)	// errno
     34 	BL	runtimeexitsyscall(SB)
     35 	RET
     36 
     37 // func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
     38 TEXT Syscall6(SB),NOSPLIT,$0-80
     39 	BL	runtimeentersyscall(SB)
     40 	MOVD	a1+8(FP), R2
     41 	MOVD	a2+16(FP), R3
     42 	MOVD	a3+24(FP), R4
     43 	MOVD	a4+32(FP), R5
     44 	MOVD	a5+40(FP), R6
     45 	MOVD	a6+48(FP), R7
     46 	MOVD	trap+0(FP), R1	// syscall entry
     47 	SYSCALL
     48 	MOVD	$0xfffffffffffff001, R8
     49 	CMPUBLT	R2, R8, ok6
     50 	MOVD	$-1, r1+56(FP)
     51 	MOVD	$0, r2+64(FP)
     52 	NEG	R2, R2
     53 	MOVD	R2, err+72(FP)	// errno
     54 	BL	runtimeexitsyscall(SB)
     55 	RET
     56 ok6:
     57 	MOVD	R2, r1+56(FP)
     58 	MOVD	R3, r2+64(FP)
     59 	MOVD	$0, err+72(FP)	// errno
     60 	BL	runtimeexitsyscall(SB)
     61 	RET
     62 
     63 // func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
     64 TEXT RawSyscall(SB),NOSPLIT,$0-56
     65 	MOVD	a1+8(FP), R2
     66 	MOVD	a2+16(FP), R3
     67 	MOVD	a3+24(FP), R4
     68 	MOVD	$0, R5
     69 	MOVD	$0, R6
     70 	MOVD	$0, R7
     71 	MOVD	trap+0(FP), R1	// syscall entry
     72 	SYSCALL
     73 	MOVD	$0xfffffffffffff001, R8
     74 	CMPUBLT	R2, R8, ok1
     75 	MOVD	$-1, r1+32(FP)
     76 	MOVD	$0, r2+40(FP)
     77 	NEG	R2, R2
     78 	MOVD	R2, err+48(FP)	// errno
     79 	RET
     80 ok1:
     81 	MOVD	R2, r1+32(FP)
     82 	MOVD	R3, r2+40(FP)
     83 	MOVD	$0, err+48(FP)	// errno
     84 	RET
     85 
     86 // func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
     87 TEXT RawSyscall6(SB),NOSPLIT,$0-80
     88 	MOVD	a1+8(FP), R2
     89 	MOVD	a2+16(FP), R3
     90 	MOVD	a3+24(FP), R4
     91 	MOVD	a4+32(FP), R5
     92 	MOVD	a5+40(FP), R6
     93 	MOVD	a6+48(FP), R7
     94 	MOVD	trap+0(FP), R1	// syscall entry
     95 	SYSCALL
     96 	MOVD	$0xfffffffffffff001, R8
     97 	CMPUBLT	R2, R8, ok2
     98 	MOVD	$-1, r1+56(FP)
     99 	MOVD	$0, r2+64(FP)
    100 	NEG	R2, R2
    101 	MOVD	R2, err+72(FP)	// errno
    102 	RET
    103 ok2:
    104 	MOVD	R2, r1+56(FP)
    105 	MOVD	R3, r2+64(FP)
    106 	MOVD	$0, err+72(FP)	// errno
    107 	RET
    108 
    109 #define SYS_SOCKETCALL 102	/* from zsysnum_linux_s390x.go */
    110 
    111 // func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err int)
    112 // Kernel interface gets call sub-number and pointer to a0.
    113 TEXT socketcall(SB),NOSPLIT,$0-72
    114 	BL	runtimeentersyscall(SB)
    115 	MOVD	$SYS_SOCKETCALL, R1	// syscall entry
    116 	MOVD	call+0(FP), R2		// socket call number
    117 	MOVD	$a0+8(FP), R3		// pointer to call arguments
    118 	MOVD	$0, R4
    119 	MOVD	$0, R5
    120 	MOVD	$0, R6
    121 	MOVD	$0, R7
    122 	SYSCALL
    123 	MOVD	$0xfffffffffffff001, R8
    124 	CMPUBLT	R2, R8, oksock
    125 	MOVD	$-1, n+56(FP)
    126 	NEG	R2, R2
    127 	MOVD	R2, err+64(FP)
    128 	BL	runtimeexitsyscall(SB)
    129 	RET
    130 oksock:
    131 	MOVD	R2, n+56(FP)
    132 	MOVD	$0, err+64(FP)
    133 	CALL	runtimeexitsyscall(SB)
    134 	RET
    135 
    136 // func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err int)
    137 // Kernel interface gets call sub-number and pointer to a0.
    138 TEXT rawsocketcall(SB),NOSPLIT,$0-72
    139 	MOVD	$SYS_SOCKETCALL, R1	// syscall entry
    140 	MOVD	call+0(FP), R2		// socket call number
    141 	MOVD	$a0+8(FP), R3		// pointer to call arguments
    142 	MOVD	$0, R4
    143 	MOVD	$0, R5
    144 	MOVD	$0, R6
    145 	MOVD	$0, R7
    146 	SYSCALL
    147 	MOVD	$0xfffffffffffff001, R8
    148 	CMPUBLT	R2, R8, oksock1
    149 	MOVD	$-1, n+56(FP)
    150 	NEG	R2, R2
    151 	MOVD	R2, err+64(FP)
    152 	RET
    153 oksock1:
    154 	MOVD	R2, n+56(FP)
    155 	MOVD	$0, err+64(FP)
    156 	RET
    157