xref: /dflybsd-src/lib/libc/x86_64/sys/asmcontext.c (revision 63261abbc5bc59d5ff6f9015d352ce1782cd1dd7)
1b2b3ffcdSSimon Schubert #define _KERNEL_STRUCTURES
2b2b3ffcdSSimon Schubert #include <sys/types.h>
3b2b3ffcdSSimon Schubert #include <sys/ucontext.h>
4b2b3ffcdSSimon Schubert #include <sys/assym.h>
5*63261abbSMatthew Dillon #include <machine/frame.h>
6*63261abbSMatthew Dillon #include <machine/tss.h>
7*63261abbSMatthew Dillon #include <machine/segments.h>
8b2b3ffcdSSimon Schubert #include <stddef.h>
9b2b3ffcdSSimon Schubert 
10b2b3ffcdSSimon Schubert ASSYM(UC_SIGMASK, offsetof(ucontext_t, uc_sigmask));
11*63261abbSMatthew Dillon ASSYM(UC_LINK, offsetof(ucontext_t, uc_link));
12b2b3ffcdSSimon Schubert ASSYM(UC_MCONTEXT, offsetof(ucontext_t, uc_mcontext));
13b2b3ffcdSSimon Schubert ASSYM(SIG_BLOCK, SIG_BLOCK);
14b2b3ffcdSSimon Schubert ASSYM(SIG_SETMASK, SIG_SETMASK);
15b2b3ffcdSSimon Schubert #ifdef __x86_64__
16*63261abbSMatthew Dillon ASSYM(KUCSEL, GSEL(GUCODE_SEL, SEL_UPL));
17*63261abbSMatthew Dillon ASSYM(KUDSEL, GSEL(GUDATA_SEL, SEL_UPL));
18b2b3ffcdSSimon Schubert ASSYM(MC_ONSTACK, offsetof(mcontext_t, mc_onstack));
19b2b3ffcdSSimon Schubert ASSYM(MC_RDI, offsetof(mcontext_t, mc_rdi));
20b2b3ffcdSSimon Schubert ASSYM(MC_RSI, offsetof(mcontext_t, mc_rsi));
21b2b3ffcdSSimon Schubert ASSYM(MC_RDX, offsetof(mcontext_t, mc_rdx));
22b2b3ffcdSSimon Schubert ASSYM(MC_RCX, offsetof(mcontext_t, mc_rcx));
23b2b3ffcdSSimon Schubert ASSYM(MC_R8, offsetof(mcontext_t, mc_r8));
24b2b3ffcdSSimon Schubert ASSYM(MC_R9, offsetof(mcontext_t, mc_r9));
25b2b3ffcdSSimon Schubert ASSYM(MC_RAX, offsetof(mcontext_t, mc_rax));
26b2b3ffcdSSimon Schubert ASSYM(MC_RBX, offsetof(mcontext_t, mc_rbx));
27b2b3ffcdSSimon Schubert ASSYM(MC_RBP, offsetof(mcontext_t, mc_rbp));
28b2b3ffcdSSimon Schubert ASSYM(MC_R10, offsetof(mcontext_t, mc_r10));
29b2b3ffcdSSimon Schubert ASSYM(MC_R11, offsetof(mcontext_t, mc_r11));
30b2b3ffcdSSimon Schubert ASSYM(MC_R12, offsetof(mcontext_t, mc_r12));
31b2b3ffcdSSimon Schubert ASSYM(MC_R13, offsetof(mcontext_t, mc_r13));
32b2b3ffcdSSimon Schubert ASSYM(MC_R14, offsetof(mcontext_t, mc_r14));
33b2b3ffcdSSimon Schubert ASSYM(MC_R15, offsetof(mcontext_t, mc_r15));
34b2b3ffcdSSimon Schubert ASSYM(MC_TRAPNO, offsetof(mcontext_t, mc_trapno));
35b2b3ffcdSSimon Schubert ASSYM(MC_ADDR, offsetof(mcontext_t, mc_addr));
36b2b3ffcdSSimon Schubert ASSYM(MC_FLAGS, offsetof(mcontext_t, mc_flags));
37b2b3ffcdSSimon Schubert ASSYM(MC_ERR, offsetof(mcontext_t, mc_err));
38b2b3ffcdSSimon Schubert ASSYM(MC_RIP, offsetof(mcontext_t, mc_rip));
39b2b3ffcdSSimon Schubert ASSYM(MC_CS, offsetof(mcontext_t, mc_cs));
40b2b3ffcdSSimon Schubert ASSYM(MC_RFLAGS, offsetof(mcontext_t, mc_rflags));
41b2b3ffcdSSimon Schubert ASSYM(MC_RSP, offsetof(mcontext_t, mc_rsp));
42b2b3ffcdSSimon Schubert ASSYM(MC_SS, offsetof(mcontext_t, mc_ss));
43b2b3ffcdSSimon Schubert ASSYM(MC_FPREGS, offsetof(mcontext_t, mc_fpregs));
44*63261abbSMatthew Dillon ASSYM(_MC_FPOWNED_NONE, _MC_FPOWNED_NONE);
45*63261abbSMatthew Dillon ASSYM(_MC_FPFMT_NODEV, _MC_FPFMT_NODEV);
46*63261abbSMatthew Dillon ASSYM(_MC_FPFMT_387, _MC_FPFMT_387);
47*63261abbSMatthew Dillon ASSYM(_MC_FPFMT_XMM, _MC_FPFMT_XMM);
48*63261abbSMatthew Dillon ASSYM(_MC_FPFMT_YMM, _MC_FPFMT_YMM);
49b2b3ffcdSSimon Schubert #endif
50b2b3ffcdSSimon Schubert ASSYM(MC_LEN, offsetof(mcontext_t, mc_len));
51b2b3ffcdSSimon Schubert ASSYM(MC_FPFORMAT, offsetof(mcontext_t, mc_fpformat));
52b2b3ffcdSSimon Schubert ASSYM(MC_OWNEDFP, offsetof(mcontext_t, mc_ownedfp));
53b2b3ffcdSSimon Schubert ASSYM(SIZEOF_MCONTEXT_T, sizeof(mcontext_t));
54*63261abbSMatthew Dillon ASSYM(SIZEOF_UCONTEXT_T, sizeof(ucontext_t));
55