github.com/ebitengine/purego@v0.8.0-alpha.2.0.20240512170805-6cd12240d332/sys_arm64.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors 3 4 //go:build darwin || freebsd || linux || windows 5 6 #include "textflag.h" 7 #include "go_asm.h" 8 #include "funcdata.h" 9 10 #define STACK_SIZE 64 11 #define PTR_ADDRESS (STACK_SIZE - 8) 12 13 // syscall15X calls a function in libc on behalf of the syscall package. 14 // syscall15X takes a pointer to a struct like: 15 // struct { 16 // fn uintptr 17 // a1 uintptr 18 // a2 uintptr 19 // a3 uintptr 20 // a4 uintptr 21 // a5 uintptr 22 // a6 uintptr 23 // a7 uintptr 24 // a8 uintptr 25 // a9 uintptr 26 // a10 uintptr 27 // a11 uintptr 28 // a12 uintptr 29 // a13 uintptr 30 // a14 uintptr 31 // a15 uintptr 32 // r1 uintptr 33 // r2 uintptr 34 // err uintptr 35 // } 36 // syscall15X must be called on the g0 stack with the 37 // C calling convention (use libcCall). 38 GLOBL ·syscall15XABI0(SB), NOPTR|RODATA, $8 39 DATA ·syscall15XABI0(SB)/8, $syscall15X(SB) 40 TEXT syscall15X(SB), NOSPLIT, $0 41 SUB $STACK_SIZE, RSP // push structure pointer 42 MOVD R0, PTR_ADDRESS(RSP) 43 MOVD R0, R9 44 45 FMOVD syscall15Args_f1(R9), F0 // f1 46 FMOVD syscall15Args_f2(R9), F1 // f2 47 FMOVD syscall15Args_f3(R9), F2 // f3 48 FMOVD syscall15Args_f4(R9), F3 // f4 49 FMOVD syscall15Args_f5(R9), F4 // f5 50 FMOVD syscall15Args_f6(R9), F5 // f6 51 FMOVD syscall15Args_f7(R9), F6 // f7 52 FMOVD syscall15Args_f8(R9), F7 // f8 53 54 MOVD syscall15Args_a1(R9), R0 // a1 55 MOVD syscall15Args_a2(R9), R1 // a2 56 MOVD syscall15Args_a3(R9), R2 // a3 57 MOVD syscall15Args_a4(R9), R3 // a4 58 MOVD syscall15Args_a5(R9), R4 // a5 59 MOVD syscall15Args_a6(R9), R5 // a6 60 MOVD syscall15Args_a7(R9), R6 // a7 61 MOVD syscall15Args_a8(R9), R7 // a8 62 MOVD syscall15Args_arm64_r8(R9), R8 // r8 63 64 MOVD syscall15Args_a9(R9), R10 65 MOVD R10, 0(RSP) // push a9 onto stack 66 MOVD syscall15Args_a10(R9), R10 67 MOVD R10, 8(RSP) // push a10 onto stack 68 MOVD syscall15Args_a11(R9), R10 69 MOVD R10, 16(RSP) // push a11 onto stack 70 MOVD syscall15Args_a12(R9), R10 71 MOVD R10, 24(RSP) // push a12 onto stack 72 MOVD syscall15Args_a13(R9), R10 73 MOVD R10, 32(RSP) // push a13 onto stack 74 MOVD syscall15Args_a14(R9), R10 75 MOVD R10, 40(RSP) // push a14 onto stack 76 MOVD syscall15Args_a15(R9), R10 77 MOVD R10, 48(RSP) // push a15 onto stack 78 79 MOVD syscall15Args_fn(R9), R10 // fn 80 BL (R10) 81 82 MOVD PTR_ADDRESS(RSP), R2 // pop structure pointer 83 ADD $STACK_SIZE, RSP 84 85 MOVD R0, syscall15Args_a1(R2) // save r1 86 MOVD R1, syscall15Args_a2(R2) // save r3 87 FMOVD F0, syscall15Args_f1(R2) // save f0 88 FMOVD F1, syscall15Args_f2(R2) // save f1 89 FMOVD F2, syscall15Args_f3(R2) // save f2 90 FMOVD F3, syscall15Args_f4(R2) // save f3 91 92 RET