Code-base clean-up and refactoring (#47)
[lunaix-os.git] / lunaix-os / arch / x86 / includes / asm / variants / abi64.h
diff --git a/lunaix-os/arch/x86/includes/asm/variants/abi64.h b/lunaix-os/arch/x86/includes/asm/variants/abi64.h
new file mode 100644 (file)
index 0000000..02cf3c9
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef __LUNAIX_ARCH_ABI64_H
+#define __LUNAIX_ARCH_ABI64_H
+
+#include "asm/x86.h"
+
+#define stack_alignment 0xfffffffffffffff0UL
+
+#ifndef __ASM__
+#define store_retval(retval) current_thread->hstate->registers.rax = (retval)
+
+#define store_retval_to(th, retval) (th)->hstate->registers.rax = (retval)
+
+static inline void must_inline 
+j_usr(ptr_t sp, ptr_t pc) 
+{
+    asm volatile(
+                 "pushq %0\n"
+                 "pushq %1\n"
+                 "pushq %2\n"
+                 "pushq %3\n"
+                 "retfq" 
+                 ::
+                    "i"(UDATA_SEG),
+                    "r"(sp),
+                    "i"(UCODE_SEG),
+                    "r"(pc)
+                 : 
+                 "memory");
+}
+
+static inline ptr_t must_inline
+abi_get_callframe()
+{
+    ptr_t val;
+    asm volatile("movq %%rbp, %0" : "=r"(val)::"memory");
+    return val;
+}
+
+#endif
+#endif /* __LUNAIX_ARCH_ABI64_H */