physdev.h 11 KB

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