gasket.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Common Gasket device kernel and user space declarations.
  4. *
  5. * Copyright (C) 2018 Google, Inc.
  6. */
  7. #ifndef __GASKET_H__
  8. #define __GASKET_H__
  9. #include <linux/ioctl.h>
  10. #include <linux/types.h>
  11. /* ioctl structure declarations */
  12. /* Ioctl structures are padded to a multiple of 64 bits */
  13. /* and padded to put 64 bit values on 64 bit boundaries. */
  14. /* Unsigned 64 bit integers are used to hold pointers. */
  15. /* This helps compatibility between 32 and 64 bits. */
  16. /*
  17. * Common structure for ioctls associating an eventfd with a device interrupt,
  18. * when using the Gasket interrupt module.
  19. */
  20. struct gasket_interrupt_eventfd {
  21. u64 interrupt;
  22. u64 event_fd;
  23. };
  24. /*
  25. * Common structure for ioctls mapping and unmapping buffers when using the
  26. * Gasket page_table module.
  27. */
  28. struct gasket_page_table_ioctl {
  29. u64 page_table_index;
  30. u64 size;
  31. u64 host_address;
  32. u64 device_address;
  33. };
  34. /*
  35. * Common structure for ioctls mapping and unmapping buffers when using the
  36. * Gasket page_table module.
  37. * dma_address: phys addr start of coherent memory, allocated by kernel
  38. */
  39. struct gasket_coherent_alloc_config_ioctl {
  40. u64 page_table_index;
  41. u64 enable;
  42. u64 size;
  43. u64 dma_address;
  44. };
  45. /* Base number for all Gasket-common IOCTLs */
  46. #define GASKET_IOCTL_BASE 0xDC
  47. /* Reset the device. */
  48. #define GASKET_IOCTL_RESET _IO(GASKET_IOCTL_BASE, 0)
  49. /* Associate the specified [event]fd with the specified interrupt. */
  50. #define GASKET_IOCTL_SET_EVENTFD \
  51. _IOW(GASKET_IOCTL_BASE, 1, struct gasket_interrupt_eventfd)
  52. /*
  53. * Clears any eventfd associated with the specified interrupt. The (ulong)
  54. * argument is the interrupt number to clear.
  55. */
  56. #define GASKET_IOCTL_CLEAR_EVENTFD _IOW(GASKET_IOCTL_BASE, 2, unsigned long)
  57. /*
  58. * [Loopbacks only] Requests that the loopback device send the specified
  59. * interrupt to the host. The (ulong) argument is the number of the interrupt to
  60. * send.
  61. */
  62. #define GASKET_IOCTL_LOOPBACK_INTERRUPT \
  63. _IOW(GASKET_IOCTL_BASE, 3, unsigned long)
  64. /* Queries the kernel for the number of page tables supported by the device. */
  65. #define GASKET_IOCTL_NUMBER_PAGE_TABLES _IOR(GASKET_IOCTL_BASE, 4, u64)
  66. /*
  67. * Queries the kernel for the maximum size of the page table. Only the size and
  68. * page_table_index fields are used from the struct gasket_page_table_ioctl.
  69. */
  70. #define GASKET_IOCTL_PAGE_TABLE_SIZE \
  71. _IOWR(GASKET_IOCTL_BASE, 5, struct gasket_page_table_ioctl)
  72. /*
  73. * Queries the kernel for the current simple page table size. Only the size and
  74. * page_table_index fields are used from the struct gasket_page_table_ioctl.
  75. */
  76. #define GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE \
  77. _IOWR(GASKET_IOCTL_BASE, 6, struct gasket_page_table_ioctl)
  78. /*
  79. * Tells the kernel to change the split between the number of simple and
  80. * extended entries in the given page table. Only the size and page_table_index
  81. * fields are used from the struct gasket_page_table_ioctl.
  82. */
  83. #define GASKET_IOCTL_PARTITION_PAGE_TABLE \
  84. _IOW(GASKET_IOCTL_BASE, 7, struct gasket_page_table_ioctl)
  85. /*
  86. * Tells the kernel to map size bytes at host_address to device_address in
  87. * page_table_index page table.
  88. */
  89. #define GASKET_IOCTL_MAP_BUFFER \
  90. _IOW(GASKET_IOCTL_BASE, 8, struct gasket_page_table_ioctl)
  91. /*
  92. * Tells the kernel to unmap size bytes at host_address from device_address in
  93. * page_table_index page table.
  94. */
  95. #define GASKET_IOCTL_UNMAP_BUFFER \
  96. _IOW(GASKET_IOCTL_BASE, 9, struct gasket_page_table_ioctl)
  97. /* Clear the interrupt counts stored for this device. */
  98. #define GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS _IO(GASKET_IOCTL_BASE, 10)
  99. /* Enable/Disable and configure the coherent allocator. */
  100. #define GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR \
  101. _IOWR(GASKET_IOCTL_BASE, 11, struct gasket_coherent_alloc_config_ioctl)
  102. #endif /* __GASKET_H__ */