adjust exec_param to keep track of sp_el0, fix incorrect use sys regs
[lunaix-os.git] / lunaix-os / arch / aarch64 / includes / asm / bits.h
diff --git a/lunaix-os/arch/aarch64/includes/asm/bits.h b/lunaix-os/arch/aarch64/includes/asm/bits.h
new file mode 100644 (file)
index 0000000..a30f254
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef __LUNAIX_ARCH_BITS_H
+#define __LUNAIX_ARCH_BITS_H
+
+#include <asm-generic/bits.h>
+
+#undef _BITS_EXTRACT
+#undef _BITS_INSERT
+
+#define _BITS_EXTRACT(from, h, l)       \
+        ({                              \
+            unsigned long _r;           \
+            asm ("ubfm %0, %1, %2, %3"  \
+                 : "=r"(_r)             \
+                 : "r"(from)            \
+                   "i"(l) "i"(h));      \
+            _r;                         \
+        })
+
+#define _BITS_INSERT(to, from, h, l)    \
+        ({                              \
+            unsigned long _r = to;      \
+            asm ("bfi %0, %1, %2, %3"   \
+                 : "=r"(_r)             \
+                 : "r"(from)            \
+                   "i"(l)               \
+                   "i"(h - l + 1));     \
+            _r;                         \
+        })
+
+
+#endif /* __LUNAIX_ARCH_BITS_H */