xref: /titanic_50/usr/src/uts/common/xen/public/physdev.h (revision 275c9da86e89f8abf71135cf63d9fc23671b2e60)
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  * Query the status of an IRQ line.
45  * @arg == pointer to physdev_irq_status_query structure.
46  */
47 #define PHYSDEVOP_irq_status_query       5
48 struct physdev_irq_status_query {
49     /* IN */
50     uint32_t irq;
51     /* OUT */
52     uint32_t flags; /* XENIRQSTAT_* */
53 };
54 typedef struct physdev_irq_status_query physdev_irq_status_query_t;
55 DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
56 
57 /* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
58 #define _XENIRQSTAT_needs_eoi   (0)
59 #define  XENIRQSTAT_needs_eoi   (1U<<_XENIRQSTAT_needs_eoi)
60 
61 /* IRQ shared by multiple guests? */
62 #define _XENIRQSTAT_shared      (1)
63 #define  XENIRQSTAT_shared      (1U<<_XENIRQSTAT_shared)
64 
65 /*
66  * Set the current VCPU's I/O privilege level.
67  * @arg == pointer to physdev_set_iopl structure.
68  */
69 #define PHYSDEVOP_set_iopl               6
70 struct physdev_set_iopl {
71     /* IN */
72     uint32_t iopl;
73 };
74 typedef struct physdev_set_iopl physdev_set_iopl_t;
75 DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
76 
77 /*
78  * Set the current VCPU's I/O-port permissions bitmap.
79  * @arg == pointer to physdev_set_iobitmap structure.
80  */
81 #define PHYSDEVOP_set_iobitmap           7
82 struct physdev_set_iobitmap {
83     /* IN */
84     XEN_GUEST_HANDLE_00030205(uint8_t) bitmap;
85     uint32_t nr_ports;
86 };
87 typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
88 DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
89 
90 /*
91  * Read or write an IO-APIC register.
92  * @arg == pointer to physdev_apic structure.
93  */
94 #define PHYSDEVOP_apic_read              8
95 #define PHYSDEVOP_apic_write             9
96 struct physdev_apic {
97     /* IN */
98     unsigned long apic_physbase;
99     uint32_t reg;
100     /* IN or OUT */
101     uint32_t value;
102 };
103 typedef struct physdev_apic physdev_apic_t;
104 DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
105 
106 /*
107  * Allocate or free a physical upcall vector for the specified IRQ line.
108  * @arg == pointer to physdev_irq structure.
109  */
110 #define PHYSDEVOP_alloc_irq_vector      10
111 #define PHYSDEVOP_free_irq_vector       11
112 struct physdev_irq {
113     /* IN */
114     uint32_t irq;
115     /* IN or OUT */
116     uint32_t vector;
117 };
118 typedef struct physdev_irq physdev_irq_t;
119 DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
120 
121 /*
122  * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
123  * hypercall since 0x00030202.
124  */
125 struct physdev_op {
126     uint32_t cmd;
127     union {
128         struct physdev_irq_status_query      irq_status_query;
129         struct physdev_set_iopl              set_iopl;
130         struct physdev_set_iobitmap          set_iobitmap;
131         struct physdev_apic                  apic_op;
132         struct physdev_irq                   irq_op;
133     } u;
134 };
135 typedef struct physdev_op physdev_op_t;
136 DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
137 
138 /*
139  * Notify that some PIRQ-bound event channels have been unmasked.
140  * ** This command is obsolete since interface version 0x00030202 and is **
141  * ** unsupported by newer versions of Xen.                              **
142  */
143 #define PHYSDEVOP_IRQ_UNMASK_NOTIFY      4
144 
145 /*
146  * These all-capitals physdev operation names are superceded by the new names
147  * (defined above) since interface version 0x00030202.
148  */
149 #define PHYSDEVOP_IRQ_STATUS_QUERY       PHYSDEVOP_irq_status_query
150 #define PHYSDEVOP_SET_IOPL               PHYSDEVOP_set_iopl
151 #define PHYSDEVOP_SET_IOBITMAP           PHYSDEVOP_set_iobitmap
152 #define PHYSDEVOP_APIC_READ              PHYSDEVOP_apic_read
153 #define PHYSDEVOP_APIC_WRITE             PHYSDEVOP_apic_write
154 #define PHYSDEVOP_ASSIGN_VECTOR          PHYSDEVOP_alloc_irq_vector
155 #define PHYSDEVOP_FREE_VECTOR            PHYSDEVOP_free_irq_vector
156 #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
157 #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
158 
159 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
160 
161 /*
162  * Local variables:
163  * mode: C
164  * c-set-style: "BSD"
165  * c-basic-offset: 4
166  * tab-width: 4
167  * indent-tabs-mode: nil
168  * End:
169  */
170