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
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
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
42 enum fixed_addresses
{
47 __end_of_fixed_addresses
50 extern void set_fixmap (enum fixed_addresses idx
, unsigned long phys
);
55 * Leave one empty page between vmalloc'ed areas and
56 * the start of the fixmap, and leave one page empty
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
);