aa64: finalise context switch, page fault handler and syscall
[lunaix-os.git] / lunaix-os / arch / aarch64 / exception / context.S
index e30f72d8e574453c926d964f01f3bef0ee327ace..23e875b99639707de984273d346f1052f43f30be 100644 (file)
@@ -1,7 +1,13 @@
 #define __ASM__
 #include <asm/aa64_msrs.h>
+#include <asm/bits.h>
 #include "hart_fields.inc"
 
+.section .data
+    .align 4
+    .skip 256
+    _aa64_csw_temp_stack:
+
 .section .text
     
     .globl _aa64_evec_prehandle
 
     _aa64_switch_task:
         // TODO
-        b     do_eret
\ No newline at end of file
+        adr  sp, _aa64_csw_temp_stack
+        
+        bl   aa64_switch_ttbr
+        
+        bl   switch_signposting
+        cbnz x0, _aa64_handle_signal
+
+        b     do_eret
+
+    _aa64_handle_signal:
+        mov  x1, #SPSR_EL0_preset
+        msr  SPSR_EL1, x1
+
+        ldr  x1, [x0, #sigact]
+        msr  ELR_E1, x1
+
+        msr  SP_EL0, x0
+
+        eret
\ No newline at end of file