hexagon_vm.h 6.4 KB

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