Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | #ifndef _LINUX_HIGHMEM_H |
2 | #define _LINUX_HIGHMEM_H |
||
3 | |||
4 | #include <linux/config.h> |
||
5 | #include <linux/fs.h> |
||
6 | #include <linux/mm.h> |
||
7 | |||
8 | #include <asm/cacheflush.h> |
||
9 | |||
10 | #ifdef CONFIG_HIGHMEM |
||
11 | |||
12 | extern struct page *highmem_start_page; |
||
13 | |||
14 | #include <asm/highmem.h> |
||
15 | |||
16 | /* declarations for linux/mm/highmem.c */ |
||
17 | unsigned int nr_free_highpages(void); |
||
18 | |||
19 | #else /* CONFIG_HIGHMEM */ |
||
20 | |||
21 | static inline unsigned int nr_free_highpages(void) { return 0; } |
||
22 | |||
23 | static inline void *kmap(struct page *page) |
||
24 | { |
||
25 | might_sleep(); |
||
26 | return page_address(page); |
||
27 | } |
||
28 | |||
29 | #define kunmap(page) do { (void) (page); } while (0) |
||
30 | |||
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) |
||
34 | |||
35 | #endif /* CONFIG_HIGHMEM */ |
||
36 | |||
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) |
||
39 | { |
||
40 | void *addr = kmap_atomic(page, KM_USER0); |
||
41 | clear_user_page(addr, vaddr, page); |
||
42 | kunmap_atomic(addr, KM_USER0); |
||
43 | } |
||
44 | |||
45 | static inline void clear_highpage(struct page *page) |
||
46 | { |
||
47 | void *kaddr = kmap_atomic(page, KM_USER0); |
||
48 | clear_page(kaddr); |
||
49 | kunmap_atomic(kaddr, KM_USER0); |
||
50 | } |
||
51 | |||
52 | /* |
||
53 | * Same but also flushes aliased cache contents to RAM. |
||
54 | */ |
||
55 | static inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size) |
||
56 | { |
||
57 | void *kaddr; |
||
58 | |||
59 | if (offset + size > PAGE_SIZE) |
||
60 | BUG(); |
||
61 | |||
62 | kaddr = kmap_atomic(page, KM_USER0); |
||
63 | memset((char *)kaddr + offset, 0, size); |
||
64 | flush_dcache_page(page); |
||
65 | kunmap_atomic(kaddr, KM_USER0); |
||
66 | } |
||
67 | |||
68 | static inline void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr) |
||
69 | { |
||
70 | char *vfrom, *vto; |
||
71 | |||
72 | vfrom = kmap_atomic(from, KM_USER0); |
||
73 | vto = kmap_atomic(to, KM_USER1); |
||
74 | copy_user_page(vto, vfrom, vaddr, to); |
||
75 | kunmap_atomic(vfrom, KM_USER0); |
||
76 | kunmap_atomic(vto, KM_USER1); |
||
77 | } |
||
78 | |||
79 | static inline void copy_highpage(struct page *to, struct page *from) |
||
80 | { |
||
81 | char *vfrom, *vto; |
||
82 | |||
83 | vfrom = kmap_atomic(from, KM_USER0); |
||
84 | vto = kmap_atomic(to, KM_USER1); |
||
85 | copy_page(vto, vfrom); |
||
86 | kunmap_atomic(vfrom, KM_USER0); |
||
87 | kunmap_atomic(vto, KM_USER1); |
||
88 | } |
||
89 | |||
90 | #endif /* _LINUX_HIGHMEM_H */ |