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/* 25 * Prototype for this hypercall is: 26 * int physdev_op(int cmd, void *args) 27 * @cmd == PHYSDEVOP_??? (physdev operation). 28 * @args == Operation-specific extra arguments (NULL if none). 29 */ 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 36struct physdev_eoi { 37 /* IN */ 38 uint32_t irq; 39}; 40typedef struct physdev_eoi physdev_eoi_t; 41DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t); 42 43/* 44 * Query the status of an IRQ line. 45 * @arg == pointer to physdev_irq_status_query structure. 46 */ 47#define PHYSDEVOP_irq_status_query 5 48struct physdev_irq_status_query { 49 /* IN */ 50 uint32_t irq; 51 /* OUT */ 52 uint32_t flags; /* XENIRQSTAT_* */ 53}; 54typedef struct physdev_irq_status_query physdev_irq_status_query_t; 55DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t); 56 57/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */ 58#define _XENIRQSTAT_needs_eoi (0) 59#define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi) 60 61/* IRQ shared by multiple guests? */ 62#define _XENIRQSTAT_shared (1) 63#define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared) 64 65/* 66 * Set the current VCPU's I/O privilege level. 67 * @arg == pointer to physdev_set_iopl structure. 68 */ 69#define PHYSDEVOP_set_iopl 6 70struct physdev_set_iopl { 71 /* IN */ 72 uint32_t iopl; 73}; 74typedef struct physdev_set_iopl physdev_set_iopl_t; 75DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t); 76 77/* 78 * Set the current VCPU's I/O-port permissions bitmap. 79 * @arg == pointer to physdev_set_iobitmap structure. 80 */ 81#define PHYSDEVOP_set_iobitmap 7 82struct physdev_set_iobitmap { 83 /* IN */ 84#if __XEN_INTERFACE_VERSION__ >= 0x00030205 85 XEN_GUEST_HANDLE(uint8) bitmap; 86#else 87 uint8_t *bitmap; 88#endif 89 uint32_t nr_ports; 90}; 91typedef struct physdev_set_iobitmap physdev_set_iobitmap_t; 92DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t); 93 94/* 95 * Read or write an IO-APIC register. 96 * @arg == pointer to physdev_apic structure. 97 */ 98#define PHYSDEVOP_apic_read 8 99#define PHYSDEVOP_apic_write 9 100struct physdev_apic { 101 /* IN */ 102 unsigned long apic_physbase; 103 uint32_t reg; 104 /* IN or OUT */ 105 uint32_t value; 106}; 107typedef struct physdev_apic physdev_apic_t; 108DEFINE_XEN_GUEST_HANDLE(physdev_apic_t); 109 110/* 111 * Allocate or free a physical upcall vector for the specified IRQ line. 112 * @arg == pointer to physdev_irq structure. 113 */ 114#define PHYSDEVOP_alloc_irq_vector 10 115#define PHYSDEVOP_free_irq_vector 11 116struct physdev_irq { 117 /* IN */ 118 uint32_t irq; 119 /* IN or OUT */ 120 uint32_t vector; 121}; 122typedef struct physdev_irq physdev_irq_t; 123DEFINE_XEN_GUEST_HANDLE(physdev_irq_t); 124 125#define MAP_PIRQ_TYPE_MSI 0x0 126#define MAP_PIRQ_TYPE_GSI 0x1 127#define MAP_PIRQ_TYPE_UNKNOWN 0x2 128 129#define PHYSDEVOP_map_pirq 13 130struct physdev_map_pirq { 131 domid_t domid; 132 /* IN */ 133 int type; 134 /* IN */ 135 int index; 136 /* IN or OUT */ 137 int pirq; 138 /* IN */ 139 int bus; 140 /* IN */ 141 int devfn; 142 /* IN */ 143 int entry_nr; 144 /* IN */ 145 uint64_t table_base; 146}; 147typedef struct physdev_map_pirq physdev_map_pirq_t; 148DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t); 149 150#define PHYSDEVOP_unmap_pirq 14 151struct physdev_unmap_pirq { 152 domid_t domid; 153 /* IN */ 154 int pirq; 155}; 156 157typedef struct physdev_unmap_pirq physdev_unmap_pirq_t; 158DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t); 159 160#define PHYSDEVOP_manage_pci_add 15 161#define PHYSDEVOP_manage_pci_remove 16 162struct physdev_manage_pci { 163 /* IN */ 164 uint8_t bus; 165 uint8_t devfn; 166}; 167 168typedef struct physdev_manage_pci physdev_manage_pci_t; 169DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t); 170 171/* 172 * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() 173 * hypercall since 0x00030202. 174 */ 175struct physdev_op { 176 uint32_t cmd; 177 union { 178 struct physdev_irq_status_query irq_status_query; 179 struct physdev_set_iopl set_iopl; 180 struct physdev_set_iobitmap set_iobitmap; 181 struct physdev_apic apic_op; 182 struct physdev_irq irq_op; 183 } u; 184}; 185typedef struct physdev_op physdev_op_t; 186DEFINE_XEN_GUEST_HANDLE(physdev_op_t); 187 188/* 189 * Notify that some PIRQ-bound event channels have been unmasked. 190 * ** This command is obsolete since interface version 0x00030202 and is ** 191 * ** unsupported by newer versions of Xen. ** 192 */ 193#define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4 194 195/* 196 * These all-capitals physdev operation names are superceded by the new names 197 * (defined above) since interface version 0x00030202. 198 */ 199#define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query 200#define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl 201#define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap 202#define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read 203#define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write 204#define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector 205#define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector 206#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi 207#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared 208 209#endif /* __XEN_PUBLIC_PHYSDEV_H__ */ 210 211/* 212 * Local variables: 213 * mode: C 214 * c-set-style: "BSD" 215 * c-basic-offset: 4 216 * tab-width: 4 217 * indent-tabs-mode: nil 218 * End: 219 */ 220