fixmap.h 4.7 KB
Newer Older
G
Gustavo F. Padovan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * fixmap.h: compile-time virtual memory allocation
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1998 Ingo Molnar
 *
 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
 * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009
 */

H
H. Peter Anvin 已提交
14 15
#ifndef _ASM_X86_FIXMAP_H
#define _ASM_X86_FIXMAP_H
16

G
Gustavo F. Padovan 已提交
17 18 19 20 21 22 23 24 25
#ifndef __ASSEMBLY__
#include <linux/kernel.h>
#include <asm/acpi.h>
#include <asm/apicdef.h>
#include <asm/page.h>
#ifdef CONFIG_X86_32
#include <linux/threads.h>
#include <asm/kmap_types.h>
#else
26
#include <uapi/asm/vsyscall.h>
G
Gustavo F. Padovan 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#endif

/*
 * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall
 * uses fixmaps that relies on FIXADDR_TOP for proper address calculation.
 * Because of this, FIXADDR_TOP x86 integration was left as later work.
 */
#ifdef CONFIG_X86_32
/* used by vmalloc.c, vsyscall.lds.S.
 *
 * Leave one empty page between vmalloc'ed areas and
 * the start of the fixmap.
 */
extern unsigned long __FIXADDR_TOP;
#define FIXADDR_TOP	((unsigned long)__FIXADDR_TOP)
#else
43 44
#define FIXADDR_TOP	(round_up(VSYSCALL_ADDR + PAGE_SIZE, 1<<PMD_SHIFT) - \
			 PAGE_SIZE)
G
Gustavo F. Padovan 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#endif


/*
 * Here we define all the compile-time 'special' virtual
 * addresses. The point is to have a constant address at
 * compile time, but to set the physical address only
 * in the boot process.
 * for x86_32: We allocate these special addresses
 * from the end of virtual memory (0xfffff000) backwards.
 * Also this lets us do fail-safe vmalloc(), we
 * can guarantee that these special addresses and
 * vmalloc()-ed addresses never overlap.
 *
 * These 'compile-time allocated' memory buffers are
 * fixed-size 4k pages (or larger if used with an increment
 * higher than 1). Use set_fixmap(idx,phys) to associate
 * physical memory with fixmap indices.
 *
 * TLB entries of such buffers will not be flushed across
 * task switches.
 */
enum fixed_addresses {
68
#ifdef CONFIG_X86_32
G
Gustavo F. Padovan 已提交
69
	FIX_HOLE,
70
#else
71
#ifdef CONFIG_X86_VSYSCALL_EMULATION
72
	VSYSCALL_PAGE = (FIXADDR_TOP - VSYSCALL_ADDR) >> PAGE_SHIFT,
73
#endif
74
#endif
G
Gustavo F. Padovan 已提交
75 76
	FIX_DBGP_BASE,
	FIX_EARLYCON_MEM_BASE,
77 78 79
#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
	FIX_OHCI1394_BASE,
#endif
G
Gustavo F. Padovan 已提交
80 81 82 83 84 85 86
#ifdef CONFIG_X86_LOCAL_APIC
	FIX_APIC_BASE,	/* local (CPU) APIC) -- required for SMP or not */
#endif
#ifdef CONFIG_X86_IO_APIC
	FIX_IO_APIC_BASE_0,
	FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,
#endif
87
	FIX_RO_IDT,	/* Virtual mapping for read-only IDT */
G
Gustavo F. Padovan 已提交
88 89 90 91 92 93 94 95 96 97
#ifdef CONFIG_X86_32
	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#ifdef CONFIG_PCI_MMCONFIG
	FIX_PCIE_MCFG,
#endif
#endif
#ifdef CONFIG_PARAVIRT
	FIX_PARAVIRT_BOOTMAP,
#endif
98 99
	FIX_TEXT_POKE1,	/* reserve 2 pages for text_poke() */
	FIX_TEXT_POKE0, /* first page is last, because allocation is backward */
100
#ifdef	CONFIG_X86_INTEL_MID
101 102
	FIX_LNW_VRTC,
#endif
103 104
	__end_of_permanent_fixed_addresses,

G
Gustavo F. Padovan 已提交
105
	/*
106
	 * 512 temporary boot-time mappings, used by early_ioremap(),
G
Gustavo F. Padovan 已提交
107 108
	 * before ioremap() is functional.
	 *
109
	 * If necessary we round it up to the next 512 pages boundary so
110
	 * that we can have a single pgd entry and a single pte table:
G
Gustavo F. Padovan 已提交
111 112
	 */
#define NR_FIX_BTMAPS		64
113
#define FIX_BTMAPS_SLOTS	8
114 115 116 117 118 119 120 121 122
#define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
	FIX_BTMAP_END =
	 (__end_of_permanent_fixed_addresses ^
	  (__end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 1)) &
	 -PTRS_PER_PTE
	 ? __end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS -
	   (__end_of_permanent_fixed_addresses & (TOTAL_FIX_BTMAPS - 1))
	 : __end_of_permanent_fixed_addresses,
	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
G
Gustavo F. Padovan 已提交
123 124
#ifdef CONFIG_X86_32
	FIX_WP_TEST,
125 126 127
#endif
#ifdef CONFIG_INTEL_TXT
	FIX_TBOOT_BASE,
G
Gustavo F. Padovan 已提交
128 129 130 131 132 133 134 135 136
#endif
	__end_of_fixed_addresses
};


extern void reserve_top_address(unsigned long reserve);

#define FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
#define FIXADDR_START		(FIXADDR_TOP - FIXADDR_SIZE)
137

J
Jeremy Fitzhardinge 已提交
138 139
extern int fixmaps_set;

140 141 142 143
extern pte_t *kmap_pte;
extern pgprot_t kmap_prot;
extern pte_t *pkmap_page_table;

144 145
void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
void native_set_fixmap(enum fixed_addresses idx,
146
		       phys_addr_t phys, pgprot_t flags);
147 148 149

#ifndef CONFIG_PARAVIRT
static inline void __set_fixmap(enum fixed_addresses idx,
150
				phys_addr_t phys, pgprot_t flags)
151 152 153 154 155
{
	native_set_fixmap(idx, phys, flags);
}
#endif

M
Mark Salter 已提交
156
#include <asm-generic/fixmap.h>
157

M
Mark Salter 已提交
158 159 160 161 162 163
#define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags)
#define __late_clear_fixmap(idx) __set_fixmap(idx, 0, __pgprot(0))

void __early_set_fixmap(enum fixed_addresses idx,
			phys_addr_t phys, pgprot_t flags);

G
Gustavo F. Padovan 已提交
164
#endif /* !__ASSEMBLY__ */
H
H. Peter Anvin 已提交
165
#endif /* _ASM_X86_FIXMAP_H */