]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/src/asm/make_i386_sysv_macho_gas.S
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / context / src / asm / make_i386_sysv_macho_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 * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | *
16 * ----------------------------------------------------------------------------------- *
17 * *
18 *****************************************************************************************/
19
20 .text
21 .globl _make_fcontext
22 .align 2
23 _make_fcontext:
24 /* first arg of make_fcontext() == top of context-stack */
25 movl 0x4(%esp), %eax
26
27 /* reserve space for first argument of context-function
28 rax might already point to a 16byte border */
29 leal -0x8(%eax), %eax
30
31 /* shift address in EAX to lower 16 byte boundary */
32 andl $-16, %eax
33
34 /* reserve space for context-data on context-stack */
35 leal -0x28(%eax), %eax
36
37 /* thrid arg of make_fcontext() == address of context-function */
38 /* stored in EBX */
39 movl 0xc(%esp), %edx
40 movl %edx, 0x8(%eax)
41
42 /* return transport_t */
43 /* FCTX == EDI, DATA == ESI */
44 leal (%eax), %ecx
45 movl %ecx, 0x14(%eax)
46
47 /* compute abs address of label trampoline */
48 call 1f
49 /* address of trampoline 1 */
50 1: popl %ecx
51 /* compute abs address of label trampoline */
52 addl $trampoline-1b, %ecx
53 /* save address of trampoline as return address */
54 /* will be entered after calling jump_fcontext() first time */
55 movl %ecx, 0x10(%eax)
56
57 /* compute abs address of label finish */
58 call 2f
59 /* address of label 2 */
60 2: popl %ecx
61 /* compute abs address of label finish */
62 addl $finish-2b, %ecx
63 /* save address of finish as return-address for context-function */
64 /* will be entered after context-function returns */
65 movl %ecx, 0xc(%eax)
66
67 ret /* return pointer to context-data */
68
69 trampoline:
70 /* move transport_t for entering context-function */
71 movl %edi, (%esp)
72 movl %esi, 0x4(%esp)
73 pushl %ebp
74 /* jump to context-function */
75 jmp *%ebx
76
77 finish:
78 /* exit code is zero */
79 xorl %eax, %eax
80 movl %eax, (%esp)
81 /* exit application */
82 call __exit
83 hlt