blob: 0c28989007fb2671fd95f2892db4ad2fca9eb74f [file] [log] [blame]
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -07001/*
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};
40
41/*
42 * Query the status of an IRQ line.
43 * @arg == pointer to physdev_irq_status_query structure.
44 */
45#define PHYSDEVOP_irq_status_query 5
46struct physdev_irq_status_query {
47 /* IN */
48 uint32_t irq;
49 /* OUT */
50 uint32_t flags; /* XENIRQSTAT_* */
51};
52
53/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
54#define _XENIRQSTAT_needs_eoi (0)
55#define XENIRQSTAT_needs_eoi (1U<<_XENIRQSTAT_needs_eoi)
56
57/* IRQ shared by multiple guests? */
58#define _XENIRQSTAT_shared (1)
59#define XENIRQSTAT_shared (1U<<_XENIRQSTAT_shared)
60
61/*
62 * Set the current VCPU's I/O privilege level.
63 * @arg == pointer to physdev_set_iopl structure.
64 */
65#define PHYSDEVOP_set_iopl 6
66struct physdev_set_iopl {
67 /* IN */
68 uint32_t iopl;
69};
70
71/*
72 * Set the current VCPU's I/O-port permissions bitmap.
73 * @arg == pointer to physdev_set_iobitmap structure.
74 */
75#define PHYSDEVOP_set_iobitmap 7
76struct physdev_set_iobitmap {
77 /* IN */
78 uint8_t * bitmap;
79 uint32_t nr_ports;
80};
81
82/*
83 * Read or write an IO-APIC register.
84 * @arg == pointer to physdev_apic structure.
85 */
86#define PHYSDEVOP_apic_read 8
87#define PHYSDEVOP_apic_write 9
88struct physdev_apic {
89 /* IN */
90 unsigned long apic_physbase;
91 uint32_t reg;
92 /* IN or OUT */
93 uint32_t value;
94};
95
96/*
97 * Allocate or free a physical upcall vector for the specified IRQ line.
98 * @arg == pointer to physdev_irq structure.
99 */
100#define PHYSDEVOP_alloc_irq_vector 10
101#define PHYSDEVOP_free_irq_vector 11
102struct physdev_irq {
103 /* IN */
104 uint32_t irq;
105 /* IN or OUT */
106 uint32_t vector;
107};
108
Stefano Stabellini42a1de52010-06-24 16:42:04 +0100109#define MAP_PIRQ_TYPE_MSI 0x0
110#define MAP_PIRQ_TYPE_GSI 0x1
111#define MAP_PIRQ_TYPE_UNKNOWN 0x2
Jan Beulich55e901f2011-09-22 09:17:57 +0100112#define MAP_PIRQ_TYPE_MSI_SEG 0x3
Stefano Stabellini42a1de52010-06-24 16:42:04 +0100113
114#define PHYSDEVOP_map_pirq 13
115struct physdev_map_pirq {
116 domid_t domid;
117 /* IN */
118 int type;
119 /* IN */
120 int index;
121 /* IN or OUT */
122 int pirq;
Jan Beulich55e901f2011-09-22 09:17:57 +0100123 /* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */
Stefano Stabellini42a1de52010-06-24 16:42:04 +0100124 int bus;
125 /* IN */
126 int devfn;
127 /* IN */
128 int entry_nr;
129 /* IN */
130 uint64_t table_base;
131};
132
133#define PHYSDEVOP_unmap_pirq 14
134struct physdev_unmap_pirq {
135 domid_t domid;
136 /* IN */
137 int pirq;
138};
139
Weidong Hane28c31a2010-10-27 17:55:04 +0100140#define PHYSDEVOP_manage_pci_add 15
141#define PHYSDEVOP_manage_pci_remove 16
142struct physdev_manage_pci {
143 /* IN */
144 uint8_t bus;
145 uint8_t devfn;
146};
147
Tang Liang8605c682011-12-08 17:36:39 +0800148#define PHYSDEVOP_restore_msi 19
149struct physdev_restore_msi {
150 /* IN */
151 uint8_t bus;
152 uint8_t devfn;
153};
154
Weidong Hane28c31a2010-10-27 17:55:04 +0100155#define PHYSDEVOP_manage_pci_add_ext 20
156struct physdev_manage_pci_ext {
157 /* IN */
158 uint8_t bus;
159 uint8_t devfn;
160 unsigned is_extfn;
161 unsigned is_virtfn;
162 struct {
163 uint8_t bus;
164 uint8_t devfn;
165 } physfn;
166};
167
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700168/*
169 * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
170 * hypercall since 0x00030202.
171 */
172struct physdev_op {
173 uint32_t cmd;
174 union {
175 struct physdev_irq_status_query irq_status_query;
176 struct physdev_set_iopl set_iopl;
177 struct physdev_set_iobitmap set_iobitmap;
178 struct physdev_apic apic_op;
179 struct physdev_irq irq_op;
180 } u;
181};
182
Jeremy Fitzhardinge38aa66f2010-09-02 14:51:39 +0100183#define PHYSDEVOP_setup_gsi 21
184struct physdev_setup_gsi {
185 int gsi;
186 /* IN */
187 uint8_t triggering;
188 /* IN */
189 uint8_t polarity;
190 /* IN */
191};
192
Stefano Stabellini01557ba2010-08-20 14:46:52 +0100193#define PHYSDEVOP_get_nr_pirqs 22
194struct physdev_nr_pirqs {
195 /* OUT */
196 uint32_t nr_pirqs;
197};
198
Stefano Stabellinie5fc7342010-12-01 14:51:44 +0000199/* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
200 * the hypercall returns a free pirq */
201#define PHYSDEVOP_get_free_pirq 23
202struct physdev_get_free_pirq {
203 /* IN */
204 int type;
205 /* OUT */
206 uint32_t pirq;
207};
208
Jan Beulich55e901f2011-09-22 09:17:57 +0100209#define XEN_PCI_DEV_EXTFN 0x1
210#define XEN_PCI_DEV_VIRTFN 0x2
211#define XEN_PCI_DEV_PXM 0x4
212
213#define PHYSDEVOP_pci_device_add 25
214struct physdev_pci_device_add {
215 /* IN */
216 uint16_t seg;
217 uint8_t bus;
218 uint8_t devfn;
219 uint32_t flags;
220 struct {
221 uint8_t bus;
222 uint8_t devfn;
223 } physfn;
224#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
225 uint32_t optarr[];
226#elif defined(__GNUC__)
227 uint32_t optarr[0];
228#endif
229};
230
231#define PHYSDEVOP_pci_device_remove 26
232#define PHYSDEVOP_restore_msi_ext 27
233struct physdev_pci_device {
234 /* IN */
235 uint16_t seg;
236 uint8_t bus;
237 uint8_t devfn;
238};
239
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700240/*
241 * Notify that some PIRQ-bound event channels have been unmasked.
242 * ** This command is obsolete since interface version 0x00030202 and is **
243 * ** unsupported by newer versions of Xen. **
244 */
245#define PHYSDEVOP_IRQ_UNMASK_NOTIFY 4
246
247/*
248 * These all-capitals physdev operation names are superceded by the new names
249 * (defined above) since interface version 0x00030202.
250 */
251#define PHYSDEVOP_IRQ_STATUS_QUERY PHYSDEVOP_irq_status_query
252#define PHYSDEVOP_SET_IOPL PHYSDEVOP_set_iopl
253#define PHYSDEVOP_SET_IOBITMAP PHYSDEVOP_set_iobitmap
254#define PHYSDEVOP_APIC_READ PHYSDEVOP_apic_read
255#define PHYSDEVOP_APIC_WRITE PHYSDEVOP_apic_write
256#define PHYSDEVOP_ASSIGN_VECTOR PHYSDEVOP_alloc_irq_vector
257#define PHYSDEVOP_FREE_VECTOR PHYSDEVOP_free_irq_vector
258#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
259#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared
260
261#endif /* __XEN_PUBLIC_PHYSDEV_H__ */