Import 2.1.118
[davej-history.git] / include / asm-i386 / fixmap.h
blobdc9d624d70b534ebc01bbc2f072484890195973a
1 /*
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
6 * for more details.
8 * Copyright (C) 1998 Ingo Molnar
9 */
11 #ifndef _ASM_FIXMAP_H
12 #define _ASM_FIXMAP_H
14 #include <asm/page.h>
15 #include <linux/kernel.h>
18 * Here we define all the compile-time 'special' virtual
19 * addresses. The point is to have a constant address at
20 * compile time, but to set the physical address only
21 * in the boot process. We allocate these special addresses
22 * from the end of virtual memory (0xfffff000) backwards.
23 * Also this lets us do fail-safe vmalloc(), we
24 * can guarantee that these special addresses and
25 * vmalloc()-ed addresses never overlap.
27 * these 'compile-time allocated' memory buffers are
28 * fixed-size 4k pages. (or larger if used with an increment
29 * bigger than 1) use fixmap_set(idx,phys) to associate
30 * physical memory with fixmap indices.
32 * TLB entries of such buffers will not be flushed across
33 * task switches.
37 * on UP currently we will have no trace of the fixmap mechanizm,
38 * no page table allocations, etc. This might change in the
39 * future, say framebuffers for the console driver(s) could be
40 * fix-mapped?
42 enum fixed_addresses {
43 #if __SMP__
44 FIX_APIC_BASE,
45 FIX_IO_APIC_BASE,
46 #endif
47 __end_of_fixed_addresses
50 extern void set_fixmap (enum fixed_addresses idx, unsigned long phys);
53 * used by vmalloc.c.
55 * Leave one empty page between vmalloc'ed areas and
56 * the start of the fixmap, and leave one page empty
57 * at the top of mem..
59 #define FIXADDR_TOP (0xffffe000UL)
60 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
61 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
63 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
65 extern void __this_fixmap_does_not_exist(void);
68 * 'index to address' translation. If anyone tries to use the idx
69 * directly without tranlation, we catch the bug with a NULL-deference
70 * kernel oops. Illegal ranges of incoming indices are caught too.
72 extern inline unsigned long fix_to_virt(const unsigned int idx)
75 * this branch gets completely eliminated after inlining,
76 * except when someone tries to use fixaddr indices in an
77 * illegal way. (such as mixing up address types or using
78 * out-of-range indices).
80 * If it doesn't get removed, the linker will complain
81 * loudly with a reasonably clear error message..
83 if (idx >= __end_of_fixed_addresses)
84 __this_fixmap_does_not_exist();
86 return __fix_to_virt(idx);
89 #endif