You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

com32_wrapper.S 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER )
  19. .text
  20. .arch i386
  21. .code32
  22. .globl com32_farcall_wrapper
  23. com32_farcall_wrapper:
  24. movl $com32_farcall, %eax
  25. jmp com32_wrapper
  26. .globl com32_cfarcall_wrapper
  27. com32_cfarcall_wrapper:
  28. movl $com32_cfarcall, %eax
  29. jmp com32_wrapper
  30. .globl com32_intcall_wrapper
  31. com32_intcall_wrapper:
  32. movl $com32_intcall, %eax
  33. /*jmp com32_wrapper*/ /* fall through */
  34. com32_wrapper:
  35. /* Switch to internal virtual address space */
  36. call _phys_to_virt
  37. mov %eax, (com32_helper_function)
  38. /* Save external COM32 stack pointer */
  39. movl %esp, (com32_external_esp)
  40. /* Copy arguments to caller-save registers */
  41. movl 12(%esp), %eax
  42. movl 8(%esp), %ecx
  43. movl 4(%esp), %edx
  44. /* Switch to internal stack */
  45. movl (com32_internal_esp), %esp
  46. /* Copy arguments to internal stack */
  47. pushl %eax
  48. pushl %ecx
  49. pushl %edx
  50. call *(com32_helper_function)
  51. /* Clean up stack */
  52. addl $12, %esp
  53. /* Save internal stack pointer and restore external stack pointer */
  54. movl %esp, (com32_internal_esp)
  55. movl (com32_external_esp), %esp
  56. /* Switch to external flat physical address space */
  57. call _virt_to_phys
  58. ret
  59. .data
  60. /* Internal iPXE virtual address space %esp */
  61. .globl com32_internal_esp
  62. .lcomm com32_internal_esp, 4
  63. /* External flat physical address space %esp */
  64. .globl com32_external_esp
  65. .lcomm com32_external_esp, 4
  66. /* Function pointer of helper to call */
  67. .lcomm com32_helper_function, 4