physdev.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /* SPDX-License-Identifier: MIT */
  2. #ifndef __XEN_PUBLIC_PHYSDEV_H__
  3. #define __XEN_PUBLIC_PHYSDEV_H__
  4. /*
  5. * Prototype for this hypercall is:
  6. * int physdev_op(int cmd, void *args)
  7. * @cmd == PHYSDEVOP_??? (physdev operation).
  8. * @args == Operation-specific extra arguments (NULL if none).
  9. */
  10. /*
  11. * Notify end-of-interrupt (EOI) for the specified IRQ.
  12. * @arg == pointer to physdev_eoi structure.
  13. */
  14. #define PHYSDEVOP_eoi 12
  15. struct physdev_eoi {
  16. /* IN */
  17. uint32_t irq;
  18. };
  19. /*
  20. * Register a shared page for the hypervisor to indicate whether the guest
  21. * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly
  22. * once the guest used this function in that the associated event channel
  23. * will automatically get unmasked. The page registered is used as a bit
  24. * array indexed by Xen's PIRQ value.
  25. */
  26. #define PHYSDEVOP_pirq_eoi_gmfn_v1 17
  27. /*
  28. * Register a shared page for the hypervisor to indicate whether the
  29. * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
  30. * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
  31. * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
  32. * Xen's PIRQ value.
  33. */
  34. #define PHYSDEVOP_pirq_eoi_gmfn_v2 28
  35. struct physdev_pirq_eoi_gmfn {
  36. /* IN */
  37. xen_ulong_t gmfn;
  38. };
  39. /*
  40. * Query the status of an IRQ line.
  41. * @arg == pointer to physdev_irq_status_query structure.
  42. */
  43. #define PHYSDEVOP_irq_status_query 5
  44. struct physdev_irq_status_query {
  45. /* IN */
  46. uint32_t irq;
  47. /* OUT */
  48. uint32_t flags; /* XENIRQSTAT_* */
  49. };
  50. /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
  51. #define _XENIRQSTAT_needs_eoi (0)
  52. #define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi)
  53. /* IRQ shared by multiple guests? */
  54. #define _XENIRQSTAT_shared (1)
  55. #define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared)
  56. /*
  57. * Set the current VCPU's I/O privilege level.
  58. * @arg == pointer to physdev_set_iopl structure.
  59. */
  60. #define PHYSDEVOP_set_iopl 6
  61. struct physdev_set_iopl {
  62. /* IN */
  63. uint32_t iopl;
  64. };
  65. /*
  66. * Set the current VCPU's I/O-port permissions bitmap.
  67. * @arg == pointer to physdev_set_iobitmap structure.
  68. */
  69. #define PHYSDEVOP_set_iobitmap 7
  70. struct physdev_set_iobitmap {
  71. /* IN */
  72. uint8_t * bitmap;
  73. uint32_t nr_ports;
  74. };
  75. /*
  76. * Read or write an IO-APIC register.
  77. * @arg == pointer to physdev_apic structure.
  78. */
  79. #define PHYSDEVOP_apic_read 8
  80. #define PHYSDEVOP_apic_write 9
  81. struct physdev_apic {
  82. /* IN */
  83. unsigned long apic_physbase;
  84. uint32_t reg;
  85. /* IN or OUT */
  86. uint32_t value;
  87. };
  88. /*
  89. * Allocate or free a physical upcall vector for the specified IRQ line.
  90. * @arg == pointer to physdev_irq structure.
  91. */
  92. #define PHYSDEVOP_alloc_irq_vector 10
  93. #define PHYSDEVOP_free_irq_vector 11
  94. struct physdev_irq {
  95. /* IN */
  96. uint32_t irq;
  97. /* IN or OUT */
  98. uint32_t vector;
  99. };
  100. #define MAP_PIRQ_TYPE_MSI 0x0
  101. #define MAP_PIRQ_TYPE_GSI 0x1
  102. #define MAP_PIRQ_TYPE_UNKNOWN 0x2
  103. #define MAP_PIRQ_TYPE_MSI_SEG 0x3
  104. #define MAP_PIRQ_TYPE_MULTI_MSI 0x4
  105. #define PHYSDEVOP_map_pirq 13
  106. struct physdev_map_pirq {
  107. domid_t domid;
  108. /* IN */
  109. int type;
  110. /* IN */
  111. int index;
  112. /* IN or OUT */
  113. int pirq;
  114. /* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */
  115. int bus;
  116. /* IN */
  117. int devfn;
  118. /* IN
  119. * - For MSI-X contains entry number.
  120. * - For MSI with ..._MULTI_MSI contains number of vectors.
  121. * OUT (..._MULTI_MSI only)
  122. * - Number of vectors allocated.
  123. */
  124. int entry_nr;
  125. /* IN */
  126. uint64_t table_base;
  127. };
  128. #define PHYSDEVOP_unmap_pirq 14
  129. struct physdev_unmap_pirq {
  130. domid_t domid;
  131. /* IN */
  132. int pirq;
  133. };
  134. #define PHYSDEVOP_manage_pci_add 15
  135. #define PHYSDEVOP_manage_pci_remove 16
  136. struct physdev_manage_pci {
  137. /* IN */
  138. uint8_t bus;
  139. uint8_t devfn;
  140. };
  141. #define PHYSDEVOP_restore_msi 19
  142. struct physdev_restore_msi {
  143. /* IN */
  144. uint8_t bus;
  145. uint8_t devfn;
  146. };
  147. #define PHYSDEVOP_manage_pci_add_ext 20
  148. struct physdev_manage_pci_ext {
  149. /* IN */
  150. uint8_t bus;
  151. uint8_t devfn;
  152. unsigned is_extfn;
  153. unsigned is_virtfn;
  154. struct {
  155. uint8_t bus;
  156. uint8_t devfn;
  157. } physfn;
  158. };
  159. /*
  160. * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  161. * hypercall since 0x00030202.
  162. */
  163. struct physdev_op {
  164. uint32_t cmd;
  165. union {
  166. struct physdev_irq_status_query irq_status_query;
  167. struct physdev_set_iopl set_iopl;
  168. struct physdev_set_iobitmap set_iobitmap;
  169. struct physdev_apic apic_op;
  170. struct physdev_irq irq_op;
  171. } u;
  172. };
  173. #define PHYSDEVOP_setup_gsi 21
  174. struct physdev_setup_gsi {
  175. int gsi;
  176. /* IN */
  177. uint8_t triggering;
  178. /* IN */
  179. uint8_t polarity;
  180. /* IN */
  181. };
  182. #define PHYSDEVOP_get_nr_pirqs 22
  183. struct physdev_nr_pirqs {
  184. /* OUT */
  185. uint32_t nr_pirqs;
  186. };
  187. /* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
  188. * the hypercall returns a free pirq */
  189. #define PHYSDEVOP_get_free_pirq 23
  190. struct physdev_get_free_pirq {
  191. /* IN */
  192. int type;
  193. /* OUT */
  194. uint32_t pirq;
  195. };
  196. #define XEN_PCI_DEV_EXTFN 0x1
  197. #define XEN_PCI_DEV_VIRTFN 0x2
  198. #define XEN_PCI_DEV_PXM 0x4
  199. #define XEN_PCI_MMCFG_RESERVED 0x1
  200. #define PHYSDEVOP_pci_mmcfg_reserved 24
  201. struct physdev_pci_mmcfg_reserved {
  202. uint64_t address;
  203. uint16_t segment;
  204. uint8_t start_bus;
  205. uint8_t end_bus;
  206. uint32_t flags;
  207. };
  208. #define PHYSDEVOP_pci_device_add 25
  209. struct physdev_pci_device_add {
  210. /* IN */
  211. uint16_t seg;
  212. uint8_t bus;
  213. uint8_t devfn;
  214. uint32_t flags;
  215. struct {
  216. uint8_t bus;
  217. uint8_t devfn;
  218. } physfn;
  219. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  220. uint32_t optarr[];
  221. #elif defined(__GNUC__)
  222. uint32_t optarr[0];
  223. #endif
  224. };
  225. #define PHYSDEVOP_pci_device_remove 26
  226. #define PHYSDEVOP_restore_msi_ext 27
  227. /*
  228. * Dom0 should use these two to announce MMIO resources assigned to
  229. * MSI-X capable devices won't (prepare) or may (release) change.
  230. */
  231. #define PHYSDEVOP_prepare_msix 30
  232. #define PHYSDEVOP_release_msix 31
  233. struct physdev_pci_device {
  234. /* IN */
  235. uint16_t seg;
  236. uint8_t bus;
  237. uint8_t devfn;
  238. };
  239. #define PHYSDEVOP_DBGP_RESET_PREPARE 1
  240. #define PHYSDEVOP_DBGP_RESET_DONE 2
  241. #define PHYSDEVOP_DBGP_BUS_UNKNOWN 0
  242. #define PHYSDEVOP_DBGP_BUS_PCI 1
  243. #define PHYSDEVOP_dbgp_op 29
  244. struct physdev_dbgp_op {
  245. /* IN */
  246. uint8_t op;
  247. uint8_t bus;
  248. union {
  249. struct physdev_pci_device pci;
  250. } u;
  251. };
  252. /*
  253. * Notify that some PIRQ-bound event channels have been unmasked.
  254. * ** This command is obsolete since interface version 0x00030202 and is **
  255. * ** unsupported by newer versions of Xen. **
  256. */
  257. #define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4
  258. /*
  259. * These all-capitals physdev operation names are superceded by the new names
  260. * (defined above) since interface version 0x00030202.
  261. */
  262. #define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query
  263. #define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl
  264. #define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap
  265. #define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read
  266. #define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write
  267. #define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector
  268. #define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector
  269. #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
  270. #define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared
  271. #endif /* __XEN_PUBLIC_PHYSDEV_H__ */