hexagon_vm.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * Declarations for to Hexagon Virtal Machine.
  3. *
  4. * Copyright (c) 2010-2011, 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. /*
  32. * Lets make this stuff visible only if configured,
  33. * so we can unconditionally include the file.
  34. */
  35. #ifndef __ASSEMBLY__
  36. enum VM_CACHE_OPS {
  37. ickill,
  38. dckill,
  39. l2kill,
  40. dccleaninva,
  41. icinva,
  42. idsync,
  43. fetch_cfg
  44. };
  45. enum VM_INT_OPS {
  46. nop,
  47. globen,
  48. globdis,
  49. locen,
  50. locdis,
  51. affinity,
  52. get,
  53. peek,
  54. status,
  55. post,
  56. clear
  57. };
  58. extern void _K_VM_event_vector(void);
  59. void __vmrte(void);
  60. long __vmsetvec(void *);
  61. long __vmsetie(long);
  62. long __vmgetie(void);
  63. long __vmintop(enum VM_INT_OPS, long, long, long, long);
  64. long __vmclrmap(void *, unsigned long);
  65. long __vmnewmap(void *);
  66. long __vmcache(enum VM_CACHE_OPS op, unsigned long addr, unsigned long len);
  67. unsigned long long __vmgettime(void);
  68. long __vmsettime(unsigned long long);
  69. long __vmstart(void *, void *);
  70. void __vmstop(void);
  71. long __vmwait(void);
  72. void __vmyield(void);
  73. long __vmvpid(void);
  74. static inline long __vmcache_ickill(void)
  75. {
  76. return __vmcache(ickill, 0, 0);
  77. }
  78. static inline long __vmcache_dckill(void)
  79. {
  80. return __vmcache(dckill, 0, 0);
  81. }
  82. static inline long __vmcache_l2kill(void)
  83. {
  84. return __vmcache(l2kill, 0, 0);
  85. }
  86. static inline long __vmcache_dccleaninva(unsigned long addr, unsigned long len)
  87. {
  88. return __vmcache(dccleaninva, addr, len);
  89. }
  90. static inline long __vmcache_icinva(unsigned long addr, unsigned long len)
  91. {
  92. return __vmcache(icinva, addr, len);
  93. }
  94. static inline long __vmcache_idsync(unsigned long addr,
  95. unsigned long len)
  96. {
  97. return __vmcache(idsync, addr, len);
  98. }
  99. static inline long __vmcache_fetch_cfg(unsigned long val)
  100. {
  101. return __vmcache(fetch_cfg, val, 0);
  102. }
  103. /* interrupt operations */
  104. static inline long __vmintop_nop(void)
  105. {
  106. return __vmintop(nop, 0, 0, 0, 0);
  107. }
  108. static inline long __vmintop_globen(long i)
  109. {
  110. return __vmintop(globen, i, 0, 0, 0);
  111. }
  112. static inline long __vmintop_globdis(long i)
  113. {
  114. return __vmintop(globdis, i, 0, 0, 0);
  115. }
  116. static inline long __vmintop_locen(long i)
  117. {
  118. return __vmintop(locen, i, 0, 0, 0);
  119. }
  120. static inline long __vmintop_locdis(long i)
  121. {
  122. return __vmintop(locdis, i, 0, 0, 0);
  123. }
  124. static inline long __vmintop_affinity(long i, long cpu)
  125. {
  126. return __vmintop(locdis, i, cpu, 0, 0);
  127. }
  128. static inline long __vmintop_get(void)
  129. {
  130. return __vmintop(get, 0, 0, 0, 0);
  131. }
  132. static inline long __vmintop_peek(void)
  133. {
  134. return __vmintop(peek, 0, 0, 0, 0);
  135. }
  136. static inline long __vmintop_status(long i)
  137. {
  138. return __vmintop(status, i, 0, 0, 0);
  139. }
  140. static inline long __vmintop_post(long i)
  141. {
  142. return __vmintop(post, i, 0, 0, 0);
  143. }
  144. static inline long __vmintop_clear(long i)
  145. {
  146. return __vmintop(clear, i, 0, 0, 0);
  147. }
  148. #else /* Only assembly code should reference these */
  149. #define HVM_TRAP1_VMRTE 1
  150. #define HVM_TRAP1_VMSETVEC 2
  151. #define HVM_TRAP1_VMSETIE 3
  152. #define HVM_TRAP1_VMGETIE 4
  153. #define HVM_TRAP1_VMINTOP 5
  154. #define HVM_TRAP1_VMCLRMAP 10
  155. #define HVM_TRAP1_VMNEWMAP 11
  156. #define HVM_TRAP1_FORMERLY_VMWIRE 12
  157. #define HVM_TRAP1_VMCACHE 13
  158. #define HVM_TRAP1_VMGETTIME 14
  159. #define HVM_TRAP1_VMSETTIME 15
  160. #define HVM_TRAP1_VMWAIT 16
  161. #define HVM_TRAP1_VMYIELD 17
  162. #define HVM_TRAP1_VMSTART 18
  163. #define HVM_TRAP1_VMSTOP 19
  164. #define HVM_TRAP1_VMVPID 20
  165. #define HVM_TRAP1_VMSETREGS 21
  166. #define HVM_TRAP1_VMGETREGS 22
  167. #endif /* __ASSEMBLY__ */
  168. /*
  169. * Constants for virtual instruction parameters and return values
  170. */
  171. /* vmsetie arguments */
  172. #define VM_INT_DISABLE 0
  173. #define VM_INT_ENABLE 1
  174. /* vmsetimask arguments */
  175. #define VM_INT_UNMASK 0
  176. #define VM_INT_MASK 1
  177. #define VM_NEWMAP_TYPE_LINEAR 0
  178. #define VM_NEWMAP_TYPE_PGTABLES 1
  179. /*
  180. * Event Record definitions useful to both C and Assembler
  181. */
  182. /* VMEST Layout */
  183. #define HVM_VMEST_UM_SFT 31
  184. #define HVM_VMEST_UM_MSK 1
  185. #define HVM_VMEST_IE_SFT 30
  186. #define HVM_VMEST_IE_MSK 1
  187. #define HVM_VMEST_EVENTNUM_SFT 16
  188. #define HVM_VMEST_EVENTNUM_MSK 0xff
  189. #define HVM_VMEST_CAUSE_SFT 0
  190. #define HVM_VMEST_CAUSE_MSK 0xffff
  191. /*
  192. * The initial program gets to find a system environment descriptor
  193. * on its stack when it begins exection. The first word is a version
  194. * code to indicate what is there. Zero means nothing more.
  195. */
  196. #define HEXAGON_VM_SED_NULL 0
  197. /*
  198. * Event numbers for vector binding
  199. */
  200. #define HVM_EV_RESET 0
  201. #define HVM_EV_MACHCHECK 1
  202. #define HVM_EV_GENEX 2
  203. #define HVM_EV_TRAP 8
  204. #define HVM_EV_INTR 15
  205. /* These shoud be nuked as soon as we know the VM is up to spec v0.1.1 */
  206. #define HVM_EV_INTR_0 16
  207. #define HVM_MAX_INTR 240
  208. /*
  209. * Cause values for General Exception
  210. */
  211. #define HVM_GE_C_BUS 0x01
  212. #define HVM_GE_C_XPROT 0x11
  213. #define HVM_GE_C_XUSER 0x14
  214. #define HVM_GE_C_INVI 0x15
  215. #define HVM_GE_C_PRIVI 0x1B
  216. #define HVM_GE_C_XMAL 0x1C
  217. #define HVM_GE_C_RMAL 0x20
  218. #define HVM_GE_C_WMAL 0x21
  219. #define HVM_GE_C_RPROT 0x22
  220. #define HVM_GE_C_WPROT 0x23
  221. #define HVM_GE_C_RUSER 0x24
  222. #define HVM_GE_C_WUSER 0x25
  223. #define HVM_GE_C_CACHE 0x28
  224. /*
  225. * Cause codes for Machine Check
  226. */
  227. #define HVM_MCHK_C_DOWN 0x00
  228. #define HVM_MCHK_C_BADSP 0x01
  229. #define HVM_MCHK_C_BADEX 0x02
  230. #define HVM_MCHK_C_BADPT 0x03
  231. #define HVM_MCHK_C_REGWR 0x29
  232. #endif