xref: /titanic_41/usr/src/uts/common/xen/public/physdev.h (revision 7c500f1b365962a44422512b5c00083faa05a79e)
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
36 struct physdev_eoi {
37     /* IN */
38     uint32_t irq;
39 };
40 typedef struct physdev_eoi physdev_eoi_t;
41 DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
42 
43 /*
44  * Register a shared page for the hypervisor to indicate whether the guest
45  * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly
46  * once the guest used this function in that the associated event channel
47  * will automatically get unmasked. The page registered is used as a bit
48  * array indexed by Xen's PIRQ value.
49  */
50 #define PHYSDEVOP_pirq_eoi_gmfn         17
51 struct physdev_pirq_eoi_gmfn {
52     /* IN */
53     xen_pfn_t gmfn;
54 };
55 typedef struct physdev_pirq_eoi_gmfn physdev_pirq_eoi_gmfn_t;
56 DEFINE_XEN_GUEST_HANDLE(physdev_pirq_eoi_gmfn_t);
57 
58 /*
59  * Query the status of an IRQ line.
60  * @arg == pointer to physdev_irq_status_query structure.
61  */
62 #define PHYSDEVOP_irq_status_query       5
63 struct physdev_irq_status_query {
64     /* IN */
65     uint32_t irq;
66     /* OUT */
67     uint32_t flags; /* XENIRQSTAT_* */
68 };
69 typedef struct physdev_irq_status_query physdev_irq_status_query_t;
70 DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
71 
72 /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
73 #define _XENIRQSTAT_needs_eoi   (0)
74 #define  XENIRQSTAT_needs_eoi   (1U<<_XENIRQSTAT_needs_eoi)
75 
76 /* IRQ shared by multiple guests? */
77 #define _XENIRQSTAT_shared      (1)
78 #define  XENIRQSTAT_shared      (1U<<_XENIRQSTAT_shared)
79 
80 /*
81  * Set the current VCPU's I/O privilege level.
82  * @arg == pointer to physdev_set_iopl structure.
83  */
84 #define PHYSDEVOP_set_iopl               6
85 struct physdev_set_iopl {
86     /* IN */
87     uint32_t iopl;
88 };
89 typedef struct physdev_set_iopl physdev_set_iopl_t;
90 DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
91 
92 /*
93  * Set the current VCPU's I/O-port permissions bitmap.
94  * @arg == pointer to physdev_set_iobitmap structure.
95  */
96 #define PHYSDEVOP_set_iobitmap           7
97 struct physdev_set_iobitmap {
98     /* IN */
99 #if __XEN_INTERFACE_VERSION__ >= 0x00030205
100     XEN_GUEST_HANDLE(uint8) bitmap;
101 #else
102     uint8_t *bitmap;
103 #endif
104     uint32_t nr_ports;
105 };
106 typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
107 DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
108 
109 /*
110  * Read or write an IO-APIC register.
111  * @arg == pointer to physdev_apic structure.
112  */
113 #define PHYSDEVOP_apic_read              8
114 #define PHYSDEVOP_apic_write             9
115 struct physdev_apic {
116     /* IN */
117     unsigned long apic_physbase;
118     uint32_t reg;
119     /* IN or OUT */
120     uint32_t value;
121 };
122 typedef struct physdev_apic physdev_apic_t;
123 DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
124 
125 /*
126  * Allocate or free a physical upcall vector for the specified IRQ line.
127  * @arg == pointer to physdev_irq structure.
128  */
129 #define PHYSDEVOP_alloc_irq_vector      10
130 #define PHYSDEVOP_free_irq_vector       11
131 struct physdev_irq {
132     /* IN */
133     uint32_t irq;
134     /* IN or OUT */
135     uint32_t vector;
136 };
137 typedef struct physdev_irq physdev_irq_t;
138 DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
139 
140 #define MAP_PIRQ_TYPE_MSI               0x0
141 #define MAP_PIRQ_TYPE_GSI               0x1
142 #define MAP_PIRQ_TYPE_UNKNOWN           0x2
143 
144 #define PHYSDEVOP_map_pirq               13
145 struct physdev_map_pirq {
146     domid_t domid;
147     /* IN */
148     int type;
149     /* IN */
150     int index;
151     /* IN or OUT */
152     int pirq;
153     /* IN */
154     int bus;
155     /* IN */
156     int devfn;
157     /* IN */
158     int entry_nr;
159     /* IN */
160     uint64_t table_base;
161 };
162 typedef struct physdev_map_pirq physdev_map_pirq_t;
163 DEFINE_XEN_GUEST_HANDLE(physdev_map_pirq_t);
164 
165 #define PHYSDEVOP_unmap_pirq             14
166 struct physdev_unmap_pirq {
167     domid_t domid;
168     /* IN */
169     int pirq;
170 };
171 
172 typedef struct physdev_unmap_pirq physdev_unmap_pirq_t;
173 DEFINE_XEN_GUEST_HANDLE(physdev_unmap_pirq_t);
174 
175 #define PHYSDEVOP_manage_pci_add         15
176 #define PHYSDEVOP_manage_pci_remove      16
177 struct physdev_manage_pci {
178     /* IN */
179     uint8_t bus;
180     uint8_t devfn;
181 };
182 
183 typedef struct physdev_manage_pci physdev_manage_pci_t;
184 DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_t);
185 
186 #define PHYSDEVOP_restore_msi            19
187 struct physdev_restore_msi {
188     /* IN */
189     uint8_t bus;
190     uint8_t devfn;
191 };
192 typedef struct physdev_restore_msi physdev_restore_msi_t;
193 DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t);
194 
195 #define PHYSDEVOP_manage_pci_add_ext     20
196 struct physdev_manage_pci_ext {
197     /* IN */
198     uint8_t bus;
199     uint8_t devfn;
200     unsigned is_extfn;
201     unsigned is_virtfn;
202     struct {
203         uint8_t bus;
204         uint8_t devfn;
205     } physfn;
206 };
207 
208 typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t;
209 DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t);
210 
211 /*
212  * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
213  * hypercall since 0x00030202.
214  */
215 struct physdev_op {
216     uint32_t cmd;
217     union {
218         struct physdev_irq_status_query      irq_status_query;
219         struct physdev_set_iopl              set_iopl;
220         struct physdev_set_iobitmap          set_iobitmap;
221         struct physdev_apic                  apic_op;
222         struct physdev_irq                   irq_op;
223     } u;
224 };
225 typedef struct physdev_op physdev_op_t;
226 DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
227 
228 /*
229  * Notify that some PIRQ-bound event channels have been unmasked.
230  * ** This command is obsolete since interface version 0x00030202 and is **
231  * ** unsupported by newer versions of Xen.                              **
232  */
233 #define PHYSDEVOP_IRQ_UNMASK_NOTIFY      4
234 
235 /*
236  * These all-capitals physdev operation names are superceded by the new names
237  * (defined above) since interface version 0x00030202.
238  */
239 #define PHYSDEVOP_IRQ_STATUS_QUERY       PHYSDEVOP_irq_status_query
240 #define PHYSDEVOP_SET_IOPL               PHYSDEVOP_set_iopl
241 #define PHYSDEVOP_SET_IOBITMAP           PHYSDEVOP_set_iobitmap
242 #define PHYSDEVOP_APIC_READ              PHYSDEVOP_apic_read
243 #define PHYSDEVOP_APIC_WRITE             PHYSDEVOP_apic_write
244 #define PHYSDEVOP_ASSIGN_VECTOR          PHYSDEVOP_alloc_irq_vector
245 #define PHYSDEVOP_FREE_VECTOR            PHYSDEVOP_free_irq_vector
246 #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
247 #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
248 
249 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
250 
251 /*
252  * Local variables:
253  * mode: C
254  * c-set-style: "BSD"
255  * c-basic-offset: 4
256  * tab-width: 4
257  * indent-tabs-mode: nil
258  * End:
259  */
260