~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/drivers/mmapper_kern.c

Version: ~ [ linux-5.3-rc4 ] ~ [ linux-5.2.8 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.66 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.138 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.71 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * arch/um/drivers/mmapper_kern.c
  3  *
  4  * BRIEF MODULE DESCRIPTION
  5  *
  6  * Copyright (C) 2000 RidgeRun, Inc.
  7  * Author: RidgeRun, Inc.
  8  *         Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
  9  *
 10  */
 11 
 12 #include <linux/stddef.h>
 13 #include <linux/types.h>
 14 #include <linux/fs.h>
 15 #include <linux/init.h>
 16 #include <linux/miscdevice.h>
 17 #include <linux/module.h>
 18 #include <linux/mm.h>
 19 
 20 #include <asm/uaccess.h>
 21 #include "mem_user.h"
 22 
 23 /* These are set in mmapper_init, which is called at boot time */
 24 static unsigned long mmapper_size;
 25 static unsigned long p_buf;
 26 static char *v_buf;
 27 
 28 static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
 29                             loff_t *ppos)
 30 {
 31         return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
 32 }
 33 
 34 static ssize_t mmapper_write(struct file *file, const char __user *buf,
 35                              size_t count, loff_t *ppos)
 36 {
 37         if (*ppos > mmapper_size)
 38                 return -EINVAL;
 39 
 40         return simple_write_to_buffer(v_buf, mmapper_size, ppos, buf, count);
 41 }
 42 
 43 static long mmapper_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 44 {
 45         return -ENOIOCTLCMD;
 46 }
 47 
 48 static int mmapper_mmap(struct file *file, struct vm_area_struct *vma)
 49 {
 50         int ret = -EINVAL;
 51         int size;
 52 
 53         if (vma->vm_pgoff != 0)
 54                 goto out;
 55 
 56         size = vma->vm_end - vma->vm_start;
 57         if (size > mmapper_size)
 58                 return -EFAULT;
 59 
 60         /*
 61          * XXX A comment above remap_pfn_range says it should only be
 62          * called when the mm semaphore is held
 63          */
 64         if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
 65                             vma->vm_page_prot))
 66                 goto out;
 67         ret = 0;
 68 out:
 69         return ret;
 70 }
 71 
 72 static int mmapper_open(struct inode *inode, struct file *file)
 73 {
 74         return 0;
 75 }
 76 
 77 static int mmapper_release(struct inode *inode, struct file *file)
 78 {
 79         return 0;
 80 }
 81 
 82 static const struct file_operations mmapper_fops = {
 83         .owner          = THIS_MODULE,
 84         .read           = mmapper_read,
 85         .write          = mmapper_write,
 86         .unlocked_ioctl = mmapper_ioctl,
 87         .mmap           = mmapper_mmap,
 88         .open           = mmapper_open,
 89         .release        = mmapper_release,
 90         .llseek         = default_llseek,
 91 };
 92 
 93 /*
 94  * No locking needed - only used (and modified) by below initcall and exitcall.
 95  */
 96 static struct miscdevice mmapper_dev = {
 97         .minor          = MISC_DYNAMIC_MINOR,
 98         .name           = "mmapper",
 99         .fops           = &mmapper_fops
100 };
101 
102 static int __init mmapper_init(void)
103 {
104         int err;
105 
106         printk(KERN_INFO "Mapper v0.1\n");
107 
108         v_buf = (char *) find_iomem("mmapper", &mmapper_size);
109         if (mmapper_size == 0) {
110                 printk(KERN_ERR "mmapper_init - find_iomem failed\n");
111                 return -ENODEV;
112         }
113         p_buf = __pa(v_buf);
114 
115         err = misc_register(&mmapper_dev);
116         if (err) {
117                 printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
118                        err);
119                 return err;
120         }
121         return 0;
122 }
123 
124 static void mmapper_exit(void)
125 {
126         misc_deregister(&mmapper_dev);
127 }
128 
129 module_init(mmapper_init);
130 module_exit(mmapper_exit);
131 
132 MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
133 MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
134 MODULE_LICENSE("GPL");
135 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp