Merge remote-tracking branch 'origin/master' into isa/arm64
[lunaix-os.git] / lunaix-os / arch / aarch64 / includes / asm / abi.h
1 #ifndef __LUNAIX_AA64_ABI_H
2 #define __LUNAIX_AA64_ABI_H
3
4 #include <lunaix/types.h>
5
6 #ifndef __ASM__
7
8 #define align_stack(ptr) ((ptr) & ~15)
9
10 #define store_retval(retval) current_thread->hstate->registers.x[0] = (retval)
11 #define store_retval_to(th, retval) (th)->hstate->registers.x[0] = (retval)
12
13
14 static inline void must_inline noret
15 switch_context() {
16     // TODO
17     asm ("b _aa64_switch_task");
18     unreachable;
19 }
20
21
22 static inline ptr_t
23 abi_get_retaddr()
24 {
25     reg_t lr;
26     asm ("mov %0, lr" : "=r"(lr));
27
28     return lr;
29 }
30
31 static inline ptr_t
32 abi_get_retaddrat(ptr_t fp)
33 {
34     return ((ptr_t*)fp)[1];
35 }
36
37 static inline ptr_t must_inline
38 abi_get_callframe()
39 {
40     ptr_t val;
41     asm volatile("mov %0, fp" : "=r"(val));
42     return val;
43 }
44
45 static inline void must_inline 
46 j_usr(ptr_t sp, ptr_t pc) 
47 {
48     // TODO
49 }
50
51 #endif
52
53 #endif /* __LUNAIX_AA64_ABI_H */