arm_inline.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Linux 2.6.32 and later Kernel module for VMware MVP Hypervisor Support
  3. *
  4. * Copyright (C) 2010-2013 VMware, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; see the file COPYING. If not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #line 5
  20. /**
  21. * @file
  22. *
  23. * @brief Inline stubs for ARM assembler instructions.
  24. */
  25. #ifndef _ARM_INLINE_H_
  26. #define _ARM_INLINE_H_
  27. #define INCLUDE_ALLOW_MVPD
  28. #define INCLUDE_ALLOW_VMX
  29. #define INCLUDE_ALLOW_MODULE
  30. #define INCLUDE_ALLOW_MONITOR
  31. #define INCLUDE_ALLOW_PV
  32. #define INCLUDE_ALLOW_GPL
  33. #include "include_check.h"
  34. #include "arm_types.h"
  35. #include "arm_defs.h"
  36. /*
  37. * Compiler specific include - we get the actual inline assembler macros here.
  38. */
  39. #include "arm_gcc_inline.h"
  40. /*
  41. * Some non-compiler specific helper functions for inline assembler macros
  42. * included above.
  43. */
  44. /**
  45. * @brief Predicate giving whether interrupts are currently enabled
  46. *
  47. * @return TRUE if enabled, FALSE otherwise
  48. */
  49. static inline _Bool
  50. ARM_InterruptsEnabled(void)
  51. {
  52. return !(ARM_ReadCPSR() & ARM_PSR_I);
  53. }
  54. /**
  55. * @brief Read current TTBR0 base machine address
  56. *
  57. * @return machine address given by translation table base register 0
  58. */
  59. static inline MA
  60. ARM_ReadTTBase0(void)
  61. {
  62. MA ttbase;
  63. ARM_MRC_CP15(TTBASE0_POINTER, ttbase);
  64. return ttbase & ARM_CP15_TTBASE_MASK;
  65. }
  66. /**
  67. * @brief Read VFP/Adv.SIMD Extension System Register
  68. *
  69. * @param specReg which VFP/Adv. SIMD Extension System Register
  70. *
  71. * @return Read value
  72. */
  73. static inline uint32
  74. ARM_ReadVFPSystemRegister(uint8 specReg)
  75. {
  76. uint32 value = 0;
  77. /*
  78. * VMRS is the instruction used to read VFP System Registers.
  79. * VMRS is the new UAL-syntax equivalent for the FMRX instruction.
  80. * At the end of the day, all these are just synonyms for MRC
  81. * instructions on CP10, as the VFP system registers sit in CP10
  82. * and MRC is the Co-processor register read instruction.
  83. * We use the primitive MRC synonym for VMRS here as VMRS/FMRX
  84. * don't seem to be working when used inside asm volatile blocks,
  85. * as, for some reason, the inline assembler seems to be setting
  86. * the VFP mode to soft-float. Moreover, we WANT the monitor code
  87. * to be compiled with soft-float so that the compiler doesn't use
  88. * VFP instructions for the monitor's own use, such as for 64-bit
  89. * integer operations, etc., since we pass-through the use of the
  90. * underlying hardware's VFP/SIMD state to the guest.
  91. */
  92. switch (specReg) {
  93. case ARM_VFP_SYSTEM_REG_FPSID:
  94. ARM_MRC_CP10(VFP_FPSID, value);
  95. break;
  96. case ARM_VFP_SYSTEM_REG_MVFR0:
  97. ARM_MRC_CP10(VFP_MVFR0, value);
  98. break;
  99. case ARM_VFP_SYSTEM_REG_MVFR1:
  100. ARM_MRC_CP10(VFP_MVFR1, value);
  101. break;
  102. case ARM_VFP_SYSTEM_REG_FPEXC:
  103. ARM_MRC_CP10(VFP_FPEXC, value);
  104. break;
  105. case ARM_VFP_SYSTEM_REG_FPSCR:
  106. ARM_MRC_CP10(VFP_FPSCR, value);
  107. break;
  108. case ARM_VFP_SYSTEM_REG_FPINST:
  109. ARM_MRC_CP10(VFP_FPINST, value);
  110. break;
  111. case ARM_VFP_SYSTEM_REG_FPINST2:
  112. ARM_MRC_CP10(VFP_FPINST2, value);
  113. break;
  114. default:
  115. NOT_IMPLEMENTED_JIRA(1849);
  116. break;
  117. }
  118. return value;
  119. }
  120. /**
  121. * @brief Write to VFP/Adv.SIMD Extension System Register
  122. *
  123. * @param specReg which VFP/Adv. SIMD Extension System Register
  124. * @param value desired value to be written to the System Register
  125. */
  126. static inline void
  127. ARM_WriteVFPSystemRegister(uint8 specReg,
  128. uint32 value)
  129. {
  130. /*
  131. * VMSR is the instruction used to write to VFP System Registers.
  132. * VMSR is the new UAL-syntax equivalent for the FMXR instruction.
  133. * At the end of the day, all these are just synonyms for MCR
  134. * instructions on CP10, as the VFP system registers sit in CP10
  135. * and MCR is the Co-processor register write instruction.
  136. * We use the primitive MCR synonym for VMSR here as VMSR/FMXR
  137. * don't seem to be working when used inside asm volatile blocks,
  138. * as, for some reason, the inline assembler seems to be setting
  139. * the VFP mode to soft-float. Moreover, we WANT the monitor code
  140. * to be compiled with soft-float so that the compiler doesn't use
  141. * VFP instructions for the monitor's own use, such as for 64-bit
  142. * integer operations, etc., since we pass-through the use of the
  143. * underlying hardware's VFP/SIMD state to the guest.
  144. */
  145. switch (specReg) {
  146. case ARM_VFP_SYSTEM_REG_FPEXC:
  147. ARM_MCR_CP10(VFP_FPEXC, value);
  148. break;
  149. case ARM_VFP_SYSTEM_REG_FPSCR:
  150. ARM_MCR_CP10(VFP_FPSCR, value);
  151. break;
  152. case ARM_VFP_SYSTEM_REG_FPINST:
  153. ARM_MCR_CP10(VFP_FPINST, value);
  154. break;
  155. case ARM_VFP_SYSTEM_REG_FPINST2:
  156. ARM_MCR_CP10(VFP_FPINST2, value);
  157. break;
  158. default:
  159. NOT_IMPLEMENTED_JIRA(1849);
  160. break;
  161. }
  162. }
  163. #endif /* ifndef _ARM_INLINE_H_ */