Import 2.3.25pre1
[davej-history.git] / include / linux / highmem.h
blob3879d1e6170f12d3c885b08411187b7568a91525
1 #ifndef _LINUX_HIGHMEM_H
2 #define _LINUX_HIGHMEM_H
4 #include <linux/config.h>
5 #include <asm/pgtable.h>
7 #ifdef CONFIG_HIGHMEM
9 extern struct page *highmem_start_page;
11 #include <asm/highmem.h>
13 /* declarations for linux/mm/highmem.c */
14 extern unsigned long highmem_mapnr;
15 extern unsigned long nr_free_highpages;
17 extern struct page * prepare_highmem_swapout(struct page *);
18 extern struct page * replace_with_highmem(struct page *);
20 #else /* CONFIG_HIGHMEM */
22 #define prepare_highmem_swapout(page) page
23 #define replace_with_highmem(page) page
24 #define kmap(page, type) page_address(page)
25 #define kunmap(vaddr, type) do { } while (0)
26 #define nr_free_highpages 0UL
28 #endif /* CONFIG_HIGHMEM */
30 /* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
31 extern inline void clear_highpage(struct page *page)
33 unsigned long kaddr;
35 kaddr = kmap(page, KM_WRITE);
36 clear_page((void *)kaddr);
37 kunmap(kaddr, KM_WRITE);
40 extern inline void memclear_highpage(struct page *page, unsigned int offset, unsigned int size)
42 unsigned long kaddr;
44 if (offset + size > PAGE_SIZE)
45 BUG();
46 kaddr = kmap(page, KM_WRITE);
47 memset((void *)(kaddr + offset), 0, size);
48 kunmap(kaddr, KM_WRITE);
52 * Same but also flushes aliased cache contents to RAM.
54 extern inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size)
56 unsigned long kaddr;
58 if (offset + size > PAGE_SIZE)
59 BUG();
60 kaddr = kmap(page, KM_WRITE);
61 memset((void *)(kaddr + offset), 0, size);
62 flush_page_to_ram(page);
63 kunmap(kaddr, KM_WRITE);
66 extern inline void copy_highpage(struct page *to, struct page *from)
68 unsigned long vfrom, vto;
70 vfrom = kmap(from, KM_READ);
71 vto = kmap(to, KM_WRITE);
72 copy_page((void *)vto, (void *)vfrom);
73 kunmap(vfrom, KM_READ);
74 kunmap(vto, KM_WRITE);
77 #endif /* _LINUX_HIGHMEM_H */