#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 <linux/dma-buf.h>
#include <linux/highmem.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_rect.h>
#include <drm/drm_modeset_lock.h>
#include <drm/drm_property.h>
#include <drm/drm_plane.h>
#define VBE_DISPI_INDEX_ID …
#define VBE_DISPI_INDEX_XRES …
#define VBE_DISPI_INDEX_YRES …
#define VBE_DISPI_INDEX_BPP …
#define VBE_DISPI_INDEX_ENABLE …
#define VBE_DISPI_INDEX_BANK …
#define VBE_DISPI_INDEX_VIRT_WIDTH …
#define VBE_DISPI_INDEX_VIRT_HEIGHT …
#define VBE_DISPI_INDEX_X_OFFSET …
#define VBE_DISPI_INDEX_Y_OFFSET …
#define VBE_DISPI_INDEX_VIDEO_MEMORY_64K …
#define VBE_DISPI_INDEX_COUNT …
#define VBE_DISPI_ID0 …
#define VBE_DISPI_ID1 …
#define VBE_DISPI_ID2 …
#define VBE_DISPI_ID3 …
#define VBE_DISPI_ID4 …
#define VBE_DISPI_ID5 …
#define VBE_DISPI_DISABLED …
#define VBE_DISPI_ENABLED …
#define VBE_DISPI_GETCAPS …
#define VBE_DISPI_8BIT_DAC …
#define VBE_DISPI_LFB_ENABLED …
#define VBE_DISPI_NOCLEARMEM …
#define MBOCHS_NAME …
#define MBOCHS_CLASS_NAME …
#define MBOCHS_EDID_REGION_INDEX …
#define MBOCHS_NUM_REGIONS …
#define MBOCHS_CONFIG_SPACE_SIZE …
#define MBOCHS_MMIO_BAR_OFFSET …
#define MBOCHS_MMIO_BAR_SIZE …
#define MBOCHS_EDID_OFFSET …
#define MBOCHS_EDID_SIZE …
#define MBOCHS_MEMORY_BAR_OFFSET …
#define MBOCHS_EDID_BLOB_OFFSET …
#define STORE_LE16(addr, val) …
#define STORE_LE32(addr, val) …
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
static int max_mbytes = …;
module_param_named(count, max_mbytes, int, 0444);
MODULE_PARM_DESC(…) …;
#define MBOCHS_TYPE_1 …
#define MBOCHS_TYPE_2 …
#define MBOCHS_TYPE_3 …
static struct mbochs_type { … } mbochs_types[] = …;
static struct mdev_type *mbochs_mdev_types[] = …;
static dev_t mbochs_devt;
static const struct class mbochs_class = …;
static struct cdev mbochs_cdev;
static struct device mbochs_dev;
static struct mdev_parent mbochs_parent;
static atomic_t mbochs_avail_mbytes;
static const struct vfio_device_ops mbochs_dev_ops;
struct vfio_region_info_ext { … };
struct mbochs_mode { … };
struct mbochs_dmabuf { … };
struct mdev_state { … };
static const char *vbe_name_list[VBE_DISPI_INDEX_COUNT] = …;
static const char *vbe_name(u32 index)
{ … }
static struct page *__mbochs_get_page(struct mdev_state *mdev_state,
pgoff_t pgoff);
static struct page *mbochs_get_page(struct mdev_state *mdev_state,
pgoff_t pgoff);
static void mbochs_create_config_space(struct mdev_state *mdev_state)
{ … }
static int mbochs_check_framebuffer(struct mdev_state *mdev_state,
struct mbochs_mode *mode)
{ … }
static bool mbochs_modes_equal(struct mbochs_mode *mode1,
struct mbochs_mode *mode2)
{ … }
static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count)
{ … }
static void handle_mmio_write(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count)
{ … }
static void handle_mmio_read(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count)
{ … }
static void handle_edid_regs(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count, bool is_write)
{ … }
static void handle_edid_blob(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count, bool is_write)
{ … }
static ssize_t mdev_access(struct mdev_state *mdev_state, char *buf,
size_t count, loff_t pos, bool is_write)
{ … }
static int mbochs_reset(struct mdev_state *mdev_state)
{ … }
static int mbochs_init_dev(struct vfio_device *vdev)
{ … }
static int mbochs_probe(struct mdev_device *mdev)
{ … }
static void mbochs_release_dev(struct vfio_device *vdev)
{ … }
static void mbochs_remove(struct mdev_device *mdev)
{ … }
static ssize_t mbochs_read(struct vfio_device *vdev, char __user *buf,
size_t count, loff_t *ppos)
{ … }
static ssize_t mbochs_write(struct vfio_device *vdev, const char __user *buf,
size_t count, loff_t *ppos)
{ … }
static struct page *__mbochs_get_page(struct mdev_state *mdev_state,
pgoff_t pgoff)
{ … }
static struct page *mbochs_get_page(struct mdev_state *mdev_state,
pgoff_t pgoff)
{ … }
static void mbochs_put_pages(struct mdev_state *mdev_state)
{ … }
static vm_fault_t mbochs_region_vm_fault(struct vm_fault *vmf)
{ … }
static const struct vm_operations_struct mbochs_region_vm_ops = …;
static int mbochs_mmap(struct vfio_device *vdev, struct vm_area_struct *vma)
{ … }
static vm_fault_t mbochs_dmabuf_vm_fault(struct vm_fault *vmf)
{ … }
static const struct vm_operations_struct mbochs_dmabuf_vm_ops = …;
static int mbochs_mmap_dmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
{ … }
static void mbochs_print_dmabuf(struct mbochs_dmabuf *dmabuf,
const char *prefix)
{ … }
static struct sg_table *mbochs_map_dmabuf(struct dma_buf_attachment *at,
enum dma_data_direction direction)
{ … }
static void mbochs_unmap_dmabuf(struct dma_buf_attachment *at,
struct sg_table *sg,
enum dma_data_direction direction)
{ … }
static void mbochs_release_dmabuf(struct dma_buf *buf)
{ … }
static struct dma_buf_ops mbochs_dmabuf_ops = …;
static struct mbochs_dmabuf *mbochs_dmabuf_alloc(struct mdev_state *mdev_state,
struct mbochs_mode *mode)
{ … }
static struct mbochs_dmabuf *
mbochs_dmabuf_find_by_mode(struct mdev_state *mdev_state,
struct mbochs_mode *mode)
{ … }
static struct mbochs_dmabuf *
mbochs_dmabuf_find_by_id(struct mdev_state *mdev_state, u32 id)
{ … }
static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf)
{ … }
static int mbochs_get_region_info(struct mdev_state *mdev_state,
struct vfio_region_info_ext *ext)
{ … }
static int mbochs_get_irq_info(struct vfio_irq_info *irq_info)
{ … }
static int mbochs_get_device_info(struct vfio_device_info *dev_info)
{ … }
static int mbochs_query_gfx_plane(struct mdev_state *mdev_state,
struct vfio_device_gfx_plane_info *plane)
{ … }
static int mbochs_get_gfx_dmabuf(struct mdev_state *mdev_state, u32 id)
{ … }
static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd,
unsigned long arg)
{ … }
static void mbochs_close_device(struct vfio_device *vdev)
{ … }
static ssize_t
memory_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(memory);
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 mbochs_show_description(struct mdev_type *mtype, char *buf)
{ … }
static unsigned int mbochs_get_available(struct mdev_type *mtype)
{ … }
static const struct vfio_device_ops mbochs_dev_ops = …;
static struct mdev_driver mbochs_driver = …;
static const struct file_operations vd_fops = …;
static void mbochs_device_release(struct device *dev)
{ … }
static int __init mbochs_dev_init(void)
{ … }
static void __exit mbochs_dev_exit(void)
{ … }
MODULE_IMPORT_NS(…);
module_init(…) …
module_exit(…)