1 1.1 cegger /****************************************************************************** 2 1.1 cegger * gntdev.h 3 1.1 cegger * 4 1.1 cegger * Interface to /dev/xen/gntdev. 5 1.1 cegger * 6 1.1 cegger * Copyright (c) 2007, D G Murray 7 1.1 cegger * 8 1.1 cegger * This program is free software; you can redistribute it and/or 9 1.1 cegger * modify it under the terms of the GNU General Public License version 2 10 1.1 cegger * as published by the Free Software Foundation; or, when distributed 11 1.1 cegger * separately from the Linux kernel or incorporated into other 12 1.1 cegger * software packages, subject to the following license: 13 1.1 cegger * 14 1.1 cegger * Permission is hereby granted, free of charge, to any person obtaining a copy 15 1.1 cegger * of this source file (the "Software"), to deal in the Software without 16 1.1 cegger * restriction, including without limitation the rights to use, copy, modify, 17 1.1 cegger * merge, publish, distribute, sublicense, and/or sell copies of the Software, 18 1.1 cegger * and to permit persons to whom the Software is furnished to do so, subject to 19 1.1 cegger * the following conditions: 20 1.1 cegger * 21 1.1 cegger * The above copyright notice and this permission notice shall be included in 22 1.1 cegger * all copies or substantial portions of the Software. 23 1.1 cegger * 24 1.1 cegger * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 1.1 cegger * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 1.1 cegger * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 1.1 cegger * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 1.1 cegger * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 1.1 cegger * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 30 1.1 cegger * IN THE SOFTWARE. 31 1.1 cegger */ 32 1.1 cegger 33 1.1 cegger #ifndef __XEN_GNTDEV_H__ 34 1.1 cegger #define __XEN_GNTDEV_H__ 35 1.1 cegger 36 1.2 dholland #include <sys/ioccom.h> 37 1.2 dholland 38 1.1 cegger struct ioctl_gntdev_grant_ref { 39 1.1 cegger /* The domain ID of the grant to be mapped. */ 40 1.1 cegger uint32_t domid; 41 1.1 cegger /* The grant reference of the grant to be mapped. */ 42 1.1 cegger uint32_t ref; 43 1.1 cegger }; 44 1.1 cegger 45 1.1 cegger /* 46 1.1 cegger * Inserts the grant references into the mapping table of an instance 47 1.1 cegger * of gntdev. N.B. This does not perform the mapping, which is deferred 48 1.1 cegger * until mmap() is called with @index as the offset. 49 1.1 cegger */ 50 1.1 cegger #define IOCTL_GNTDEV_MAP_GRANT_REF \ 51 1.1 cegger _IOWR('G', 0, sizeof(struct ioctl_gntdev_map_grant_ref)) 52 1.1 cegger struct ioctl_gntdev_map_grant_ref { 53 1.1 cegger /* IN parameters */ 54 1.1 cegger /* The number of grants to be mapped. */ 55 1.1 cegger uint32_t count; 56 1.1 cegger uint32_t pad; 57 1.1 cegger /* OUT parameters */ 58 1.1 cegger /* The offset to be used on a subsequent call to mmap(). */ 59 1.1 cegger uint64_t index; 60 1.1 cegger /* Variable IN parameter. */ 61 1.1 cegger /* Array of grant references, of size @count. */ 62 1.1 cegger struct ioctl_gntdev_grant_ref refs[1]; 63 1.1 cegger }; 64 1.1 cegger 65 1.1 cegger /* 66 1.1 cegger * Removes the grant references from the mapping table of an instance of 67 1.1 cegger * of gntdev. N.B. munmap() must be called on the relevant virtual address(es) 68 1.1 cegger * before this ioctl is called, or an error will result. 69 1.1 cegger */ 70 1.1 cegger #define IOCTL_GNTDEV_UNMAP_GRANT_REF \ 71 1.1 cegger _IOW('G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref)) 72 1.1 cegger struct ioctl_gntdev_unmap_grant_ref { 73 1.1 cegger /* IN parameters */ 74 1.1 cegger /* The offset was returned by the corresponding map operation. */ 75 1.1 cegger uint64_t index; 76 1.1 cegger /* The number of pages to be unmapped. */ 77 1.1 cegger uint32_t count; 78 1.1 cegger uint32_t pad; 79 1.1 cegger }; 80 1.1 cegger 81 1.1 cegger /* 82 1.1 cegger * Returns the offset in the driver's address space that corresponds 83 1.1 cegger * to @vaddr. This can be used to perform a munmap(), followed by an 84 1.1 cegger * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by 85 1.1 cegger * the caller. The number of pages that were allocated at the same time as 86 1.1 cegger * @vaddr is returned in @count. 87 1.1 cegger * 88 1.1 cegger * N.B. Where more than one page has been mapped into a contiguous range, the 89 1.1 cegger * supplied @vaddr must correspond to the start of the range; otherwise 90 1.1 cegger * an error will result. It is only possible to munmap() the entire 91 1.1 cegger * contiguously-allocated range at once, and not any subrange thereof. 92 1.1 cegger */ 93 1.1 cegger #define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \ 94 1.1 cegger _IOWR('G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr)) 95 1.1 cegger struct ioctl_gntdev_get_offset_for_vaddr { 96 1.1 cegger /* IN parameters */ 97 1.1 cegger /* The virtual address of the first mapped page in a range. */ 98 1.1 cegger uint64_t vaddr; 99 1.1 cegger /* OUT parameters */ 100 1.1 cegger /* The offset that was used in the initial mmap() operation. */ 101 1.1 cegger uint64_t offset; 102 1.1 cegger /* The number of pages mapped in the VM area that begins at @vaddr. */ 103 1.1 cegger uint32_t count; 104 1.1 cegger uint32_t pad; 105 1.1 cegger }; 106 1.1 cegger 107 1.1 cegger /* 108 1.1 cegger * Sets the maximum number of grants that may mapped at once by this gntdev 109 1.1 cegger * instance. 110 1.1 cegger * 111 1.1 cegger * N.B. This must be called before any other ioctl is performed on the device. 112 1.1 cegger */ 113 1.1 cegger #define IOCTL_GNTDEV_SET_MAX_GRANTS \ 114 1.1 cegger _IOW('G', 3, sizeof(struct ioctl_gntdev_set_max_grants)) 115 1.1 cegger struct ioctl_gntdev_set_max_grants { 116 1.1 cegger /* IN parameter */ 117 1.1 cegger /* The maximum number of grants that may be mapped at once. */ 118 1.1 cegger uint32_t count; 119 1.1 cegger }; 120 1.1 cegger 121 1.1 cegger #endif /* __XEN_GNTDEV_H__ */ 122