1 #ifndef _LINUX_HIGHMEM_H
2 #define _LINUX_HIGHMEM_H
4 #include <linux/config.h>
8 #include <asm/cacheflush.h>
12 extern struct page
*highmem_start_page
;
14 #include <asm/highmem.h>
16 /* declarations for linux/mm/highmem.c */
17 unsigned int nr_free_highpages(void);
19 #else /* CONFIG_HIGHMEM */
21 static inline unsigned int nr_free_highpages(void) { return 0; }
23 static inline void *kmap(struct page
*page
)
26 return page_address(page
);
29 #define kunmap(page) do { (void) (page); } while (0)
31 #define kmap_atomic(page, idx) page_address(page)
32 #define kunmap_atomic(addr, idx) do { } while (0)
33 #define kmap_atomic_to_page(ptr) virt_to_page(ptr)
35 #endif /* CONFIG_HIGHMEM */
37 /* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
38 static inline void clear_user_highpage(struct page
*page
, unsigned long vaddr
)
40 void *addr
= kmap_atomic(page
, KM_USER0
);
41 clear_user_page(addr
, vaddr
, page
);
42 kunmap_atomic(addr
, KM_USER0
);
43 /* Make sure this page is cleared on other CPU's too before using it */
47 static inline void clear_highpage(struct page
*page
)
49 void *kaddr
= kmap_atomic(page
, KM_USER0
);
51 kunmap_atomic(kaddr
, KM_USER0
);
55 * Same but also flushes aliased cache contents to RAM.
57 static inline void memclear_highpage_flush(struct page
*page
, unsigned int offset
, unsigned int size
)
61 BUG_ON(offset
+ size
> PAGE_SIZE
);
63 kaddr
= kmap_atomic(page
, KM_USER0
);
64 memset((char *)kaddr
+ offset
, 0, size
);
65 flush_dcache_page(page
);
66 kunmap_atomic(kaddr
, KM_USER0
);
69 static inline void copy_user_highpage(struct page
*to
, struct page
*from
, unsigned long vaddr
)
73 vfrom
= kmap_atomic(from
, KM_USER0
);
74 vto
= kmap_atomic(to
, KM_USER1
);
75 copy_user_page(vto
, vfrom
, vaddr
, to
);
76 kunmap_atomic(vfrom
, KM_USER0
);
77 kunmap_atomic(vto
, KM_USER1
);
78 /* Make sure this page is cleared on other CPU's too before using it */
82 static inline void copy_highpage(struct page
*to
, struct page
*from
)
86 vfrom
= kmap_atomic(from
, KM_USER0
);
87 vto
= kmap_atomic(to
, KM_USER1
);
88 copy_page(vto
, vfrom
);
89 kunmap_atomic(vfrom
, KM_USER0
);
90 kunmap_atomic(vto
, KM_USER1
);
93 #endif /* _LINUX_HIGHMEM_H */