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