ia64/xen-unstable

view linux-2.4-xen-sparse/include/linux/highmem.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
line source
1 #ifndef _LINUX_HIGHMEM_H
2 #define _LINUX_HIGHMEM_H
4 #include <linux/config.h>
5 #include <asm/pgalloc.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 unsigned int nr_free_highpages(void);
15 void kmap_flush_unused(void);
17 extern struct buffer_head *create_bounce(int rw, struct buffer_head * bh_orig);
19 static inline char *bh_kmap(struct buffer_head *bh)
20 {
21 return kmap(bh->b_page) + bh_offset(bh);
22 }
24 static inline void bh_kunmap(struct buffer_head *bh)
25 {
26 kunmap(bh->b_page);
27 }
29 /*
30 * remember to add offset! and never ever reenable interrupts between a
31 * bh_kmap_irq and bh_kunmap_irq!!
32 */
33 static inline char *bh_kmap_irq(struct buffer_head *bh, unsigned long *flags)
34 {
35 unsigned long addr;
37 __save_flags(*flags);
39 /*
40 * could be low
41 */
42 if (!PageHighMem(bh->b_page))
43 return bh->b_data;
45 /*
46 * it's a highmem page
47 */
48 __cli();
49 addr = (unsigned long) kmap_atomic(bh->b_page, KM_BH_IRQ);
51 if (addr & ~PAGE_MASK)
52 BUG();
54 return (char *) addr + bh_offset(bh);
55 }
57 static inline void bh_kunmap_irq(char *buffer, unsigned long *flags)
58 {
59 unsigned long ptr = (unsigned long) buffer & PAGE_MASK;
61 kunmap_atomic((void *) ptr, KM_BH_IRQ);
62 __restore_flags(*flags);
63 }
65 #else /* CONFIG_HIGHMEM */
67 static inline unsigned int nr_free_highpages(void) { return 0; }
68 static inline void kmap_flush_unused(void) { }
70 static inline void *kmap(struct page *page) { return page_address(page); }
72 #define kunmap(page) do { } while (0)
74 #define kmap_atomic(page,idx) kmap(page)
75 #define kunmap_atomic(page,idx) kunmap(page)
77 #define bh_kmap(bh) ((bh)->b_data)
78 #define bh_kunmap(bh) do { } while (0)
79 #define kmap_nonblock(page) kmap(page)
80 #define bh_kmap_irq(bh, flags) ((bh)->b_data)
81 #define bh_kunmap_irq(bh, flags) do { *(flags) = 0; } while (0)
83 #endif /* CONFIG_HIGHMEM */
85 /* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
86 static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
87 {
88 void *addr = kmap_atomic(page, KM_USER0);
89 clear_user_page(addr, vaddr);
90 kunmap_atomic(addr, KM_USER0);
91 }
93 static inline void clear_highpage(struct page *page)
94 {
95 clear_page(kmap(page));
96 kunmap(page);
97 }
99 /*
100 * Same but also flushes aliased cache contents to RAM.
101 */
102 static inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size)
103 {
104 char *kaddr;
106 if (offset + size > PAGE_SIZE)
107 out_of_line_bug();
108 kaddr = kmap(page);
109 memset(kaddr + offset, 0, size);
110 flush_dcache_page(page);
111 flush_page_to_ram(page);
112 kunmap(page);
113 }
115 static inline void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr)
116 {
117 char *vfrom, *vto;
119 vfrom = kmap_atomic(from, KM_USER0);
120 vto = kmap_atomic(to, KM_USER1);
121 copy_user_page(vto, vfrom, vaddr);
122 kunmap_atomic(vfrom, KM_USER0);
123 kunmap_atomic(vto, KM_USER1);
124 }
126 static inline void copy_highpage(struct page *to, struct page *from)
127 {
128 char *vfrom, *vto;
130 vfrom = kmap_atomic(from, KM_USER0);
131 vto = kmap_atomic(to, KM_USER1);
132 copy_page(vto, vfrom);
133 kunmap_atomic(vfrom, KM_USER0);
134 kunmap_atomic(vto, KM_USER1);
135 }
137 #endif /* _LINUX_HIGHMEM_H */