/******************************************************************************1* gntdev.h2*3* Interface to /dev/xen/gntdev.4*5* Copyright (c) 2007, D G Murray6*7* This program is free software; you can redistribute it and/or8* modify it under the terms of the GNU General Public License version 29* as published by the Free Software Foundation; or, when distributed10* separately from the Linux kernel or incorporated into other11* software packages, subject to the following license:12*13* Permission is hereby granted, free of charge, to any person obtaining a copy14* of this source file (the "Software"), to deal in the Software without15* restriction, including without limitation the rights to use, copy, modify,16* merge, publish, distribute, sublicense, and/or sell copies of the Software,17* and to permit persons to whom the Software is furnished to do so, subject to18* the following conditions:19*20* The above copyright notice and this permission notice shall be included in21* all copies or substantial portions of the Software.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR24* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,25* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE26* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER27* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING28* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS29* IN THE SOFTWARE.30*/3132#ifndef __LINUX_PUBLIC_GNTDEV_H__33#define __LINUX_PUBLIC_GNTDEV_H__3435struct ioctl_gntdev_grant_ref {36/* The domain ID of the grant to be mapped. */37uint32_t domid;38/* The grant reference of the grant to be mapped. */39uint32_t ref;40};4142/*43* Inserts the grant references into the mapping table of an instance44* of gntdev. N.B. This does not perform the mapping, which is deferred45* until mmap() is called with @index as the offset.46*/47#define IOCTL_GNTDEV_MAP_GRANT_REF \48_IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))49struct ioctl_gntdev_map_grant_ref {50/* IN parameters */51/* The number of grants to be mapped. */52uint32_t count;53uint32_t pad;54/* OUT parameters */55/* The offset to be used on a subsequent call to mmap(). */56uint64_t index;57/* Variable IN parameter. */58/* Array of grant references, of size @count. */59struct ioctl_gntdev_grant_ref refs[1];60};6162/*63* Removes the grant references from the mapping table of an instance of64* of gntdev. N.B. munmap() must be called on the relevant virtual address(es)65* before this ioctl is called, or an error will result.66*/67#define IOCTL_GNTDEV_UNMAP_GRANT_REF \68_IOC(_IOC_NONE, 'G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref))69struct ioctl_gntdev_unmap_grant_ref {70/* IN parameters */71/* The offset was returned by the corresponding map operation. */72uint64_t index;73/* The number of pages to be unmapped. */74uint32_t count;75uint32_t pad;76};7778/*79* Returns the offset in the driver's address space that corresponds80* to @vaddr. This can be used to perform a munmap(), followed by an81* UNMAP_GRANT_REF ioctl, where no state about the offset is retained by82* the caller. The number of pages that were allocated at the same time as83* @vaddr is returned in @count.84*85* N.B. Where more than one page has been mapped into a contiguous range, the86* supplied @vaddr must correspond to the start of the range; otherwise87* an error will result. It is only possible to munmap() the entire88* contiguously-allocated range at once, and not any subrange thereof.89*/90#define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \91_IOC(_IOC_NONE, 'G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr))92struct ioctl_gntdev_get_offset_for_vaddr {93/* IN parameters */94/* The virtual address of the first mapped page in a range. */95uint64_t vaddr;96/* OUT parameters */97/* The offset that was used in the initial mmap() operation. */98uint64_t offset;99/* The number of pages mapped in the VM area that begins at @vaddr. */100uint32_t count;101uint32_t pad;102};103104/*105* Sets the maximum number of grants that may mapped at once by this gntdev106* instance.107*108* N.B. This must be called before any other ioctl is performed on the device.109*/110#define IOCTL_GNTDEV_SET_MAX_GRANTS \111_IOC(_IOC_NONE, 'G', 3, sizeof(struct ioctl_gntdev_set_max_grants))112struct ioctl_gntdev_set_max_grants {113/* IN parameter */114/* The maximum number of grants that may be mapped at once. */115uint32_t count;116};117118/*119* Sets up an unmap notification within the page, so that the other side can do120* cleanup if this side crashes. Required to implement cross-domain robust121* mutexes or close notification on communication channels.122*123* Each mapped page only supports one notification; multiple calls referring to124* the same page overwrite the previous notification. You must clear the125* notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it126* to occur.127*/128#define IOCTL_GNTDEV_SET_UNMAP_NOTIFY \129_IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntdev_unmap_notify))130struct ioctl_gntdev_unmap_notify {131/* IN parameters */132/* Offset in the file descriptor for a byte within the page (same as133* used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to134* be cleared. Otherwise, it can be any byte in the page whose135* notification we are adjusting.136*/137uint64_t index;138/* Action(s) to take on unmap */139uint32_t action;140/* Event channel to notify */141uint32_t event_channel_port;142};143144/* Clear (set to zero) the byte specified by index */145#define UNMAP_NOTIFY_CLEAR_BYTE 0x1146/* Send an interrupt on the indicated event channel */147#define UNMAP_NOTIFY_SEND_EVENT 0x2148149#endif /* __LINUX_PUBLIC_GNTDEV_H__ */150151152