xenio.h revision 1.12 1 1.12 bouyer /* $NetBSD: xenio.h,v 1.12 2020/05/26 10:11:56 bouyer Exp $ */
2 1.1 cl
3 1.2 bouyer /******************************************************************************
4 1.2 bouyer * privcmd.h
5 1.2 bouyer *
6 1.2 bouyer * Copyright (c) 2003-2004, K A Fraser
7 1.2 bouyer *
8 1.2 bouyer * This file may be distributed separately from the Linux kernel, or
9 1.2 bouyer * incorporated into other software packages, subject to the following license:
10 1.2 bouyer *
11 1.1 cl * Permission is hereby granted, free of charge, to any person obtaining a copy
12 1.2 bouyer * of this source file (the "Software"), to deal in the Software without
13 1.2 bouyer * restriction, including without limitation the rights to use, copy, modify,
14 1.2 bouyer * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 1.2 bouyer * and to permit persons to whom the Software is furnished to do so, subject to
16 1.2 bouyer * the following conditions:
17 1.1 cl *
18 1.1 cl * The above copyright notice and this permission notice shall be included in
19 1.1 cl * all copies or substantial portions of the Software.
20 1.1 cl *
21 1.2 bouyer * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 1.2 bouyer * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 1.2 bouyer * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 1.2 bouyer * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 1.2 bouyer * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 1.2 bouyer * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 1.2 bouyer * IN THE SOFTWARE.
28 1.1 cl */
29 1.1 cl
30 1.7 cegger #ifndef __XEN_XENIO_H__
31 1.7 cegger #define __XEN_XENIO_H__
32 1.1 cl
33 1.2 bouyer /* Interface to /proc/xen/privcmd */
34 1.1 cl
35 1.10 dholland #include <sys/ioccom.h>
36 1.10 dholland
37 1.10 dholland
38 1.2 bouyer typedef struct privcmd_hypercall
39 1.2 bouyer {
40 1.2 bouyer unsigned long op;
41 1.2 bouyer unsigned long arg[5];
42 1.6 bouyer long retval;
43 1.1 cl } privcmd_hypercall_t;
44 1.1 cl
45 1.2 bouyer typedef struct privcmd_mmap_entry {
46 1.2 bouyer unsigned long va;
47 1.2 bouyer unsigned long mfn;
48 1.2 bouyer unsigned long npages;
49 1.11 msaitoh } privcmd_mmap_entry_t;
50 1.2 bouyer
51 1.2 bouyer typedef struct privcmd_mmap {
52 1.2 bouyer int num;
53 1.2 bouyer domid_t dom; /* target domain */
54 1.2 bouyer privcmd_mmap_entry_t *entry;
55 1.11 msaitoh } privcmd_mmap_t;
56 1.2 bouyer
57 1.2 bouyer typedef struct privcmd_mmapbatch {
58 1.2 bouyer int num; /* number of pages to populate */
59 1.2 bouyer domid_t dom; /* target domain */
60 1.2 bouyer unsigned long addr; /* virtual address */
61 1.2 bouyer unsigned long *arr; /* array of mfns - top nibble set on err */
62 1.11 msaitoh } privcmd_mmapbatch_t;
63 1.2 bouyer
64 1.8 cegger typedef struct privcmd_mmapbatch_v2 {
65 1.8 cegger int num; /* number of pages to populate */
66 1.8 cegger domid_t dom; /* target domain */
67 1.8 cegger uint64_t addr; /* virtual address */
68 1.8 cegger const xen_pfn_t *arr; /* array of mfns */
69 1.8 cegger int *err; /* array of error codes */
70 1.11 msaitoh } privcmd_mmapbatch_v2_t;
71 1.8 cegger
72 1.2 bouyer typedef struct privcmd_blkmsg
73 1.2 bouyer {
74 1.2 bouyer unsigned long op;
75 1.2 bouyer void *buf;
76 1.2 bouyer int buf_size;
77 1.1 cl } privcmd_blkmsg_t;
78 1.1 cl
79 1.2 bouyer /*
80 1.2 bouyer * @cmd: IOCTL_PRIVCMD_HYPERCALL
81 1.2 bouyer * @arg: &privcmd_hypercall_t
82 1.2 bouyer * Return: Value returned from execution of the specified hypercall.
83 1.2 bouyer */
84 1.2 bouyer #define IOCTL_PRIVCMD_HYPERCALL \
85 1.2 bouyer _IOWR('P', 0, privcmd_hypercall_t)
86 1.2 bouyer
87 1.3 yamt #if defined(_KERNEL)
88 1.3 yamt /* compat */
89 1.3 yamt #define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN_OLD \
90 1.2 bouyer _IO('P', 1)
91 1.6 bouyer
92 1.6 bouyer typedef struct oprivcmd_hypercall
93 1.6 bouyer {
94 1.6 bouyer unsigned long op;
95 1.6 bouyer unsigned long arg[5];
96 1.6 bouyer } oprivcmd_hypercall_t;
97 1.6 bouyer
98 1.6 bouyer #define IOCTL_PRIVCMD_HYPERCALL_OLD \
99 1.6 bouyer _IOWR('P', 0, oprivcmd_hypercall_t)
100 1.3 yamt #endif /* defined(_KERNEL) */
101 1.2 bouyer
102 1.2 bouyer #define IOCTL_PRIVCMD_MMAP \
103 1.2 bouyer _IOW('P', 2, privcmd_mmap_t)
104 1.2 bouyer #define IOCTL_PRIVCMD_MMAPBATCH \
105 1.2 bouyer _IOW('P', 3, privcmd_mmapbatch_t)
106 1.2 bouyer #define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \
107 1.4 bouyer _IOR('P', 4, unsigned long)
108 1.2 bouyer
109 1.3 yamt /*
110 1.3 yamt * @cmd: IOCTL_PRIVCMD_INITDOMAIN_EVTCHN
111 1.3 yamt * @arg: n/a
112 1.3 yamt * Return: Port associated with domain-controller end of control event channel
113 1.3 yamt * for the initial domain.
114 1.3 yamt */
115 1.3 yamt #define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN \
116 1.3 yamt _IOR('P', 5, int)
117 1.12 bouyer
118 1.8 cegger #define IOCTL_PRIVCMD_MMAPBATCH_V2 \
119 1.9 cegger _IOW('P', 6, privcmd_mmapbatch_v2_t)
120 1.3 yamt
121 1.12 bouyer /*
122 1.12 bouyer * @cmd: IOCTL_PRIVCMD_MMAP_RESOURCE
123 1.12 bouyer * @arg &privcmd_mmap_resource_t
124 1.12 bouyer * Return:
125 1.12 bouyer * map the specified resource at the provided virtual address
126 1.12 bouyer */
127 1.12 bouyer
128 1.12 bouyer typedef struct privcmd_mmap_resource {
129 1.12 bouyer domid_t dom;
130 1.12 bouyer uint32_t type;
131 1.12 bouyer uint32_t id;
132 1.12 bouyer uint32_t idx;
133 1.12 bouyer uint64_t num;
134 1.12 bouyer uint64_t addr;
135 1.12 bouyer } privcmd_mmap_resource_t;
136 1.12 bouyer
137 1.12 bouyer #define IOCTL_PRIVCMD_MMAP_RESOURCE \
138 1.12 bouyer _IOW('P', 7, privcmd_mmap_resource_t)
139 1.12 bouyer
140 1.12 bouyer /*
141 1.12 bouyer * @cmd: IOCTL_GNTDEV_MMAP_GRANT_REF
142 1.12 bouyer * @arg &ioctl_gntdev_mmap_grant_ref
143 1.12 bouyer * Return:
144 1.12 bouyer * map the grant references at the virtual address provided by caller
145 1.12 bouyer * The grant ref already exists (e.g. comes from a remote domain)
146 1.12 bouyer */
147 1.12 bouyer struct ioctl_gntdev_grant_ref {
148 1.12 bouyer /* The domain ID of the grant to be mapped. */
149 1.12 bouyer uint32_t domid;
150 1.12 bouyer /* The grant reference of the grant to be mapped. */
151 1.12 bouyer uint32_t ref;
152 1.12 bouyer };
153 1.12 bouyer
154 1.12 bouyer struct ioctl_gntdev_grant_notify {
155 1.12 bouyer ssize_t offset;
156 1.12 bouyer uint32_t action;
157 1.12 bouyer uint32_t event_channel_port;
158 1.12 bouyer };
159 1.12 bouyer #define UNMAP_NOTIFY_CLEAR_BYTE 0x1
160 1.12 bouyer #define UNMAP_NOTIFY_SEND_EVENT 0x2
161 1.12 bouyer
162 1.12 bouyer struct ioctl_gntdev_mmap_grant_ref {
163 1.12 bouyer /* The number of grants to be mapped. */
164 1.12 bouyer uint32_t count;
165 1.12 bouyer uint32_t pad;
166 1.12 bouyer /* The virtual address where they should be mapped */
167 1.12 bouyer void *va;
168 1.12 bouyer /* notify action */
169 1.12 bouyer struct ioctl_gntdev_grant_notify notify;
170 1.12 bouyer /* Array of grant references, of size @count. */
171 1.12 bouyer struct ioctl_gntdev_grant_ref *refs;
172 1.12 bouyer };
173 1.12 bouyer
174 1.12 bouyer #define IOCTL_GNTDEV_MMAP_GRANT_REF \
175 1.12 bouyer _IOW('P', 8, struct ioctl_gntdev_mmap_grant_ref)
176 1.12 bouyer
177 1.12 bouyer /*
178 1.12 bouyer * @cmd: IOCTL_GNTDEV_ALLOC_GRANT_REF
179 1.12 bouyer * @arg &ioctl_gntdev_alloc_grant_ref
180 1.12 bouyer * Return:
181 1.12 bouyer * Allocate local memory and grant it to a remote domain.
182 1.12 bouyer * local memory is mmaped at the virtual address provided by caller
183 1.12 bouyer */
184 1.12 bouyer
185 1.12 bouyer struct ioctl_gntdev_alloc_grant_ref {
186 1.12 bouyer /* IN parameters */
187 1.12 bouyer uint16_t domid;
188 1.12 bouyer uint16_t flags;
189 1.12 bouyer uint32_t count;
190 1.12 bouyer void *va;
191 1.12 bouyer /* notify action */
192 1.12 bouyer struct ioctl_gntdev_grant_notify notify;
193 1.12 bouyer /* Variable OUT parameter */
194 1.12 bouyer uint32_t *gref_ids;
195 1.12 bouyer };
196 1.12 bouyer
197 1.12 bouyer #define IOCTL_GNTDEV_ALLOC_GRANT_REF \
198 1.12 bouyer _IOW('P', 9, struct ioctl_gntdev_alloc_grant_ref)
199 1.12 bouyer
200 1.12 bouyer #define GNTDEV_ALLOC_FLAG_WRITABLE 0x01
201 1.12 bouyer
202 1.12 bouyer
203 1.2 bouyer /* Interface to /dev/xenevt */
204 1.2 bouyer /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
205 1.2 bouyer #define EVTCHN_RESET _IO('E', 1)
206 1.2 bouyer /* EVTCHN_BIND: Bind to the specified event-channel port. */
207 1.2 bouyer #define EVTCHN_BIND _IOW('E', 2, unsigned long)
208 1.2 bouyer /* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
209 1.2 bouyer #define EVTCHN_UNBIND _IOW('E', 3, unsigned long)
210 1.1 cl
211 1.7 cegger #endif /* __XEN_XENIO_H__ */
212