Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

com32_wrapper.S 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #include "librm.h"
  21. .text
  22. .code32
  23. .globl com32_farcall_wrapper
  24. com32_farcall_wrapper:
  25. movl $VIRTUAL(com32_farcall), %eax
  26. jmp com32_wrapper
  27. .code32
  28. .globl com32_cfarcall_wrapper
  29. com32_cfarcall_wrapper:
  30. movl $VIRTUAL(com32_cfarcall), %eax
  31. jmp com32_wrapper
  32. .code32
  33. .globl com32_intcall_wrapper
  34. com32_intcall_wrapper:
  35. movl $VIRTUAL(com32_intcall), %eax
  36. /* fall through */
  37. .code32
  38. com32_wrapper:
  39. /* Disable interrupts */
  40. cli
  41. /* Switch to internal virtual address space */
  42. call _phys_to_virt
  43. #ifdef __x86_64__
  44. .code64
  45. /* Preserve registers which are callee-save for COM32 (i386 API) */
  46. pushq %rdi
  47. pushq %rsi
  48. pushq %rbp
  49. /* Extract parameters from stack */
  50. movl 28(%rsp), %edi
  51. movl 32(%rsp), %esi
  52. movl 36(%rsp), %edx
  53. /* Align stack pointer */
  54. movq %rsp, %rbp
  55. andq $~0x07, %rsp
  56. /* Call helper function */
  57. movslq %eax, %rax
  58. call *%rax
  59. /* Restore stack pointer */
  60. movq %rbp, %rsp
  61. /* Restore registers */
  62. popq %rbp
  63. popq %rsi
  64. popq %rdi
  65. #else /* _x86_64 */
  66. /* Call helper function */
  67. pushl 12(%esp)
  68. pushl 12(%esp)
  69. pushl 12(%esp)
  70. call *%eax
  71. addl $12, %esp
  72. #endif /* _x86_64 */
  73. /* Switch to external flat physical address space */
  74. call _virt_to_phys
  75. .code32
  76. /* Reenable interrupts and return */
  77. sti
  78. ret