2
0

physdev.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (c) 2006, Keir Fraser
  4. */
  5. #ifndef __XEN_PUBLIC_PHYSDEV_H__
  6. #define __XEN_PUBLIC_PHYSDEV_H__
  7. #include "xen.h"
  8. /*
  9. * Prototype for this hypercall is:
  10. * int physdev_op(int cmd, void *args)
  11. * @cmd == PHYSDEVOP_??? (physdev operation).
  12. * @args == Operation-specific extra arguments (NULL if none).
  13. */
  14. /*
  15. * Notify end-of-interrupt (EOI) for the specified IRQ.
  16. * @arg == pointer to physdev_eoi structure.
  17. */
  18. #define PHYSDEVOP_eoi 12
  19. struct physdev_eoi {
  20. /* IN */
  21. uint32_t irq;
  22. };
  23. typedef struct physdev_eoi physdev_eoi_t;
  24. DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
  25. /*
  26. * Register a shared page for the hypervisor to indicate whether the guest
  27. * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly
  28. * once the guest used this function in that the associated event channel
  29. * will automatically get unmasked. The page registered is used as a bit
  30. * array indexed by Xen's PIRQ value.
  31. */
  32. #define PHYSDEVOP_pirq_eoi_gmfn_v1 17
  33. /*
  34. * Register a shared page for the hypervisor to indicate whether the
  35. * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
  36. * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
  37. * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
  38. * Xen's PIRQ value.
  39. */
  40. #define PHYSDEVOP_pirq_eoi_gmfn_v2 28
  41. struct physdev_pirq_eoi_gmfn {
  42. /* IN */
  43. xen_pfn_t gmfn;
  44. };
  45. typedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t;
  46. DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t);
  47. /*
  48. * Query the status of an IRQ line.
  49. * @arg == pointer to physdev_irq_status_query structure.
  50. */
  51. #define PHYSDEVOP_irq_status_query 5
  52. struct physdev_irq_status_query {
  53. /* IN */
  54. uint32_t irq;
  55. /* OUT */
  56. uint32_t flags; /* XENIRQSTAT_* */
  57. };
  58. typedef struct physdev_irq_status_query physdev_irq_status_query_t;
  59. DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
  60. /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
  61. #define _XENIRQSTAT_needs_eoi (0)
  62. #define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi)
  63. /* IRQ shared by multiple guests? */
  64. #define _XENIRQSTAT_shared (1)
  65. #define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared)
  66. /*
  67. * Set the current VCPU's I/O privilege level.
  68. * @arg == pointer to physdev_set_iopl structure.
  69. */
  70. #define PHYSDEVOP_set_iopl 6
  71. struct physdev_set_iopl {
  72. /* IN */
  73. uint32_t iopl;
  74. };
  75. typedef struct physdev_set_iopl physdev_set_iopl_t;
  76. DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
  77. /*
  78. * Set the current VCPU's I/O-port permissions bitmap.
  79. * @arg == pointer to physdev_set_iobitmap structure.
  80. */
  81. #define PHYSDEVOP_set_iobitmap 7
  82. struct physdev_set_iobitmap {
  83. /* IN */
  84. #if __XEN_INTERFACE_VERSION__ >= 0x00030205
  85. XEN_GUEST_HANDLE(uint8) bitmap;
  86. #else
  87. uint8_t *bitmap;
  88. #endif
  89. uint32_t nr_ports;
  90. };
  91. typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
  92. DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
  93. /*
  94. * Read or write an IO-APIC register.
  95. * @arg == pointer to physdev_apic structure.
  96. */
  97. #define PHYSDEVOP_apic_read 8
  98. #define PHYSDEVOP_apic_write 9
  99. struct physdev_apic {
  100. /* IN */
  101. unsigned long apic_physbase;
  102. uint32_t reg;
  103. /* IN or OUT */
  104. uint32_t value;
  105. };
  106. typedef struct physdev_apic physdev_apic_t;
  107. DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
  108. /*
  109. * Allocate or free a physical upcall vector for the specified IRQ line.
  110. * @arg == pointer to physdev_irq structure.
  111. */
  112. #define PHYSDEVOP_alloc_irq_vector 10
  113. #define PHYSDEVOP_free_irq_vector 11
  114. struct physdev_irq {
  115. /* IN */
  116. uint32_t irq;
  117. /* IN or OUT */
  118. uint32_t vector;
  119. };
  120. typedef struct physdev_irq physdev_irq_t;
  121. DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
  122. #define MAP_PIRQ_TYPE_MSI 0x0
  123. #define MAP_PIRQ_TYPE_GSI 0x1
  124. #define MAP_PIRQ_TYPE_UNKNOWN 0x2
  125. #define MAP_PIRQ_TYPE_MSI_SEG 0x3
  126. #define MAP_PIRQ_TYPE_MULTI_MSI 0x4
  127. #define PHYSDEVOP_map_pirq 13
  128. struct physdev_map_pirq {
  129. domid_t domid;
  130. /* IN */
  131. int type;
  132. /* IN (ignored for ..._MULTI_MSI) */
  133. int index;
  134. /* IN or OUT */
  135. int pirq;
  136. /* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */
  137. int bus;
  138. /* IN */
  139. int devfn;
  140. /* IN (also OUT for ..._MULTI_MSI) */
  141. int entry_nr;
  142. /* IN */
  143. uint64_t table_base;
  144. };
  145. typedef struct physdev_map_pirq physdev_map_pirq_t;
  146. DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t);
  147. #define PHYSDEVOP_unmap_pirq 14
  148. struct physdev_unmap_pirq {
  149. domid_t domid;
  150. /* IN */
  151. int pirq;
  152. };
  153. typedef struct physdev_unmap_pirq physdev_unmap_pirq_t;
  154. DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t);
  155. #define PHYSDEVOP_manage_pci_add 15
  156. #define PHYSDEVOP_manage_pci_remove 16
  157. struct physdev_manage_pci {
  158. /* IN */
  159. uint8_t bus;
  160. uint8_t devfn;
  161. };
  162. typedef struct physdev_manage_pci physdev_manage_pci_t;
  163. DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t);
  164. #define PHYSDEVOP_restore_msi 19
  165. struct physdev_restore_msi {
  166. /* IN */
  167. uint8_t bus;
  168. uint8_t devfn;
  169. };
  170. typedef struct physdev_restore_msi physdev_restore_msi_t;
  171. DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t);
  172. #define PHYSDEVOP_manage_pci_add_ext 20
  173. struct physdev_manage_pci_ext {
  174. /* IN */
  175. uint8_t bus;
  176. uint8_t devfn;
  177. uint32_t is_extfn;
  178. uint32_t is_virtfn;
  179. struct {
  180. uint8_t bus;
  181. uint8_t devfn;
  182. } physfn;
  183. };
  184. typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t;
  185. DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t);
  186. /*
  187. * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  188. * hypercall since 0x00030202.
  189. */
  190. struct physdev_op {
  191. uint32_t cmd;
  192. union {
  193. physdev_irq_status_query_t irq_status_query;
  194. physdev_set_iopl_t set_iopl;
  195. physdev_set_iobitmap_t set_iobitmap;
  196. physdev_apic_t apic_op;
  197. physdev_irq_t irq_op;
  198. } u;
  199. };
  200. typedef struct physdev_op physdev_op_t;
  201. DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
  202. #define PHYSDEVOP_setup_gsi 21
  203. struct physdev_setup_gsi {
  204. int gsi;
  205. /* IN */
  206. uint8_t triggering;
  207. /* IN */
  208. uint8_t polarity;
  209. /* IN */
  210. };
  211. typedef struct physdev_setup_gsi physdev_setup_gsi_t;
  212. DEFINE_XEN_GUEST_HANDLE(physdev_setup_gsi_t);
  213. /* leave PHYSDEVOP 22 free */
  214. /* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
  215. * the hypercall returns a free pirq */
  216. #define PHYSDEVOP_get_free_pirq 23
  217. struct physdev_get_free_pirq {
  218. /* IN */
  219. int type;
  220. /* OUT */
  221. uint32_t pirq;
  222. };
  223. typedef struct physdev_get_free_pirq physdev_get_free_pirq_t;
  224. DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
  225. #define XEN_PCI_MMCFG_RESERVED 0x1
  226. #define PHYSDEVOP_pci_mmcfg_reserved 24
  227. struct physdev_pci_mmcfg_reserved {
  228. uint64_t address;
  229. uint16_t segment;
  230. uint8_t start_bus;
  231. uint8_t end_bus;
  232. uint32_t flags;
  233. };
  234. typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t;
  235. DEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t);
  236. #define XEN_PCI_DEV_EXTFN 0x1
  237. #define XEN_PCI_DEV_VIRTFN 0x2
  238. #define XEN_PCI_DEV_PXM 0x4
  239. #define PHYSDEVOP_pci_device_add 25
  240. struct physdev_pci_device_add {
  241. /* IN */
  242. uint16_t seg;
  243. uint8_t bus;
  244. uint8_t devfn;
  245. uint32_t flags;
  246. struct {
  247. uint8_t bus;
  248. uint8_t devfn;
  249. } physfn;
  250. /*
  251. * Optional parameters array.
  252. * First element ([0]) is PXM domain associated with the device (if
  253. * XEN_PCI_DEV_PXM is set)
  254. */
  255. uint32_t optarr[XEN_FLEX_ARRAY_DIM];
  256. };
  257. typedef struct physdev_pci_device_add physdev_pci_device_add_t;
  258. DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_add_t);
  259. #define PHYSDEVOP_pci_device_remove 26
  260. #define PHYSDEVOP_restore_msi_ext 27
  261. /*
  262. * Dom0 should use these two to announce MMIO resources assigned to
  263. * MSI-X capable devices won't (prepare) or may (release) change.
  264. */
  265. #define PHYSDEVOP_prepare_msix 30
  266. #define PHYSDEVOP_release_msix 31
  267. struct physdev_pci_device {
  268. /* IN */
  269. uint16_t seg;
  270. uint8_t bus;
  271. uint8_t devfn;
  272. };
  273. typedef struct physdev_pci_device physdev_pci_device_t;
  274. DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t);
  275. #define PHYSDEVOP_DBGP_RESET_PREPARE 1
  276. #define PHYSDEVOP_DBGP_RESET_DONE 2
  277. #define PHYSDEVOP_DBGP_BUS_UNKNOWN 0
  278. #define PHYSDEVOP_DBGP_BUS_PCI 1
  279. #define PHYSDEVOP_dbgp_op 29
  280. struct physdev_dbgp_op {
  281. /* IN */
  282. uint8_t op;
  283. uint8_t bus;
  284. union {
  285. physdev_pci_device_t pci;
  286. } u;
  287. };
  288. typedef struct physdev_dbgp_op physdev_dbgp_op_t;
  289. DEFINE_XEN_GUEST_HANDLE(physdev_dbgp_op_t);
  290. /*
  291. * Notify that some PIRQ-bound event channels have been unmasked.
  292. * ** This command is obsolete since interface version 0x00030202 and is **
  293. * ** unsupported by newer versions of Xen. **
  294. */
  295. #define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4
  296. #if __XEN_INTERFACE_VERSION__ < 0x00040600
  297. /*
  298. * These all-capitals physdev operation names are superceded by the new names
  299. * (defined above) since interface version 0x00030202. The guard above was
  300. * added post-4.5 only though and hence shouldn't check for 0x00030202.
  301. */
  302. #define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query
  303. #define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl
  304. #define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap
  305. #define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read
  306. #define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write
  307. #define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector
  308. #define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector
  309. #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
  310. #define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared
  311. #endif
  312. #if __XEN_INTERFACE_VERSION__ < 0x00040200
  313. #define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1
  314. #else
  315. #define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2
  316. #endif
  317. #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
  318. /*
  319. * Local variables:
  320. * mode: C
  321. * c-file-style: "BSD"
  322. * c-basic-offset: 4
  323. * tab-width: 4
  324. * indent-tabs-mode: nil
  325. * End:
  326. */