direct-io.hg

view xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c @ 64:0404a26ceafb

bitkeeper revision 1.7.3.39 (3e02f222DUWnS0NGcQ8843YSDyLHDg)

debug
author lynx@idefix.cl.cam.ac.uk
date Fri Dec 20 10:34:10 2002 +0000 (2002-12-20)
parents 9ad56dbe65c3
children 654b3fe81bb9
line source
2 #include <linux/slab.h>
3 #include <linux/shm.h>
4 #include <linux/mman.h>
5 #include <linux/pagemap.h>
6 #include <linux/swap.h>
7 #include <linux/swapctl.h>
8 #include <linux/smp_lock.h>
9 #include <linux/init.h>
10 #include <linux/file.h>
11 #include <linux/fs.h>
12 #include <linux/personality.h>
14 #include <asm/uaccess.h>
15 #include <asm/pgalloc.h>
17 static int direct_mapped(unsigned long addr)
18 {
19 direct_mmap_node_t * node;
20 struct list_head * curr;
21 struct list_head * direct_list = &current->mm->context.direct_list;
23 /* now, this loop is going to make things slow, maybe should think
24 * of a better way to implement it, maybe without list_head
25 */
26 curr = direct_list->next;
27 while(curr != direct_list){
28 node = list_entry(curr, direct_mmap_node_t, list);
29 if(node->addr == addr)
30 break;
31 curr = curr->next;
32 }
34 if(curr == direct_list)
35 return 0;
37 return 1;
38 }
40 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
41 {
42 struct vm_area_struct *vma;
44 if (len > TASK_SIZE)
45 return -ENOMEM;
47 if (addr) {
48 addr = PAGE_ALIGN(addr);
49 vma = find_vma(current->mm, addr);
50 if (TASK_SIZE - len >= addr &&
51 (!vma || addr + len <= vma->vm_start))
52 return addr;
53 }
54 addr = PAGE_ALIGN(TASK_UNMAPPED_BASE);
56 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
57 /* At this point: (!vma || addr < vma->vm_end). */
58 if (TASK_SIZE - len < addr)
59 return -ENOMEM;
61 /* here we check whether the vma is big enough and we also check
62 * whether it has already been direct mapped, in which case it
63 * is not available. this is the only difference to generic
64 * arch_get_unmapped_area.
65 */
66 printk(KERN_ALERT "bd240 debug: gua: vm addr found %lx\n", addr);
67 if ((!vma || addr + len <= vma->vm_start) && !direct_mapped(addr)){
68 printk(KERN_ALERT "bd240 debug: gua: first condition %d, %lx, %lx\n",vma, addr + len, vma->vm_start);
69 printk(KERN_ALERT "bd240 debug: gua: second condition %d\n", direct_mapped(addr));
71 return addr;
72 }
74 addr = vma->vm_end;
75 }
76 }