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>
19 /* These are set in mmapper_init, which is called at boot time */
20 static unsigned long mmapper_size
;
21 static unsigned long p_buf
= 0;
22 static char *v_buf
= NULL
;
25 mmapper_read(struct file
*file
, char __user
*buf
, size_t count
, loff_t
*ppos
)
27 return simple_read_from_buffer(buf
, count
, ppos
, v_buf
, mmapper_size
);
31 mmapper_write(struct file
*file
, const char __user
*buf
, size_t count
, loff_t
*ppos
)
33 if (*ppos
> mmapper_size
)
36 if (count
> mmapper_size
- *ppos
)
37 count
= mmapper_size
- *ppos
;
39 if (copy_from_user(&v_buf
[*ppos
], buf
, count
))
46 mmapper_ioctl(struct inode
*inode
, struct file
*file
, unsigned int cmd
,
53 mmapper_mmap(struct file
*file
, struct vm_area_struct
* vma
)
58 if (vma
->vm_pgoff
!= 0)
61 size
= vma
->vm_end
- vma
->vm_start
;
62 if(size
> mmapper_size
) return(-EFAULT
);
64 /* XXX A comment above remap_pfn_range says it should only be
65 * called when the mm semaphore is held
67 if (remap_pfn_range(vma
, vma
->vm_start
, p_buf
>> PAGE_SHIFT
, size
,
76 mmapper_open(struct inode
*inode
, struct file
*file
)
82 mmapper_release(struct inode
*inode
, struct file
*file
)
87 static const struct file_operations mmapper_fops
= {
90 .write
= mmapper_write
,
91 .ioctl
= mmapper_ioctl
,
94 .release
= mmapper_release
,
97 /* No locking needed - only used (and modified) by below initcall and exitcall. */
98 static struct miscdevice mmapper_dev
= {
99 .minor
= MISC_DYNAMIC_MINOR
,
101 .fops
= &mmapper_fops
104 static int __init
mmapper_init(void)
108 printk(KERN_INFO
"Mapper v0.1\n");
110 v_buf
= (char *) find_iomem("mmapper", &mmapper_size
);
111 if(mmapper_size
== 0){
112 printk(KERN_ERR
"mmapper_init - find_iomem failed\n");
116 err
= misc_register(&mmapper_dev
);
118 printk(KERN_ERR
"mmapper - misc_register failed, err = %d\n",
128 static void mmapper_exit(void)
130 misc_deregister(&mmapper_dev
);
133 module_init(mmapper_init
);
134 module_exit(mmapper_exit
);
136 MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
137 MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
139 * ---------------------------------------------------------------------------
141 * c-file-style: "linux"