Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / i386 / interface / syslinux / com32_wrapper.S
1 /*
2  * Copyright (C) 2008 Daniel Verkamp <daniel@drv.nu>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19
20 FILE_LICENCE ( GPL2_OR_LATER )
21
22         .text
23         .arch i386
24         .code32
25
26         .globl com32_farcall_wrapper
27 com32_farcall_wrapper:
28
29         movl $com32_farcall, %eax
30         jmp com32_wrapper
31
32
33         .globl com32_cfarcall_wrapper
34 com32_cfarcall_wrapper:
35
36         movl $com32_cfarcall, %eax
37         jmp com32_wrapper
38
39
40         .globl com32_intcall_wrapper
41 com32_intcall_wrapper:
42
43         movl $com32_intcall, %eax
44         /*jmp com32_wrapper*/ /* fall through */
45
46 com32_wrapper:
47         cli
48
49         /* Switch to internal virtual address space */
50         call _phys_to_virt
51
52         mov %eax, (com32_helper_function)
53
54         /* Save external COM32 stack pointer */
55         movl %esp, (com32_external_esp)
56
57         /* Copy arguments to caller-save registers */
58         movl 12(%esp), %eax
59         movl 8(%esp), %ecx
60         movl 4(%esp), %edx
61
62         /* Switch to internal stack */
63         movl (com32_internal_esp), %esp
64
65         /* Copy arguments to internal stack */
66         pushl %eax
67         pushl %ecx
68         pushl %edx
69
70         call *(com32_helper_function)
71
72         /* Clean up stack */
73         addl $12, %esp
74
75         /* Save internal stack pointer and restore external stack pointer */
76         movl %esp, (com32_internal_esp)
77         movl (com32_external_esp), %esp
78
79         /* Switch to external flat physical address space */
80         call _virt_to_phys
81
82         sti
83         ret
84
85
86         .data
87
88 /* Internal iPXE virtual address space %esp */
89 .globl com32_internal_esp
90 .lcomm com32_internal_esp, 4
91
92 /* External flat physical address space %esp */
93 .globl com32_external_esp
94 .lcomm com32_external_esp, 4
95
96 /* Function pointer of helper to call */
97 .lcomm com32_helper_function, 4