]> code.delx.au - pulseaudio/blob - src/modules/xen/gntdev.h
xen: Add Xen paravirtualized sink support.
[pulseaudio] / src / modules / xen / gntdev.h
1 /*
2 * This file is copied from the linux kernel headers. It defines the standard
3 * interface to the xen/gntdev device.
4 *
5 */
6
7 /******************************************************************************
8 * gntdev.h
9 *
10 * Interface to /dev/xen/gntdev.
11 *
12 * Copyright (c) 2007, D G Murray
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation; or, when distributed
17 * separately from the Linux kernel or incorporated into other
18 * software packages, subject to the following license:
19 *
20 * Permission is hereby granted, free of charge, to any person obtaining a copy
21 * of this source file (the "Software"), to deal in the Software without
22 * restriction, including without limitation the rights to use, copy, modify,
23 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
24 * and to permit persons to whom the Software is furnished to do so, subject to
25 * the following conditions:
26 *
27 * The above copyright notice and this permission notice shall be included in
28 * all copies or substantial portions of the Software.
29 *
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
36 * IN THE SOFTWARE.
37 */
38
39 #ifndef __LINUX_PUBLIC_GNTDEV_H__
40 #define __LINUX_PUBLIC_GNTDEV_H__
41
42 struct ioctl_gntdev_grant_ref {
43 /* The domain ID of the grant to be mapped. */
44 uint32_t domid;
45 /* The grant reference of the grant to be mapped. */
46 uint32_t ref;
47 };
48
49 /*
50 * Inserts the grant references into the mapping table of an instance
51 * of gntdev. N.B. This does not perform the mapping, which is deferred
52 * until mmap() is called with @index as the offset.
53 */
54 #define IOCTL_GNTDEV_MAP_GRANT_REF \
55 _IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
56 struct ioctl_gntdev_map_grant_ref {
57 /* IN parameters */
58 /* The number of grants to be mapped. */
59 uint32_t count;
60 uint32_t pad;
61 /* OUT parameters */
62 /* The offset to be used on a subsequent call to mmap(). */
63 uint64_t index;
64 /* Variable IN parameter. */
65 /* Array of grant references, of size @count. */
66 struct ioctl_gntdev_grant_ref refs[1];
67 };
68
69 /*
70 * Removes the grant references from the mapping table of an instance of
71 * of gntdev. N.B. munmap() must be called on the relevant virtual address(es)
72 * before this ioctl is called, or an error will result.
73 */
74 #define IOCTL_GNTDEV_UNMAP_GRANT_REF \
75 _IOC(_IOC_NONE, 'G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref))
76 struct ioctl_gntdev_unmap_grant_ref {
77 /* IN parameters */
78 /* The offset was returned by the corresponding map operation. */
79 uint64_t index;
80 /* The number of pages to be unmapped. */
81 uint32_t count;
82 uint32_t pad;
83 };
84
85 /*
86 * Returns the offset in the driver's address space that corresponds
87 * to @vaddr. This can be used to perform a munmap(), followed by an
88 * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by
89 * the caller. The number of pages that were allocated at the same time as
90 * @vaddr is returned in @count.
91 *
92 * N.B. Where more than one page has been mapped into a contiguous range, the
93 * supplied @vaddr must correspond to the start of the range; otherwise
94 * an error will result. It is only possible to munmap() the entire
95 * contiguously-allocated range at once, and not any subrange thereof.
96 */
97 #define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \
98 _IOC(_IOC_NONE, 'G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr))
99 struct ioctl_gntdev_get_offset_for_vaddr {
100 /* IN parameters */
101 /* The virtual address of the first mapped page in a range. */
102 uint64_t vaddr;
103 /* OUT parameters */
104 /* The offset that was used in the initial mmap() operation. */
105 uint64_t offset;
106 /* The number of pages mapped in the VM area that begins at @vaddr. */
107 uint32_t count;
108 uint32_t pad;
109 };
110
111 /*
112 * Sets the maximum number of grants that may mapped at once by this gntdev
113 * instance.
114 *
115 * N.B. This must be called before any other ioctl is performed on the device.
116 */
117 #define IOCTL_GNTDEV_SET_MAX_GRANTS \
118 _IOC(_IOC_NONE, 'G', 3, sizeof(struct ioctl_gntdev_set_max_grants))
119 struct ioctl_gntdev_set_max_grants {
120 /* IN parameter */
121 /* The maximum number of grants that may be mapped at once. */
122 uint32_t count;
123 };
124
125 /*
126 * Sets up an unmap notification within the page, so that the other side can do
127 * cleanup if this side crashes. Required to implement cross-domain robust
128 * mutexes or close notification on communication channels.
129 *
130 * Each mapped page only supports one notification; multiple calls referring to
131 * the same page overwrite the previous notification. You must clear the
132 * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it
133 * to occur.
134 */
135 #define IOCTL_GNTDEV_SET_UNMAP_NOTIFY \
136 _IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntdev_unmap_notify))
137 struct ioctl_gntdev_unmap_notify {
138 /* IN parameters */
139 /* Offset in the file descriptor for a byte within the page (same as
140 * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to
141 * be cleared. Otherwise, it can be any byte in the page whose
142 * notification we are adjusting.
143 */
144 uint64_t index;
145 /* Action(s) to take on unmap */
146 uint32_t action;
147 /* Event channel to notify */
148 uint32_t event_channel_port;
149 };
150
151 /* Clear (set to zero) the byte specified by index */
152 #define UNMAP_NOTIFY_CLEAR_BYTE 0x1
153 /* Send an interrupt on the indicated event channel */
154 #define UNMAP_NOTIFY_SEND_EVENT 0x2
155
156 #endif /* __LINUX_PUBLIC_GNTDEV_H__ */