direct-io.hg

view linux-2.6-xen-sparse/drivers/xen/util.c @ 7547:03612b7f69d5

Don't use XendRoot.get_vif_bridge to provide a default bridge -- instead, pass
no bridge parameter and let the vif-bridge script find one for itself.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sun Oct 30 13:45:06 2005 +0100 (2005-10-30)
parents 06d84bf87159
children 76392609363f
line source
1 #include <linux/config.h>
2 #include <linux/mm.h>
3 #include <linux/slab.h>
4 #include <linux/vmalloc.h>
5 #include <asm/uaccess.h>
6 #include <asm-xen/driver_util.h>
8 static int f(pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
9 {
10 /* generic_page_range() does all the hard work. */
11 return 0;
12 }
14 struct vm_struct *alloc_vm_area(unsigned long size)
15 {
16 struct vm_struct *area;
18 area = get_vm_area(size, VM_IOREMAP);
19 if (area == NULL)
20 return NULL;
22 /*
23 * This ensures that page tables are constructed for this region
24 * of kernel virtual address space and mapped into init_mm.
25 */
26 if (generic_page_range(&init_mm, (unsigned long)area->addr,
27 area->size, f, NULL)) {
28 free_vm_area(area);
29 return NULL;
30 }
32 return area;
33 }
35 void free_vm_area(struct vm_struct *area)
36 {
37 BUG_ON(remove_vm_area(area->addr) != area);
38 kfree(area);
39 }
41 void lock_vm_area(struct vm_struct *area)
42 {
43 unsigned long i;
44 char c;
46 /*
47 * Prevent context switch to a lazy mm that doesn't have this area
48 * mapped into its page tables.
49 */
50 preempt_disable();
52 /*
53 * Ensure that the page tables are mapped into the current mm. The
54 * page-fault path will copy the page directory pointers from init_mm.
55 */
56 for (i = 0; i < area->size; i += PAGE_SIZE)
57 (void)__get_user(c, (char *)area->addr + i);
58 }
60 void unlock_vm_area(struct vm_struct *area)
61 {
62 preempt_enable();
63 }
65 /*
66 * Local variables:
67 * c-file-style: "linux"
68 * indent-tabs-mode: t
69 * c-indent-level: 8
70 * c-basic-offset: 8
71 * tab-width: 8
72 * End:
73 */