1843e1988Sjohnlev /* 2843e1988Sjohnlev * Permission is hereby granted, free of charge, to any person obtaining a copy 3843e1988Sjohnlev * of this software and associated documentation files (the "Software"), to 4843e1988Sjohnlev * deal in the Software without restriction, including without limitation the 5843e1988Sjohnlev * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6843e1988Sjohnlev * sell copies of the Software, and to permit persons to whom the Software is 7843e1988Sjohnlev * furnished to do so, subject to the following conditions: 8843e1988Sjohnlev * 9843e1988Sjohnlev * The above copyright notice and this permission notice shall be included in 10843e1988Sjohnlev * all copies or substantial portions of the Software. 11843e1988Sjohnlev * 12843e1988Sjohnlev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13843e1988Sjohnlev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14843e1988Sjohnlev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15843e1988Sjohnlev * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16843e1988Sjohnlev * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17843e1988Sjohnlev * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18843e1988Sjohnlev * DEALINGS IN THE SOFTWARE. 19843e1988Sjohnlev */ 20843e1988Sjohnlev 21843e1988Sjohnlev #ifndef __XEN_PUBLIC_PHYSDEV_H__ 22843e1988Sjohnlev #define __XEN_PUBLIC_PHYSDEV_H__ 23843e1988Sjohnlev 24843e1988Sjohnlev /* 25843e1988Sjohnlev * Prototype for this hypercall is: 26843e1988Sjohnlev * int physdev_op(int cmd, void *args) 27843e1988Sjohnlev * @cmd == PHYSDEVOP_??? (physdev operation). 28843e1988Sjohnlev * @args == Operation-specific extra arguments (NULL if none). 29843e1988Sjohnlev */ 30843e1988Sjohnlev 31843e1988Sjohnlev /* 32843e1988Sjohnlev * Notify end-of-interrupt (EOI) for the specified IRQ. 33843e1988Sjohnlev * @arg == pointer to physdev_eoi structure. 34843e1988Sjohnlev */ 35843e1988Sjohnlev #define PHYSDEVOP_eoi 12 36843e1988Sjohnlev struct physdev_eoi { 37843e1988Sjohnlev /* IN */ 38843e1988Sjohnlev uint32_t irq; 39843e1988Sjohnlev }; 40843e1988Sjohnlev typedef struct physdev_eoi physdev_eoi_t; 41843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t); 42843e1988Sjohnlev 43843e1988Sjohnlev /* 44*ad09f8b8SMark Johnson * Register a shared page for the hypervisor to indicate whether the guest 45*ad09f8b8SMark Johnson * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly 46*ad09f8b8SMark Johnson * once the guest used this function in that the associated event channel 47*ad09f8b8SMark Johnson * will automatically get unmasked. The page registered is used as a bit 48*ad09f8b8SMark Johnson * array indexed by Xen's PIRQ value. 49*ad09f8b8SMark Johnson */ 50*ad09f8b8SMark Johnson #define PHYSDEVOP_pirq_eoi_gmfn 17 51*ad09f8b8SMark Johnson struct physdev_pirq_eoi_gmfn { 52*ad09f8b8SMark Johnson /* IN */ 53*ad09f8b8SMark Johnson xen_pfn_t gmfn; 54*ad09f8b8SMark Johnson }; 55*ad09f8b8SMark Johnson typedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t; 56*ad09f8b8SMark Johnson DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t); 57*ad09f8b8SMark Johnson 58*ad09f8b8SMark Johnson /* 59843e1988Sjohnlev * Query the status of an IRQ line. 60843e1988Sjohnlev * @arg == pointer to physdev_irq_status_query structure. 61843e1988Sjohnlev */ 62843e1988Sjohnlev #define PHYSDEVOP_irq_status_query 5 63843e1988Sjohnlev struct physdev_irq_status_query { 64843e1988Sjohnlev /* IN */ 65843e1988Sjohnlev uint32_t irq; 66843e1988Sjohnlev /* OUT */ 67843e1988Sjohnlev uint32_t flags; /* XENIRQSTAT_* */ 68843e1988Sjohnlev }; 69843e1988Sjohnlev typedef struct physdev_irq_status_query physdev_irq_status_query_t; 70843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t); 71843e1988Sjohnlev 72843e1988Sjohnlev /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */ 73843e1988Sjohnlev #define _XENIRQSTAT_needs_eoi (0) 74843e1988Sjohnlev #define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi) 75843e1988Sjohnlev 76843e1988Sjohnlev /* IRQ shared by multiple guests? */ 77843e1988Sjohnlev #define _XENIRQSTAT_shared (1) 78843e1988Sjohnlev #define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared) 79843e1988Sjohnlev 80843e1988Sjohnlev /* 81843e1988Sjohnlev * Set the current VCPU's I/O privilege level. 82843e1988Sjohnlev * @arg == pointer to physdev_set_iopl structure. 83843e1988Sjohnlev */ 84843e1988Sjohnlev #define PHYSDEVOP_set_iopl 6 85843e1988Sjohnlev struct physdev_set_iopl { 86843e1988Sjohnlev /* IN */ 87843e1988Sjohnlev uint32_t iopl; 88843e1988Sjohnlev }; 89843e1988Sjohnlev typedef struct physdev_set_iopl physdev_set_iopl_t; 90843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t); 91843e1988Sjohnlev 92843e1988Sjohnlev /* 93843e1988Sjohnlev * Set the current VCPU's I/O-port permissions bitmap. 94843e1988Sjohnlev * @arg == pointer to physdev_set_iobitmap structure. 95843e1988Sjohnlev */ 96843e1988Sjohnlev #define PHYSDEVOP_set_iobitmap 7 97843e1988Sjohnlev struct physdev_set_iobitmap { 98843e1988Sjohnlev /* IN */ 99349b53ddSStuart Maybee #if __XEN_INTERFACE_VERSION__ >= 0x00030205 100349b53ddSStuart Maybee XEN_GUEST_HANDLE(uint8) bitmap; 101349b53ddSStuart Maybee #else 102349b53ddSStuart Maybee uint8_t *bitmap; 103349b53ddSStuart Maybee #endif 104843e1988Sjohnlev uint32_t nr_ports; 105843e1988Sjohnlev }; 106843e1988Sjohnlev typedef struct physdev_set_iobitmap physdev_set_iobitmap_t; 107843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t); 108843e1988Sjohnlev 109843e1988Sjohnlev /* 110843e1988Sjohnlev * Read or write an IO-APIC register. 111843e1988Sjohnlev * @arg == pointer to physdev_apic structure. 112843e1988Sjohnlev */ 113843e1988Sjohnlev #define PHYSDEVOP_apic_read 8 114843e1988Sjohnlev #define PHYSDEVOP_apic_write 9 115843e1988Sjohnlev struct physdev_apic { 116843e1988Sjohnlev /* IN */ 117843e1988Sjohnlev unsigned long apic_physbase; 118843e1988Sjohnlev uint32_t reg; 119843e1988Sjohnlev /* IN or OUT */ 120843e1988Sjohnlev uint32_t value; 121843e1988Sjohnlev }; 122843e1988Sjohnlev typedef struct physdev_apic physdev_apic_t; 123843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_apic_t); 124843e1988Sjohnlev 125843e1988Sjohnlev /* 126843e1988Sjohnlev * Allocate or free a physical upcall vector for the specified IRQ line. 127843e1988Sjohnlev * @arg == pointer to physdev_irq structure. 128843e1988Sjohnlev */ 129843e1988Sjohnlev #define PHYSDEVOP_alloc_irq_vector 10 130843e1988Sjohnlev #define PHYSDEVOP_free_irq_vector 11 131843e1988Sjohnlev struct physdev_irq { 132843e1988Sjohnlev /* IN */ 133843e1988Sjohnlev uint32_t irq; 134843e1988Sjohnlev /* IN or OUT */ 135843e1988Sjohnlev uint32_t vector; 136843e1988Sjohnlev }; 137843e1988Sjohnlev typedef struct physdev_irq physdev_irq_t; 138843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_irq_t); 139843e1988Sjohnlev 140349b53ddSStuart Maybee #define MAP_PIRQ_TYPE_MSI 0x0 141349b53ddSStuart Maybee #define MAP_PIRQ_TYPE_GSI 0x1 142349b53ddSStuart Maybee #define MAP_PIRQ_TYPE_UNKNOWN 0x2 143349b53ddSStuart Maybee 144349b53ddSStuart Maybee #define PHYSDEVOP_map_pirq 13 145349b53ddSStuart Maybee struct physdev_map_pirq { 146349b53ddSStuart Maybee domid_t domid; 147349b53ddSStuart Maybee /* IN */ 148349b53ddSStuart Maybee int type; 149349b53ddSStuart Maybee /* IN */ 150349b53ddSStuart Maybee int index; 151349b53ddSStuart Maybee /* IN or OUT */ 152349b53ddSStuart Maybee int pirq; 153349b53ddSStuart Maybee /* IN */ 154349b53ddSStuart Maybee int bus; 155349b53ddSStuart Maybee /* IN */ 156349b53ddSStuart Maybee int devfn; 157349b53ddSStuart Maybee /* IN */ 158349b53ddSStuart Maybee int entry_nr; 159349b53ddSStuart Maybee /* IN */ 160349b53ddSStuart Maybee uint64_t table_base; 161349b53ddSStuart Maybee }; 162349b53ddSStuart Maybee typedef struct physdev_map_pirq physdev_map_pirq_t; 163349b53ddSStuart Maybee DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t); 164349b53ddSStuart Maybee 165349b53ddSStuart Maybee #define PHYSDEVOP_unmap_pirq 14 166349b53ddSStuart Maybee struct physdev_unmap_pirq { 167349b53ddSStuart Maybee domid_t domid; 168349b53ddSStuart Maybee /* IN */ 169349b53ddSStuart Maybee int pirq; 170349b53ddSStuart Maybee }; 171349b53ddSStuart Maybee 172349b53ddSStuart Maybee typedef struct physdev_unmap_pirq physdev_unmap_pirq_t; 173349b53ddSStuart Maybee DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t); 174349b53ddSStuart Maybee 175349b53ddSStuart Maybee #define PHYSDEVOP_manage_pci_add 15 176349b53ddSStuart Maybee #define PHYSDEVOP_manage_pci_remove 16 177349b53ddSStuart Maybee struct physdev_manage_pci { 178349b53ddSStuart Maybee /* IN */ 179349b53ddSStuart Maybee uint8_t bus; 180349b53ddSStuart Maybee uint8_t devfn; 181349b53ddSStuart Maybee }; 182349b53ddSStuart Maybee 183349b53ddSStuart Maybee typedef struct physdev_manage_pci physdev_manage_pci_t; 184349b53ddSStuart Maybee DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t); 185349b53ddSStuart Maybee 186*ad09f8b8SMark Johnson #define PHYSDEVOP_restore_msi 19 187*ad09f8b8SMark Johnson struct physdev_restore_msi { 188*ad09f8b8SMark Johnson /* IN */ 189*ad09f8b8SMark Johnson uint8_t bus; 190*ad09f8b8SMark Johnson uint8_t devfn; 191*ad09f8b8SMark Johnson }; 192*ad09f8b8SMark Johnson typedef struct physdev_restore_msi physdev_restore_msi_t; 193*ad09f8b8SMark Johnson DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t); 194*ad09f8b8SMark Johnson 195*ad09f8b8SMark Johnson #define PHYSDEVOP_manage_pci_add_ext 20 196*ad09f8b8SMark Johnson struct physdev_manage_pci_ext { 197*ad09f8b8SMark Johnson /* IN */ 198*ad09f8b8SMark Johnson uint8_t bus; 199*ad09f8b8SMark Johnson uint8_t devfn; 200*ad09f8b8SMark Johnson unsigned is_extfn; 201*ad09f8b8SMark Johnson unsigned is_virtfn; 202*ad09f8b8SMark Johnson struct { 203*ad09f8b8SMark Johnson uint8_t bus; 204*ad09f8b8SMark Johnson uint8_t devfn; 205*ad09f8b8SMark Johnson } physfn; 206*ad09f8b8SMark Johnson }; 207*ad09f8b8SMark Johnson 208*ad09f8b8SMark Johnson typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t; 209*ad09f8b8SMark Johnson DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t); 210*ad09f8b8SMark Johnson 211843e1988Sjohnlev /* 212843e1988Sjohnlev * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() 213843e1988Sjohnlev * hypercall since 0x00030202. 214843e1988Sjohnlev */ 215843e1988Sjohnlev struct physdev_op { 216843e1988Sjohnlev uint32_t cmd; 217843e1988Sjohnlev union { 218843e1988Sjohnlev struct physdev_irq_status_query irq_status_query; 219843e1988Sjohnlev struct physdev_set_iopl set_iopl; 220843e1988Sjohnlev struct physdev_set_iobitmap set_iobitmap; 221843e1988Sjohnlev struct physdev_apic apic_op; 222843e1988Sjohnlev struct physdev_irq irq_op; 223843e1988Sjohnlev } u; 224843e1988Sjohnlev }; 225843e1988Sjohnlev typedef struct physdev_op physdev_op_t; 226843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_op_t); 227843e1988Sjohnlev 228843e1988Sjohnlev /* 229843e1988Sjohnlev * Notify that some PIRQ-bound event channels have been unmasked. 230843e1988Sjohnlev * ** This command is obsolete since interface version 0x00030202 and is ** 231843e1988Sjohnlev * ** unsupported by newer versions of Xen. ** 232843e1988Sjohnlev */ 233843e1988Sjohnlev #define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4 234843e1988Sjohnlev 235843e1988Sjohnlev /* 236843e1988Sjohnlev * These all-capitals physdev operation names are superceded by the new names 237843e1988Sjohnlev * (defined above) since interface version 0x00030202. 238843e1988Sjohnlev */ 239843e1988Sjohnlev #define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query 240843e1988Sjohnlev #define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl 241843e1988Sjohnlev #define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap 242843e1988Sjohnlev #define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read 243843e1988Sjohnlev #define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write 244843e1988Sjohnlev #define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector 245843e1988Sjohnlev #define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector 246843e1988Sjohnlev #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi 247843e1988Sjohnlev #define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared 248843e1988Sjohnlev 249843e1988Sjohnlev #endif /* __XEN_PUBLIC_PHYSDEV_H__ */ 250843e1988Sjohnlev 251843e1988Sjohnlev /* 252843e1988Sjohnlev * Local variables: 253843e1988Sjohnlev * mode: C 254843e1988Sjohnlev * c-set-style: "BSD" 255843e1988Sjohnlev * c-basic-offset: 4 256843e1988Sjohnlev * tab-width: 4 257843e1988Sjohnlev * indent-tabs-mode: nil 258843e1988Sjohnlev * End: 259843e1988Sjohnlev */ 260