1 /* 2 * Ripped off from arch/arm64/include/asm/sysreg.h 3 * 4 * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com> 5 * 6 * This work is licensed under the terms of the GNU LGPL, version 2. 7 */ 8 #ifndef _ASMARM64_SYSREG_H_ 9 #define _ASMARM64_SYSREG_H_ 10 11 #ifndef __ASSEMBLY__ 12 #include <libcflat.h> 13 14 #define read_sysreg(r) ({ \ 15 u64 __val; \ 16 asm volatile("mrs %0, " xstr(r) : "=r" (__val)); \ 17 __val; \ 18 }) 19 20 #define write_sysreg(v, r) do { \ 21 u64 __val = (u64)v; \ 22 asm volatile("msr " xstr(r) ", %x0" : : "rZ" (__val)); \ 23 } while (0) 24 25 #endif /* !__ASSEMBLY__ */ 26 #endif /* _ASMARM64_SYSREG_H_ */ 27