Home | History | Annotate | Download | only in syslinux
      1 /*
      2  * Copyright (C) 2008 Daniel Verkamp <daniel (at) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
     17  */
     18 
     19 FILE_LICENCE ( GPL2_OR_LATER )
     20 
     21 	.text
     22 	.arch i386
     23 	.code32
     24 
     25 	.globl com32_farcall_wrapper
     26 com32_farcall_wrapper:
     27 
     28 	movl $com32_farcall, %eax
     29 	jmp com32_wrapper
     30 
     31 
     32 	.globl com32_cfarcall_wrapper
     33 com32_cfarcall_wrapper:
     34 
     35 	movl $com32_cfarcall, %eax
     36 	jmp com32_wrapper
     37 
     38 
     39 	.globl com32_intcall_wrapper
     40 com32_intcall_wrapper:
     41 
     42 	movl $com32_intcall, %eax
     43 	/*jmp com32_wrapper*/ /* fall through */
     44 
     45 com32_wrapper:
     46 
     47 	/* Switch to internal virtual address space */
     48 	call _phys_to_virt
     49 
     50 	mov %eax, (com32_helper_function)
     51 
     52 	/* Save external COM32 stack pointer */
     53 	movl %esp, (com32_external_esp)
     54 
     55 	/* Copy arguments to caller-save registers */
     56 	movl 12(%esp), %eax
     57 	movl 8(%esp), %ecx
     58 	movl 4(%esp), %edx
     59 
     60 	/* Switch to internal stack */
     61 	movl (com32_internal_esp), %esp
     62 
     63 	/* Copy arguments to internal stack */
     64 	pushl %eax
     65 	pushl %ecx
     66 	pushl %edx
     67 
     68 	call *(com32_helper_function)
     69 
     70 	/* Clean up stack */
     71 	addl $12, %esp
     72 
     73 	/* Save internal stack pointer and restore external stack pointer */
     74 	movl %esp, (com32_internal_esp)
     75 	movl (com32_external_esp), %esp
     76 
     77 	/* Switch to external flat physical address space */
     78 	call _virt_to_phys
     79 
     80 	ret
     81 
     82 
     83 	.data
     84 
     85 /* Internal gPXE virtual address space %esp */
     86 .globl com32_internal_esp
     87 .lcomm com32_internal_esp, 4
     88 
     89 /* External flat physical address space %esp */
     90 .globl com32_external_esp
     91 .lcomm com32_external_esp, 4
     92 
     93 /* Function pointer of helper to call */
     94 .lcomm com32_helper_function, 4
     95