[CONNECTOR]: Replace delayed work with usual work queue.
[linux-2.6/verdex.git] / include / linux / highmem.h
blobca9a602cffd7a2b8ea03c3d7fb0a60c4a1a3acb2
1 #ifndef _LINUX_HIGHMEM_H
2 #define _LINUX_HIGHMEM_H
4 #include <linux/fs.h>
5 #include <linux/mm.h>
6 #include <linux/uaccess.h>
8 #include <asm/cacheflush.h>
10 #ifndef ARCH_HAS_FLUSH_ANON_PAGE
11 static inline void flush_anon_page(struct page *page, unsigned long vmaddr)
14 #endif
16 #ifndef ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
17 static inline void flush_kernel_dcache_page(struct page *page)
20 #endif
22 #ifdef CONFIG_HIGHMEM
24 #include <asm/highmem.h>
26 /* declarations for linux/mm/highmem.c */
27 unsigned int nr_free_highpages(void);
28 extern unsigned long totalhigh_pages;
30 #else /* CONFIG_HIGHMEM */
32 static inline unsigned int nr_free_highpages(void) { return 0; }
34 #define totalhigh_pages 0
36 #ifndef ARCH_HAS_KMAP
37 static inline void *kmap(struct page *page)
39 might_sleep();
40 return page_address(page);
43 #define kunmap(page) do { (void) (page); } while (0)
45 #define kmap_atomic(page, idx) \
46 ({ pagefault_disable(); page_address(page); })
47 #define kunmap_atomic(addr, idx) do { pagefault_enable(); } while (0)
48 #define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
49 #define kmap_atomic_to_page(ptr) virt_to_page(ptr)
50 #endif
52 #endif /* CONFIG_HIGHMEM */
54 /* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
55 static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
57 void *addr = kmap_atomic(page, KM_USER0);
58 clear_user_page(addr, vaddr, page);
59 kunmap_atomic(addr, KM_USER0);
60 /* Make sure this page is cleared on other CPU's too before using it */
61 smp_wmb();
64 #ifndef __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
65 static inline struct page *
66 alloc_zeroed_user_highpage(struct vm_area_struct *vma, unsigned long vaddr)
68 struct page *page = alloc_page_vma(GFP_HIGHUSER, vma, vaddr);
70 if (page)
71 clear_user_highpage(page, vaddr);
73 return page;
75 #endif
77 static inline void clear_highpage(struct page *page)
79 void *kaddr = kmap_atomic(page, KM_USER0);
80 clear_page(kaddr);
81 kunmap_atomic(kaddr, KM_USER0);
85 * Same but also flushes aliased cache contents to RAM.
87 static inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size)
89 void *kaddr;
91 BUG_ON(offset + size > PAGE_SIZE);
93 kaddr = kmap_atomic(page, KM_USER0);
94 memset((char *)kaddr + offset, 0, size);
95 flush_dcache_page(page);
96 kunmap_atomic(kaddr, KM_USER0);
99 #ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE
101 static inline void copy_user_highpage(struct page *to, struct page *from,
102 unsigned long vaddr, struct vm_area_struct *vma)
104 char *vfrom, *vto;
106 vfrom = kmap_atomic(from, KM_USER0);
107 vto = kmap_atomic(to, KM_USER1);
108 copy_user_page(vto, vfrom, vaddr, to);
109 kunmap_atomic(vfrom, KM_USER0);
110 kunmap_atomic(vto, KM_USER1);
111 /* Make sure this page is cleared on other CPU's too before using it */
112 smp_wmb();
115 #endif
117 static inline void copy_highpage(struct page *to, struct page *from)
119 char *vfrom, *vto;
121 vfrom = kmap_atomic(from, KM_USER0);
122 vto = kmap_atomic(to, KM_USER1);
123 copy_page(vto, vfrom);
124 kunmap_atomic(vfrom, KM_USER0);
125 kunmap_atomic(vto, KM_USER1);
128 #endif /* _LINUX_HIGHMEM_H */