gntalloc.h 2.6 KB

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