engines/libzbc: set FIO_RO_NEEDS_RW_OPEN engine flag
[fio.git] / arch / arch-aarch64.h
1 #ifndef ARCH_AARCH64_H
2 #define ARCH_AARCH64_H
3
4 #include <unistd.h>
5 #include <stdlib.h>
6 #include <sys/types.h>
7 #include <sys/wait.h>
8
9 #define FIO_ARCH        (arch_aarch64)
10
11 #define nop             do { __asm__ __volatile__ ("yield"); } while (0)
12 #define read_barrier()  do { __sync_synchronize(); } while (0)
13 #define write_barrier() do { __sync_synchronize(); } while (0)
14
15 static inline int arch_ffz(unsigned long bitmask)
16 {
17         unsigned long count, reversed_bits;
18         if (~bitmask == 0)      /* ffz() in lib/ffz.h does this. */
19                 return 63;
20
21         __asm__ __volatile__ ("rbit %1, %2\n"
22                               "clz %0, %1\n" : 
23                               "=r"(count), "=&r"(reversed_bits) :
24                               "r"(~bitmask));
25         return count;
26 }
27
28 #define ARCH_HAVE_FFZ
29
30 #define isb()   asm volatile("isb" : : : "memory")
31
32 static inline unsigned long long get_cpu_clock(void)
33 {
34         unsigned long val;
35
36         isb();
37         asm volatile("mrs %0, cntvct_el0" : "=r" (val));
38         return val;
39 }
40 #define ARCH_HAVE_CPU_CLOCK
41
42 #define ARCH_HAVE_INIT
43 extern bool tsc_reliable;
44 static inline int arch_init(char *envp[])
45 {
46         tsc_reliable = true;
47         return 0;
48 }
49
50 #define __do_syscallN(...) ({                                           \
51         __asm__ volatile (                                              \
52                 "svc 0"                                                 \
53                 : "=r"(x0)                                              \
54                 : __VA_ARGS__                                           \
55                 : "memory", "cc");                                      \
56         (long) x0;                                                      \
57 })
58
59 #define __do_syscall0(__n) ({                                           \
60         register long x8 __asm__("x8") = __n;                           \
61         register long x0 __asm__("x0");                                 \
62                                                                         \
63         __do_syscallN("r" (x8));                                        \
64 })
65
66 #define __do_syscall1(__n, __a) ({                                      \
67         register long x8 __asm__("x8") = __n;                           \
68         register __typeof__(__a) x0 __asm__("x0") = __a;                \
69                                                                         \
70         __do_syscallN("r" (x8), "0" (x0));                              \
71 })
72
73 #define __do_syscall2(__n, __a, __b) ({                                 \
74         register long x8 __asm__("x8") = __n;                           \
75         register __typeof__(__a) x0 __asm__("x0") = __a;                \
76         register __typeof__(__b) x1 __asm__("x1") = __b;                \
77                                                                         \
78         __do_syscallN("r" (x8), "0" (x0), "r" (x1));                    \
79 })
80
81 #define __do_syscall3(__n, __a, __b, __c) ({                            \
82         register long x8 __asm__("x8") = __n;                           \
83         register __typeof__(__a) x0 __asm__("x0") = __a;                \
84         register __typeof__(__b) x1 __asm__("x1") = __b;                \
85         register __typeof__(__c) x2 __asm__("x2") = __c;                \
86                                                                         \
87         __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2));          \
88 })
89
90 #define __do_syscall4(__n, __a, __b, __c, __d) ({                       \
91         register long x8 __asm__("x8") = __n;                           \
92         register __typeof__(__a) x0 __asm__("x0") = __a;                \
93         register __typeof__(__b) x1 __asm__("x1") = __b;                \
94         register __typeof__(__c) x2 __asm__("x2") = __c;                \
95         register __typeof__(__d) x3 __asm__("x3") = __d;                \
96                                                                         \
97         __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2), "r" (x3));\
98 })
99
100 #define __do_syscall5(__n, __a, __b, __c, __d, __e) ({                  \
101         register long x8 __asm__("x8") = __n;                           \
102         register __typeof__(__a) x0 __asm__("x0") = __a;                \
103         register __typeof__(__b) x1 __asm__("x1") = __b;                \
104         register __typeof__(__c) x2 __asm__("x2") = __c;                \
105         register __typeof__(__d) x3 __asm__("x3") = __d;                \
106         register __typeof__(__e) x4 __asm__("x4") = __e;                \
107                                                                         \
108         __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2), "r" (x3), \
109                         "r"(x4));                                       \
110 })
111
112 #define __do_syscall6(__n, __a, __b, __c, __d, __e, __f) ({             \
113         register long x8 __asm__("x8") = __n;                           \
114         register __typeof__(__a) x0 __asm__("x0") = __a;                \
115         register __typeof__(__b) x1 __asm__("x1") = __b;                \
116         register __typeof__(__c) x2 __asm__("x2") = __c;                \
117         register __typeof__(__d) x3 __asm__("x3") = __d;                \
118         register __typeof__(__e) x4 __asm__("x4") = __e;                \
119         register __typeof__(__f) x5 __asm__("x5") = __f;                \
120                                                                         \
121         __do_syscallN("r" (x8), "0" (x0), "r" (x1), "r" (x2), "r" (x3), \
122                         "r" (x4), "r"(x5));                             \
123 })
124
125 #define FIO_ARCH_HAS_SYSCALL
126
127 #endif