aa64: finalise context switch, page fault handler and syscall
[lunaix-os.git] / lunaix-os / arch / aarch64 / includes / asm / hart.h
index ae84ddd13c70c373f7bda587d324f626ff522784..52571e67a07664f5aee5379a8834c51e7655ed39 100644 (file)
@@ -15,7 +15,7 @@ struct regcontext
     union {
         reg_t x[31];
         struct {
-            reg_t x[29];
+            reg_t x_[29];
             reg_t fp;
             reg_t lr;
         };
@@ -29,7 +29,7 @@ struct exec_param
     reg_t link;
     struct {
         reg_t sp_el0;
-        reg_t sp_el1;
+        reg_t rsvd;
     };
     
     reg_t syndrome;
@@ -43,12 +43,14 @@ struct hart_state
 } compact align(16);
 
 static inline int
-hart_vector_stamp(struct hart_state* hstate) {
+hart_vector_stamp(struct hart_state* hstate) 
+{
     return BITS_GET(hstate->execp.syndrome, SYNDROME_ETYPE);
 }
 
 static inline unsigned int
-hart_ecause(struct hart_state* hstate) {
+hart_ecause(struct hart_state* hstate) 
+{
     return hstate->execp.syndrome;
 }
 
@@ -73,17 +75,16 @@ hart_pc(struct hart_state* hstate)
 static inline ptr_t
 hart_sp(struct hart_state* hstate)
 {
-    if (spsr_from_el0(hstate->execp.spsr)) {
-        return hstate->execp.sp_el0;
-    }
-    return hstate->execp.sp_el1;
+    return __ptr(&hstate[-1]);
 }
 
 static inline bool
 kernel_context(struct hart_state* hstate)
 {
-    // TODO
-    return false;
+    reg_t spsr;
+
+    spsr = hstate->execp.spsr;
+    return !spsr_from_el0(spsr);
 }
 
 static inline ptr_t