| 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 |
// func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) |
| 8 |
// |
| 9 |
// We need to convert to the syscall ABI. |
| 10 |
// |
| 11 |
// arg | ABIInternal | Syscall |
| 12 |
// --------------------------- |
| 13 |
// num | A0 | A7 |
| 14 |
// a1 | A1 | A0 |
| 15 |
// a2 | A2 | A1 |
| 16 |
// a3 | A3 | A2 |
| 17 |
// a4 | A4 | A3 |
| 18 |
// a5 | A5 | A4 |
| 19 |
// a6 | A6 | A5 |
| 20 |
// |
| 21 |
// r1 | A0 | A0 |
| 22 |
// r2 | A1 | A1 |
| 23 |
// err | A2 | part of A0 |
| 24 |
TEXT ·Syscall6<ABIInternal>(SB),NOSPLIT,$0-80 |
| 25 |
MOV A0, A7 |
| 26 |
MOV A1, A0 |
| 27 |
MOV A2, A1 |
| 28 |
MOV A3, A2 |
| 29 |
MOV A4, A3 |
| 30 |
MOV A5, A4 |
| 31 |
MOV A6, A5 |
| 32 |
ECALL |
| 33 |
MOV $-4096, T0 |
| 34 |
BLTU T0, A0, err |
| 35 |
// r1 already in A0 |
| 36 |
// r2 already in A1 |
| 37 |
MOV ZERO, A2 // errno |
| 38 |
RET |
| 39 |
err: |
| 40 |
SUB A0, ZERO, A2 // errno |
| 41 |
MOV $-1, A0 // r1 |
| 42 |
MOV ZERO, A1 // r2 |
| 43 |
RET |