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