/* SPDX-License-Identifier: MIT */12#ifndef __XEN_PUBLIC_PHYSDEV_H__3#define __XEN_PUBLIC_PHYSDEV_H__45/*6* Prototype for this hypercall is:7* int physdev_op(int cmd, void *args)8* @cmd == PHYSDEVOP_??? (physdev operation).9* @args == Operation-specific extra arguments (NULL if none).10*/1112/*13* Notify end-of-interrupt (EOI) for the specified IRQ.14* @arg == pointer to physdev_eoi structure.15*/16#define PHYSDEVOP_eoi 1217struct physdev_eoi {18/* IN */19uint32_t irq;20};2122/*23* Register a shared page for the hypervisor to indicate whether the guest24* must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly25* once the guest used this function in that the associated event channel26* will automatically get unmasked. The page registered is used as a bit27* array indexed by Xen's PIRQ value.28*/29#define PHYSDEVOP_pirq_eoi_gmfn_v1 1730/*31* Register a shared page for the hypervisor to indicate whether the32* guest must issue PHYSDEVOP_eoi. This hypercall is very similar to33* PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of34* PHYSDEVOP_eoi. The page registered is used as a bit array indexed by35* Xen's PIRQ value.36*/37#define PHYSDEVOP_pirq_eoi_gmfn_v2 2838struct physdev_pirq_eoi_gmfn {39/* IN */40xen_ulong_t gmfn;41};4243/*44* Query the status of an IRQ line.45* @arg == pointer to physdev_irq_status_query structure.46*/47#define PHYSDEVOP_irq_status_query 548struct physdev_irq_status_query {49/* IN */50uint32_t irq;51/* OUT */52uint32_t flags; /* XENIRQSTAT_* */53};5455/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */56#define _XENIRQSTAT_needs_eoi (0)57#define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi)5859/* IRQ shared by multiple guests? */60#define _XENIRQSTAT_shared (1)61#define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared)6263/*64* Set the current VCPU's I/O privilege level.65* @arg == pointer to physdev_set_iopl structure.66*/67#define PHYSDEVOP_set_iopl 668struct physdev_set_iopl {69/* IN */70uint32_t iopl;71};7273/*74* Set the current VCPU's I/O-port permissions bitmap.75* @arg == pointer to physdev_set_iobitmap structure.76*/77#define PHYSDEVOP_set_iobitmap 778struct physdev_set_iobitmap {79/* IN */80uint8_t * bitmap;81uint32_t nr_ports;82};8384/*85* Read or write an IO-APIC register.86* @arg == pointer to physdev_apic structure.87*/88#define PHYSDEVOP_apic_read 889#define PHYSDEVOP_apic_write 990struct physdev_apic {91/* IN */92unsigned long apic_physbase;93uint32_t reg;94/* IN or OUT */95uint32_t value;96};9798/*99* Allocate or free a physical upcall vector for the specified IRQ line.100* @arg == pointer to physdev_irq structure.101*/102#define PHYSDEVOP_alloc_irq_vector 10103#define PHYSDEVOP_free_irq_vector 11104struct physdev_irq {105/* IN */106uint32_t irq;107/* IN or OUT */108uint32_t vector;109};110111#define MAP_PIRQ_TYPE_MSI 0x0112#define MAP_PIRQ_TYPE_GSI 0x1113#define MAP_PIRQ_TYPE_UNKNOWN 0x2114#define MAP_PIRQ_TYPE_MSI_SEG 0x3115#define MAP_PIRQ_TYPE_MULTI_MSI 0x4116117#define PHYSDEVOP_map_pirq 13118struct physdev_map_pirq {119domid_t domid;120/* IN */121int type;122/* IN */123int index;124/* IN or OUT */125int pirq;126/* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */127int bus;128/* IN */129int devfn;130/* IN131* - For MSI-X contains entry number.132* - For MSI with ..._MULTI_MSI contains number of vectors.133* OUT (..._MULTI_MSI only)134* - Number of vectors allocated.135*/136int entry_nr;137/* IN */138uint64_t table_base;139};140141#define PHYSDEVOP_unmap_pirq 14142struct physdev_unmap_pirq {143domid_t domid;144/* IN */145int pirq;146};147148#define PHYSDEVOP_manage_pci_add 15149#define PHYSDEVOP_manage_pci_remove 16150struct physdev_manage_pci {151/* IN */152uint8_t bus;153uint8_t devfn;154};155156#define PHYSDEVOP_restore_msi 19157struct physdev_restore_msi {158/* IN */159uint8_t bus;160uint8_t devfn;161};162163#define PHYSDEVOP_manage_pci_add_ext 20164struct physdev_manage_pci_ext {165/* IN */166uint8_t bus;167uint8_t devfn;168unsigned is_extfn;169unsigned is_virtfn;170struct {171uint8_t bus;172uint8_t devfn;173} physfn;174};175176/*177* Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()178* hypercall since 0x00030202.179*/180struct physdev_op {181uint32_t cmd;182union {183struct physdev_irq_status_query irq_status_query;184struct physdev_set_iopl set_iopl;185struct physdev_set_iobitmap set_iobitmap;186struct physdev_apic apic_op;187struct physdev_irq irq_op;188} u;189};190191#define PHYSDEVOP_setup_gsi 21192struct physdev_setup_gsi {193int gsi;194/* IN */195uint8_t triggering;196/* IN */197uint8_t polarity;198/* IN */199};200201#define PHYSDEVOP_get_nr_pirqs 22202struct physdev_nr_pirqs {203/* OUT */204uint32_t nr_pirqs;205};206207/* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI208* the hypercall returns a free pirq */209#define PHYSDEVOP_get_free_pirq 23210struct physdev_get_free_pirq {211/* IN */212int type;213/* OUT */214uint32_t pirq;215};216217#define XEN_PCI_DEV_EXTFN 0x1218#define XEN_PCI_DEV_VIRTFN 0x2219#define XEN_PCI_DEV_PXM 0x4220221#define XEN_PCI_MMCFG_RESERVED 0x1222223#define PHYSDEVOP_pci_mmcfg_reserved 24224struct physdev_pci_mmcfg_reserved {225uint64_t address;226uint16_t segment;227uint8_t start_bus;228uint8_t end_bus;229uint32_t flags;230};231232#define PHYSDEVOP_pci_device_add 25233struct physdev_pci_device_add {234/* IN */235uint16_t seg;236uint8_t bus;237uint8_t devfn;238uint32_t flags;239struct {240uint8_t bus;241uint8_t devfn;242} physfn;243#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L244uint32_t optarr[];245#elif defined(__GNUC__)246uint32_t optarr[0];247#endif248};249250#define PHYSDEVOP_pci_device_remove 26251#define PHYSDEVOP_restore_msi_ext 27252/*253* Dom0 should use these two to announce MMIO resources assigned to254* MSI-X capable devices won't (prepare) or may (release) change.255*/256#define PHYSDEVOP_prepare_msix 30257#define PHYSDEVOP_release_msix 31258/*259* Notify the hypervisor that a PCI device has been reset, so that any260* internally cached state is regenerated. Should be called after any261* device reset performed by the hardware domain.262*/263#define PHYSDEVOP_pci_device_reset 32264265struct physdev_pci_device {266/* IN */267uint16_t seg;268uint8_t bus;269uint8_t devfn;270};271272struct pci_device_reset {273struct physdev_pci_device dev;274#define PCI_DEVICE_RESET_COLD 0x0275#define PCI_DEVICE_RESET_WARM 0x1276#define PCI_DEVICE_RESET_HOT 0x2277#define PCI_DEVICE_RESET_FLR 0x3278#define PCI_DEVICE_RESET_MASK 0x3279uint32_t flags;280};281282#define PHYSDEVOP_DBGP_RESET_PREPARE 1283#define PHYSDEVOP_DBGP_RESET_DONE 2284285#define PHYSDEVOP_DBGP_BUS_UNKNOWN 0286#define PHYSDEVOP_DBGP_BUS_PCI 1287288#define PHYSDEVOP_dbgp_op 29289struct physdev_dbgp_op {290/* IN */291uint8_t op;292uint8_t bus;293union {294struct physdev_pci_device pci;295} u;296};297298/*299* Notify that some PIRQ-bound event channels have been unmasked.300* ** This command is obsolete since interface version 0x00030202 and is **301* ** unsupported by newer versions of Xen. **302*/303#define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4304305/*306* These all-capitals physdev operation names are superceded by the new names307* (defined above) since interface version 0x00030202.308*/309#define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query310#define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl311#define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap312#define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read313#define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write314#define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector315#define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector316#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi317#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared318319#endif /* __XEN_PUBLIC_PHYSDEV_H__ */320321322