Text file src/syscall/asm_freebsd_riscv64.s

     1  // Copyright 2022 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 riscv64, FreeBSD
     9  //
    10  
    11  // func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64)
    12  TEXT ·Syscall(SB),NOSPLIT,$0-56
    13  	CALL	runtime·entersyscall(SB)
    14  	MOV	a1+8(FP), A0
    15  	MOV	a2+16(FP), A1
    16  	MOV	a3+24(FP), A2
    17  	MOV	trap+0(FP), T0	// syscall entry
    18  	ECALL
    19  	BNE	T0, ZERO, err
    20  	MOV	A0, r1+32(FP)	// r1
    21  	MOV	A1, r2+40(FP)	// r2
    22  	MOV	ZERO, err+48(FP)	// errno
    23  	CALL	runtime·exitsyscall(SB)
    24  	RET
    25  err:
    26  	MOV	$-1, T0
    27  	MOV	T0, r1+32(FP)	// r1
    28  	MOV	ZERO, r2+40(FP)	// r2
    29  	MOV	A0, err+48(FP)	// errno
    30  	CALL	runtime·exitsyscall(SB)
    31  	RET
    32  
    33  
    34  // func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
    35  TEXT ·Syscall6(SB),NOSPLIT,$0-80
    36  	CALL	runtime·entersyscall(SB)
    37  	MOV	a1+8(FP), A0
    38  	MOV	a2+16(FP), A1
    39  	MOV	a3+24(FP), A2
    40  	MOV	a4+32(FP), A3
    41  	MOV	a5+40(FP), A4
    42  	MOV	a6+48(FP), A5
    43  	MOV	trap+0(FP), T0	// syscall entry
    44  	ECALL
    45  	BNE	T0, ZERO, err
    46  	MOV	A0, r1+56(FP)	// r1
    47  	MOV	A1, r2+64(FP)	// r2
    48  	MOV	ZERO, err+72(FP)	// errno
    49  	CALL	runtime·exitsyscall(SB)
    50  	RET
    51  err:
    52  	MOV	$-1, T0
    53  	MOV	T0, r1+56(FP)	// r1
    54  	MOV	ZERO, r2+64(FP)	// r2
    55  	MOV	A0, err+72(FP)	// errno
    56  	CALL	runtime·exitsyscall(SB)
    57  	RET
    58  
    59  // func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
    60  TEXT ·RawSyscall(SB),NOSPLIT,$0-56
    61  	MOV	a1+8(FP), A0
    62  	MOV	a2+16(FP), A1
    63  	MOV	a3+24(FP), A2
    64  	MOV	trap+0(FP), T0	// syscall entry
    65  	ECALL
    66  	BNE	T0, ZERO, err
    67  	MOV	A0, r1+32(FP)	// r1
    68  	MOV	A1, r2+40(FP)	// r2
    69  	MOV	ZERO, err+48(FP)	// errno
    70  	RET
    71  err:
    72  	MOV	$-1, T0
    73  	MOV	T0, r1+32(FP)	// r1
    74  	MOV	ZERO, r2+40(FP)	// r2
    75  	MOV	A0, err+48(FP)	// errno
    76  	RET
    77  
    78  // func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
    79  TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
    80  	MOV	a1+8(FP), A0
    81  	MOV	a2+16(FP), A1
    82  	MOV	a3+24(FP), A2
    83  	MOV	a4+32(FP), A3
    84  	MOV	a5+40(FP), A4
    85  	MOV	a6+48(FP), A5
    86  	MOV	trap+0(FP), T0	// syscall entry
    87  	ECALL
    88  	BNE	T0, ZERO, err
    89  	MOV	A0, r1+56(FP)	// r1
    90  	MOV	A1, r2+64(FP)	// r2
    91  	MOV	ZERO, err+72(FP)	// errno
    92  	RET
    93  err:
    94  	MOV	$-1, T0
    95  	MOV	T0, r1+56(FP)	// r1
    96  	MOV	ZERO, r2+64(FP)	// r2
    97  	MOV	A0, err+72(FP)	// errno
    98  	RET
    99  
   100  // Actually Syscall7
   101  // func Syscall9(num uintptr, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr)
   102  TEXT ·Syscall9(SB),NOSPLIT,$0-104
   103  	CALL	runtime·entersyscall(SB)
   104  	MOV	a1+8(FP), A0
   105  	MOV	a2+16(FP), A1
   106  	MOV	a3+24(FP), A2
   107  	MOV	a4+32(FP), A3
   108  	MOV	a5+40(FP), A4
   109  	MOV	a6+48(FP), A5
   110  	MOV	a7+56(FP), A6
   111  	MOV	num+0(FP), T0	// syscall entry
   112  	ECALL
   113  	BNE	T0, ZERO, err
   114  	MOV	A0, r1+80(FP)	// r1
   115  	MOV	A1, r2+88(FP)	// r2
   116  	MOV	ZERO, err+96(FP)	// errno
   117  	CALL	runtime·exitsyscall(SB)
   118  	RET
   119  err:
   120  	MOV	$-1, T0
   121  	MOV	T0, r1+80(FP)	// r1
   122  	MOV	ZERO, r2+88(FP)	// r2
   123  	MOV	A0, err+96(FP)	// errno
   124  	CALL	runtime·exitsyscall(SB)
   125  	RET
   126  

View as plain text