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 */
65 FIX_KMAP_BEGIN
, /* reserved pte's for temporary kernel mappings */
66 FIX_KMAP_END
= FIX_KMAP_BEGIN
+(KM_TYPE_NR
*NR_CPUS
)-1,
68 __end_of_fixed_addresses
71 extern void __set_fixmap (enum fixed_addresses idx
,
72 unsigned long phys
, pgprot_t flags
);
74 #define set_fixmap(idx, phys) \
75 __set_fixmap(idx, phys, PAGE_KERNEL)
77 * Some hardware wants to get fixmapped without caching.
79 #define set_fixmap_nocache(idx, phys) \
80 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
84 * Leave one empty page between vmalloc'ed areas and
85 * the start of the fixmap, and leave one page empty
88 #define FIXADDR_TOP (0xffffe000UL)
89 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
90 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
92 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
94 extern void __this_fixmap_does_not_exist(void);
97 * 'index to address' translation. If anyone tries to use the idx
98 * directly without tranlation, we catch the bug with a NULL-deference
99 * kernel oops. Illegal ranges of incoming indices are caught too.
101 extern inline unsigned long fix_to_virt(const unsigned int idx
)
104 * this branch gets completely eliminated after inlining,
105 * except when someone tries to use fixaddr indices in an
106 * illegal way. (such as mixing up address types or using
107 * out-of-range indices).
109 * If it doesn't get removed, the linker will complain
110 * loudly with a reasonably clear error message..
112 if (idx
>= __end_of_fixed_addresses
)
113 __this_fixmap_does_not_exist();
115 return __fix_to_virt(idx
);