physdev.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. #ifndef __XEN_PUBLIC_PHYSDEV_H__
  21. #define __XEN_PUBLIC_PHYSDEV_H__
  22. /*
  23. * Prototype for this hypercall is:
  24. * int physdev_op(int cmd, void *args)
  25. * @cmd == PHYSDEVOP_??? (physdev operation).
  26. * @args == Operation-specific extra arguments (NULL if none).
  27. */
  28. /*
  29. * Notify end-of-interrupt (EOI) for the specified IRQ.
  30. * @arg == pointer to physdev_eoi structure.
  31. */
  32. #define PHYSDEVOP_eoi 12
  33. struct physdev_eoi {
  34. /* IN */
  35. uint32_t irq;
  36. };
  37. /*
  38. * Query the status of an IRQ line.
  39. * @arg == pointer to physdev_irq_status_query structure.
  40. */
  41. #define PHYSDEVOP_irq_status_query 5
  42. struct physdev_irq_status_query {
  43. /* IN */
  44. uint32_t irq;
  45. /* OUT */
  46. uint32_t flags; /* XENIRQSTAT_* */
  47. };
  48. /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
  49. #define _XENIRQSTAT_needs_eoi (0)
  50. #define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi)
  51. /* IRQ shared by multiple guests? */
  52. #define _XENIRQSTAT_shared (1)
  53. #define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared)
  54. /*
  55. * Set the current VCPU's I/O privilege level.
  56. * @arg == pointer to physdev_set_iopl structure.
  57. */
  58. #define PHYSDEVOP_set_iopl 6
  59. struct physdev_set_iopl {
  60. /* IN */
  61. uint32_t iopl;
  62. };
  63. /*
  64. * Set the current VCPU's I/O-port permissions bitmap.
  65. * @arg == pointer to physdev_set_iobitmap structure.
  66. */
  67. #define PHYSDEVOP_set_iobitmap 7
  68. struct physdev_set_iobitmap {
  69. /* IN */
  70. uint8_t * bitmap;
  71. uint32_t nr_ports;
  72. };
  73. /*
  74. * Read or write an IO-APIC register.
  75. * @arg == pointer to physdev_apic structure.
  76. */
  77. #define PHYSDEVOP_apic_read 8
  78. #define PHYSDEVOP_apic_write 9
  79. struct physdev_apic {
  80. /* IN */
  81. unsigned long apic_physbase;
  82. uint32_t reg;
  83. /* IN or OUT */
  84. uint32_t value;
  85. };
  86. /*
  87. * Allocate or free a physical upcall vector for the specified IRQ line.
  88. * @arg == pointer to physdev_irq structure.
  89. */
  90. #define PHYSDEVOP_alloc_irq_vector 10
  91. #define PHYSDEVOP_free_irq_vector 11
  92. struct physdev_irq {
  93. /* IN */
  94. uint32_t irq;
  95. /* IN or OUT */
  96. uint32_t vector;
  97. };
  98. #define MAP_PIRQ_TYPE_MSI 0x0
  99. #define MAP_PIRQ_TYPE_GSI 0x1
  100. #define MAP_PIRQ_TYPE_UNKNOWN 0x2
  101. #define MAP_PIRQ_TYPE_MSI_SEG 0x3
  102. #define PHYSDEVOP_map_pirq 13
  103. struct physdev_map_pirq {
  104. domid_t domid;
  105. /* IN */
  106. int type;
  107. /* IN */
  108. int index;
  109. /* IN or OUT */
  110. int pirq;
  111. /* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */
  112. int bus;
  113. /* IN */
  114. int devfn;
  115. /* IN */
  116. int entry_nr;
  117. /* IN */
  118. uint64_t table_base;
  119. };
  120. #define PHYSDEVOP_unmap_pirq 14
  121. struct physdev_unmap_pirq {
  122. domid_t domid;
  123. /* IN */
  124. int pirq;
  125. };
  126. #define PHYSDEVOP_manage_pci_add 15
  127. #define PHYSDEVOP_manage_pci_remove 16
  128. struct physdev_manage_pci {
  129. /* IN */
  130. uint8_t bus;
  131. uint8_t devfn;
  132. };
  133. #define PHYSDEVOP_restore_msi 19
  134. struct physdev_restore_msi {
  135. /* IN */
  136. uint8_t bus;
  137. uint8_t devfn;
  138. };
  139. #define PHYSDEVOP_manage_pci_add_ext 20
  140. struct physdev_manage_pci_ext {
  141. /* IN */
  142. uint8_t bus;
  143. uint8_t devfn;
  144. unsigned is_extfn;
  145. unsigned is_virtfn;
  146. struct {
  147. uint8_t bus;
  148. uint8_t devfn;
  149. } physfn;
  150. };
  151. /*
  152. * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  153. * hypercall since 0x00030202.
  154. */
  155. struct physdev_op {
  156. uint32_t cmd;
  157. union {
  158. struct physdev_irq_status_query irq_status_query;
  159. struct physdev_set_iopl set_iopl;
  160. struct physdev_set_iobitmap set_iobitmap;
  161. struct physdev_apic apic_op;
  162. struct physdev_irq irq_op;
  163. } u;
  164. };
  165. #define PHYSDEVOP_setup_gsi 21
  166. struct physdev_setup_gsi {
  167. int gsi;
  168. /* IN */
  169. uint8_t triggering;
  170. /* IN */
  171. uint8_t polarity;
  172. /* IN */
  173. };
  174. #define PHYSDEVOP_get_nr_pirqs 22
  175. struct physdev_nr_pirqs {
  176. /* OUT */
  177. uint32_t nr_pirqs;
  178. };
  179. /* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
  180. * the hypercall returns a free pirq */
  181. #define PHYSDEVOP_get_free_pirq 23
  182. struct physdev_get_free_pirq {
  183. /* IN */
  184. int type;
  185. /* OUT */
  186. uint32_t pirq;
  187. };
  188. #define XEN_PCI_DEV_EXTFN 0x1
  189. #define XEN_PCI_DEV_VIRTFN 0x2
  190. #define XEN_PCI_DEV_PXM 0x4
  191. #define PHYSDEVOP_pci_device_add 25
  192. struct physdev_pci_device_add {
  193. /* IN */
  194. uint16_t seg;
  195. uint8_t bus;
  196. uint8_t devfn;
  197. uint32_t flags;
  198. struct {
  199. uint8_t bus;
  200. uint8_t devfn;
  201. } physfn;
  202. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  203. uint32_t optarr[];
  204. #elif defined(__GNUC__)
  205. uint32_t optarr[0];
  206. #endif
  207. };
  208. #define PHYSDEVOP_pci_device_remove 26
  209. #define PHYSDEVOP_restore_msi_ext 27
  210. struct physdev_pci_device {
  211. /* IN */
  212. uint16_t seg;
  213. uint8_t bus;
  214. uint8_t devfn;
  215. };
  216. /*
  217. * Notify that some PIRQ-bound event channels have been unmasked.
  218. * ** This command is obsolete since interface version 0x00030202 and is **
  219. * ** unsupported by newer versions of Xen. **
  220. */
  221. #define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4
  222. /*
  223. * These all-capitals physdev operation names are superceded by the new names
  224. * (defined above) since interface version 0x00030202.
  225. */
  226. #define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query
  227. #define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl
  228. #define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap
  229. #define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read
  230. #define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write
  231. #define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector
  232. #define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector
  233. #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
  234. #define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared
  235. #endif /* __XEN_PUBLIC_PHYSDEV_H__ */