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

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