31#ifndef XPSEUDO_ASM_GCC_H
32#define XPSEUDO_ASM_GCC_H
49#define stringify(s) tostring(s)
52#if defined (__aarch64__)
54#define mfcpsr() ({u32 rval = 0U; \
55 asm volatile("mrs %0, DAIF" : "=r" (rval));\
59#define mtcpsr(v) __asm__ __volatile__ ("msr DAIF, %0" : : "r" (v))
85#define isb() __asm__ __volatile__ ("isb sy")
88#define dsb() __asm__ __volatile__("dsb sy")
91#define dmb() __asm__ __volatile__("dmb sy")
95#define ldr(adr) ({u64 rval; \
96 __asm__ __volatile__(\
98 : "=r" (rval) : "r" (adr)\
103#define mfelrel3() ({u64 rval = 0U; \
104 asm volatile("mrs %0, ELR_EL3" : "=r" (rval));\
108#define mtelrel3(v) __asm__ __volatile__ ("msr ELR_EL3, %0" : : "r" (v))
113#define mfcpsr() ({u32 rval = 0U; \
114 __asm__ __volatile__(\
121#define mtcpsr(v) __asm__ __volatile__(\
126#define cpsiei() __asm__ __volatile__("cpsie i\n")
127#define cpsidi() __asm__ __volatile__("cpsid i\n")
129#define cpsief() __asm__ __volatile__("cpsie f\n")
130#define cpsidf() __asm__ __volatile__("cpsid f\n")
134#define mtgpr(rn, v) __asm__ __volatile__(\
135 "mov r" stringify(rn) ", %0 \n"\
139#define mfgpr(rn) ({u32 rval; \
140 __asm__ __volatile__(\
141 "mov %0,r" stringify(rn) "\n"\
150#define isb() __asm__ __volatile__ ("isb" : : : "memory")
153#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
156#define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
160#define ldr(adr) ({u32 rval; \
161 __asm__ __volatile__(\
163 : "=r" (rval) : "r" (adr)\
170#define ldrb(adr) ({u8 rval; \
171 __asm__ __volatile__(\
173 : "=r" (rval) : "r" (adr)\
178#define strw(adr, val) __asm__ __volatile__(\
180 : : "r" (val), "r" (adr)\
183#define strb(adr, val) __asm__ __volatile__(\
185 : : "r" (val), "r" (adr)\
189#define clz(arg) ({u8 rval; \
190 __asm__ __volatile__(\
192 : "=r" (rval) : "r" (arg)\
197#if defined (__aarch64__)
198#define mtcpdc(reg,val) __asm__ __volatile__("dc " #reg ",%0" : : "r" (val))
199#define mtcpic(reg,val) __asm__ __volatile__("ic " #reg ",%0" : : "r" (val))
201#define mtcpicall(reg) __asm__ __volatile__("ic " #reg)
202#define mtcptlbi(reg) __asm__ __volatile__("tlbi " #reg)
203#define mtcpat(reg,val) __asm__ __volatile__("at " #reg ",%0" : : "r" (val))
205#define mfcp(reg) ({u64 rval = 0U;\
206 __asm__ __volatile__("mrs %0, " #reg : "=r" (rval));\
210#define mtcp(reg,val) __asm__ __volatile__("msr " #reg ",%0" : : "r" (val))
214#define mtcp(rn, v) __asm__ __volatile__(\
219#define mfcp(rn) ({u32 rval = 0U; \
220 __asm__ __volatile__(\