debuggers.hg

view linux-2.6.8.1-xen-sparse/drivers/char/mem.c @ 2624:23bc5e8a9321

bitkeeper revision 1.1159.98.1 (415e7911bLQPew3o_RI5Cm8viw6VCQ)

Remove Xen-specific ioctl from /dev/mem device. Update domain-building
tools to use the correct device file for mapping foreign memory.
author kaf24@freefall.cl.cam.ac.uk
date Sat Oct 02 09:46:57 2004 +0000 (2004-10-02)
parents 11be1dfb262b
children 0f3e0ef73bd5
line source
1 /*
2 * linux/drivers/char/mem.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * Added devfs support.
7 * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu>
8 * Shared /dev/zero mmaping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com>
9 *
10 * MODIFIED FOR XEN by Keir Fraser, 10th July 2003.
11 * Linux running on Xen has strange semantics for /dev/mem and /dev/kmem!!
12 * 1. mmap will not work on /dev/kmem
13 * 2. mmap on /dev/mem interprets the 'file offset' as a machine address
14 * rather than a physical address.
15 * I don't believe anyone sane mmaps /dev/kmem, but /dev/mem is mmapped
16 * to get at memory-mapped I/O spaces (eg. the VESA X server does this).
17 * For this to work at all we need to expect machine addresses.
18 * Reading/writing of /dev/kmem expects kernel virtual addresses, as usual.
19 * Reading/writing of /dev/mem expects 'physical addresses' as usual -- this
20 * is because /dev/mem can only read/write existing kernel mappings, which
21 * will be normal RAM, and we should present pseudo-physical layout for all
22 * except I/O (which is the sticky case that mmap is hacked to deal with).
23 */
25 #include <linux/config.h>
26 #include <linux/mm.h>
27 #include <linux/miscdevice.h>
28 #include <linux/slab.h>
29 #include <linux/vmalloc.h>
30 #include <linux/mman.h>
31 #include <linux/random.h>
32 #include <linux/init.h>
33 #include <linux/raw.h>
34 #include <linux/tty.h>
35 #include <linux/capability.h>
36 #include <linux/smp_lock.h>
37 #include <linux/devfs_fs_kernel.h>
38 #include <linux/ptrace.h>
39 #include <linux/device.h>
41 #include <asm/uaccess.h>
42 #include <asm/io.h>
43 #include <asm/pgalloc.h>
45 #ifdef CONFIG_IA64
46 # include <linux/efi.h>
47 #endif
49 #ifdef CONFIG_FB
50 extern void fbmem_init(void);
51 #endif
52 #if defined(CONFIG_S390_TAPE) && defined(CONFIG_S390_TAPE_CHAR)
53 extern void tapechar_init(void);
54 #endif
56 /*
57 * Architectures vary in how they handle caching for addresses
58 * outside of main memory.
59 *
60 */
61 static inline int uncached_access(struct file *file, unsigned long addr)
62 {
63 #if defined(__i386__)
64 /*
65 * On the PPro and successors, the MTRRs are used to set
66 * memory types for physical addresses outside main memory,
67 * so blindly setting PCD or PWT on those pages is wrong.
68 * For Pentiums and earlier, the surround logic should disable
69 * caching for the high addresses through the KEN pin, but
70 * we maintain the tradition of paranoia in this code.
71 */
72 if (file->f_flags & O_SYNC)
73 return 1;
74 return !( test_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability) ||
75 test_bit(X86_FEATURE_K6_MTRR, boot_cpu_data.x86_capability) ||
76 test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) ||
77 test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) )
78 && addr >= __pa(high_memory);
79 #elif defined(__x86_64__)
80 /*
81 * This is broken because it can generate memory type aliases,
82 * which can cause cache corruptions
83 * But it is only available for root and we have to be bug-to-bug
84 * compatible with i386.
85 */
86 if (file->f_flags & O_SYNC)
87 return 1;
88 /* same behaviour as i386. PAT always set to cached and MTRRs control the
89 caching behaviour.
90 Hopefully a full PAT implementation will fix that soon. */
91 return 0;
92 #elif defined(CONFIG_IA64)
93 /*
94 * On ia64, we ignore O_SYNC because we cannot tolerate memory attribute aliases.
95 */
96 return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
97 #elif defined(CONFIG_PPC64)
98 /* On PPC64, we always do non-cacheable access to the IO hole and
99 * cacheable elsewhere. Cache paradox can checkstop the CPU and
100 * the high_memory heuristic below is wrong on machines with memory
101 * above the IO hole... Ah, and of course, XFree86 doesn't pass
102 * O_SYNC when mapping us to tap IO space. Surprised ?
103 */
104 return !page_is_ram(addr);
105 #else
106 /*
107 * Accessing memory above the top the kernel knows about or through a file pointer
108 * that was marked O_SYNC will be done non-cached.
109 */
110 if (file->f_flags & O_SYNC)
111 return 1;
112 return addr >= __pa(high_memory);
113 #endif
114 }
116 #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
117 static inline int valid_phys_addr_range(unsigned long addr, size_t *count)
118 {
119 unsigned long end_mem;
121 end_mem = __pa(high_memory);
122 if (addr >= end_mem)
123 return 0;
125 if (*count > end_mem - addr)
126 *count = end_mem - addr;
128 return 1;
129 }
130 #endif
132 static ssize_t do_write_mem(void *p, unsigned long realp,
133 const char __user * buf, size_t count, loff_t *ppos)
134 {
135 ssize_t written;
136 unsigned long copied;
138 written = 0;
139 #if defined(__sparc__) || (defined(__mc68000__) && defined(CONFIG_MMU))
140 /* we don't have page 0 mapped on sparc and m68k.. */
141 if (realp < PAGE_SIZE) {
142 unsigned long sz = PAGE_SIZE-realp;
143 if (sz > count) sz = count;
144 /* Hmm. Do something? */
145 buf+=sz;
146 p+=sz;
147 count-=sz;
148 written+=sz;
149 }
150 #endif
151 copied = copy_from_user(p, buf, count);
152 if (copied) {
153 ssize_t ret = written + (count - copied);
155 if (ret)
156 return ret;
157 return -EFAULT;
158 }
159 written += count;
160 *ppos += written;
161 return written;
162 }
165 /*
166 * This funcion reads the *physical* memory. The f_pos points directly to the
167 * memory location.
168 */
169 static ssize_t read_mem(struct file * file, char __user * buf,
170 size_t count, loff_t *ppos)
171 {
172 unsigned long p = *ppos;
173 ssize_t read;
175 if (!valid_phys_addr_range(p, &count))
176 return -EFAULT;
177 read = 0;
178 #if defined(__sparc__) || (defined(__mc68000__) && defined(CONFIG_MMU))
179 /* we don't have page 0 mapped on sparc and m68k.. */
180 if (p < PAGE_SIZE) {
181 unsigned long sz = PAGE_SIZE-p;
182 if (sz > count)
183 sz = count;
184 if (sz > 0) {
185 if (clear_user(buf, sz))
186 return -EFAULT;
187 buf += sz;
188 p += sz;
189 count -= sz;
190 read += sz;
191 }
192 }
193 #endif
194 if (copy_to_user(buf, __va(p), count))
195 return -EFAULT;
196 read += count;
197 *ppos += read;
198 return read;
199 }
201 static ssize_t write_mem(struct file * file, const char __user * buf,
202 size_t count, loff_t *ppos)
203 {
204 unsigned long p = *ppos;
206 if (!valid_phys_addr_range(p, &count))
207 return -EFAULT;
208 return do_write_mem(__va(p), p, buf, count, ppos);
209 }
211 #if !defined(CONFIG_XEN)
212 static int mmap_mem(struct file * file, struct vm_area_struct * vma)
213 {
214 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
215 int uncached;
217 uncached = uncached_access(file, offset);
218 #ifdef pgprot_noncached
219 if (uncached)
220 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
221 #endif
223 /* Don't try to swap out physical pages.. */
224 vma->vm_flags |= VM_RESERVED;
226 /*
227 * Don't dump addresses that are not real memory to a core file.
228 */
229 if (uncached)
230 vma->vm_flags |= VM_IO;
232 if (remap_page_range(vma, vma->vm_start, offset, vma->vm_end-vma->vm_start,
233 vma->vm_page_prot))
234 return -EAGAIN;
235 return 0;
236 }
237 #elif !defined(CONFIG_XEN_PRIVILEGED_GUEST)
238 static int mmap_mem(struct file * file, struct vm_area_struct * vma)
239 {
240 return -ENXIO;
241 }
242 #else
243 static int mmap_mem(struct file * file, struct vm_area_struct * vma)
244 {
245 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
247 if (!(start_info.flags & SIF_PRIVILEGED))
248 return -ENXIO;
250 /* DONTCOPY is essential for Xen as copy_page_range is broken. */
251 vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY;
252 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
253 if (direct_remap_area_pages(vma->vm_mm, vma->vm_start, offset,
254 vma->vm_end-vma->vm_start, vma->vm_page_prot,
255 DOMID_IO))
256 return -EAGAIN;
257 return 0;
258 }
259 #endif /* CONFIG_XEN */
261 extern long vread(char *buf, char *addr, unsigned long count);
262 extern long vwrite(char *buf, char *addr, unsigned long count);
264 /*
265 * This function reads the *virtual* memory as seen by the kernel.
266 */
267 static ssize_t read_kmem(struct file *file, char __user *buf,
268 size_t count, loff_t *ppos)
269 {
270 unsigned long p = *ppos;
271 ssize_t read = 0;
272 ssize_t virtr = 0;
273 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
275 if (p < (unsigned long) high_memory) {
276 read = count;
277 if (count > (unsigned long) high_memory - p)
278 read = (unsigned long) high_memory - p;
280 #if defined(__sparc__) || (defined(__mc68000__) && defined(CONFIG_MMU))
281 /* we don't have page 0 mapped on sparc and m68k.. */
282 if (p < PAGE_SIZE && read > 0) {
283 size_t tmp = PAGE_SIZE - p;
284 if (tmp > read) tmp = read;
285 if (clear_user(buf, tmp))
286 return -EFAULT;
287 buf += tmp;
288 p += tmp;
289 read -= tmp;
290 count -= tmp;
291 }
292 #endif
293 if (copy_to_user(buf, (char *)p, read))
294 return -EFAULT;
295 p += read;
296 buf += read;
297 count -= read;
298 }
300 if (count > 0) {
301 kbuf = (char *)__get_free_page(GFP_KERNEL);
302 if (!kbuf)
303 return -ENOMEM;
304 while (count > 0) {
305 int len = count;
307 if (len > PAGE_SIZE)
308 len = PAGE_SIZE;
309 len = vread(kbuf, (char *)p, len);
310 if (!len)
311 break;
312 if (copy_to_user(buf, kbuf, len)) {
313 free_page((unsigned long)kbuf);
314 return -EFAULT;
315 }
316 count -= len;
317 buf += len;
318 virtr += len;
319 p += len;
320 }
321 free_page((unsigned long)kbuf);
322 }
323 *ppos = p;
324 return virtr + read;
325 }
327 /*
328 * This function writes to the *virtual* memory as seen by the kernel.
329 */
330 static ssize_t write_kmem(struct file * file, const char __user * buf,
331 size_t count, loff_t *ppos)
332 {
333 unsigned long p = *ppos;
334 ssize_t wrote = 0;
335 ssize_t virtr = 0;
336 ssize_t written;
337 char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
339 if (p < (unsigned long) high_memory) {
341 wrote = count;
342 if (count > (unsigned long) high_memory - p)
343 wrote = (unsigned long) high_memory - p;
345 written = do_write_mem((void*)p, p, buf, wrote, ppos);
346 if (written != wrote)
347 return written;
348 wrote = written;
349 p += wrote;
350 buf += wrote;
351 count -= wrote;
352 }
354 if (count > 0) {
355 kbuf = (char *)__get_free_page(GFP_KERNEL);
356 if (!kbuf)
357 return wrote ? wrote : -ENOMEM;
358 while (count > 0) {
359 int len = count;
361 if (len > PAGE_SIZE)
362 len = PAGE_SIZE;
363 if (len) {
364 written = copy_from_user(kbuf, buf, len);
365 if (written) {
366 ssize_t ret;
368 free_page((unsigned long)kbuf);
369 ret = wrote + virtr + (len - written);
370 return ret ? ret : -EFAULT;
371 }
372 }
373 len = vwrite(kbuf, (char *)p, len);
374 count -= len;
375 buf += len;
376 virtr += len;
377 p += len;
378 }
379 free_page((unsigned long)kbuf);
380 }
382 *ppos = p;
383 return virtr + wrote;
384 }
386 #if defined(CONFIG_ISA) || !defined(__mc68000__)
387 static ssize_t read_port(struct file * file, char __user * buf,
388 size_t count, loff_t *ppos)
389 {
390 unsigned long i = *ppos;
391 char __user *tmp = buf;
393 if (verify_area(VERIFY_WRITE,buf,count))
394 return -EFAULT;
395 while (count-- > 0 && i < 65536) {
396 if (__put_user(inb(i),tmp) < 0)
397 return -EFAULT;
398 i++;
399 tmp++;
400 }
401 *ppos = i;
402 return tmp-buf;
403 }
405 static ssize_t write_port(struct file * file, const char __user * buf,
406 size_t count, loff_t *ppos)
407 {
408 unsigned long i = *ppos;
409 const char __user * tmp = buf;
411 if (verify_area(VERIFY_READ,buf,count))
412 return -EFAULT;
413 while (count-- > 0 && i < 65536) {
414 char c;
415 if (__get_user(c, tmp))
416 return -EFAULT;
417 outb(c,i);
418 i++;
419 tmp++;
420 }
421 *ppos = i;
422 return tmp-buf;
423 }
424 #endif
426 static ssize_t read_null(struct file * file, char __user * buf,
427 size_t count, loff_t *ppos)
428 {
429 return 0;
430 }
432 static ssize_t write_null(struct file * file, const char __user * buf,
433 size_t count, loff_t *ppos)
434 {
435 return count;
436 }
438 #ifdef CONFIG_MMU
439 /*
440 * For fun, we are using the MMU for this.
441 */
442 static inline size_t read_zero_pagealigned(char __user * buf, size_t size)
443 {
444 struct mm_struct *mm;
445 struct vm_area_struct * vma;
446 unsigned long addr=(unsigned long)buf;
448 mm = current->mm;
449 /* Oops, this was forgotten before. -ben */
450 down_read(&mm->mmap_sem);
452 /* For private mappings, just map in zero pages. */
453 for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
454 unsigned long count;
456 if (vma->vm_start > addr || (vma->vm_flags & VM_WRITE) == 0)
457 goto out_up;
458 if (vma->vm_flags & VM_SHARED)
459 break;
460 count = vma->vm_end - addr;
461 if (count > size)
462 count = size;
464 zap_page_range(vma, addr, count, NULL);
465 zeromap_page_range(vma, addr, count, PAGE_COPY);
467 size -= count;
468 buf += count;
469 addr += count;
470 if (size == 0)
471 goto out_up;
472 }
474 up_read(&mm->mmap_sem);
476 /* The shared case is hard. Let's do the conventional zeroing. */
477 do {
478 unsigned long unwritten = clear_user(buf, PAGE_SIZE);
479 if (unwritten)
480 return size + unwritten - PAGE_SIZE;
481 cond_resched();
482 buf += PAGE_SIZE;
483 size -= PAGE_SIZE;
484 } while (size);
486 return size;
487 out_up:
488 up_read(&mm->mmap_sem);
489 return size;
490 }
492 static ssize_t read_zero(struct file * file, char __user * buf,
493 size_t count, loff_t *ppos)
494 {
495 unsigned long left, unwritten, written = 0;
497 if (!count)
498 return 0;
500 if (!access_ok(VERIFY_WRITE, buf, count))
501 return -EFAULT;
503 left = count;
505 /* do we want to be clever? Arbitrary cut-off */
506 if (count >= PAGE_SIZE*4) {
507 unsigned long partial;
509 /* How much left of the page? */
510 partial = (PAGE_SIZE-1) & -(unsigned long) buf;
511 unwritten = clear_user(buf, partial);
512 written = partial - unwritten;
513 if (unwritten)
514 goto out;
515 left -= partial;
516 buf += partial;
517 unwritten = read_zero_pagealigned(buf, left & PAGE_MASK);
518 written += (left & PAGE_MASK) - unwritten;
519 if (unwritten)
520 goto out;
521 buf += left & PAGE_MASK;
522 left &= ~PAGE_MASK;
523 }
524 unwritten = clear_user(buf, left);
525 written += left - unwritten;
526 out:
527 return written ? written : -EFAULT;
528 }
530 static int mmap_zero(struct file * file, struct vm_area_struct * vma)
531 {
532 if (vma->vm_flags & VM_SHARED)
533 return shmem_zero_setup(vma);
534 if (zeromap_page_range(vma, vma->vm_start, vma->vm_end - vma->vm_start, vma->vm_page_prot))
535 return -EAGAIN;
536 return 0;
537 }
538 #else /* CONFIG_MMU */
539 static ssize_t read_zero(struct file * file, char * buf,
540 size_t count, loff_t *ppos)
541 {
542 size_t todo = count;
544 while (todo) {
545 size_t chunk = todo;
547 if (chunk > 4096)
548 chunk = 4096; /* Just for latency reasons */
549 if (clear_user(buf, chunk))
550 return -EFAULT;
551 buf += chunk;
552 todo -= chunk;
553 cond_resched();
554 }
555 return count;
556 }
558 static int mmap_zero(struct file * file, struct vm_area_struct * vma)
559 {
560 return -ENOSYS;
561 }
562 #endif /* CONFIG_MMU */
564 static ssize_t write_full(struct file * file, const char __user * buf,
565 size_t count, loff_t *ppos)
566 {
567 return -ENOSPC;
568 }
570 /*
571 * Special lseek() function for /dev/null and /dev/zero. Most notably, you
572 * can fopen() both devices with "a" now. This was previously impossible.
573 * -- SRB.
574 */
576 static loff_t null_lseek(struct file * file, loff_t offset, int orig)
577 {
578 return file->f_pos = 0;
579 }
581 /*
582 * The memory devices use the full 32/64 bits of the offset, and so we cannot
583 * check against negative addresses: they are ok. The return value is weird,
584 * though, in that case (0).
585 *
586 * also note that seeking relative to the "end of file" isn't supported:
587 * it has no meaning, so it returns -EINVAL.
588 */
589 static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
590 {
591 loff_t ret;
593 down(&file->f_dentry->d_inode->i_sem);
594 switch (orig) {
595 case 0:
596 file->f_pos = offset;
597 ret = file->f_pos;
598 force_successful_syscall_return();
599 break;
600 case 1:
601 file->f_pos += offset;
602 ret = file->f_pos;
603 force_successful_syscall_return();
604 break;
605 default:
606 ret = -EINVAL;
607 }
608 up(&file->f_dentry->d_inode->i_sem);
609 return ret;
610 }
612 static int open_port(struct inode * inode, struct file * filp)
613 {
614 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
615 }
617 #define mmap_kmem mmap_mem
618 #define zero_lseek null_lseek
619 #define full_lseek null_lseek
620 #define write_zero write_null
621 #define read_full read_zero
622 #define open_mem open_port
623 #define open_kmem open_mem
625 static struct file_operations mem_fops = {
626 .llseek = memory_lseek,
627 .read = read_mem,
628 .write = write_mem,
629 .mmap = mmap_mem,
630 .open = open_mem,
631 };
633 static struct file_operations kmem_fops = {
634 .llseek = memory_lseek,
635 .read = read_kmem,
636 .write = write_kmem,
637 #if !defined(CONFIG_XEN)
638 .mmap = mmap_kmem,
639 #endif
640 .open = open_kmem,
641 };
643 static struct file_operations null_fops = {
644 .llseek = null_lseek,
645 .read = read_null,
646 .write = write_null,
647 };
649 #if defined(CONFIG_ISA) || !defined(__mc68000__)
650 static struct file_operations port_fops = {
651 .llseek = memory_lseek,
652 .read = read_port,
653 .write = write_port,
654 .open = open_port,
655 };
656 #endif
658 static struct file_operations zero_fops = {
659 .llseek = zero_lseek,
660 .read = read_zero,
661 .write = write_zero,
662 .mmap = mmap_zero,
663 };
665 static struct file_operations full_fops = {
666 .llseek = full_lseek,
667 .read = read_full,
668 .write = write_full,
669 };
671 static ssize_t kmsg_write(struct file * file, const char __user * buf,
672 size_t count, loff_t *ppos)
673 {
674 char *tmp;
675 int ret;
677 tmp = kmalloc(count + 1, GFP_KERNEL);
678 if (tmp == NULL)
679 return -ENOMEM;
680 ret = -EFAULT;
681 if (!copy_from_user(tmp, buf, count)) {
682 tmp[count] = 0;
683 ret = printk("%s", tmp);
684 }
685 kfree(tmp);
686 return ret;
687 }
689 static struct file_operations kmsg_fops = {
690 .write = kmsg_write,
691 };
693 static int memory_open(struct inode * inode, struct file * filp)
694 {
695 switch (iminor(inode)) {
696 case 1:
697 filp->f_op = &mem_fops;
698 break;
699 case 2:
700 filp->f_op = &kmem_fops;
701 break;
702 case 3:
703 filp->f_op = &null_fops;
704 break;
705 #if defined(CONFIG_ISA) || !defined(__mc68000__)
706 case 4:
707 filp->f_op = &port_fops;
708 break;
709 #endif
710 case 5:
711 filp->f_op = &zero_fops;
712 break;
713 case 7:
714 filp->f_op = &full_fops;
715 break;
716 case 8:
717 filp->f_op = &random_fops;
718 break;
719 case 9:
720 filp->f_op = &urandom_fops;
721 break;
722 case 11:
723 filp->f_op = &kmsg_fops;
724 break;
725 default:
726 return -ENXIO;
727 }
728 if (filp->f_op && filp->f_op->open)
729 return filp->f_op->open(inode,filp);
730 return 0;
731 }
733 static struct file_operations memory_fops = {
734 .open = memory_open, /* just a selector for the real open */
735 };
737 static const struct {
738 unsigned int minor;
739 char *name;
740 umode_t mode;
741 struct file_operations *fops;
742 } devlist[] = { /* list of minor devices */
743 {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops},
744 {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops},
745 {3, "null", S_IRUGO | S_IWUGO, &null_fops},
746 #if defined(CONFIG_ISA) || !defined(__mc68000__)
747 {4, "port", S_IRUSR | S_IWUSR | S_IRGRP, &port_fops},
748 #endif
749 {5, "zero", S_IRUGO | S_IWUGO, &zero_fops},
750 {7, "full", S_IRUGO | S_IWUGO, &full_fops},
751 {8, "random", S_IRUGO | S_IWUSR, &random_fops},
752 {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops},
753 {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops},
754 };
756 static struct class_simple *mem_class;
758 static int __init chr_dev_init(void)
759 {
760 int i;
762 if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
763 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
765 mem_class = class_simple_create(THIS_MODULE, "mem");
766 for (i = 0; i < ARRAY_SIZE(devlist); i++) {
767 class_simple_device_add(mem_class,
768 MKDEV(MEM_MAJOR, devlist[i].minor),
769 NULL, devlist[i].name);
770 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
771 S_IFCHR | devlist[i].mode, devlist[i].name);
772 }
774 #if defined (CONFIG_FB)
775 fbmem_init();
776 #endif
777 return 0;
778 }
780 fs_initcall(chr_dev_init);