Boot framework rework (#45)
[lunaix-os.git] / lunaix-os / usr / libc / arch / x86_64 / trampoline.S
1 #include <lunaix/syscallid.h>
2
3 .section .text
4     /*
5     stack structure:
6
7         ...saved_state  \
8         void* sighand;   > struct siguctx
9         void* sigact;   /
10         int sig_num;    <--- %rsp
11     */
12     .global sigtrampoline
13     sigtrampoline:
14         movq %rsp, %rax
15         andq $-16, %rsp
16         pushq %rax
17         
18         movl (%rax), %edi      // signum
19         xorq %rsi, %rsi        // siginfo = NULL
20         leaq 4(%rax), %rdx     // (struct siguctx*)&sigact
21         call sig_dohandling
22         
23         movq $__SYSCALL_sigreturn, %rax
24         popq %rbx
25         int $33
26     
27     .global th_trampoline
28     th_trampoline:
29         movq (%rsp), %rax
30         movq 8(%rsp), %rdi
31
32         callq *%rax
33
34         movq %rax, %rbx
35         movq $__SYSCALL_th_exit, %rax
36         int $33