148198f2aScegger /****************************************************************************** 248198f2aScegger * gntdev.h 348198f2aScegger * 448198f2aScegger * Interface to /dev/xen/gntdev. 548198f2aScegger * 648198f2aScegger * Copyright (c) 2007, D G Murray 748198f2aScegger * 848198f2aScegger * This program is free software; you can redistribute it and/or 948198f2aScegger * modify it under the terms of the GNU General Public License version 2 1048198f2aScegger * as published by the Free Software Foundation; or, when distributed 1148198f2aScegger * separately from the Linux kernel or incorporated into other 1248198f2aScegger * software packages, subject to the following license: 1348198f2aScegger * 1448198f2aScegger * Permission is hereby granted, free of charge, to any person obtaining a copy 1548198f2aScegger * of this source file (the "Software"), to deal in the Software without 1648198f2aScegger * restriction, including without limitation the rights to use, copy, modify, 1748198f2aScegger * merge, publish, distribute, sublicense, and/or sell copies of the Software, 1848198f2aScegger * and to permit persons to whom the Software is furnished to do so, subject to 1948198f2aScegger * the following conditions: 2048198f2aScegger * 2148198f2aScegger * The above copyright notice and this permission notice shall be included in 2248198f2aScegger * all copies or substantial portions of the Software. 2348198f2aScegger * 2448198f2aScegger * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2548198f2aScegger * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2648198f2aScegger * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2748198f2aScegger * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2848198f2aScegger * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2948198f2aScegger * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 3048198f2aScegger * IN THE SOFTWARE. 3148198f2aScegger */ 3248198f2aScegger 3348198f2aScegger #ifndef __XEN_GNTDEV_H__ 3448198f2aScegger #define __XEN_GNTDEV_H__ 3548198f2aScegger 36*25d3b9e7Sdholland #include <sys/ioccom.h> 37*25d3b9e7Sdholland 3848198f2aScegger struct ioctl_gntdev_grant_ref { 3948198f2aScegger /* The domain ID of the grant to be mapped. */ 4048198f2aScegger uint32_t domid; 4148198f2aScegger /* The grant reference of the grant to be mapped. */ 4248198f2aScegger uint32_t ref; 4348198f2aScegger }; 4448198f2aScegger 4548198f2aScegger /* 4648198f2aScegger * Inserts the grant references into the mapping table of an instance 4748198f2aScegger * of gntdev. N.B. This does not perform the mapping, which is deferred 4848198f2aScegger * until mmap() is called with @index as the offset. 4948198f2aScegger */ 5048198f2aScegger #define IOCTL_GNTDEV_MAP_GRANT_REF \ 5148198f2aScegger _IOWR('G', 0, sizeof(struct ioctl_gntdev_map_grant_ref)) 5248198f2aScegger struct ioctl_gntdev_map_grant_ref { 5348198f2aScegger /* IN parameters */ 5448198f2aScegger /* The number of grants to be mapped. */ 5548198f2aScegger uint32_t count; 5648198f2aScegger uint32_t pad; 5748198f2aScegger /* OUT parameters */ 5848198f2aScegger /* The offset to be used on a subsequent call to mmap(). */ 5948198f2aScegger uint64_t index; 6048198f2aScegger /* Variable IN parameter. */ 6148198f2aScegger /* Array of grant references, of size @count. */ 6248198f2aScegger struct ioctl_gntdev_grant_ref refs[1]; 6348198f2aScegger }; 6448198f2aScegger 6548198f2aScegger /* 6648198f2aScegger * Removes the grant references from the mapping table of an instance of 6748198f2aScegger * of gntdev. N.B. munmap() must be called on the relevant virtual address(es) 6848198f2aScegger * before this ioctl is called, or an error will result. 6948198f2aScegger */ 7048198f2aScegger #define IOCTL_GNTDEV_UNMAP_GRANT_REF \ 7148198f2aScegger _IOW('G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref)) 7248198f2aScegger struct ioctl_gntdev_unmap_grant_ref { 7348198f2aScegger /* IN parameters */ 7448198f2aScegger /* The offset was returned by the corresponding map operation. */ 7548198f2aScegger uint64_t index; 7648198f2aScegger /* The number of pages to be unmapped. */ 7748198f2aScegger uint32_t count; 7848198f2aScegger uint32_t pad; 7948198f2aScegger }; 8048198f2aScegger 8148198f2aScegger /* 8248198f2aScegger * Returns the offset in the driver's address space that corresponds 8348198f2aScegger * to @vaddr. This can be used to perform a munmap(), followed by an 8448198f2aScegger * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by 8548198f2aScegger * the caller. The number of pages that were allocated at the same time as 8648198f2aScegger * @vaddr is returned in @count. 8748198f2aScegger * 8848198f2aScegger * N.B. Where more than one page has been mapped into a contiguous range, the 8948198f2aScegger * supplied @vaddr must correspond to the start of the range; otherwise 9048198f2aScegger * an error will result. It is only possible to munmap() the entire 9148198f2aScegger * contiguously-allocated range at once, and not any subrange thereof. 9248198f2aScegger */ 9348198f2aScegger #define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \ 9448198f2aScegger _IOWR('G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr)) 9548198f2aScegger struct ioctl_gntdev_get_offset_for_vaddr { 9648198f2aScegger /* IN parameters */ 9748198f2aScegger /* The virtual address of the first mapped page in a range. */ 9848198f2aScegger uint64_t vaddr; 9948198f2aScegger /* OUT parameters */ 10048198f2aScegger /* The offset that was used in the initial mmap() operation. */ 10148198f2aScegger uint64_t offset; 10248198f2aScegger /* The number of pages mapped in the VM area that begins at @vaddr. */ 10348198f2aScegger uint32_t count; 10448198f2aScegger uint32_t pad; 10548198f2aScegger }; 10648198f2aScegger 10748198f2aScegger /* 10848198f2aScegger * Sets the maximum number of grants that may mapped at once by this gntdev 10948198f2aScegger * instance. 11048198f2aScegger * 11148198f2aScegger * N.B. This must be called before any other ioctl is performed on the device. 11248198f2aScegger */ 11348198f2aScegger #define IOCTL_GNTDEV_SET_MAX_GRANTS \ 11448198f2aScegger _IOW('G', 3, sizeof(struct ioctl_gntdev_set_max_grants)) 11548198f2aScegger struct ioctl_gntdev_set_max_grants { 11648198f2aScegger /* IN parameter */ 11748198f2aScegger /* The maximum number of grants that may be mapped at once. */ 11848198f2aScegger uint32_t count; 11948198f2aScegger }; 12048198f2aScegger 12148198f2aScegger #endif /* __XEN_GNTDEV_H__ */ 122