#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/cdev.h>
#include <linux/vfio.h>
#include <linux/iommu.h>
#include <linux/sysfs.h>
#include <linux/mdev.h>
#include <linux/pci.h>
#include <drm/drm_fourcc.h>
#include "mdpy-defs.h"
#define MDPY_NAME …
#define MDPY_CLASS_NAME …
#define MDPY_CONFIG_SPACE_SIZE …
#define MDPY_MEMORY_BAR_OFFSET …
#define MDPY_DISPLAY_REGION …
#define STORE_LE16(addr, val) …
#define STORE_LE32(addr, val) …
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
#define MDPY_TYPE_1 …
#define MDPY_TYPE_2 …
#define MDPY_TYPE_3 …
static struct mdpy_type { … } mdpy_types[] = …;
static struct mdev_type *mdpy_mdev_types[] = …;
static dev_t mdpy_devt;
static const struct class mdpy_class = …;
static struct cdev mdpy_cdev;
static struct device mdpy_dev;
static struct mdev_parent mdpy_parent;
static const struct vfio_device_ops mdpy_dev_ops;
struct mdev_state { … };
static void mdpy_create_config_space(struct mdev_state *mdev_state)
{ … }
static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count)
{ … }
static ssize_t mdev_access(struct mdev_state *mdev_state, char *buf,
size_t count, loff_t pos, bool is_write)
{ … }
static int mdpy_reset(struct mdev_state *mdev_state)
{ … }
static int mdpy_init_dev(struct vfio_device *vdev)
{ … }
static int mdpy_probe(struct mdev_device *mdev)
{ … }
static void mdpy_release_dev(struct vfio_device *vdev)
{ … }
static void mdpy_remove(struct mdev_device *mdev)
{ … }
static ssize_t mdpy_read(struct vfio_device *vdev, char __user *buf,
size_t count, loff_t *ppos)
{ … }
static ssize_t mdpy_write(struct vfio_device *vdev, const char __user *buf,
size_t count, loff_t *ppos)
{ … }
static int mdpy_mmap(struct vfio_device *vdev, struct vm_area_struct *vma)
{ … }
static int mdpy_get_region_info(struct mdev_state *mdev_state,
struct vfio_region_info *region_info,
u16 *cap_type_id, void **cap_type)
{ … }
static int mdpy_get_irq_info(struct vfio_irq_info *irq_info)
{ … }
static int mdpy_get_device_info(struct vfio_device_info *dev_info)
{ … }
static int mdpy_query_gfx_plane(struct mdev_state *mdev_state,
struct vfio_device_gfx_plane_info *plane)
{ … }
static long mdpy_ioctl(struct vfio_device *vdev, unsigned int cmd,
unsigned long arg)
{ … }
static ssize_t
resolution_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(resolution);
static struct attribute *mdev_dev_attrs[] = …;
static const struct attribute_group mdev_dev_group = …;
static const struct attribute_group *mdev_dev_groups[] = …;
static ssize_t mdpy_show_description(struct mdev_type *mtype, char *buf)
{ … }
static const struct vfio_device_ops mdpy_dev_ops = …;
static struct mdev_driver mdpy_driver = …;
static const struct file_operations vd_fops = …;
static void mdpy_device_release(struct device *dev)
{ … }
static int __init mdpy_dev_init(void)
{ … }
static void __exit mdpy_dev_exit(void)
{ … }
module_param_named(count, mdpy_driver.max_instances, int, 0444);
MODULE_PARM_DESC(…) …;
module_init(…) …
module_exit(…)