Boot framework rework (#45)
[lunaix-os.git] / lunaix-os / arch / x86 / includes / sys / abi32.h
1 #ifndef __LUNAIX_ARCH_ABI32_H
2 #define __LUNAIX_ARCH_ABI32_H
3
4 #include "sys/x86_isa.h"
5
6 #define stack_alignment 0xfffffff0
7
8 #ifndef __ASM__
9 #define store_retval(retval) current_thread->hstate->registers.eax = (retval)
10
11 #define store_retval_to(th, retval) (th)->hstate->registers.eax = (retval)
12
13 static inline void must_inline 
14 j_usr(ptr_t sp, ptr_t pc) 
15 {
16     asm volatile("movw %0, %%ax\n"
17                  "movw %%ax, %%es\n"
18                  "movw %%ax, %%ds\n"
19                  "movw %%ax, %%fs\n"
20                  "movw %%ax, %%gs\n"
21                  "pushl %0\n"
22                  "pushl %1\n"
23                  "pushl %2\n"
24                  "pushl %3\n"
25                  "retf" ::"i"(UDATA_SEG),
26                  "r"(sp),
27                  "i"(UCODE_SEG),
28                  "r"(pc)
29                  : "eax", "memory");
30 }
31
32 static inline ptr_t must_inline
33 abi_get_callframe()
34 {
35     ptr_t val;
36     asm("movl %%ebp, %0" : "=r"(val)::);
37     return val;
38 }
39
40 #endif
41 #endif /* __LUNAIX_ARCH_ABI32_H */