summaryrefslogtreecommitdiffstats
path: root/kernel/arch/um/drivers/mmapper_kern.c
diff options
context:
space:
mode:
authorYunhong Jiang <yunhong.jiang@intel.com>2015-08-04 12:17:53 -0700
committerYunhong Jiang <yunhong.jiang@intel.com>2015-08-04 15:44:42 -0700
commit9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (patch)
tree1c9cafbcd35f783a87880a10f85d1a060db1a563 /kernel/arch/um/drivers/mmapper_kern.c
parent98260f3884f4a202f9ca5eabed40b1354c489b29 (diff)
Add the rt linux 4.1.3-rt3 as base
Import the rt linux 4.1.3-rt3 as OPNFV kvm base. It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and the base is: commit 0917f823c59692d751951bf5ea699a2d1e2f26a2 Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: Sat Jul 25 12:13:34 2015 +0200 Prepare v4.1.3-rt3 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> We lose all the git history this way and it's not good. We should apply another opnfv project repo in future. Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423 Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Diffstat (limited to 'kernel/arch/um/drivers/mmapper_kern.c')
-rw-r--r--kernel/arch/um/drivers/mmapper_kern.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/kernel/arch/um/drivers/mmapper_kern.c b/kernel/arch/um/drivers/mmapper_kern.c
new file mode 100644
index 000000000..62145c276
--- /dev/null
+++ b/kernel/arch/um/drivers/mmapper_kern.c
@@ -0,0 +1,134 @@
+/*
+ * arch/um/drivers/mmapper_kern.c
+ *
+ * BRIEF MODULE DESCRIPTION
+ *
+ * Copyright (C) 2000 RidgeRun, Inc.
+ * Author: RidgeRun, Inc.
+ * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
+ *
+ */
+
+#include <linux/stddef.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/uaccess.h>
+#include <mem_user.h>
+
+/* These are set in mmapper_init, which is called at boot time */
+static unsigned long mmapper_size;
+static unsigned long p_buf;
+static char *v_buf;
+
+static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
+ loff_t *ppos)
+{
+ return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
+}
+
+static ssize_t mmapper_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ if (*ppos > mmapper_size)
+ return -EINVAL;
+
+ return simple_write_to_buffer(v_buf, mmapper_size, ppos, buf, count);
+}
+
+static long mmapper_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ return -ENOIOCTLCMD;
+}
+
+static int mmapper_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ int ret = -EINVAL;
+ int size;
+
+ if (vma->vm_pgoff != 0)
+ goto out;
+
+ size = vma->vm_end - vma->vm_start;
+ if (size > mmapper_size)
+ return -EFAULT;
+
+ /*
+ * XXX A comment above remap_pfn_range says it should only be
+ * called when the mm semaphore is held
+ */
+ if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
+ vma->vm_page_prot))
+ goto out;
+ ret = 0;
+out:
+ return ret;
+}
+
+static int mmapper_open(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static int mmapper_release(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static const struct file_operations mmapper_fops = {
+ .owner = THIS_MODULE,
+ .read = mmapper_read,
+ .write = mmapper_write,
+ .unlocked_ioctl = mmapper_ioctl,
+ .mmap = mmapper_mmap,
+ .open = mmapper_open,
+ .release = mmapper_release,
+ .llseek = default_llseek,
+};
+
+/*
+ * No locking needed - only used (and modified) by below initcall and exitcall.
+ */
+static struct miscdevice mmapper_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "mmapper",
+ .fops = &mmapper_fops
+};
+
+static int __init mmapper_init(void)
+{
+ int err;
+
+ printk(KERN_INFO "Mapper v0.1\n");
+
+ v_buf = (char *) find_iomem("mmapper", &mmapper_size);
+ if (mmapper_size == 0) {
+ printk(KERN_ERR "mmapper_init - find_iomem failed\n");
+ return -ENODEV;
+ }
+ p_buf = __pa(v_buf);
+
+ err = misc_register(&mmapper_dev);
+ if (err) {
+ printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
+ err);
+ return err;
+ }
+ return 0;
+}
+
+static void mmapper_exit(void)
+{
+ misc_deregister(&mmapper_dev);
+}
+
+module_init(mmapper_init);
+module_exit(mmapper_exit);
+
+MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
+MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
+MODULE_LICENSE("GPL");