aa64: finalise context switch, page fault handler and syscall
[lunaix-os.git] / lunaix-os / arch / aarch64 / includes / asm / abi.h
index cc18bba28d47d3cef59165ba4d8e719063680d7d..dac3d269a0188674c2c12d9c7583414795f8cf38 100644 (file)
@@ -5,15 +5,21 @@
 
 #ifndef __ASM__
 
+#include <asm/aa64_msrs.h>
+#include <asm/aa64_spsr.h>
+
 #define align_stack(ptr) ((ptr) & ~15)
 
-#define store_retval(retval) current_thread->hstate->registers.x[0] = (retval)
-#define store_retval_to(th, retval) (th)->hstate->registers.x[0] = (retval)
+#define store_retval(retval) \
+            current_thread->hstate->registers.x[0] = (retval)
+
+#define store_retval_to(th, retval) \
+            (th)->hstate->registers.x[0] = (retval)
 
 
 static inline void must_inline noret
-switch_context() {
-    // TODO
+switch_context() 
+{
     asm ("b _aa64_switch_task");
     unreachable;
 }
@@ -45,7 +51,12 @@ abi_get_callframe()
 static inline void must_inline 
 j_usr(ptr_t sp, ptr_t pc) 
 {
-    // TODO
+    set_sysreg(SPSR_EL1, SPSR_EL0_preset);
+    set_sysreg(SP_EL0, sp);
+    set_sysreg(ELR_E1, pc);
+    asm ("eret");
+
+    unreachable;
 }
 
 #endif