2 * arch/um/drivers/mmapper_kern.c
4 * BRIEF MODULE DESCRIPTION
6 * Copyright (C) 2000 RidgeRun, Inc.
7 * Author: RidgeRun, Inc.
8 * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
12 #include <linux/init.h>
13 #include <linux/module.h>
15 #include <linux/miscdevice.h>
16 #include <asm/uaccess.h>
18 #include "user_util.h"
20 /* These are set in mmapper_init, which is called at boot time */
21 static unsigned long mmapper_size;
22 static unsigned long p_buf = 0;
23 static char *v_buf = NULL;
26 mmapper_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
28 return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
32 mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
34 if (*ppos > mmapper_size)
37 if (count > mmapper_size - *ppos)
38 count = mmapper_size - *ppos;
40 if (copy_from_user(&v_buf[*ppos], buf, count))
47 mmapper_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
54 mmapper_mmap(struct file *file, struct vm_area_struct * vma)
59 if (vma->vm_pgoff != 0)
62 size = vma->vm_end - vma->vm_start;
63 if(size > mmapper_size) return(-EFAULT);
65 /* XXX A comment above remap_pfn_range says it should only be
66 * called when the mm semaphore is held
68 if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
77 mmapper_open(struct inode *inode, struct file *file)
83 mmapper_release(struct inode *inode, struct file *file)
88 static const struct file_operations mmapper_fops = {
91 .write = mmapper_write,
92 .ioctl = mmapper_ioctl,
95 .release = mmapper_release,
98 /* No locking needed - only used (and modified) by below initcall and exitcall. */
99 static struct miscdevice mmapper_dev = {
100 .minor = MISC_DYNAMIC_MINOR,
102 .fops = &mmapper_fops
105 static int __init mmapper_init(void)
109 printk(KERN_INFO "Mapper v0.1\n");
111 v_buf = (char *) find_iomem("mmapper", &mmapper_size);
112 if(mmapper_size == 0){
113 printk(KERN_ERR "mmapper_init - find_iomem failed\n");
117 err = misc_register(&mmapper_dev);
119 printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
129 static void mmapper_exit(void)
131 misc_deregister(&mmapper_dev);
134 module_init(mmapper_init);
135 module_exit(mmapper_exit);
137 MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
138 MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
140 * ---------------------------------------------------------------------------
142 * c-file-style: "linux"