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/stddef.h>
13 #include <linux/types.h>
15 #include <linux/init.h>
16 #include <linux/miscdevice.h>
17 #include <linux/module.h>
20 #include <asm/uaccess.h>
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
;
28 static ssize_t
mmapper_read(struct file
*file
, char __user
*buf
, size_t count
,
31 return simple_read_from_buffer(buf
, count
, ppos
, v_buf
, mmapper_size
);
34 static ssize_t
mmapper_write(struct file
*file
, const char __user
*buf
,
35 size_t count
, loff_t
*ppos
)
37 if (*ppos
> mmapper_size
)
40 return simple_write_to_buffer(v_buf
, mmapper_size
, ppos
, buf
, count
);
43 static long mmapper_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
48 static int mmapper_mmap(struct file
*file
, struct vm_area_struct
*vma
)
53 if (vma
->vm_pgoff
!= 0)
56 size
= vma
->vm_end
- vma
->vm_start
;
57 if (size
> mmapper_size
)
61 * XXX A comment above remap_pfn_range says it should only be
62 * called when the mm semaphore is held
64 if (remap_pfn_range(vma
, vma
->vm_start
, p_buf
>> PAGE_SHIFT
, size
,
72 static int mmapper_open(struct inode
*inode
, struct file
*file
)
77 static int mmapper_release(struct inode
*inode
, struct file
*file
)
82 static const struct file_operations mmapper_fops
= {
85 .write
= mmapper_write
,
86 .unlocked_ioctl
= mmapper_ioctl
,
89 .release
= mmapper_release
,
90 .llseek
= default_llseek
,
94 * No locking needed - only used (and modified) by below initcall and exitcall.
96 static struct miscdevice mmapper_dev
= {
97 .minor
= MISC_DYNAMIC_MINOR
,
102 static int __init
mmapper_init(void)
106 printk(KERN_INFO
"Mapper v0.1\n");
108 v_buf
= (char *) find_iomem("mmapper", &mmapper_size
);
109 if (mmapper_size
== 0) {
110 printk(KERN_ERR
"mmapper_init - find_iomem failed\n");
115 err
= misc_register(&mmapper_dev
);
117 printk(KERN_ERR
"mmapper - misc_register failed, err = %d\n",
124 static void mmapper_exit(void)
126 misc_deregister(&mmapper_dev
);
129 module_init(mmapper_init
);
130 module_exit(mmapper_exit
);
132 MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
133 MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
134 MODULE_LICENSE("GPL");