1 #ifndef __LUNAIX_I386ABI_H
2 #define __LUNAIX_I386ABI_H
4 #include <sys/x86_isa.h>
6 #define stack_alignment 0xfffffff0
9 #define align_stack(ptr) ((ptr) & stack_alignment)
10 #define store_retval(retval) current_thread->intr_ctx->registers.eax = (retval)
12 #define store_retval_to(th, retval) (th)->intr_ctx->registers.eax = (retval)
14 #define eret_target(th) (th)->intr_ctx->execp->eip
15 #define eret_stack(th) (th)->intr_ctx->execp->esp
16 #define intr_ivec(th) (th)->intr_ctx->execp->vector
17 #define intr_ierr(th) (th)->intr_ctx->execp->err_code
19 #define j_usr(sp, pc) \
20 asm volatile("movw %0, %%ax\n" \
29 "retf" ::"i"(UDATA_SEG), \
36 static inline void must_inline noret
38 asm volatile("jmp do_switch\n");
42 #define push_arg1(stack_ptr, arg) *((typeof((arg))*)(stack_ptr)--) = arg
43 #define push_arg2(stack_ptr, arg1, arg2) \
45 *((typeof((arg1))*)(stack_ptr)--) = arg1; \
46 *((typeof((arg2))*)(stack_ptr)--) = arg2; \
48 #define push_arg3(stack_ptr, arg1, arg2, arg3) \
50 *((typeof((arg1))*)(stack_ptr)--) = arg1; \
51 *((typeof((arg2))*)(stack_ptr)--) = arg2; \
52 *((typeof((arg3))*)(stack_ptr)--) = arg3; \
54 #define push_arg4(stack_ptr, arg1, arg2, arg3, arg4) \
56 *((typeof((arg1))*)(stack_ptr)--) = arg1; \
57 *((typeof((arg2))*)(stack_ptr)--) = arg2; \
58 *((typeof((arg3))*)(stack_ptr)--) = arg3; \
59 *((typeof((arg4))*)(stack_ptr)--) = arg4; \
63 static inline ptr_t must_inline
67 asm("movl %%ebp, %0" : "=r"(val)::);
74 return *((ptr_t*)abi_get_callframe() + 1);
78 abi_get_retaddrat(ptr_t fp)
80 return *((ptr_t*)fp + 1);
83 #endif /* __LUNAIX_ABI_H */