xref: /OK3568_Linux_fs/kernel/arch/arm64/include/asm/fixmap.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * fixmap.h: compile-time virtual memory allocation
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
5*4882a593Smuzhiyun  * License.  See the file "COPYING" in the main directory of this archive
6*4882a593Smuzhiyun  * for more details.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Copyright (C) 1998 Ingo Molnar
9*4882a593Smuzhiyun  * Copyright (C) 2013 Mark Salter <msalter@redhat.com>
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * Adapted from arch/x86 version.
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  */
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifndef _ASM_ARM64_FIXMAP_H
16*4882a593Smuzhiyun #define _ASM_ARM64_FIXMAP_H
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #ifndef __ASSEMBLY__
19*4882a593Smuzhiyun #include <linux/kernel.h>
20*4882a593Smuzhiyun #include <linux/sizes.h>
21*4882a593Smuzhiyun #include <asm/boot.h>
22*4882a593Smuzhiyun #include <asm/page.h>
23*4882a593Smuzhiyun #include <asm/pgtable-prot.h>
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /*
26*4882a593Smuzhiyun  * Here we define all the compile-time 'special' virtual
27*4882a593Smuzhiyun  * addresses. The point is to have a constant address at
28*4882a593Smuzhiyun  * compile time, but to set the physical address only
29*4882a593Smuzhiyun  * in the boot process.
30*4882a593Smuzhiyun  *
31*4882a593Smuzhiyun  * Each enum increment in these 'compile-time allocated'
32*4882a593Smuzhiyun  * memory buffers is page-sized. Use set_fixmap(idx,phys)
33*4882a593Smuzhiyun  * to associate physical memory with a fixmap index.
34*4882a593Smuzhiyun  */
35*4882a593Smuzhiyun enum fixed_addresses {
36*4882a593Smuzhiyun 	FIX_HOLE,
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 	/*
39*4882a593Smuzhiyun 	 * Reserve a virtual window for the FDT that is 2 MB larger than the
40*4882a593Smuzhiyun 	 * maximum supported size, and put it at the top of the fixmap region.
41*4882a593Smuzhiyun 	 * The additional space ensures that any FDT that does not exceed
42*4882a593Smuzhiyun 	 * MAX_FDT_SIZE can be mapped regardless of whether it crosses any
43*4882a593Smuzhiyun 	 * 2 MB alignment boundaries.
44*4882a593Smuzhiyun 	 *
45*4882a593Smuzhiyun 	 * Keep this at the top so it remains 2 MB aligned.
46*4882a593Smuzhiyun 	 */
47*4882a593Smuzhiyun #define FIX_FDT_SIZE		(MAX_FDT_SIZE + SZ_2M)
48*4882a593Smuzhiyun 	FIX_FDT_END,
49*4882a593Smuzhiyun 	FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun 	FIX_EARLYCON_MEM_BASE,
52*4882a593Smuzhiyun 	FIX_TEXT_POKE0,
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #ifdef CONFIG_ACPI_APEI_GHES
55*4882a593Smuzhiyun 	/* Used for GHES mapping from assorted contexts */
56*4882a593Smuzhiyun 	FIX_APEI_GHES_IRQ,
57*4882a593Smuzhiyun 	FIX_APEI_GHES_SEA,
58*4882a593Smuzhiyun #ifdef CONFIG_ARM_SDE_INTERFACE
59*4882a593Smuzhiyun 	FIX_APEI_GHES_SDEI_NORMAL,
60*4882a593Smuzhiyun 	FIX_APEI_GHES_SDEI_CRITICAL,
61*4882a593Smuzhiyun #endif
62*4882a593Smuzhiyun #endif /* CONFIG_ACPI_APEI_GHES */
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
65*4882a593Smuzhiyun 	FIX_ENTRY_TRAMP_TEXT3,
66*4882a593Smuzhiyun 	FIX_ENTRY_TRAMP_TEXT2,
67*4882a593Smuzhiyun 	FIX_ENTRY_TRAMP_TEXT1,
68*4882a593Smuzhiyun 	FIX_ENTRY_TRAMP_DATA,
69*4882a593Smuzhiyun #define TRAMP_VALIAS		(__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1))
70*4882a593Smuzhiyun #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
71*4882a593Smuzhiyun 	__end_of_permanent_fixed_addresses,
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 	/*
74*4882a593Smuzhiyun 	 * Temporary boot-time mappings, used by early_ioremap(),
75*4882a593Smuzhiyun 	 * before ioremap() is functional.
76*4882a593Smuzhiyun 	 */
77*4882a593Smuzhiyun #define NR_FIX_BTMAPS		(SZ_256K / PAGE_SIZE)
78*4882a593Smuzhiyun #define FIX_BTMAPS_SLOTS	7
79*4882a593Smuzhiyun #define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun 	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
82*4882a593Smuzhiyun 	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun 	/*
85*4882a593Smuzhiyun 	 * Used for kernel page table creation, so unmapped memory may be used
86*4882a593Smuzhiyun 	 * for tables.
87*4882a593Smuzhiyun 	 */
88*4882a593Smuzhiyun 	FIX_PTE,
89*4882a593Smuzhiyun 	FIX_PMD,
90*4882a593Smuzhiyun 	FIX_PUD,
91*4882a593Smuzhiyun 	FIX_PGD,
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun 	__end_of_fixed_addresses
94*4882a593Smuzhiyun };
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #define FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
97*4882a593Smuzhiyun #define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun #define FIXMAP_PAGE_IO     __pgprot(PROT_DEVICE_nGnRE)
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun void __init early_fixmap_init(void);
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun #define __early_set_fixmap __set_fixmap
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun #define __late_set_fixmap __set_fixmap
106*4882a593Smuzhiyun #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun #include <asm-generic/fixmap.h>
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun #endif /* !__ASSEMBLY__ */
113*4882a593Smuzhiyun #endif /* _ASM_ARM64_FIXMAP_H */
114