diff options
author | Mark Salter <msalter@redhat.com> | 2014-01-23 18:53:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:36:54 -0500 |
commit | d57c33c5daa4efa9e4d303bd0faf868080b532be (patch) | |
tree | 673bc9e2a1769c4d8b380b7a385dd7be681b99b2 /include/asm-generic | |
parent | 2252b62a56601c9e31396da230b4ce792f167fb4 (diff) |
add generic fixmap.h
Many architectures provide an asm/fixmap.h which defines support for
compile-time 'special' virtual mappings which need to be made before
paging_init() has run. This support is also used for early ioremap on
x86. Much of this support is identical across the architectures. This
patch consolidates all of the common bits into asm-generic/fixmap.h
which is intended to be included from arch/*/include/asm/fixmap.h.
Signed-off-by: Mark Salter <msalter@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/fixmap.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h new file mode 100644 index 000000000000..5a64ca4621f3 --- /dev/null +++ b/include/asm-generic/fixmap.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * fixmap.h: compile-time virtual memory allocation | ||
3 | * | ||
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 | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1998 Ingo Molnar | ||
9 | * | ||
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 | ||
12 | * Break out common bits to asm-generic by Mark Salter, November 2013 | ||
13 | */ | ||
14 | |||
15 | #ifndef __ASM_GENERIC_FIXMAP_H | ||
16 | #define __ASM_GENERIC_FIXMAP_H | ||
17 | |||
18 | #include <linux/bug.h> | ||
19 | |||
20 | #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) | ||
21 | #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) | ||
22 | |||
23 | #ifndef __ASSEMBLY__ | ||
24 | /* | ||
25 | * 'index to address' translation. If anyone tries to use the idx | ||
26 | * directly without translation, we catch the bug with a NULL-deference | ||
27 | * kernel oops. Illegal ranges of incoming indices are caught too. | ||
28 | */ | ||
29 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) | ||
30 | { | ||
31 | BUILD_BUG_ON(idx >= __end_of_fixed_addresses); | ||
32 | return __fix_to_virt(idx); | ||
33 | } | ||
34 | |||
35 | static inline unsigned long virt_to_fix(const unsigned long vaddr) | ||
36 | { | ||
37 | BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); | ||
38 | return __virt_to_fix(vaddr); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * Provide some reasonable defaults for page flags. | ||
43 | * Not all architectures use all of these different types and some | ||
44 | * architectures use different names. | ||
45 | */ | ||
46 | #ifndef FIXMAP_PAGE_NORMAL | ||
47 | #define FIXMAP_PAGE_NORMAL PAGE_KERNEL | ||
48 | #endif | ||
49 | #ifndef FIXMAP_PAGE_NOCACHE | ||
50 | #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE | ||
51 | #endif | ||
52 | #ifndef FIXMAP_PAGE_IO | ||
53 | #define FIXMAP_PAGE_IO PAGE_KERNEL_IO | ||
54 | #endif | ||
55 | #ifndef FIXMAP_PAGE_CLEAR | ||
56 | #define FIXMAP_PAGE_CLEAR __pgprot(0) | ||
57 | #endif | ||
58 | |||
59 | #ifndef set_fixmap | ||
60 | #define set_fixmap(idx, phys) \ | ||
61 | __set_fixmap(idx, phys, FIXMAP_PAGE_NORMAL) | ||
62 | #endif | ||
63 | |||
64 | #ifndef clear_fixmap | ||
65 | #define clear_fixmap(idx) \ | ||
66 | __set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR) | ||
67 | #endif | ||
68 | |||
69 | /* Return a pointer with offset calculated */ | ||
70 | #define __set_fixmap_offset(idx, phys, flags) \ | ||
71 | ({ \ | ||
72 | unsigned long addr; \ | ||
73 | __set_fixmap(idx, phys, flags); \ | ||
74 | addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \ | ||
75 | addr; \ | ||
76 | }) | ||
77 | |||
78 | #define set_fixmap_offset(idx, phys) \ | ||
79 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL) | ||
80 | |||
81 | /* | ||
82 | * Some hardware wants to get fixmapped without caching. | ||
83 | */ | ||
84 | #define set_fixmap_nocache(idx, phys) \ | ||
85 | __set_fixmap(idx, phys, FIXMAP_PAGE_NOCACHE) | ||
86 | |||
87 | #define set_fixmap_offset_nocache(idx, phys) \ | ||
88 | __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NOCACHE) | ||
89 | |||
90 | /* | ||
91 | * Some fixmaps are for IO | ||
92 | */ | ||
93 | #define set_fixmap_io(idx, phys) \ | ||
94 | __set_fixmap(idx, phys, FIXMAP_PAGE_IO) | ||
95 | |||
96 | #endif /* __ASSEMBLY__ */ | ||
97 | #endif /* __ASM_GENERIC_FIXMAP_H */ | ||