efiemu.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/symbol.h>
  19. /*
  20. * x86_64 uses registry to pass parameters. Unfortunately, gcc and efi use
  21. * different call conversion, so we need to do some conversion.
  22. *
  23. * gcc:
  24. * %rdi, %rsi, %rdx, %rcx, %r8, %r9, 8(%rsp), 16(%rsp), ...
  25. *
  26. * efi:
  27. * %rcx, %rdx, %r8, %r9, 32(%rsp), 40(%rsp), 48(%rsp), ...
  28. *
  29. */
  30. .file "efiemu.S"
  31. .text
  32. FUNCTION (efiemu_get_time)
  33. push %rdi
  34. push %rsi
  35. mov %rcx, %rdi
  36. mov %rdx, %rsi
  37. call efiemu_get_time_real
  38. pop %rsi
  39. pop %rdi
  40. ret
  41. FUNCTION (efiemu_set_time)
  42. push %rdi
  43. push %rsi
  44. mov %rcx, %rdi
  45. call efiemu_set_time_real
  46. pop %rsi
  47. pop %rdi
  48. ret
  49. FUNCTION (efiemu_get_wakeup_time)
  50. push %rdi
  51. push %rsi
  52. mov %rcx, %rdi
  53. mov %rdx, %rsi
  54. mov %r8, %rdx
  55. call efiemu_get_wakeup_time_real
  56. pop %rsi
  57. pop %rdi
  58. ret
  59. FUNCTION (efiemu_set_wakeup_time)
  60. push %rdi
  61. push %rsi
  62. mov %rcx, %rdi
  63. mov %rdx, %rsi
  64. call efiemu_set_wakeup_time_real
  65. pop %rsi
  66. pop %rdi
  67. ret
  68. FUNCTION (efiemu_get_variable)
  69. push %rdi
  70. push %rsi
  71. mov %rcx, %rdi
  72. mov %rdx, %rsi
  73. mov %r8, %rdx
  74. mov %r9, %rcx
  75. mov 56(%rsp), %r8
  76. call efiemu_get_variable_real
  77. pop %rsi
  78. pop %rdi
  79. ret
  80. FUNCTION (efiemu_get_next_variable_name)
  81. push %rdi
  82. push %rsi
  83. mov %rcx, %rdi
  84. mov %rdx, %rsi
  85. mov %r8, %rdx
  86. call efiemu_get_next_variable_name_real
  87. pop %rsi
  88. pop %rdi
  89. ret
  90. FUNCTION (efiemu_set_variable)
  91. push %rdi
  92. push %rsi
  93. mov %rcx, %rdi
  94. mov %rdx, %rsi
  95. mov %r8, %rdx
  96. mov %r9, %rcx
  97. mov 56(%rsp), %r8
  98. call efiemu_set_variable_real
  99. pop %rsi
  100. pop %rdi
  101. ret
  102. FUNCTION (efiemu_get_next_high_monotonic_count)
  103. push %rdi
  104. push %rsi
  105. mov %rcx, %rdi
  106. call efiemu_get_next_high_monotonic_count_real
  107. pop %rsi
  108. pop %rdi
  109. ret
  110. FUNCTION (efiemu_reset_system)
  111. push %rdi
  112. push %rsi
  113. mov %rcx, %rdi
  114. mov %rdx, %rsi
  115. mov %r8, %rdx
  116. mov %r9, %rcx
  117. call efiemu_reset_system_real
  118. pop %rsi
  119. pop %rdi
  120. ret
  121. /* The following functions are always called in physical mode */
  122. .section ".text-physical", "ax"
  123. FUNCTION (efiemu_set_virtual_address_map)
  124. push %rdi
  125. push %rsi
  126. mov %rcx, %rdi
  127. mov %rdx, %rsi
  128. mov %r8, %rdx
  129. mov %r9, %rcx
  130. call efiemu_set_virtual_address_map_real
  131. pop %rsi
  132. pop %rdi
  133. ret
  134. FUNCTION (efiemu_convert_pointer)
  135. push %rdi
  136. push %rsi
  137. mov %rcx, %rdi
  138. mov %rdx, %rsi
  139. call efiemu_convert_pointer_real
  140. pop %rsi
  141. pop %rdi
  142. ret