xref: /openbmc/linux/arch/arm64/include/asm/fixmap.h (revision 61bd93ce)
1bf4b558eSMark Salter /*
2bf4b558eSMark Salter  * fixmap.h: compile-time virtual memory allocation
3bf4b558eSMark Salter  *
4bf4b558eSMark Salter  * This file is subject to the terms and conditions of the GNU General Public
5bf4b558eSMark Salter  * License.  See the file "COPYING" in the main directory of this archive
6bf4b558eSMark Salter  * for more details.
7bf4b558eSMark Salter  *
8bf4b558eSMark Salter  * Copyright (C) 1998 Ingo Molnar
9bf4b558eSMark Salter  * Copyright (C) 2013 Mark Salter <msalter@redhat.com>
10bf4b558eSMark Salter  *
11bf4b558eSMark Salter  * Adapted from arch/x86_64 version.
12bf4b558eSMark Salter  *
13bf4b558eSMark Salter  */
14bf4b558eSMark Salter 
15bf4b558eSMark Salter #ifndef _ASM_ARM64_FIXMAP_H
16bf4b558eSMark Salter #define _ASM_ARM64_FIXMAP_H
17bf4b558eSMark Salter 
18bf4b558eSMark Salter #ifndef __ASSEMBLY__
19bf4b558eSMark Salter #include <linux/kernel.h>
2061bd93ceSArd Biesheuvel #include <asm/boot.h>
21bf4b558eSMark Salter #include <asm/page.h>
22bf4b558eSMark Salter 
23bf4b558eSMark Salter /*
24bf4b558eSMark Salter  * Here we define all the compile-time 'special' virtual
25bf4b558eSMark Salter  * addresses. The point is to have a constant address at
26bf4b558eSMark Salter  * compile time, but to set the physical address only
27bf4b558eSMark Salter  * in the boot process.
28bf4b558eSMark Salter  *
29bf4b558eSMark Salter  * These 'compile-time allocated' memory buffers are
30bf4b558eSMark Salter  * page-sized. Use set_fixmap(idx,phys) to associate
31bf4b558eSMark Salter  * physical memory with fixmap indices.
32bf4b558eSMark Salter  *
33bf4b558eSMark Salter  */
34bf4b558eSMark Salter enum fixed_addresses {
35dab78b6dSLaura Abbott 	FIX_HOLE,
3661bd93ceSArd Biesheuvel 
3761bd93ceSArd Biesheuvel 	/*
3861bd93ceSArd Biesheuvel 	 * Reserve a virtual window for the FDT that is 2 MB larger than the
3961bd93ceSArd Biesheuvel 	 * maximum supported size, and put it at the top of the fixmap region.
4061bd93ceSArd Biesheuvel 	 * The additional space ensures that any FDT that does not exceed
4161bd93ceSArd Biesheuvel 	 * MAX_FDT_SIZE can be mapped regardless of whether it crosses any
4261bd93ceSArd Biesheuvel 	 * 2 MB alignment boundaries.
4361bd93ceSArd Biesheuvel 	 *
4461bd93ceSArd Biesheuvel 	 * Keep this at the top so it remains 2 MB aligned.
4561bd93ceSArd Biesheuvel 	 */
4661bd93ceSArd Biesheuvel #define FIX_FDT_SIZE		(MAX_FDT_SIZE + SZ_2M)
4761bd93ceSArd Biesheuvel 	FIX_FDT_END,
4861bd93ceSArd Biesheuvel 	FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
4961bd93ceSArd Biesheuvel 
50bf4b558eSMark Salter 	FIX_EARLYCON_MEM_BASE,
5119fc5775SMark Rutland 	FIX_TEXT_POKE0,
52bf4b558eSMark Salter 	__end_of_permanent_fixed_addresses,
53bf4b558eSMark Salter 
54bf4b558eSMark Salter 	/*
55bf4b558eSMark Salter 	 * Temporary boot-time mappings, used by early_ioremap(),
56bf4b558eSMark Salter 	 * before ioremap() is functional.
57bf4b558eSMark Salter 	 */
58bf4b558eSMark Salter #ifdef CONFIG_ARM64_64K_PAGES
59bf4b558eSMark Salter #define NR_FIX_BTMAPS		4
60bf4b558eSMark Salter #else
61bf4b558eSMark Salter #define NR_FIX_BTMAPS		64
62bf4b558eSMark Salter #endif
63bf4b558eSMark Salter #define FIX_BTMAPS_SLOTS	7
64bf4b558eSMark Salter #define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
65bf4b558eSMark Salter 
66bf4b558eSMark Salter 	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
67bf4b558eSMark Salter 	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
68bf4b558eSMark Salter 	__end_of_fixed_addresses
69bf4b558eSMark Salter };
70bf4b558eSMark Salter 
71bf4b558eSMark Salter #define FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
72bf4b558eSMark Salter #define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
73bf4b558eSMark Salter 
74bf4b558eSMark Salter #define FIXMAP_PAGE_IO     __pgprot(PROT_DEVICE_nGnRE)
75bf4b558eSMark Salter 
76af86e597SLaura Abbott void __init early_fixmap_init(void);
77bf4b558eSMark Salter 
78af86e597SLaura Abbott #define __early_set_fixmap __set_fixmap
79af86e597SLaura Abbott 
80b2cedba0SMark Salter #define __late_set_fixmap __set_fixmap
81b2cedba0SMark Salter #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
82b2cedba0SMark Salter 
83af86e597SLaura Abbott extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
84bf4b558eSMark Salter 
85bf4b558eSMark Salter #include <asm-generic/fixmap.h>
86bf4b558eSMark Salter 
87bf4b558eSMark Salter #endif /* !__ASSEMBLY__ */
88bf4b558eSMark Salter #endif /* _ASM_ARM64_FIXMAP_H */
89