Rev 6934 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6934 | Rev 7143 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * fixmap.h: compile-time virtual memory allocation |
2 | * fixmap.h: compile-time virtual memory allocation |
3 | * |
3 | * |
4 | * This file is subject to the terms and conditions of the GNU General Public |
4 | * This file is subject to the terms and conditions of the GNU General Public |
5 | * License. See the file "COPYING" in the main directory of this archive |
5 | * License. See the file "COPYING" in the main directory of this archive |
6 | * for more details. |
6 | * for more details. |
7 | * |
7 | * |
8 | * Copyright (C) 1998 Ingo Molnar |
8 | * Copyright (C) 1998 Ingo Molnar |
9 | * |
9 | * |
10 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 |
10 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 |
11 | * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009 |
11 | * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009 |
12 | * Break out common bits to asm-generic by Mark Salter, November 2013 |
12 | * Break out common bits to asm-generic by Mark Salter, November 2013 |
13 | */ |
13 | */ |
14 | 14 | ||
15 | #ifndef __ASM_GENERIC_FIXMAP_H |
15 | #ifndef __ASM_GENERIC_FIXMAP_H |
16 | #define __ASM_GENERIC_FIXMAP_H |
16 | #define __ASM_GENERIC_FIXMAP_H |
17 | 17 | ||
18 | #include |
18 | #include |
19 | 19 | ||
20 | #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) |
20 | #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) |
21 | #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) |
21 | #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) |
22 | 22 | ||
23 | #ifndef __ASSEMBLY__ |
23 | #ifndef __ASSEMBLY__ |
24 | /* |
24 | /* |
25 | * 'index to address' translation. If anyone tries to use the idx |
25 | * 'index to address' translation. If anyone tries to use the idx |
26 | * directly without translation, we catch the bug with a NULL-deference |
26 | * directly without translation, we catch the bug with a NULL-deference |
27 | * kernel oops. Illegal ranges of incoming indices are caught too. |
27 | * kernel oops. Illegal ranges of incoming indices are caught too. |
28 | */ |
28 | */ |
29 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) |
29 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) |
30 | { |
30 | { |
31 | BUILD_BUG_ON(idx >= __end_of_fixed_addresses); |
31 | BUILD_BUG_ON(idx >= __end_of_fixed_addresses); |
32 | return __fix_to_virt(idx); |
32 | return __fix_to_virt(idx); |
33 | } |
33 | } |
34 | 34 | ||
35 | static inline unsigned long virt_to_fix(const unsigned long vaddr) |
35 | static inline unsigned long virt_to_fix(const unsigned long vaddr) |
36 | { |
36 | { |
37 | BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); |
37 | BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); |
38 | return __virt_to_fix(vaddr); |
38 | return __virt_to_fix(vaddr); |
39 | } |
39 | } |
40 | 40 | ||
41 | /* |
41 | /* |
42 | * Provide some reasonable defaults for page flags. |
42 | * Provide some reasonable defaults for page flags. |
43 | * Not all architectures use all of these different types and some |
43 | * Not all architectures use all of these different types and some |
44 | * architectures use different names. |
44 | * architectures use different names. |
45 | */ |
45 | */ |
46 | #ifndef FIXMAP_PAGE_NORMAL |
46 | #ifndef FIXMAP_PAGE_NORMAL |
47 | #define FIXMAP_PAGE_NORMAL PAGE_KERNEL |
47 | #define FIXMAP_PAGE_NORMAL PAGE_KERNEL |
48 | #endif |
48 | #endif |
49 | #if !defined(FIXMAP_PAGE_RO) && defined(PAGE_KERNEL_RO) |
49 | #if !defined(FIXMAP_PAGE_RO) && defined(PAGE_KERNEL_RO) |
50 | #define FIXMAP_PAGE_RO PAGE_KERNEL_RO |
50 | #define FIXMAP_PAGE_RO PAGE_KERNEL_RO |
51 | #endif |
51 | #endif |
52 | #ifndef FIXMAP_PAGE_NOCACHE |
52 | #ifndef FIXMAP_PAGE_NOCACHE |
53 | #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE |
53 | #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE |
54 | #endif |
54 | #endif |
55 | #ifndef FIXMAP_PAGE_IO |
55 | #ifndef FIXMAP_PAGE_IO |
56 | #define FIXMAP_PAGE_IO PAGE_KERNEL_IO |
56 | #define FIXMAP_PAGE_IO PAGE_KERNEL_IO |
57 | #endif |
57 | #endif |
58 | #ifndef FIXMAP_PAGE_CLEAR |
58 | #ifndef FIXMAP_PAGE_CLEAR |
59 | #define FIXMAP_PAGE_CLEAR __pgprot(0) |
59 | #define FIXMAP_PAGE_CLEAR __pgprot(0) |
60 | #endif |
60 | #endif |
61 | 61 | ||
62 | #ifndef set_fixmap |
62 | #ifndef set_fixmap |
63 | #define set_fixmap(idx, phys) \ |
63 | #define set_fixmap(idx, phys) \ |
64 | __set_fixmap(idx, phys, FIXMAP_PAGE_NORMAL) |
64 | __set_fixmap(idx, phys, FIXMAP_PAGE_NORMAL) |
65 | #endif |
65 | #endif |
66 | 66 | ||
67 | #ifndef clear_fixmap |
67 | #ifndef clear_fixmap |
68 | #define clear_fixmap(idx) \ |
68 | #define clear_fixmap(idx) \ |
69 | __set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR) |
69 | __set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR) |
70 | #endif |
70 | #endif |
71 | 71 | ||
72 | /* Return a pointer with offset calculated */ |
72 | /* Return a pointer with offset calculated */ |
73 | #define __set_fixmap_offset(idx, phys, flags) \ |
73 | #define __set_fixmap_offset(idx, phys, flags) \ |
74 | ({ \ |
74 | ({ \ |
75 | unsigned long addr; \ |
75 | unsigned long ________addr; \ |
76 | __set_fixmap(idx, phys, flags); \ |
76 | __set_fixmap(idx, phys, flags); \ |
77 | addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \ |
77 | ________addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \ |
78 | addr; \ |
78 | ________addr; \ |
79 | }) |
79 | }) |
80 | 80 | ||
81 | #define set_fixmap_offset(idx, phys) \ |
81 | #define set_fixmap_offset(idx, phys) \ |
82 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL) |
82 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL) |
83 | 83 | ||
84 | /* |
84 | /* |
85 | * Some hardware wants to get fixmapped without caching. |
85 | * Some hardware wants to get fixmapped without caching. |
86 | */ |
86 | */ |
87 | #define set_fixmap_nocache(idx, phys) \ |
87 | #define set_fixmap_nocache(idx, phys) \ |
88 | __set_fixmap(idx, phys, FIXMAP_PAGE_NOCACHE) |
88 | __set_fixmap(idx, phys, FIXMAP_PAGE_NOCACHE) |
89 | 89 | ||
90 | #define set_fixmap_offset_nocache(idx, phys) \ |
90 | #define set_fixmap_offset_nocache(idx, phys) \ |
91 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NOCACHE) |
91 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NOCACHE) |
92 | 92 | ||
93 | /* |
93 | /* |
94 | * Some fixmaps are for IO |
94 | * Some fixmaps are for IO |
95 | */ |
95 | */ |
96 | #define set_fixmap_io(idx, phys) \ |
96 | #define set_fixmap_io(idx, phys) \ |
97 | __set_fixmap(idx, phys, FIXMAP_PAGE_IO) |
97 | __set_fixmap(idx, phys, FIXMAP_PAGE_IO) |
98 | 98 | ||
99 | #define set_fixmap_offset_io(idx, phys) \ |
99 | #define set_fixmap_offset_io(idx, phys) \ |
100 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_IO) |
100 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_IO) |
101 | 101 | ||
102 | #endif /* __ASSEMBLY__ */ |
102 | #endif /* __ASSEMBLY__ */ |
103 | #endif /* __ASM_GENERIC_FIXMAP_H */>><> |
103 | #endif /* __ASM_GENERIC_FIXMAP_H */>><> |