gntalloc.h 2.6 KB

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