ia64/linux-2.6.18-xen.hg

annotate include/asm-i386/fixmap.h @ 0:831230e53067

Import 2.6.18 from kernel.org tarball.
author Ian Campbell <ian.campbell@xensource.com>
date Wed Apr 11 14:15:44 2007 +0100 (2007-04-11)
parents
children cb5094f46707
rev   line source
ian@0 1 /*
ian@0 2 * fixmap.h: compile-time virtual memory allocation
ian@0 3 *
ian@0 4 * This file is subject to the terms and conditions of the GNU General Public
ian@0 5 * License. See the file "COPYING" in the main directory of this archive
ian@0 6 * for more details.
ian@0 7 *
ian@0 8 * Copyright (C) 1998 Ingo Molnar
ian@0 9 *
ian@0 10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
ian@0 11 */
ian@0 12
ian@0 13 #ifndef _ASM_FIXMAP_H
ian@0 14 #define _ASM_FIXMAP_H
ian@0 15
ian@0 16
ian@0 17 /* used by vmalloc.c, vsyscall.lds.S.
ian@0 18 *
ian@0 19 * Leave one empty page between vmalloc'ed areas and
ian@0 20 * the start of the fixmap.
ian@0 21 */
ian@0 22 #define __FIXADDR_TOP 0xfffff000
ian@0 23
ian@0 24 #ifndef __ASSEMBLY__
ian@0 25 #include <linux/kernel.h>
ian@0 26 #include <asm/acpi.h>
ian@0 27 #include <asm/apicdef.h>
ian@0 28 #include <asm/page.h>
ian@0 29 #ifdef CONFIG_HIGHMEM
ian@0 30 #include <linux/threads.h>
ian@0 31 #include <asm/kmap_types.h>
ian@0 32 #endif
ian@0 33
ian@0 34 /*
ian@0 35 * Here we define all the compile-time 'special' virtual
ian@0 36 * addresses. The point is to have a constant address at
ian@0 37 * compile time, but to set the physical address only
ian@0 38 * in the boot process. We allocate these special addresses
ian@0 39 * from the end of virtual memory (0xfffff000) backwards.
ian@0 40 * Also this lets us do fail-safe vmalloc(), we
ian@0 41 * can guarantee that these special addresses and
ian@0 42 * vmalloc()-ed addresses never overlap.
ian@0 43 *
ian@0 44 * these 'compile-time allocated' memory buffers are
ian@0 45 * fixed-size 4k pages. (or larger if used with an increment
ian@0 46 * highger than 1) use fixmap_set(idx,phys) to associate
ian@0 47 * physical memory with fixmap indices.
ian@0 48 *
ian@0 49 * TLB entries of such buffers will not be flushed across
ian@0 50 * task switches.
ian@0 51 */
ian@0 52 enum fixed_addresses {
ian@0 53 FIX_HOLE,
ian@0 54 FIX_VDSO,
ian@0 55 #ifdef CONFIG_X86_LOCAL_APIC
ian@0 56 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
ian@0 57 #endif
ian@0 58 #ifdef CONFIG_X86_IO_APIC
ian@0 59 FIX_IO_APIC_BASE_0,
ian@0 60 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
ian@0 61 #endif
ian@0 62 #ifdef CONFIG_X86_VISWS_APIC
ian@0 63 FIX_CO_CPU, /* Cobalt timer */
ian@0 64 FIX_CO_APIC, /* Cobalt APIC Redirection Table */
ian@0 65 FIX_LI_PCIA, /* Lithium PCI Bridge A */
ian@0 66 FIX_LI_PCIB, /* Lithium PCI Bridge B */
ian@0 67 #endif
ian@0 68 #ifdef CONFIG_X86_F00F_BUG
ian@0 69 FIX_F00F_IDT, /* Virtual mapping for IDT */
ian@0 70 #endif
ian@0 71 #ifdef CONFIG_X86_CYCLONE_TIMER
ian@0 72 FIX_CYCLONE_TIMER, /*cyclone timer register*/
ian@0 73 #endif
ian@0 74 #ifdef CONFIG_HIGHMEM
ian@0 75 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
ian@0 76 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
ian@0 77 #endif
ian@0 78 #ifdef CONFIG_ACPI
ian@0 79 FIX_ACPI_BEGIN,
ian@0 80 FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
ian@0 81 #endif
ian@0 82 #ifdef CONFIG_PCI_MMCONFIG
ian@0 83 FIX_PCIE_MCFG,
ian@0 84 #endif
ian@0 85 __end_of_permanent_fixed_addresses,
ian@0 86 /* temporary boot-time mappings, used before ioremap() is functional */
ian@0 87 #define NR_FIX_BTMAPS 16
ian@0 88 FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
ian@0 89 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
ian@0 90 FIX_WP_TEST,
ian@0 91 __end_of_fixed_addresses
ian@0 92 };
ian@0 93
ian@0 94 extern void __set_fixmap (enum fixed_addresses idx,
ian@0 95 unsigned long phys, pgprot_t flags);
ian@0 96
ian@0 97 #define set_fixmap(idx, phys) \
ian@0 98 __set_fixmap(idx, phys, PAGE_KERNEL)
ian@0 99 /*
ian@0 100 * Some hardware wants to get fixmapped without caching.
ian@0 101 */
ian@0 102 #define set_fixmap_nocache(idx, phys) \
ian@0 103 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
ian@0 104
ian@0 105 #define clear_fixmap(idx) \
ian@0 106 __set_fixmap(idx, 0, __pgprot(0))
ian@0 107
ian@0 108 #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)
ian@0 109
ian@0 110 #define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
ian@0 111 #define __FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
ian@0 112 #define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
ian@0 113 #define FIXADDR_BOOT_START (FIXADDR_TOP - __FIXADDR_BOOT_SIZE)
ian@0 114
ian@0 115 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
ian@0 116 #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
ian@0 117
ian@0 118 extern void __this_fixmap_does_not_exist(void);
ian@0 119
ian@0 120 /*
ian@0 121 * 'index to address' translation. If anyone tries to use the idx
ian@0 122 * directly without tranlation, we catch the bug with a NULL-deference
ian@0 123 * kernel oops. Illegal ranges of incoming indices are caught too.
ian@0 124 */
ian@0 125 static __always_inline unsigned long fix_to_virt(const unsigned int idx)
ian@0 126 {
ian@0 127 /*
ian@0 128 * this branch gets completely eliminated after inlining,
ian@0 129 * except when someone tries to use fixaddr indices in an
ian@0 130 * illegal way. (such as mixing up address types or using
ian@0 131 * out-of-range indices).
ian@0 132 *
ian@0 133 * If it doesn't get removed, the linker will complain
ian@0 134 * loudly with a reasonably clear error message..
ian@0 135 */
ian@0 136 if (idx >= __end_of_fixed_addresses)
ian@0 137 __this_fixmap_does_not_exist();
ian@0 138
ian@0 139 return __fix_to_virt(idx);
ian@0 140 }
ian@0 141
ian@0 142 static inline unsigned long virt_to_fix(const unsigned long vaddr)
ian@0 143 {
ian@0 144 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
ian@0 145 return __virt_to_fix(vaddr);
ian@0 146 }
ian@0 147
ian@0 148 #endif /* !__ASSEMBLY__ */
ian@0 149 #endif