linux/drivers/staging/vme_user/vme_user.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * VMEbus User access driver
 *
 * Author: Martyn Welch <[email protected]>
 * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
 *
 * Based on work by:
 *   Tom Armistead and Ajit Prem
 *     Copyright 2004 Motorola Inc.
 */

#define pr_fmt(fmt)

#include <linux/refcount.h>
#include <linux/cdev.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/pci.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/syscalls.h>
#include <linux/types.h>

#include <linux/io.h>
#include <linux/uaccess.h>

#include "vme.h"
#include "vme_user.h"

#define DRIVER_NAME

static int bus[VME_USER_BUS_MAX];
static unsigned int bus_num;

/* Currently Documentation/admin-guide/devices.rst defines the
 * following for VME:
 *
 * 221 char	VME bus
 *		  0 = /dev/bus/vme/m0		First master image
 *		  1 = /dev/bus/vme/m1		Second master image
 *		  2 = /dev/bus/vme/m2		Third master image
 *		  3 = /dev/bus/vme/m3		Fourth master image
 *		  4 = /dev/bus/vme/s0		First slave image
 *		  5 = /dev/bus/vme/s1		Second slave image
 *		  6 = /dev/bus/vme/s2		Third slave image
 *		  7 = /dev/bus/vme/s3		Fourth slave image
 *		  8 = /dev/bus/vme/ctl		Control
 *
 *		It is expected that all VME bus drivers will use the
 *		same interface.  For interface documentation see
 *		http://www.vmelinux.org/.
 *
 * However the VME driver at http://www.vmelinux.org/ is rather old and doesn't
 * even support the tsi148 chipset (which has 8 master and 8 slave windows).
 * We'll run with this for now as far as possible, however it probably makes
 * sense to get rid of the old mappings and just do everything dynamically.
 *
 * So for now, we'll restrict the driver to providing 4 masters and 4 slaves as
 * defined above and try to support at least some of the interface from
 * http://www.vmelinux.org/ as an alternative the driver can be written
 * providing a saner interface later.
 *
 * The vmelinux.org driver never supported slave images, the devices reserved
 * for slaves were repurposed to support all 8 master images on the UniverseII!
 * We shall support 4 masters and 4 slaves with this driver.
 */
#define VME_MAJOR
#define VME_DEVS

#define MASTER_MINOR
#define MASTER_MAX
#define SLAVE_MINOR
#define SLAVE_MAX
#define CONTROL_MINOR

#define PCI_BUF_SIZE

/*
 * Structure to handle image related parameters.
 */
struct image_desc {};

static struct image_desc image[VME_DEVS];

static struct cdev *vme_user_cdev;		/* Character device */
static struct vme_dev *vme_user_bridge;		/* Pointer to user device */

static const struct class vme_user_sysfs_class =;

static const int type[VME_DEVS] =;

struct vme_user_vma_priv {};

static ssize_t resource_to_user(int minor, char __user *buf, size_t count,
				loff_t *ppos)
{}

static ssize_t resource_from_user(unsigned int minor, const char __user *buf,
				  size_t count, loff_t *ppos)
{}

static ssize_t buffer_to_user(unsigned int minor, char __user *buf,
			      size_t count, loff_t *ppos)
{}

static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
				size_t count, loff_t *ppos)
{}

static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
			     loff_t *ppos)
{}

static ssize_t vme_user_write(struct file *file, const char __user *buf,
			      size_t count, loff_t *ppos)
{}

static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
{}

/*
 * The ioctls provided by the old VME access method (the one at vmelinux.org)
 * are most certainly wrong as the effectively push the registers layout
 * through to user space. Given that the VME core can handle multiple bridges,
 * with different register layouts this is most certainly not the way to go.
 *
 * We aren't using the structures defined in the Motorola driver either - these
 * are also quite low level, however we should use the definitions that have
 * already been defined.
 */
static int vme_user_ioctl(struct inode *inode, struct file *file,
			  unsigned int cmd, unsigned long arg)
{}

static long
vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{}

static void vme_user_vm_open(struct vm_area_struct *vma)
{}

static void vme_user_vm_close(struct vm_area_struct *vma)
{}

static const struct vm_operations_struct vme_user_vm_ops =;

static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
{}

static int vme_user_mmap(struct file *file, struct vm_area_struct *vma)
{}

static const struct file_operations vme_user_fops =;

static int vme_user_match(struct vme_dev *vdev)
{}

/*
 * In this simple access driver, the old behaviour is being preserved as much
 * as practical. We will therefore reserve the buffers and request the images
 * here so that we don't have to do it later.
 */
static int vme_user_probe(struct vme_dev *vdev)
{}

static void vme_user_remove(struct vme_dev *dev)
{}

static struct vme_driver vme_user_driver =;

static int __init vme_user_init(void)
{}

static void __exit vme_user_exit(void)
{}

MODULE_PARM_DESC();
module_param_array();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();

module_init();
module_exit(vme_user_exit);