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