Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * gntalloc.h |
| 3 | * |
| 4 | * Interface to /dev/xen/gntalloc. |
| 5 | * |
| 6 | * Author: Daniel De Graaf <dgdegra@tycho.nsa.gov> |
| 7 | * |
| 8 | * This file is in the public domain. |
| 9 | */ |
| 10 | |
| 11 | #ifndef __LINUX_PUBLIC_GNTALLOC_H__ |
| 12 | #define __LINUX_PUBLIC_GNTALLOC_H__ |
| 13 | |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 14 | #include <linux/types.h> |
| 15 | |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 16 | /* |
| 17 | * Allocates a new page and creates a new grant reference. |
| 18 | */ |
| 19 | #define IOCTL_GNTALLOC_ALLOC_GREF \ |
| 20 | _IOC(_IOC_NONE, 'G', 5, sizeof(struct ioctl_gntalloc_alloc_gref)) |
| 21 | struct ioctl_gntalloc_alloc_gref { |
| 22 | /* IN parameters */ |
| 23 | /* The ID of the domain to be given access to the grants. */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 24 | __u16 domid; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 25 | /* Flags for this mapping */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 26 | __u16 flags; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 27 | /* Number of pages to map */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 28 | __u32 count; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 29 | /* OUT parameters */ |
| 30 | /* The offset to be used on a subsequent call to mmap(). */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 31 | __u64 index; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 32 | /* The grant references of the newly created grant, one per page */ |
| 33 | /* Variable size, depending on count */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 34 | __u32 gref_ids[1]; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | #define GNTALLOC_FLAG_WRITABLE 1 |
| 38 | |
| 39 | /* |
| 40 | * Deallocates the grant reference, allowing the associated page to be freed if |
| 41 | * no other domains are using it. |
| 42 | */ |
| 43 | #define IOCTL_GNTALLOC_DEALLOC_GREF \ |
| 44 | _IOC(_IOC_NONE, 'G', 6, sizeof(struct ioctl_gntalloc_dealloc_gref)) |
| 45 | struct ioctl_gntalloc_dealloc_gref { |
| 46 | /* IN parameters */ |
| 47 | /* The offset returned in the map operation */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 48 | __u64 index; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 49 | /* Number of references to unmap */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 50 | __u32 count; |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 51 | }; |
Daniel De Graaf | bdc612d | 2011-02-03 12:19:04 -0500 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * Sets up an unmap notification within the page, so that the other side can do |
| 55 | * cleanup if this side crashes. Required to implement cross-domain robust |
| 56 | * mutexes or close notification on communication channels. |
| 57 | * |
| 58 | * Each mapped page only supports one notification; multiple calls referring to |
| 59 | * the same page overwrite the previous notification. You must clear the |
| 60 | * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it |
| 61 | * to occur. |
| 62 | */ |
| 63 | #define IOCTL_GNTALLOC_SET_UNMAP_NOTIFY \ |
| 64 | _IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntalloc_unmap_notify)) |
| 65 | struct ioctl_gntalloc_unmap_notify { |
| 66 | /* IN parameters */ |
| 67 | /* Offset in the file descriptor for a byte within the page (same as |
| 68 | * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to |
| 69 | * be cleared. Otherwise, it can be any byte in the page whose |
| 70 | * notification we are adjusting. |
| 71 | */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 72 | __u64 index; |
Daniel De Graaf | bdc612d | 2011-02-03 12:19:04 -0500 | [diff] [blame] | 73 | /* Action(s) to take on unmap */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 74 | __u32 action; |
Daniel De Graaf | bdc612d | 2011-02-03 12:19:04 -0500 | [diff] [blame] | 75 | /* Event channel to notify */ |
Mikko Rapeli | 91afb7c | 2015-10-15 07:56:07 +0200 | [diff] [blame] | 76 | __u32 event_channel_port; |
Daniel De Graaf | bdc612d | 2011-02-03 12:19:04 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | /* Clear (set to zero) the byte specified by index */ |
| 80 | #define UNMAP_NOTIFY_CLEAR_BYTE 0x1 |
| 81 | /* Send an interrupt on the indicated event channel */ |
| 82 | #define UNMAP_NOTIFY_SEND_EVENT 0x2 |
| 83 | |
Daniel De Graaf | dd31405 | 2011-02-07 17:23:05 -0500 | [diff] [blame] | 84 | #endif /* __LINUX_PUBLIC_GNTALLOC_H__ */ |