physdev.h revision 251767
1181624Skmacy/* 2181624Skmacy * Permission is hereby granted, free of charge, to any person obtaining a copy 3181624Skmacy * of this software and associated documentation files (the "Software"), to 4181624Skmacy * deal in the Software without restriction, including without limitation the 5181624Skmacy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6181624Skmacy * sell copies of the Software, and to permit persons to whom the Software is 7181624Skmacy * furnished to do so, subject to the following conditions: 8181624Skmacy * 9181624Skmacy * The above copyright notice and this permission notice shall be included in 10181624Skmacy * all copies or substantial portions of the Software. 11181624Skmacy * 12181624Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13181624Skmacy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14181624Skmacy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15181624Skmacy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16181624Skmacy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17181624Skmacy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18181624Skmacy * DEALINGS IN THE SOFTWARE. 19181624Skmacy */ 20181624Skmacy 21181624Skmacy#ifndef __XEN_PUBLIC_PHYSDEV_H__ 22181624Skmacy#define __XEN_PUBLIC_PHYSDEV_H__ 23181624Skmacy 24251767Sgibbs#include "xen.h" 25251767Sgibbs 26181624Skmacy/* 27181624Skmacy * Prototype for this hypercall is: 28181624Skmacy * int physdev_op(int cmd, void *args) 29181624Skmacy * @cmd == PHYSDEVOP_??? (physdev operation). 30181624Skmacy * @args == Operation-specific extra arguments (NULL if none). 31181624Skmacy */ 32181624Skmacy 33181624Skmacy/* 34181624Skmacy * Notify end-of-interrupt (EOI) for the specified IRQ. 35181624Skmacy * @arg == pointer to physdev_eoi structure. 36181624Skmacy */ 37181624Skmacy#define PHYSDEVOP_eoi 12 38181624Skmacystruct physdev_eoi { 39181624Skmacy /* IN */ 40181624Skmacy uint32_t irq; 41181624Skmacy}; 42181624Skmacytypedef struct physdev_eoi physdev_eoi_t; 43181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_eoi_t); 44181624Skmacy 45181624Skmacy/* 46251767Sgibbs * Register a shared page for the hypervisor to indicate whether the guest 47251767Sgibbs * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly 48251767Sgibbs * once the guest used this function in that the associated event channel 49251767Sgibbs * will automatically get unmasked. The page registered is used as a bit 50251767Sgibbs * array indexed by Xen's PIRQ value. 51251767Sgibbs */ 52251767Sgibbs#define PHYSDEVOP_pirq_eoi_gmfn_v1 17 53251767Sgibbs/* 54251767Sgibbs * Register a shared page for the hypervisor to indicate whether the 55251767Sgibbs * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to 56251767Sgibbs * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of 57251767Sgibbs * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by 58251767Sgibbs * Xen's PIRQ value. 59251767Sgibbs */ 60251767Sgibbs#define PHYSDEVOP_pirq_eoi_gmfn_v2 28 61251767Sgibbsstruct physdev_pirq_eoi_gmfn { 62251767Sgibbs /* IN */ 63251767Sgibbs xen_pfn_t gmfn; 64251767Sgibbs}; 65251767Sgibbstypedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t; 66251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t); 67251767Sgibbs 68251767Sgibbs/* 69181624Skmacy * Query the status of an IRQ line. 70181624Skmacy * @arg == pointer to physdev_irq_status_query structure. 71181624Skmacy */ 72181624Skmacy#define PHYSDEVOP_irq_status_query 5 73181624Skmacystruct physdev_irq_status_query { 74181624Skmacy /* IN */ 75181624Skmacy uint32_t irq; 76181624Skmacy /* OUT */ 77181624Skmacy uint32_t flags; /* XENIRQSTAT_* */ 78181624Skmacy}; 79181624Skmacytypedef struct physdev_irq_status_query physdev_irq_status_query_t; 80181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t); 81181624Skmacy 82181624Skmacy/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */ 83181624Skmacy#define _XENIRQSTAT_needs_eoi (0) 84181624Skmacy#define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi) 85181624Skmacy 86181624Skmacy/* IRQ shared by multiple guests? */ 87181624Skmacy#define _XENIRQSTAT_shared (1) 88181624Skmacy#define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared) 89181624Skmacy 90181624Skmacy/* 91181624Skmacy * Set the current VCPU's I/O privilege level. 92181624Skmacy * @arg == pointer to physdev_set_iopl structure. 93181624Skmacy */ 94181624Skmacy#define PHYSDEVOP_set_iopl 6 95181624Skmacystruct physdev_set_iopl { 96181624Skmacy /* IN */ 97181624Skmacy uint32_t iopl; 98181624Skmacy}; 99181624Skmacytypedef struct physdev_set_iopl physdev_set_iopl_t; 100181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t); 101181624Skmacy 102181624Skmacy/* 103181624Skmacy * Set the current VCPU's I/O-port permissions bitmap. 104181624Skmacy * @arg == pointer to physdev_set_iobitmap structure. 105181624Skmacy */ 106181624Skmacy#define PHYSDEVOP_set_iobitmap 7 107181624Skmacystruct physdev_set_iobitmap { 108181624Skmacy /* IN */ 109183340Skmacy#if __XEN_INTERFACE_VERSION__ >= 0x00030205 110183340Skmacy XEN_GUEST_HANDLE(uint8) bitmap; 111183340Skmacy#else 112183340Skmacy uint8_t *bitmap; 113183340Skmacy#endif 114181624Skmacy uint32_t nr_ports; 115181624Skmacy}; 116181624Skmacytypedef struct physdev_set_iobitmap physdev_set_iobitmap_t; 117181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t); 118181624Skmacy 119181624Skmacy/* 120181624Skmacy * Read or write an IO-APIC register. 121181624Skmacy * @arg == pointer to physdev_apic structure. 122181624Skmacy */ 123181624Skmacy#define PHYSDEVOP_apic_read 8 124181624Skmacy#define PHYSDEVOP_apic_write 9 125181624Skmacystruct physdev_apic { 126181624Skmacy /* IN */ 127181624Skmacy unsigned long apic_physbase; 128181624Skmacy uint32_t reg; 129181624Skmacy /* IN or OUT */ 130181624Skmacy uint32_t value; 131181624Skmacy}; 132181624Skmacytypedef struct physdev_apic physdev_apic_t; 133181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_apic_t); 134181624Skmacy 135181624Skmacy/* 136181624Skmacy * Allocate or free a physical upcall vector for the specified IRQ line. 137181624Skmacy * @arg == pointer to physdev_irq structure. 138181624Skmacy */ 139181624Skmacy#define PHYSDEVOP_alloc_irq_vector 10 140181624Skmacy#define PHYSDEVOP_free_irq_vector 11 141181624Skmacystruct physdev_irq { 142181624Skmacy /* IN */ 143181624Skmacy uint32_t irq; 144181624Skmacy /* IN or OUT */ 145181624Skmacy uint32_t vector; 146181624Skmacy}; 147181624Skmacytypedef struct physdev_irq physdev_irq_t; 148181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_irq_t); 149183340Skmacy 150183340Skmacy#define MAP_PIRQ_TYPE_MSI 0x0 151183340Skmacy#define MAP_PIRQ_TYPE_GSI 0x1 152183340Skmacy#define MAP_PIRQ_TYPE_UNKNOWN 0x2 153251767Sgibbs#define MAP_PIRQ_TYPE_MSI_SEG 0x3 154181624Skmacy 155183340Skmacy#define PHYSDEVOP_map_pirq 13 156183340Skmacystruct physdev_map_pirq { 157183340Skmacy domid_t domid; 158183340Skmacy /* IN */ 159183340Skmacy int type; 160183340Skmacy /* IN */ 161183340Skmacy int index; 162183340Skmacy /* IN or OUT */ 163183340Skmacy int pirq; 164251767Sgibbs /* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */ 165183340Skmacy int bus; 166183340Skmacy /* IN */ 167183340Skmacy int devfn; 168183340Skmacy /* IN */ 169183340Skmacy int entry_nr; 170183340Skmacy /* IN */ 171183340Skmacy uint64_t table_base; 172183340Skmacy}; 173183340Skmacytypedef struct physdev_map_pirq physdev_map_pirq_t; 174183340SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t); 175183340Skmacy 176183340Skmacy#define PHYSDEVOP_unmap_pirq 14 177183340Skmacystruct physdev_unmap_pirq { 178183340Skmacy domid_t domid; 179183340Skmacy /* IN */ 180183340Skmacy int pirq; 181183340Skmacy}; 182183340Skmacy 183183340Skmacytypedef struct physdev_unmap_pirq physdev_unmap_pirq_t; 184183340SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t); 185183340Skmacy 186183340Skmacy#define PHYSDEVOP_manage_pci_add 15 187183340Skmacy#define PHYSDEVOP_manage_pci_remove 16 188183340Skmacystruct physdev_manage_pci { 189183340Skmacy /* IN */ 190183340Skmacy uint8_t bus; 191183340Skmacy uint8_t devfn; 192183340Skmacy}; 193183340Skmacy 194183340Skmacytypedef struct physdev_manage_pci physdev_manage_pci_t; 195183340SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t); 196183340Skmacy 197251767Sgibbs#define PHYSDEVOP_restore_msi 19 198251767Sgibbsstruct physdev_restore_msi { 199251767Sgibbs /* IN */ 200251767Sgibbs uint8_t bus; 201251767Sgibbs uint8_t devfn; 202251767Sgibbs}; 203251767Sgibbstypedef struct physdev_restore_msi physdev_restore_msi_t; 204251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t); 205251767Sgibbs 206251767Sgibbs#define PHYSDEVOP_manage_pci_add_ext 20 207251767Sgibbsstruct physdev_manage_pci_ext { 208251767Sgibbs /* IN */ 209251767Sgibbs uint8_t bus; 210251767Sgibbs uint8_t devfn; 211251767Sgibbs unsigned is_extfn; 212251767Sgibbs unsigned is_virtfn; 213251767Sgibbs struct { 214251767Sgibbs uint8_t bus; 215251767Sgibbs uint8_t devfn; 216251767Sgibbs } physfn; 217251767Sgibbs}; 218251767Sgibbs 219251767Sgibbstypedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t; 220251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t); 221251767Sgibbs 222181624Skmacy/* 223181624Skmacy * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() 224181624Skmacy * hypercall since 0x00030202. 225181624Skmacy */ 226181624Skmacystruct physdev_op { 227181624Skmacy uint32_t cmd; 228181624Skmacy union { 229181624Skmacy struct physdev_irq_status_query irq_status_query; 230181624Skmacy struct physdev_set_iopl set_iopl; 231181624Skmacy struct physdev_set_iobitmap set_iobitmap; 232181624Skmacy struct physdev_apic apic_op; 233181624Skmacy struct physdev_irq irq_op; 234181624Skmacy } u; 235181624Skmacy}; 236181624Skmacytypedef struct physdev_op physdev_op_t; 237181624SkmacyDEFINE_XEN_GUEST_HANDLE(physdev_op_t); 238181624Skmacy 239251767Sgibbs#define PHYSDEVOP_setup_gsi 21 240251767Sgibbsstruct physdev_setup_gsi { 241251767Sgibbs int gsi; 242251767Sgibbs /* IN */ 243251767Sgibbs uint8_t triggering; 244251767Sgibbs /* IN */ 245251767Sgibbs uint8_t polarity; 246251767Sgibbs /* IN */ 247251767Sgibbs}; 248251767Sgibbs 249251767Sgibbstypedef struct physdev_setup_gsi physdev_setup_gsi_t; 250251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_setup_gsi_t); 251251767Sgibbs 252251767Sgibbs/* leave PHYSDEVOP 22 free */ 253251767Sgibbs 254251767Sgibbs/* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI 255251767Sgibbs * the hypercall returns a free pirq */ 256251767Sgibbs#define PHYSDEVOP_get_free_pirq 23 257251767Sgibbsstruct physdev_get_free_pirq { 258251767Sgibbs /* IN */ 259251767Sgibbs int type; 260251767Sgibbs /* OUT */ 261251767Sgibbs uint32_t pirq; 262251767Sgibbs}; 263251767Sgibbs 264251767Sgibbstypedef struct physdev_get_free_pirq physdev_get_free_pirq_t; 265251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t); 266251767Sgibbs 267251767Sgibbs#define XEN_PCI_MMCFG_RESERVED 0x1 268251767Sgibbs 269251767Sgibbs#define PHYSDEVOP_pci_mmcfg_reserved 24 270251767Sgibbsstruct physdev_pci_mmcfg_reserved { 271251767Sgibbs uint64_t address; 272251767Sgibbs uint16_t segment; 273251767Sgibbs uint8_t start_bus; 274251767Sgibbs uint8_t end_bus; 275251767Sgibbs uint32_t flags; 276251767Sgibbs}; 277251767Sgibbstypedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t; 278251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t); 279251767Sgibbs 280251767Sgibbs#define XEN_PCI_DEV_EXTFN 0x1 281251767Sgibbs#define XEN_PCI_DEV_VIRTFN 0x2 282251767Sgibbs#define XEN_PCI_DEV_PXM 0x4 283251767Sgibbs 284251767Sgibbs#define PHYSDEVOP_pci_device_add 25 285251767Sgibbsstruct physdev_pci_device_add { 286251767Sgibbs /* IN */ 287251767Sgibbs uint16_t seg; 288251767Sgibbs uint8_t bus; 289251767Sgibbs uint8_t devfn; 290251767Sgibbs uint32_t flags; 291251767Sgibbs struct { 292251767Sgibbs uint8_t bus; 293251767Sgibbs uint8_t devfn; 294251767Sgibbs } physfn; 295251767Sgibbs#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 296251767Sgibbs uint32_t optarr[]; 297251767Sgibbs#elif defined(__GNUC__) 298251767Sgibbs uint32_t optarr[0]; 299251767Sgibbs#endif 300251767Sgibbs}; 301251767Sgibbstypedef struct physdev_pci_device_add physdev_pci_device_add_t; 302251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_pci_device_add_t); 303251767Sgibbs 304251767Sgibbs#define PHYSDEVOP_pci_device_remove 26 305251767Sgibbs#define PHYSDEVOP_restore_msi_ext 27 306251767Sgibbsstruct physdev_pci_device { 307251767Sgibbs /* IN */ 308251767Sgibbs uint16_t seg; 309251767Sgibbs uint8_t bus; 310251767Sgibbs uint8_t devfn; 311251767Sgibbs}; 312251767Sgibbstypedef struct physdev_pci_device physdev_pci_device_t; 313251767SgibbsDEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t); 314251767Sgibbs 315181624Skmacy/* 316181624Skmacy * Notify that some PIRQ-bound event channels have been unmasked. 317181624Skmacy * ** This command is obsolete since interface version 0x00030202 and is ** 318181624Skmacy * ** unsupported by newer versions of Xen. ** 319181624Skmacy */ 320181624Skmacy#define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4 321181624Skmacy 322181624Skmacy/* 323181624Skmacy * These all-capitals physdev operation names are superceded by the new names 324181624Skmacy * (defined above) since interface version 0x00030202. 325181624Skmacy */ 326181624Skmacy#define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query 327181624Skmacy#define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl 328181624Skmacy#define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap 329181624Skmacy#define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read 330181624Skmacy#define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write 331181624Skmacy#define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector 332181624Skmacy#define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector 333181624Skmacy#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi 334181624Skmacy#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared 335181624Skmacy 336251767Sgibbs#if __XEN_INTERFACE_VERSION__ < 0x00040200 337251767Sgibbs#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1 338251767Sgibbs#else 339251767Sgibbs#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2 340251767Sgibbs#endif 341251767Sgibbs 342181624Skmacy#endif /* __XEN_PUBLIC_PHYSDEV_H__ */ 343181624Skmacy 344181624Skmacy/* 345181624Skmacy * Local variables: 346181624Skmacy * mode: C 347181624Skmacy * c-set-style: "BSD" 348181624Skmacy * c-basic-offset: 4 349181624Skmacy * tab-width: 4 350181624Skmacy * indent-tabs-mode: nil 351181624Skmacy * End: 352181624Skmacy */ 353