make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-i386 / fixmap.h
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  */
12
13 #ifndef _ASM_FIXMAP_H
14 #define _ASM_FIXMAP_H
15
16 #include <linux/config.h>
17 #include <linux/kernel.h>
18 #include <asm/apicdef.h>
19 #include <asm/page.h>
20 #ifdef CONFIG_HIGHMEM
21 #include <linux/threads.h>
22 #include <asm/kmap_types.h>
23 #endif
24
25 /*
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.
34  *
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.
39  *
40  * TLB entries of such buffers will not be flushed across
41  * task switches.
42  */
43
44 /*
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
48  * fix-mapped?
49  */
50 enum fixed_addresses {
51 #ifdef CONFIG_X86_LOCAL_APIC
52         FIX_APIC_BASE,  /* local (CPU) APIC) -- required for SMP or not */
53 #endif
54 #ifdef CONFIG_X86_IO_APIC
55         FIX_IO_APIC_BASE_0,
56         FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
57 #endif
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 */
63 #endif
64 #ifndef CONFIG_X86_F00F_WORKS_OK
65         FIX_F00F,
66 #endif
67 #ifdef CONFIG_X86_SUMMIT
68         FIX_CYCLONE_TIMER, /*cyclone timer register*/
69 #endif 
70 #ifdef CONFIG_HIGHMEM
71         FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
72         FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
73 #endif
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
80 };
81
82 extern void __set_fixmap (enum fixed_addresses idx,
83                                         unsigned long phys, pgprot_t flags);
84
85 #define set_fixmap(idx, phys) \
86                 __set_fixmap(idx, phys, PAGE_KERNEL)
87 /*
88  * Some hardware wants to get fixmapped without caching.
89  */
90 #define set_fixmap_nocache(idx, phys) \
91                 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
92 /*
93  * used by vmalloc.c.
94  *
95  * Leave one empty page between vmalloc'ed areas and
96  * the start of the fixmap, and leave one page empty
97  * at the top of mem..
98  */
99 #define FIXADDR_TOP     (0xffffe000UL)
100 #define __FIXADDR_SIZE  (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
101 #define FIXADDR_START   (FIXADDR_TOP - __FIXADDR_SIZE)
102
103 #define __fix_to_virt(x)        (FIXADDR_TOP - ((x) << PAGE_SHIFT))
104
105 extern void __this_fixmap_does_not_exist(void);
106
107 /*
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.
111  */
112 static inline unsigned long fix_to_virt(const unsigned int idx)
113 {
114         /*
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).
119          *
120          * If it doesn't get removed, the linker will complain
121          * loudly with a reasonably clear error message..
122          */
123         if (idx >= __end_of_fixed_addresses)
124                 __this_fixmap_does_not_exist();
125
126         return __fix_to_virt(idx);
127 }
128
129 #endif