]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/src/asm/make_i386_sysv_elf_gas.S
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / context / src / asm / make_i386_sysv_elf_gas.S
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| EDI | ESI | EBX | EBP | EIP | hidden | *
16 * ---------------------------------------------------------------------------------- *
17 * ---------------------------------------------------------------------------------- *
18 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
19 * ---------------------------------------------------------------------------------- *
20 * | 0x20 | 0x24 | | *
21 * ---------------------------------------------------------------------------------- *
22 * | to | data | | *
23 * ---------------------------------------------------------------------------------- *
24 * *
25 ****************************************************************************************/
26
27 .text
28 .globl make_fcontext
29 .align 2
30 .type make_fcontext,@function
31 make_fcontext:
32 /* first arg of make_fcontext() == top of context-stack */
33 movl 0x4(%esp), %eax
34
35 /* reserve space for first argument of context-function
36 eax might already point to a 16byte border */
37 leal -0x8(%eax), %eax
38
39 /* shift address in EAX to lower 16 byte boundary */
40 andl $-16, %eax
41
42 /* reserve space for context-data on context-stack */
43 leal -0x28(%eax), %eax
44
45 /* third arg of make_fcontext() == address of context-function */
46 /* stored in EBX */
47 movl 0xc(%esp), %ecx
48 movl %ecx, 0x10(%eax)
49
50 /* save MMX control- and status-word */
51 stmxcsr (%eax)
52 /* save x87 control-word */
53 fnstcw 0x4(%eax)
54
55 /* return transport_t */
56 /* FCTX == EDI, DATA == ESI */
57 leal 0x8(%eax), %ecx
58 movl %ecx, 0x1c(%eax)
59
60 /* compute abs address of label trampoline */
61 call 1f
62 /* address of trampoline 1 */
63 1: popl %ecx
64 /* compute abs address of label trampoline */
65 addl $trampoline-1b, %ecx
66 /* save address of trampoline as return address */
67 /* will be entered after calling jump_fcontext() first time */
68 movl %ecx, 0x18(%eax)
69
70 /* compute abs address of label finish */
71 call 2f
72 /* address of label 2 */
73 2: popl %ecx
74 /* compute abs address of label finish */
75 addl $finish-2b, %ecx
76 /* save address of finish as return-address for context-function */
77 /* will be entered after context-function returns */
78 movl %ecx, 0x14(%eax)
79
80 ret /* return pointer to context-data */
81
82 trampoline:
83 /* move transport_t for entering context-function */
84 movl %edi, (%esp)
85 movl %esi, 0x4(%esp)
86 pushl %ebp
87 /* jump to context-function */
88 jmp *%ebx
89
90 finish:
91 call 3f
92 /* address of label 3 */
93 3: popl %ebx
94 /* compute address of GOT and store it in EBX */
95 addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx
96
97 /* exit code is zero */
98 xorl %eax, %eax
99 movl %eax, (%esp)
100 /* exit application */
101 call _exit@PLT
102 hlt
103 .size make_fcontext,.-make_fcontext
104
105 /* Mark that we don't need executable stack. */
106 .section .note.GNU-stack,"",%progbits