0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _GNTDEV_COMMON_H
0012 #define _GNTDEV_COMMON_H
0013
0014 #include <linux/mm.h>
0015 #include <linux/mman.h>
0016 #include <linux/mmu_notifier.h>
0017 #include <linux/types.h>
0018 #include <xen/interface/event_channel.h>
0019 #include <xen/grant_table.h>
0020
0021 struct gntdev_dmabuf_priv;
0022
0023 struct gntdev_priv {
0024
0025 struct list_head maps;
0026
0027 struct mutex lock;
0028
0029 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
0030
0031 struct device *dma_dev;
0032 #endif
0033
0034 #ifdef CONFIG_XEN_GNTDEV_DMABUF
0035 struct gntdev_dmabuf_priv *dmabuf_priv;
0036 #endif
0037 };
0038
0039 struct gntdev_unmap_notify {
0040 int flags;
0041
0042 int addr;
0043 evtchn_port_t event;
0044 };
0045
0046 struct gntdev_grant_map {
0047 struct mmu_interval_notifier notifier;
0048 struct list_head next;
0049 struct vm_area_struct *vma;
0050 int index;
0051 int count;
0052 int flags;
0053 refcount_t users;
0054 struct gntdev_unmap_notify notify;
0055 struct ioctl_gntdev_grant_ref *grants;
0056 struct gnttab_map_grant_ref *map_ops;
0057 struct gnttab_unmap_grant_ref *unmap_ops;
0058 struct gnttab_map_grant_ref *kmap_ops;
0059 struct gnttab_unmap_grant_ref *kunmap_ops;
0060 bool *being_removed;
0061 struct page **pages;
0062 unsigned long pages_vm_start;
0063
0064 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
0065
0066
0067
0068
0069
0070 struct device *dma_dev;
0071
0072 int dma_flags;
0073 void *dma_vaddr;
0074 dma_addr_t dma_bus_addr;
0075
0076 xen_pfn_t *frames;
0077 #endif
0078
0079
0080 atomic_t live_grants;
0081
0082 struct gntab_unmap_queue_data unmap_data;
0083 };
0084
0085 struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
0086 int dma_flags);
0087
0088 void gntdev_add_map(struct gntdev_priv *priv, struct gntdev_grant_map *add);
0089
0090 void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map);
0091
0092 bool gntdev_test_page_count(unsigned int count);
0093
0094 int gntdev_map_grant_pages(struct gntdev_grant_map *map);
0095
0096 #endif