hexagon_vm.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Declarations for to Hexagon Virtal Machine.
  4. *
  5. * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  6. */
  7. #ifndef ASM_HEXAGON_VM_H
  8. #define ASM_HEXAGON_VM_H
  9. /*
  10. * In principle, a Linux kernel for the VM could
  11. * selectively define the virtual instructions
  12. * as inline assembler macros, but for a first pass,
  13. * we'll use subroutines for both the VM and the native
  14. * kernels. It's costing a subroutine call/return,
  15. * but it makes for a single set of entry points
  16. * for tracing/debugging.
  17. */
  18. #define HVM_TRAP1_VMVERSION 0
  19. #define HVM_TRAP1_VMRTE 1
  20. #define HVM_TRAP1_VMSETVEC 2
  21. #define HVM_TRAP1_VMSETIE 3
  22. #define HVM_TRAP1_VMGETIE 4
  23. #define HVM_TRAP1_VMINTOP 5
  24. #define HVM_TRAP1_VMCLRMAP 10
  25. #define HVM_TRAP1_VMNEWMAP 11
  26. #define HVM_TRAP1_FORMERLY_VMWIRE 12
  27. #define HVM_TRAP1_VMCACHE 13
  28. #define HVM_TRAP1_VMGETTIME 14
  29. #define HVM_TRAP1_VMSETTIME 15
  30. #define HVM_TRAP1_VMWAIT 16
  31. #define HVM_TRAP1_VMYIELD 17
  32. #define HVM_TRAP1_VMSTART 18
  33. #define HVM_TRAP1_VMSTOP 19
  34. #define HVM_TRAP1_VMVPID 20
  35. #define HVM_TRAP1_VMSETREGS 21
  36. #define HVM_TRAP1_VMGETREGS 22
  37. #define HVM_TRAP1_VMTIMEROP 24
  38. #ifndef __ASSEMBLY__
  39. enum VM_CACHE_OPS {
  40. hvmc_ickill,
  41. hvmc_dckill,
  42. hvmc_l2kill,
  43. hvmc_dccleaninva,
  44. hvmc_icinva,
  45. hvmc_idsync,
  46. hvmc_fetch_cfg
  47. };
  48. enum VM_INT_OPS {
  49. hvmi_nop,
  50. hvmi_globen,
  51. hvmi_globdis,
  52. hvmi_locen,
  53. hvmi_locdis,
  54. hvmi_affinity,
  55. hvmi_get,
  56. hvmi_peek,
  57. hvmi_status,
  58. hvmi_post,
  59. hvmi_clear
  60. };
  61. extern void _K_VM_event_vector(void);
  62. void __vmrte(void);
  63. long __vmsetvec(void *);
  64. long __vmsetie(long);
  65. long __vmgetie(void);
  66. long __vmintop(enum VM_INT_OPS, long, long, long, long);
  67. long __vmclrmap(void *, unsigned long);
  68. long __vmnewmap(void *);
  69. long __vmcache(enum VM_CACHE_OPS op, unsigned long addr, unsigned long len);
  70. unsigned long long __vmgettime(void);
  71. long __vmsettime(unsigned long long);
  72. long __vmstart(void *, void *);
  73. void __vmstop(void);
  74. long __vmwait(void);
  75. void __vmyield(void);
  76. long __vmvpid(void);
  77. static inline long __vmcache_ickill(void)
  78. {
  79. return __vmcache(hvmc_ickill, 0, 0);
  80. }
  81. static inline long __vmcache_dckill(void)
  82. {
  83. return __vmcache(hvmc_dckill, 0, 0);
  84. }
  85. static inline long __vmcache_l2kill(void)
  86. {
  87. return __vmcache(hvmc_l2kill, 0, 0);
  88. }
  89. static inline long __vmcache_dccleaninva(unsigned long addr, unsigned long len)
  90. {
  91. return __vmcache(hvmc_dccleaninva, addr, len);
  92. }
  93. static inline long __vmcache_icinva(unsigned long addr, unsigned long len)
  94. {
  95. return __vmcache(hvmc_icinva, addr, len);
  96. }
  97. static inline long __vmcache_idsync(unsigned long addr,
  98. unsigned long len)
  99. {
  100. return __vmcache(hvmc_idsync, addr, len);
  101. }
  102. static inline long __vmcache_fetch_cfg(unsigned long val)
  103. {
  104. return __vmcache(hvmc_fetch_cfg, val, 0);
  105. }
  106. /* interrupt operations */
  107. static inline long __vmintop_nop(void)
  108. {
  109. return __vmintop(hvmi_nop, 0, 0, 0, 0);
  110. }
  111. static inline long __vmintop_globen(long i)
  112. {
  113. return __vmintop(hvmi_globen, i, 0, 0, 0);
  114. }
  115. static inline long __vmintop_globdis(long i)
  116. {
  117. return __vmintop(hvmi_globdis, i, 0, 0, 0);
  118. }
  119. static inline long __vmintop_locen(long i)
  120. {
  121. return __vmintop(hvmi_locen, i, 0, 0, 0);
  122. }
  123. static inline long __vmintop_locdis(long i)
  124. {
  125. return __vmintop(hvmi_locdis, i, 0, 0, 0);
  126. }
  127. static inline long __vmintop_affinity(long i, long cpu)
  128. {
  129. return __vmintop(hvmi_affinity, i, cpu, 0, 0);
  130. }
  131. static inline long __vmintop_get(void)
  132. {
  133. return __vmintop(hvmi_get, 0, 0, 0, 0);
  134. }
  135. static inline long __vmintop_peek(void)
  136. {
  137. return __vmintop(hvmi_peek, 0, 0, 0, 0);
  138. }
  139. static inline long __vmintop_status(long i)
  140. {
  141. return __vmintop(hvmi_status, i, 0, 0, 0);
  142. }
  143. static inline long __vmintop_post(long i)
  144. {
  145. return __vmintop(hvmi_post, i, 0, 0, 0);
  146. }
  147. static inline long __vmintop_clear(long i)
  148. {
  149. return __vmintop(hvmi_clear, i, 0, 0, 0);
  150. }
  151. #else /* Only assembly code should reference these */
  152. #endif /* __ASSEMBLY__ */
  153. /*
  154. * Constants for virtual instruction parameters and return values
  155. */
  156. /* vmnewmap arguments */
  157. #define VM_TRANS_TYPE_LINEAR 0
  158. #define VM_TRANS_TYPE_TABLE 1
  159. #define VM_TLB_INVALIDATE_FALSE 0
  160. #define VM_TLB_INVALIDATE_TRUE 1
  161. /* vmsetie arguments */
  162. #define VM_INT_DISABLE 0
  163. #define VM_INT_ENABLE 1
  164. /* vmsetimask arguments */
  165. #define VM_INT_UNMASK 0
  166. #define VM_INT_MASK 1
  167. #define VM_NEWMAP_TYPE_LINEAR 0
  168. #define VM_NEWMAP_TYPE_PGTABLES 1
  169. /*
  170. * Event Record definitions useful to both C and Assembler
  171. */
  172. /* VMEST Layout */
  173. #define HVM_VMEST_UM_SFT 31
  174. #define HVM_VMEST_UM_MSK 1
  175. #define HVM_VMEST_IE_SFT 30
  176. #define HVM_VMEST_IE_MSK 1
  177. #define HVM_VMEST_SS_SFT 29
  178. #define HVM_VMEST_SS_MSK 1
  179. #define HVM_VMEST_EVENTNUM_SFT 16
  180. #define HVM_VMEST_EVENTNUM_MSK 0xff
  181. #define HVM_VMEST_CAUSE_SFT 0
  182. #define HVM_VMEST_CAUSE_MSK 0xffff
  183. /*
  184. * The initial program gets to find a system environment descriptor
  185. * on its stack when it begins execution. The first word is a version
  186. * code to indicate what is there. Zero means nothing more.
  187. */
  188. #define HEXAGON_VM_SED_NULL 0
  189. /*
  190. * Event numbers for vector binding
  191. */
  192. #define HVM_EV_RESET 0
  193. #define HVM_EV_MACHCHECK 1
  194. #define HVM_EV_GENEX 2
  195. #define HVM_EV_TRAP 8
  196. #define HVM_EV_INTR 15
  197. /* These shoud be nuked as soon as we know the VM is up to spec v0.1.1 */
  198. #define HVM_EV_INTR_0 16
  199. #define HVM_MAX_INTR 240
  200. /*
  201. * Cause values for General Exception
  202. */
  203. #define HVM_GE_C_BUS 0x01
  204. #define HVM_GE_C_XPROT 0x11
  205. #define HVM_GE_C_XUSER 0x14
  206. #define HVM_GE_C_INVI 0x15
  207. #define HVM_GE_C_PRIVI 0x1B
  208. #define HVM_GE_C_XMAL 0x1C
  209. #define HVM_GE_C_WREG 0x1D
  210. #define HVM_GE_C_PCAL 0x1E
  211. #define HVM_GE_C_RMAL 0x20
  212. #define HVM_GE_C_WMAL 0x21
  213. #define HVM_GE_C_RPROT 0x22
  214. #define HVM_GE_C_WPROT 0x23
  215. #define HVM_GE_C_RUSER 0x24
  216. #define HVM_GE_C_WUSER 0x25
  217. #define HVM_GE_C_CACHE 0x28
  218. /*
  219. * Cause codes for Machine Check
  220. */
  221. #define HVM_MCHK_C_DOWN 0x00
  222. #define HVM_MCHK_C_BADSP 0x01
  223. #define HVM_MCHK_C_BADEX 0x02
  224. #define HVM_MCHK_C_BADPT 0x03
  225. #define HVM_MCHK_C_REGWR 0x29
  226. #endif