1 /* SPDX-License-Identifier: MIT */ 2 3 #ifndef LIBURING_ARCH_AARCH64_SYSCALL_H 4 #define LIBURING_ARCH_AARCH64_SYSCALL_H 5 6 #if defined(__aarch64__) 7 8 #define __do_syscallN(...) ({ \ 9 __asm__ volatile ( \ 10 "svc 0" \ 11 : "=r"(x0) \ 12 : __VA_ARGS__ \ 13 : "memory", "cc"); \ 14 (long) x0; \ 15 }) 16 17 #define __do_syscall0(__n) ({ \ 18 register long x8 __asm__("x8") = __n; \ 19 register long x0 __asm__("x0"); \ 20 \ 21 __do_syscallN("r" (x8)); \ 22 }) 23 24 #define __do_syscall1(__n, __a) ({ \ 25 register long x8 __asm__("x8") = __n; \ 26 register __typeof__(__a) x0 __asm__("x0") = __a; \ 27 \ 28 __do_syscallN("r" (x8), "0" (x0)); \ 29 }) 30 31 #define __do_syscall2(__n, __a, __b) ({ \ 32 register long x8 __asm__("x8") = __n; \ 33 register __typeof__(__a) x0 __asm__("x0") = __a; \ 34 register __typeof__(__b) x1 __asm__("x1") = __b; \ 35 \ 36 __do_syscallN("r" (x8), "0" (x0), "r" (x1)); \ 37 }) 38 39 #define __do_syscall3(__n, __a, __b, __c) ({ \ 40 register long x8 __asm__("x8") = __n; \ 41 register __typeof__(__a) x0 __asm__("x0") = __a; \ 42 register __typeof__(__b) x1 __asm__("x1") = __b; \ 43 register __typeof__(__c) x2 __asm__("x2") = __c; \ 44 \ 45 __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2)); \ 46 }) 47 48 #define __do_syscall4(__n, __a, __b, __c, __d) ({ \ 49 register long x8 __asm__("x8") = __n; \ 50 register __typeof__(__a) x0 __asm__("x0") = __a; \ 51 register __typeof__(__b) x1 __asm__("x1") = __b; \ 52 register __typeof__(__c) x2 __asm__("x2") = __c; \ 53 register __typeof__(__d) x3 __asm__("x3") = __d; \ 54 \ 55 __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2), "r" (x3));\ 56 }) 57 58 #define __do_syscall5(__n, __a, __b, __c, __d, __e) ({ \ 59 register long x8 __asm__("x8") = __n; \ 60 register __typeof__(__a) x0 __asm__("x0") = __a; \ 61 register __typeof__(__b) x1 __asm__("x1") = __b; \ 62 register __typeof__(__c) x2 __asm__("x2") = __c; \ 63 register __typeof__(__d) x3 __asm__("x3") = __d; \ 64 register __typeof__(__e) x4 __asm__("x4") = __e; \ 65 \ 66 __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2), "r" (x3), \ 67 "r"(x4)); \ 68 }) 69 70 #define __do_syscall6(__n, __a, __b, __c, __d, __e, __f) ({ \ 71 register long x8 __asm__("x8") = __n; \ 72 register __typeof__(__a) x0 __asm__("x0") = __a; \ 73 register __typeof__(__b) x1 __asm__("x1") = __b; \ 74 register __typeof__(__c) x2 __asm__("x2") = __c; \ 75 register __typeof__(__d) x3 __asm__("x3") = __d; \ 76 register __typeof__(__e) x4 __asm__("x4") = __e; \ 77 register __typeof__(__f) x5 __asm__("x5") = __f; \ 78 \ 79 __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2), "r" (x3), \ 80 "r" (x4), "r"(x5)); \ 81 }) 82 83 #include "../syscall-defs.h" 84 85 #else /* #if defined(__aarch64__) */ 86 87 #include "../generic/syscall.h" 88 89 #endif /* #if defined(__aarch64__) */ 90 91 #endif /* #ifndef LIBURING_ARCH_AARCH64_SYSCALL_H */ 92