add basic exception model and context switching for aarch64
[lunaix-os.git] / lunaix-os / arch / aarch64 / exception / handler.c
1 #include <lunaix/process.h>
2 #include <asm/hart.h>
3
4 static inline void
5 update_thread_context(struct hart_state* state)
6 {
7     if (!current_thread) {
8         return;
9     }
10
11     struct hart_state* parent = current_thread->hstate;
12     hart_push_state(parent, state);
13     current_thread->hstate = state;
14
15     if (parent) {
16         state->depth = parent->depth + 1;
17     }
18 }
19
20
21 struct hart_state*
22 handle_exception(struct hart_state* hstate)
23 {
24     update_thread_context(hstate);
25
26     return hstate;
27 }