2 * fixmap.h: compile-time virtual memory allocation
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
8 * Copyright (C) 1998 Ingo Molnar
10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
16 #include <linux/config.h>
17 #include <linux/kernel.h>
18 #include <asm/apicdef.h>
21 #include <linux/threads.h>
22 #include <asm/kmap_types.h>
26 * Here we define all the compile-time 'special' virtual
27 * addresses. The point is to have a constant address at
28 * compile time, but to set the physical address only
29 * in the boot process. We allocate these special addresses
30 * from the end of virtual memory (0xfffff000) backwards.
31 * Also this lets us do fail-safe vmalloc(), we
32 * can guarantee that these special addresses and
33 * vmalloc()-ed addresses never overlap.
35 * these 'compile-time allocated' memory buffers are
36 * fixed-size 4k pages. (or larger if used with an increment
37 * highger than 1) use fixmap_set(idx,phys) to associate
38 * physical memory with fixmap indices.
40 * TLB entries of such buffers will not be flushed across
45 * on UP currently we will have no trace of the fixmap mechanizm,
46 * no page table allocations, etc. This might change in the
47 * future, say framebuffers for the console driver(s) could be
50 enum fixed_addresses {
51 #ifdef CONFIG_X86_LOCAL_APIC
52 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
54 #ifdef CONFIG_X86_IO_APIC
56 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
58 #ifdef CONFIG_X86_VISWS_APIC
59 FIX_CO_CPU, /* Cobalt timer */
60 FIX_CO_APIC, /* Cobalt APIC Redirection Table */
61 FIX_LI_PCIA, /* Lithium PCI Bridge A */
62 FIX_LI_PCIB, /* Lithium PCI Bridge B */
64 #ifndef CONFIG_X86_F00F_WORKS_OK
67 #ifdef CONFIG_X86_SUMMIT
68 FIX_CYCLONE_TIMER, /*cyclone timer register*/
71 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
72 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
74 __end_of_permanent_fixed_addresses,
75 /* temporary boot-time mappings, used before ioremap() is functional */
76 #define NR_FIX_BTMAPS 16
77 FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
78 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
79 __end_of_fixed_addresses
82 extern void __set_fixmap (enum fixed_addresses idx,
83 unsigned long phys, pgprot_t flags);
85 #define set_fixmap(idx, phys) \
86 __set_fixmap(idx, phys, PAGE_KERNEL)
88 * Some hardware wants to get fixmapped without caching.
90 #define set_fixmap_nocache(idx, phys) \
91 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
95 * Leave one empty page between vmalloc'ed areas and
96 * the start of the fixmap, and leave one page empty
99 #define FIXADDR_TOP (0xffffe000UL)
100 #define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
101 #define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
103 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
105 extern void __this_fixmap_does_not_exist(void);
108 * 'index to address' translation. If anyone tries to use the idx
109 * directly without tranlation, we catch the bug with a NULL-deference
110 * kernel oops. Illegal ranges of incoming indices are caught too.
112 static inline unsigned long fix_to_virt(const unsigned int idx)
115 * this branch gets completely eliminated after inlining,
116 * except when someone tries to use fixaddr indices in an
117 * illegal way. (such as mixing up address types or using
118 * out-of-range indices).
120 * If it doesn't get removed, the linker will complain
121 * loudly with a reasonably clear error message..
123 if (idx >= __end_of_fixed_addresses)
124 __this_fixmap_does_not_exist();
126 return __fix_to_virt(idx);