xref: /onnv-gate/usr/src/uts/common/xen/public/physdev.h (revision 10175:dd9708d1f561)
15084Sjohnlev /*
25084Sjohnlev  * Permission is hereby granted, free of charge, to any person obtaining a copy
35084Sjohnlev  * of this software and associated documentation files (the "Software"), to
45084Sjohnlev  * deal in the Software without restriction, including without limitation the
55084Sjohnlev  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
65084Sjohnlev  * sell copies of the Software, and to permit persons to whom the Software is
75084Sjohnlev  * furnished to do so, subject to the following conditions:
85084Sjohnlev  *
95084Sjohnlev  * The above copyright notice and this permission notice shall be included in
105084Sjohnlev  * all copies or substantial portions of the Software.
115084Sjohnlev  *
125084Sjohnlev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
135084Sjohnlev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
145084Sjohnlev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
155084Sjohnlev  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
165084Sjohnlev  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
175084Sjohnlev  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
185084Sjohnlev  * DEALINGS IN THE SOFTWARE.
195084Sjohnlev  */
205084Sjohnlev 
215084Sjohnlev #ifndef __XEN_PUBLIC_PHYSDEV_H__
225084Sjohnlev #define __XEN_PUBLIC_PHYSDEV_H__
235084Sjohnlev 
245084Sjohnlev /*
255084Sjohnlev  * Prototype for this hypercall is:
265084Sjohnlev  *  int physdev_op(int cmd, void *args)
275084Sjohnlev  * @cmd  == PHYSDEVOP_??? (physdev operation).
285084Sjohnlev  * @args == Operation-specific extra arguments (NULL if none).
295084Sjohnlev  */
305084Sjohnlev 
315084Sjohnlev /*
325084Sjohnlev  * Notify end-of-interrupt (EOI) for the specified IRQ.
335084Sjohnlev  * @arg == pointer to physdev_eoi structure.
345084Sjohnlev  */
355084Sjohnlev #define PHYSDEVOP_eoi                   12
365084Sjohnlev struct physdev_eoi {
375084Sjohnlev     /* IN */
385084Sjohnlev     uint32_t irq;
395084Sjohnlev };
405084Sjohnlev typedef struct physdev_eoi physdev_eoi_t;
415084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
425084Sjohnlev 
435084Sjohnlev /*
445084Sjohnlev  * Query the status of an IRQ line.
455084Sjohnlev  * @arg == pointer to physdev_irq_status_query structure.
465084Sjohnlev  */
475084Sjohnlev #define PHYSDEVOP_irq_status_query       5
485084Sjohnlev struct physdev_irq_status_query {
495084Sjohnlev     /* IN */
505084Sjohnlev     uint32_t irq;
515084Sjohnlev     /* OUT */
525084Sjohnlev     uint32_t flags; /* XENIRQSTAT_* */
535084Sjohnlev };
545084Sjohnlev typedef struct physdev_irq_status_query physdev_irq_status_query_t;
555084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
565084Sjohnlev 
575084Sjohnlev /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
585084Sjohnlev #define _XENIRQSTAT_needs_eoi   (0)
595084Sjohnlev #define  XENIRQSTAT_needs_eoi   (1U<<_XENIRQSTAT_needs_eoi)
605084Sjohnlev 
615084Sjohnlev /* IRQ shared by multiple guests? */
625084Sjohnlev #define _XENIRQSTAT_shared      (1)
635084Sjohnlev #define  XENIRQSTAT_shared      (1U<<_XENIRQSTAT_shared)
645084Sjohnlev 
655084Sjohnlev /*
665084Sjohnlev  * Set the current VCPU's I/O privilege level.
675084Sjohnlev  * @arg == pointer to physdev_set_iopl structure.
685084Sjohnlev  */
695084Sjohnlev #define PHYSDEVOP_set_iopl               6
705084Sjohnlev struct physdev_set_iopl {
715084Sjohnlev     /* IN */
725084Sjohnlev     uint32_t iopl;
735084Sjohnlev };
745084Sjohnlev typedef struct physdev_set_iopl physdev_set_iopl_t;
755084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
765084Sjohnlev 
775084Sjohnlev /*
785084Sjohnlev  * Set the current VCPU's I/O-port permissions bitmap.
795084Sjohnlev  * @arg == pointer to physdev_set_iobitmap structure.
805084Sjohnlev  */
815084Sjohnlev #define PHYSDEVOP_set_iobitmap           7
825084Sjohnlev struct physdev_set_iobitmap {
835084Sjohnlev     /* IN */
84*10175SStuart.Maybee@Sun.COM #if __XEN_INTERFACE_VERSION__ >= 0x00030205
85*10175SStuart.Maybee@Sun.COM     XEN_GUEST_HANDLE(uint8) bitmap;
86*10175SStuart.Maybee@Sun.COM #else
87*10175SStuart.Maybee@Sun.COM     uint8_t *bitmap;
88*10175SStuart.Maybee@Sun.COM #endif
895084Sjohnlev     uint32_t nr_ports;
905084Sjohnlev };
915084Sjohnlev typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
925084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
935084Sjohnlev 
945084Sjohnlev /*
955084Sjohnlev  * Read or write an IO-APIC register.
965084Sjohnlev  * @arg == pointer to physdev_apic structure.
975084Sjohnlev  */
985084Sjohnlev #define PHYSDEVOP_apic_read              8
995084Sjohnlev #define PHYSDEVOP_apic_write             9
1005084Sjohnlev struct physdev_apic {
1015084Sjohnlev     /* IN */
1025084Sjohnlev     unsigned long apic_physbase;
1035084Sjohnlev     uint32_t reg;
1045084Sjohnlev     /* IN or OUT */
1055084Sjohnlev     uint32_t value;
1065084Sjohnlev };
1075084Sjohnlev typedef struct physdev_apic physdev_apic_t;
1085084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
1095084Sjohnlev 
1105084Sjohnlev /*
1115084Sjohnlev  * Allocate or free a physical upcall vector for the specified IRQ line.
1125084Sjohnlev  * @arg == pointer to physdev_irq structure.
1135084Sjohnlev  */
1145084Sjohnlev #define PHYSDEVOP_alloc_irq_vector      10
1155084Sjohnlev #define PHYSDEVOP_free_irq_vector       11
1165084Sjohnlev struct physdev_irq {
1175084Sjohnlev     /* IN */
1185084Sjohnlev     uint32_t irq;
1195084Sjohnlev     /* IN or OUT */
1205084Sjohnlev     uint32_t vector;
1215084Sjohnlev };
1225084Sjohnlev typedef struct physdev_irq physdev_irq_t;
1235084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
124*10175SStuart.Maybee@Sun.COM 
125*10175SStuart.Maybee@Sun.COM #define MAP_PIRQ_TYPE_MSI               0x0
126*10175SStuart.Maybee@Sun.COM #define MAP_PIRQ_TYPE_GSI               0x1
127*10175SStuart.Maybee@Sun.COM #define MAP_PIRQ_TYPE_UNKNOWN           0x2
128*10175SStuart.Maybee@Sun.COM 
129*10175SStuart.Maybee@Sun.COM #define PHYSDEVOP_map_pirq               13
130*10175SStuart.Maybee@Sun.COM struct physdev_map_pirq {
131*10175SStuart.Maybee@Sun.COM     domid_t domid;
132*10175SStuart.Maybee@Sun.COM     /* IN */
133*10175SStuart.Maybee@Sun.COM     int type;
134*10175SStuart.Maybee@Sun.COM     /* IN */
135*10175SStuart.Maybee@Sun.COM     int index;
136*10175SStuart.Maybee@Sun.COM     /* IN or OUT */
137*10175SStuart.Maybee@Sun.COM     int pirq;
138*10175SStuart.Maybee@Sun.COM     /* IN */
139*10175SStuart.Maybee@Sun.COM     int bus;
140*10175SStuart.Maybee@Sun.COM     /* IN */
141*10175SStuart.Maybee@Sun.COM     int devfn;
142*10175SStuart.Maybee@Sun.COM     /* IN */
143*10175SStuart.Maybee@Sun.COM     int entry_nr;
144*10175SStuart.Maybee@Sun.COM     /* IN */
145*10175SStuart.Maybee@Sun.COM     uint64_t table_base;
146*10175SStuart.Maybee@Sun.COM };
147*10175SStuart.Maybee@Sun.COM typedef struct physdev_map_pirq physdev_map_pirq_t;
148*10175SStuart.Maybee@Sun.COM DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t);
149*10175SStuart.Maybee@Sun.COM 
150*10175SStuart.Maybee@Sun.COM #define PHYSDEVOP_unmap_pirq             14
151*10175SStuart.Maybee@Sun.COM struct physdev_unmap_pirq {
152*10175SStuart.Maybee@Sun.COM     domid_t domid;
153*10175SStuart.Maybee@Sun.COM     /* IN */
154*10175SStuart.Maybee@Sun.COM     int pirq;
155*10175SStuart.Maybee@Sun.COM };
156*10175SStuart.Maybee@Sun.COM 
157*10175SStuart.Maybee@Sun.COM typedef struct physdev_unmap_pirq physdev_unmap_pirq_t;
158*10175SStuart.Maybee@Sun.COM DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t);
159*10175SStuart.Maybee@Sun.COM 
160*10175SStuart.Maybee@Sun.COM #define PHYSDEVOP_manage_pci_add         15
161*10175SStuart.Maybee@Sun.COM #define PHYSDEVOP_manage_pci_remove      16
162*10175SStuart.Maybee@Sun.COM struct physdev_manage_pci {
163*10175SStuart.Maybee@Sun.COM     /* IN */
164*10175SStuart.Maybee@Sun.COM     uint8_t bus;
165*10175SStuart.Maybee@Sun.COM     uint8_t devfn;
166*10175SStuart.Maybee@Sun.COM };
167*10175SStuart.Maybee@Sun.COM 
168*10175SStuart.Maybee@Sun.COM typedef struct physdev_manage_pci physdev_manage_pci_t;
169*10175SStuart.Maybee@Sun.COM DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t);
1705084Sjohnlev 
1715084Sjohnlev /*
1725084Sjohnlev  * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
1735084Sjohnlev  * hypercall since 0x00030202.
1745084Sjohnlev  */
1755084Sjohnlev struct physdev_op {
1765084Sjohnlev     uint32_t cmd;
1775084Sjohnlev     union {
1785084Sjohnlev         struct physdev_irq_status_query      irq_status_query;
1795084Sjohnlev         struct physdev_set_iopl              set_iopl;
1805084Sjohnlev         struct physdev_set_iobitmap          set_iobitmap;
1815084Sjohnlev         struct physdev_apic                  apic_op;
1825084Sjohnlev         struct physdev_irq                   irq_op;
1835084Sjohnlev     } u;
1845084Sjohnlev };
1855084Sjohnlev typedef struct physdev_op physdev_op_t;
1865084Sjohnlev DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
1875084Sjohnlev 
1885084Sjohnlev /*
1895084Sjohnlev  * Notify that some PIRQ-bound event channels have been unmasked.
1905084Sjohnlev  * ** This command is obsolete since interface version 0x00030202 and is **
1915084Sjohnlev  * ** unsupported by newer versions of Xen.                              **
1925084Sjohnlev  */
1935084Sjohnlev #define PHYSDEVOP_IRQ_UNMASK_NOTIFY      4
1945084Sjohnlev 
1955084Sjohnlev /*
1965084Sjohnlev  * These all-capitals physdev operation names are superceded by the new names
1975084Sjohnlev  * (defined above) since interface version 0x00030202.
1985084Sjohnlev  */
1995084Sjohnlev #define PHYSDEVOP_IRQ_STATUS_QUERY       PHYSDEVOP_irq_status_query
2005084Sjohnlev #define PHYSDEVOP_SET_IOPL               PHYSDEVOP_set_iopl
2015084Sjohnlev #define PHYSDEVOP_SET_IOBITMAP           PHYSDEVOP_set_iobitmap
2025084Sjohnlev #define PHYSDEVOP_APIC_READ              PHYSDEVOP_apic_read
2035084Sjohnlev #define PHYSDEVOP_APIC_WRITE             PHYSDEVOP_apic_write
2045084Sjohnlev #define PHYSDEVOP_ASSIGN_VECTOR          PHYSDEVOP_alloc_irq_vector
2055084Sjohnlev #define PHYSDEVOP_FREE_VECTOR            PHYSDEVOP_free_irq_vector
2065084Sjohnlev #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
2075084Sjohnlev #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
2085084Sjohnlev 
2095084Sjohnlev #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
2105084Sjohnlev 
2115084Sjohnlev /*
2125084Sjohnlev  * Local variables:
2135084Sjohnlev  * mode: C
2145084Sjohnlev  * c-set-style: "BSD"
2155084Sjohnlev  * c-basic-offset: 4
2165084Sjohnlev  * tab-width: 4
2175084Sjohnlev  * indent-tabs-mode: nil
2185084Sjohnlev  * End:
2195084Sjohnlev  */
220