]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | Copyright Oliver Kowalke 2009. | |
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at | |
5 | http://www.boost.org/LICENSE_1_0.txt) | |
6 | */ | |
7 | ||
8 | /**************************************************************************************** | |
9 | * * | |
10 | * ---------------------------------------------------------------------------------- * | |
11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | |
12 | * ---------------------------------------------------------------------------------- * | |
13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * | |
14 | * ---------------------------------------------------------------------------------- * | |
15 | * | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | * | |
16 | * ---------------------------------------------------------------------------------- * | |
17 | * ---------------------------------------------------------------------------------- * | |
18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * | |
19 | * ---------------------------------------------------------------------------------- * | |
20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * | |
21 | * ---------------------------------------------------------------------------------- * | |
22 | * | R15 | RBX | RBP | RIP | * | |
23 | * ---------------------------------------------------------------------------------- * | |
24 | * * | |
25 | ****************************************************************************************/ | |
26 | ||
27 | .text | |
28 | .globl _ontop_fcontext | |
29 | .align 8 | |
30 | _ontop_fcontext: | |
31 | /* preserve ontop-function in R8 */ | |
32 | movq %rdx, %r8 | |
33 | ||
34 | leaq -0x38(%rsp), %rsp /* prepare stack */ | |
35 | ||
36 | #if !defined(BOOST_USE_TSX) | |
37 | stmxcsr (%rsp) /* save MMX control- and status-word */ | |
38 | fnstcw 0x4(%rsp) /* save x87 control-word */ | |
39 | #endif | |
40 | ||
41 | movq %r12, 0x8(%rsp) /* save R12 */ | |
42 | movq %r13, 0x10(%rsp) /* save R13 */ | |
43 | movq %r14, 0x18(%rsp) /* save R14 */ | |
44 | movq %r15, 0x20(%rsp) /* save R15 */ | |
45 | movq %rbx, 0x28(%rsp) /* save RBX */ | |
46 | movq %rbp, 0x30(%rsp) /* save RBP */ | |
47 | ||
48 | /* store RSP (pointing to context-data) in RAX */ | |
49 | movq %rsp, %rax | |
50 | ||
51 | /* restore RSP (pointing to context-data) from RDI */ | |
52 | movq %rdi, %rsp | |
53 | ||
54 | #if !defined(BOOST_USE_TSX) | |
55 | ldmxcsr (%rsp) /* restore MMX control- and status-word */ | |
56 | fldcw 0x4(%rsp) /* restore x87 control-word */ | |
57 | #endif | |
58 | ||
59 | movq 0x8(%rsp), %r12 /* restore R12 */ | |
60 | movq 0x10(%rsp), %r13 /* restore R13 */ | |
61 | movq 0x18(%rsp), %r14 /* restore R14 */ | |
62 | movq 0x20(%rsp), %r15 /* restore R15 */ | |
63 | movq 0x28(%rsp), %rbx /* restore RBX */ | |
64 | movq 0x30(%rsp), %rbp /* restore RBP */ | |
65 | ||
66 | leaq 0x38(%rsp), %rsp /* prepare stack */ | |
67 | ||
68 | /* return transfer_t from jump */ | |
69 | /* RAX == fctx, RDX == data */ | |
70 | movq %rsi, %rdx | |
71 | /* pass transfer_t as first arg in context function */ | |
72 | /* RDI == fctx, RSI == data */ | |
73 | movq %rax, %rdi | |
74 | ||
75 | /* keep return-address on stack */ | |
76 | ||
77 | /* indirect jump to context */ | |
78 | jmp *%r8 |