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