physical page list mapping
[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 #include <asm/aa64_msrs.h>
9 #include <asm/aa64_spsr.h>
10
11 #define align_stack(ptr) ((ptr) & ~15)
12
13 #define store_retval(retval) \
14             current_thread->hstate->registers.x[0] = (retval)
15
16 #define store_retval_to(th, retval) \
17             (th)->hstate->registers.x[0] = (retval)
18
19
20 static inline void must_inline noret
21 switch_context() 
22 {
23     asm ("b _aa64_switch_task");
24     unreachable;
25 }
26
27
28 static inline ptr_t
29 abi_get_retaddr()
30 {
31     reg_t lr;
32     asm ("mov %0, lr" : "=r"(lr));
33
34     return lr;
35 }
36
37 static inline ptr_t
38 abi_get_retaddrat(ptr_t fp)
39 {
40     return ((ptr_t*)fp)[1];
41 }
42
43 static inline ptr_t must_inline
44 abi_get_callframe()
45 {
46     ptr_t val;
47     asm volatile("mov %0, fp" : "=r"(val));
48     return val;
49 }
50
51 static inline void must_inline 
52 j_usr(ptr_t sp, ptr_t pc) 
53 {
54     set_sysreg(SPSR_EL1, SPSR_EL0_preset);
55     set_sysreg(SP_EL0, sp);
56     set_sysreg(ELR_E1, pc);
57     asm ("eret");
58
59     unreachable;
60 }
61
62 #endif
63
64 #endif /* __LUNAIX_AA64_ABI_H */