#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/dma-buf.h>
#include <linux/dma-direct.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/module.h>
#include <xen/xen.h>
#include <xen/grant_table.h>
#include "gntdev-common.h"
#include "gntdev-dmabuf.h"
MODULE_IMPORT_NS(…);
struct gntdev_dmabuf { … };
struct gntdev_dmabuf_wait_obj { … };
struct gntdev_dmabuf_attachment { … };
struct gntdev_dmabuf_priv { … };
static void dmabuf_exp_release(struct kref *kref);
static struct gntdev_dmabuf_wait_obj *
dmabuf_exp_wait_obj_new(struct gntdev_dmabuf_priv *priv,
struct gntdev_dmabuf *gntdev_dmabuf)
{ … }
static void dmabuf_exp_wait_obj_free(struct gntdev_dmabuf_priv *priv,
struct gntdev_dmabuf_wait_obj *obj)
{ … }
static int dmabuf_exp_wait_obj_wait(struct gntdev_dmabuf_wait_obj *obj,
u32 wait_to_ms)
{ … }
static void dmabuf_exp_wait_obj_signal(struct gntdev_dmabuf_priv *priv,
struct gntdev_dmabuf *gntdev_dmabuf)
{ … }
static struct gntdev_dmabuf *
dmabuf_exp_wait_obj_get_dmabuf(struct gntdev_dmabuf_priv *priv, int fd)
{ … }
static int dmabuf_exp_wait_released(struct gntdev_dmabuf_priv *priv, int fd,
int wait_to_ms)
{ … }
static struct sg_table *
dmabuf_pages_to_sgt(struct page **pages, unsigned int nr_pages)
{ … }
static int dmabuf_exp_ops_attach(struct dma_buf *dma_buf,
struct dma_buf_attachment *attach)
{ … }
static void dmabuf_exp_ops_detach(struct dma_buf *dma_buf,
struct dma_buf_attachment *attach)
{ … }
static struct sg_table *
dmabuf_exp_ops_map_dma_buf(struct dma_buf_attachment *attach,
enum dma_data_direction dir)
{ … }
static void dmabuf_exp_ops_unmap_dma_buf(struct dma_buf_attachment *attach,
struct sg_table *sgt,
enum dma_data_direction dir)
{ … }
static void dmabuf_exp_release(struct kref *kref)
{ … }
static void dmabuf_exp_remove_map(struct gntdev_priv *priv,
struct gntdev_grant_map *map)
{ … }
static void dmabuf_exp_ops_release(struct dma_buf *dma_buf)
{ … }
static const struct dma_buf_ops dmabuf_exp_ops = …;
struct gntdev_dmabuf_export_args { … };
static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
{ … }
static struct gntdev_grant_map *
dmabuf_exp_alloc_backing_storage(struct gntdev_priv *priv, int dmabuf_flags,
int count)
{ … }
static int dmabuf_exp_from_refs(struct gntdev_priv *priv, int flags,
int count, u32 domid, u32 *refs, u32 *fd)
{ … }
static int
dmabuf_imp_grant_foreign_access(unsigned long *gfns, u32 *refs,
int count, int domid)
{ … }
static void dmabuf_imp_end_foreign_access(u32 *refs, int count)
{ … }
static void dmabuf_imp_free_storage(struct gntdev_dmabuf *gntdev_dmabuf)
{ … }
static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count)
{ … }
static struct gntdev_dmabuf *
dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev,
int fd, int count, int domid)
{ … }
static struct gntdev_dmabuf *
dmabuf_imp_find_unlink(struct gntdev_dmabuf_priv *priv, int fd)
{ … }
static int dmabuf_imp_release(struct gntdev_dmabuf_priv *priv, u32 fd)
{ … }
static void dmabuf_imp_release_all(struct gntdev_dmabuf_priv *priv)
{ … }
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
struct ioctl_gntdev_dmabuf_exp_from_refs __user *u)
{ … }
long gntdev_ioctl_dmabuf_exp_wait_released(struct gntdev_priv *priv,
struct ioctl_gntdev_dmabuf_exp_wait_released __user *u)
{ … }
long gntdev_ioctl_dmabuf_imp_to_refs(struct gntdev_priv *priv,
struct ioctl_gntdev_dmabuf_imp_to_refs __user *u)
{ … }
long gntdev_ioctl_dmabuf_imp_release(struct gntdev_priv *priv,
struct ioctl_gntdev_dmabuf_imp_release __user *u)
{ … }
struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp)
{ … }
void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv)
{ … }