Home | History | Annotate | Line # | Download | only in public
      1  1.1  cherry /*
      2  1.1  cherry  * Permission is hereby granted, free of charge, to any person obtaining a copy
      3  1.1  cherry  * of this software and associated documentation files (the "Software"), to
      4  1.1  cherry  * deal in the Software without restriction, including without limitation the
      5  1.1  cherry  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
      6  1.1  cherry  * sell copies of the Software, and to permit persons to whom the Software is
      7  1.1  cherry  * furnished to do so, subject to the following conditions:
      8  1.1  cherry  *
      9  1.1  cherry  * The above copyright notice and this permission notice shall be included in
     10  1.1  cherry  * all copies or substantial portions of the Software.
     11  1.1  cherry  *
     12  1.1  cherry  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     13  1.1  cherry  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     14  1.1  cherry  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     15  1.1  cherry  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     16  1.1  cherry  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     17  1.1  cherry  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     18  1.1  cherry  * DEALINGS IN THE SOFTWARE.
     19  1.1  cherry  *
     20  1.1  cherry  * Copyright (c) 2006, Keir Fraser
     21  1.1  cherry  */
     22  1.1  cherry 
     23  1.1  cherry #ifndef __XEN_PUBLIC_PHYSDEV_H__
     24  1.1  cherry #define __XEN_PUBLIC_PHYSDEV_H__
     25  1.1  cherry 
     26  1.1  cherry #include "xen.h"
     27  1.1  cherry 
     28  1.1  cherry /*
     29  1.1  cherry  * Prototype for this hypercall is:
     30  1.1  cherry  *  int physdev_op(int cmd, void *args)
     31  1.1  cherry  * @cmd  == PHYSDEVOP_??? (physdev operation).
     32  1.1  cherry  * @args == Operation-specific extra arguments (NULL if none).
     33  1.1  cherry  */
     34  1.1  cherry 
     35  1.1  cherry /*
     36  1.1  cherry  * Notify end-of-interrupt (EOI) for the specified IRQ.
     37  1.1  cherry  * @arg == pointer to physdev_eoi structure.
     38  1.1  cherry  */
     39  1.1  cherry #define PHYSDEVOP_eoi                   12
     40  1.1  cherry struct physdev_eoi {
     41  1.1  cherry     /* IN */
     42  1.1  cherry     uint32_t irq;
     43  1.1  cherry };
     44  1.1  cherry typedef struct physdev_eoi physdev_eoi_t;
     45  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
     46  1.1  cherry 
     47  1.1  cherry /*
     48  1.1  cherry  * Register a shared page for the hypervisor to indicate whether the guest
     49  1.1  cherry  * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly
     50  1.1  cherry  * once the guest used this function in that the associated event channel
     51  1.1  cherry  * will automatically get unmasked. The page registered is used as a bit
     52  1.1  cherry  * array indexed by Xen's PIRQ value.
     53  1.1  cherry  */
     54  1.1  cherry #define PHYSDEVOP_pirq_eoi_gmfn_v1       17
     55  1.1  cherry /*
     56  1.1  cherry  * Register a shared page for the hypervisor to indicate whether the
     57  1.1  cherry  * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
     58  1.1  cherry  * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
     59  1.1  cherry  * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
     60  1.1  cherry  * Xen's PIRQ value.
     61  1.1  cherry  */
     62  1.1  cherry #define PHYSDEVOP_pirq_eoi_gmfn_v2       28
     63  1.1  cherry struct physdev_pirq_eoi_gmfn {
     64  1.1  cherry     /* IN */
     65  1.1  cherry     xen_pfn_t gmfn;
     66  1.1  cherry };
     67  1.1  cherry typedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t;
     68  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t);
     69  1.1  cherry 
     70  1.1  cherry /*
     71  1.1  cherry  * Query the status of an IRQ line.
     72  1.1  cherry  * @arg == pointer to physdev_irq_status_query structure.
     73  1.1  cherry  */
     74  1.1  cherry #define PHYSDEVOP_irq_status_query       5
     75  1.1  cherry struct physdev_irq_status_query {
     76  1.1  cherry     /* IN */
     77  1.1  cherry     uint32_t irq;
     78  1.1  cherry     /* OUT */
     79  1.1  cherry     uint32_t flags; /* XENIRQSTAT_* */
     80  1.1  cherry };
     81  1.1  cherry typedef struct physdev_irq_status_query physdev_irq_status_query_t;
     82  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
     83  1.1  cherry 
     84  1.1  cherry /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
     85  1.1  cherry #define _XENIRQSTAT_needs_eoi   (0)
     86  1.1  cherry #define  XENIRQSTAT_needs_eoi   (1U<<_XENIRQSTAT_needs_eoi)
     87  1.1  cherry 
     88  1.1  cherry /* IRQ shared by multiple guests? */
     89  1.1  cherry #define _XENIRQSTAT_shared      (1)
     90  1.1  cherry #define  XENIRQSTAT_shared      (1U<<_XENIRQSTAT_shared)
     91  1.1  cherry 
     92  1.1  cherry /*
     93  1.1  cherry  * Set the current VCPU's I/O privilege level.
     94  1.1  cherry  * @arg == pointer to physdev_set_iopl structure.
     95  1.1  cherry  */
     96  1.1  cherry #define PHYSDEVOP_set_iopl               6
     97  1.1  cherry struct physdev_set_iopl {
     98  1.1  cherry     /* IN */
     99  1.1  cherry     uint32_t iopl;
    100  1.1  cherry };
    101  1.1  cherry typedef struct physdev_set_iopl physdev_set_iopl_t;
    102  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
    103  1.1  cherry 
    104  1.1  cherry /*
    105  1.1  cherry  * Set the current VCPU's I/O-port permissions bitmap.
    106  1.1  cherry  * @arg == pointer to physdev_set_iobitmap structure.
    107  1.1  cherry  */
    108  1.1  cherry #define PHYSDEVOP_set_iobitmap           7
    109  1.1  cherry struct physdev_set_iobitmap {
    110  1.1  cherry     /* IN */
    111  1.1  cherry #if __XEN_INTERFACE_VERSION__ >= 0x00030205
    112  1.1  cherry     XEN_GUEST_HANDLE(uint8) bitmap;
    113  1.1  cherry #else
    114  1.1  cherry     uint8_t *bitmap;
    115  1.1  cherry #endif
    116  1.1  cherry     uint32_t nr_ports;
    117  1.1  cherry };
    118  1.1  cherry typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
    119  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
    120  1.1  cherry 
    121  1.1  cherry /*
    122  1.1  cherry  * Read or write an IO-APIC register.
    123  1.1  cherry  * @arg == pointer to physdev_apic structure.
    124  1.1  cherry  */
    125  1.1  cherry #define PHYSDEVOP_apic_read              8
    126  1.1  cherry #define PHYSDEVOP_apic_write             9
    127  1.1  cherry struct physdev_apic {
    128  1.1  cherry     /* IN */
    129  1.1  cherry     unsigned long apic_physbase;
    130  1.1  cherry     uint32_t reg;
    131  1.1  cherry     /* IN or OUT */
    132  1.1  cherry     uint32_t value;
    133  1.1  cherry };
    134  1.1  cherry typedef struct physdev_apic physdev_apic_t;
    135  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
    136  1.1  cherry 
    137  1.1  cherry /*
    138  1.1  cherry  * Allocate or free a physical upcall vector for the specified IRQ line.
    139  1.1  cherry  * @arg == pointer to physdev_irq structure.
    140  1.1  cherry  */
    141  1.1  cherry #define PHYSDEVOP_alloc_irq_vector      10
    142  1.1  cherry #define PHYSDEVOP_free_irq_vector       11
    143  1.1  cherry struct physdev_irq {
    144  1.1  cherry     /* IN */
    145  1.1  cherry     uint32_t irq;
    146  1.1  cherry     /* IN or OUT */
    147  1.1  cherry     uint32_t vector;
    148  1.1  cherry };
    149  1.1  cherry typedef struct physdev_irq physdev_irq_t;
    150  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
    151  1.1  cherry 
    152  1.1  cherry #define MAP_PIRQ_TYPE_MSI               0x0
    153  1.1  cherry #define MAP_PIRQ_TYPE_GSI               0x1
    154  1.1  cherry #define MAP_PIRQ_TYPE_UNKNOWN           0x2
    155  1.1  cherry #define MAP_PIRQ_TYPE_MSI_SEG           0x3
    156  1.1  cherry #define MAP_PIRQ_TYPE_MULTI_MSI         0x4
    157  1.1  cherry 
    158  1.1  cherry #define PHYSDEVOP_map_pirq               13
    159  1.1  cherry struct physdev_map_pirq {
    160  1.1  cherry     domid_t domid;
    161  1.1  cherry     /* IN */
    162  1.1  cherry     int type;
    163  1.1  cherry     /* IN (ignored for ..._MULTI_MSI) */
    164  1.1  cherry     int index;
    165  1.1  cherry     /* IN or OUT */
    166  1.1  cherry     int pirq;
    167  1.1  cherry     /* IN - high 16 bits hold segment for ..._MSI_SEG and ..._MULTI_MSI */
    168  1.1  cherry     int bus;
    169  1.1  cherry     /* IN */
    170  1.1  cherry     int devfn;
    171  1.1  cherry     /* IN (also OUT for ..._MULTI_MSI) */
    172  1.1  cherry     int entry_nr;
    173  1.1  cherry     /* IN */
    174  1.1  cherry     uint64_t table_base;
    175  1.1  cherry };
    176  1.1  cherry typedef struct physdev_map_pirq physdev_map_pirq_t;
    177  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t);
    178  1.1  cherry 
    179  1.1  cherry #define PHYSDEVOP_unmap_pirq             14
    180  1.1  cherry struct physdev_unmap_pirq {
    181  1.1  cherry     domid_t domid;
    182  1.1  cherry     /* IN */
    183  1.1  cherry     int pirq;
    184  1.1  cherry };
    185  1.1  cherry 
    186  1.1  cherry typedef struct physdev_unmap_pirq physdev_unmap_pirq_t;
    187  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t);
    188  1.1  cherry 
    189  1.1  cherry #define PHYSDEVOP_manage_pci_add         15
    190  1.1  cherry #define PHYSDEVOP_manage_pci_remove      16
    191  1.1  cherry struct physdev_manage_pci {
    192  1.1  cherry     /* IN */
    193  1.1  cherry     uint8_t bus;
    194  1.1  cherry     uint8_t devfn;
    195  1.1  cherry };
    196  1.1  cherry 
    197  1.1  cherry typedef struct physdev_manage_pci physdev_manage_pci_t;
    198  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t);
    199  1.1  cherry 
    200  1.1  cherry #define PHYSDEVOP_restore_msi            19
    201  1.1  cherry struct physdev_restore_msi {
    202  1.1  cherry     /* IN */
    203  1.1  cherry     uint8_t bus;
    204  1.1  cherry     uint8_t devfn;
    205  1.1  cherry };
    206  1.1  cherry typedef struct physdev_restore_msi physdev_restore_msi_t;
    207  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t);
    208  1.1  cherry 
    209  1.1  cherry #define PHYSDEVOP_manage_pci_add_ext     20
    210  1.1  cherry struct physdev_manage_pci_ext {
    211  1.1  cherry     /* IN */
    212  1.1  cherry     uint8_t bus;
    213  1.1  cherry     uint8_t devfn;
    214  1.1  cherry     unsigned is_extfn;
    215  1.1  cherry     unsigned is_virtfn;
    216  1.1  cherry     struct {
    217  1.1  cherry         uint8_t bus;
    218  1.1  cherry         uint8_t devfn;
    219  1.1  cherry     } physfn;
    220  1.1  cherry };
    221  1.1  cherry 
    222  1.1  cherry typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t;
    223  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t);
    224  1.1  cherry 
    225  1.1  cherry /*
    226  1.1  cherry  * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
    227  1.1  cherry  * hypercall since 0x00030202.
    228  1.1  cherry  */
    229  1.1  cherry struct physdev_op {
    230  1.1  cherry     uint32_t cmd;
    231  1.1  cherry     union {
    232  1.1  cherry         struct physdev_irq_status_query      irq_status_query;
    233  1.1  cherry         struct physdev_set_iopl              set_iopl;
    234  1.1  cherry         struct physdev_set_iobitmap          set_iobitmap;
    235  1.1  cherry         struct physdev_apic                  apic_op;
    236  1.1  cherry         struct physdev_irq                   irq_op;
    237  1.1  cherry     } u;
    238  1.1  cherry };
    239  1.1  cherry typedef struct physdev_op physdev_op_t;
    240  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
    241  1.1  cherry 
    242  1.1  cherry #define PHYSDEVOP_setup_gsi    21
    243  1.1  cherry struct physdev_setup_gsi {
    244  1.1  cherry     int gsi;
    245  1.1  cherry     /* IN */
    246  1.1  cherry     uint8_t triggering;
    247  1.1  cherry     /* IN */
    248  1.1  cherry     uint8_t polarity;
    249  1.1  cherry     /* IN */
    250  1.1  cherry };
    251  1.1  cherry 
    252  1.1  cherry typedef struct physdev_setup_gsi physdev_setup_gsi_t;
    253  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_setup_gsi_t);
    254  1.1  cherry 
    255  1.1  cherry /* leave PHYSDEVOP 22 free */
    256  1.1  cherry 
    257  1.1  cherry /* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
    258  1.1  cherry  * the hypercall returns a free pirq */
    259  1.1  cherry #define PHYSDEVOP_get_free_pirq    23
    260  1.1  cherry struct physdev_get_free_pirq {
    261  1.1  cherry     /* IN */
    262  1.1  cherry     int type;
    263  1.1  cherry     /* OUT */
    264  1.1  cherry     uint32_t pirq;
    265  1.1  cherry };
    266  1.1  cherry 
    267  1.1  cherry typedef struct physdev_get_free_pirq physdev_get_free_pirq_t;
    268  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
    269  1.1  cherry 
    270  1.1  cherry #define XEN_PCI_MMCFG_RESERVED         0x1
    271  1.1  cherry 
    272  1.1  cherry #define PHYSDEVOP_pci_mmcfg_reserved    24
    273  1.1  cherry struct physdev_pci_mmcfg_reserved {
    274  1.1  cherry     uint64_t address;
    275  1.1  cherry     uint16_t segment;
    276  1.1  cherry     uint8_t start_bus;
    277  1.1  cherry     uint8_t end_bus;
    278  1.1  cherry     uint32_t flags;
    279  1.1  cherry };
    280  1.1  cherry typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t;
    281  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t);
    282  1.1  cherry 
    283  1.1  cherry #define XEN_PCI_DEV_EXTFN              0x1
    284  1.1  cherry #define XEN_PCI_DEV_VIRTFN             0x2
    285  1.1  cherry #define XEN_PCI_DEV_PXM                0x4
    286  1.1  cherry 
    287  1.1  cherry #define PHYSDEVOP_pci_device_add        25
    288  1.1  cherry struct physdev_pci_device_add {
    289  1.1  cherry     /* IN */
    290  1.1  cherry     uint16_t seg;
    291  1.1  cherry     uint8_t bus;
    292  1.1  cherry     uint8_t devfn;
    293  1.1  cherry     uint32_t flags;
    294  1.1  cherry     struct {
    295  1.1  cherry         uint8_t bus;
    296  1.1  cherry         uint8_t devfn;
    297  1.1  cherry     } physfn;
    298  1.1  cherry     /*
    299  1.1  cherry      * Optional parameters array.
    300  1.1  cherry      * First element ([0]) is PXM domain associated with the device (if
    301  1.1  cherry      * XEN_PCI_DEV_PXM is set)
    302  1.1  cherry      */
    303  1.1  cherry #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    304  1.1  cherry     uint32_t optarr[];
    305  1.1  cherry #elif defined(__GNUC__)
    306  1.1  cherry     uint32_t optarr[0];
    307  1.1  cherry #endif
    308  1.1  cherry };
    309  1.1  cherry typedef struct physdev_pci_device_add physdev_pci_device_add_t;
    310  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_add_t);
    311  1.1  cherry 
    312  1.1  cherry #define PHYSDEVOP_pci_device_remove     26
    313  1.1  cherry #define PHYSDEVOP_restore_msi_ext       27
    314  1.1  cherry /*
    315  1.1  cherry  * Dom0 should use these two to announce MMIO resources assigned to
    316  1.1  cherry  * MSI-X capable devices won't (prepare) or may (release) change.
    317  1.1  cherry  */
    318  1.1  cherry #define PHYSDEVOP_prepare_msix          30
    319  1.1  cherry #define PHYSDEVOP_release_msix          31
    320  1.1  cherry struct physdev_pci_device {
    321  1.1  cherry     /* IN */
    322  1.1  cherry     uint16_t seg;
    323  1.1  cherry     uint8_t bus;
    324  1.1  cherry     uint8_t devfn;
    325  1.1  cherry };
    326  1.1  cherry typedef struct physdev_pci_device physdev_pci_device_t;
    327  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t);
    328  1.1  cherry 
    329  1.1  cherry #define PHYSDEVOP_DBGP_RESET_PREPARE    1
    330  1.1  cherry #define PHYSDEVOP_DBGP_RESET_DONE       2
    331  1.1  cherry 
    332  1.1  cherry #define PHYSDEVOP_DBGP_BUS_UNKNOWN      0
    333  1.1  cherry #define PHYSDEVOP_DBGP_BUS_PCI          1
    334  1.1  cherry 
    335  1.1  cherry #define PHYSDEVOP_dbgp_op               29
    336  1.1  cherry struct physdev_dbgp_op {
    337  1.1  cherry     /* IN */
    338  1.1  cherry     uint8_t op;
    339  1.1  cherry     uint8_t bus;
    340  1.1  cherry     union {
    341  1.1  cherry         struct physdev_pci_device pci;
    342  1.1  cherry     } u;
    343  1.1  cherry };
    344  1.1  cherry typedef struct physdev_dbgp_op physdev_dbgp_op_t;
    345  1.1  cherry DEFINE_XEN_GUEST_HANDLE(physdev_dbgp_op_t);
    346  1.1  cherry 
    347  1.1  cherry /*
    348  1.1  cherry  * Notify that some PIRQ-bound event channels have been unmasked.
    349  1.1  cherry  * ** This command is obsolete since interface version 0x00030202 and is **
    350  1.1  cherry  * ** unsupported by newer versions of Xen.                              **
    351  1.1  cherry  */
    352  1.1  cherry #define PHYSDEVOP_IRQ_UNMASK_NOTIFY      4
    353  1.1  cherry 
    354  1.1  cherry #if __XEN_INTERFACE_VERSION__ < 0x00040600
    355  1.1  cherry /*
    356  1.1  cherry  * These all-capitals physdev operation names are superceded by the new names
    357  1.1  cherry  * (defined above) since interface version 0x00030202. The guard above was
    358  1.1  cherry  * added post-4.5 only though and hence shouldn't check for 0x00030202.
    359  1.1  cherry  */
    360  1.1  cherry #define PHYSDEVOP_IRQ_STATUS_QUERY       PHYSDEVOP_irq_status_query
    361  1.1  cherry #define PHYSDEVOP_SET_IOPL               PHYSDEVOP_set_iopl
    362  1.1  cherry #define PHYSDEVOP_SET_IOBITMAP           PHYSDEVOP_set_iobitmap
    363  1.1  cherry #define PHYSDEVOP_APIC_READ              PHYSDEVOP_apic_read
    364  1.1  cherry #define PHYSDEVOP_APIC_WRITE             PHYSDEVOP_apic_write
    365  1.1  cherry #define PHYSDEVOP_ASSIGN_VECTOR          PHYSDEVOP_alloc_irq_vector
    366  1.1  cherry #define PHYSDEVOP_FREE_VECTOR            PHYSDEVOP_free_irq_vector
    367  1.1  cherry #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
    368  1.1  cherry #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
    369  1.1  cherry #endif
    370  1.1  cherry 
    371  1.1  cherry #if __XEN_INTERFACE_VERSION__ < 0x00040200
    372  1.1  cherry #define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1
    373  1.1  cherry #else
    374  1.1  cherry #define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2
    375  1.1  cherry #endif
    376  1.1  cherry 
    377  1.1  cherry #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
    378  1.1  cherry 
    379  1.1  cherry /*
    380  1.1  cherry  * Local variables:
    381  1.1  cherry  * mode: C
    382  1.1  cherry  * c-file-style: "BSD"
    383  1.1  cherry  * c-basic-offset: 4
    384  1.1  cherry  * tab-width: 4
    385  1.1  cherry  * indent-tabs-mode: nil
    386  1.1  cherry  * End:
    387  1.1  cherry  */
    388