18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * fixmap.h: compile-time virtual memory allocation
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
58c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
68c2ecf20Sopenharmony_ci * for more details.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (C) 1998 Ingo Molnar
98c2ecf20Sopenharmony_ci * Copyright (C) 2013 Mark Salter <msalter@redhat.com>
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Adapted from arch/x86 version.
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#ifndef _ASM_ARM64_FIXMAP_H
168c2ecf20Sopenharmony_ci#define _ASM_ARM64_FIXMAP_H
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
198c2ecf20Sopenharmony_ci#include <linux/kernel.h>
208c2ecf20Sopenharmony_ci#include <linux/sizes.h>
218c2ecf20Sopenharmony_ci#include <asm/boot.h>
228c2ecf20Sopenharmony_ci#include <asm/page.h>
238c2ecf20Sopenharmony_ci#include <asm/pgtable-prot.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/*
268c2ecf20Sopenharmony_ci * Here we define all the compile-time 'special' virtual
278c2ecf20Sopenharmony_ci * addresses. The point is to have a constant address at
288c2ecf20Sopenharmony_ci * compile time, but to set the physical address only
298c2ecf20Sopenharmony_ci * in the boot process.
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci * Each enum increment in these 'compile-time allocated'
328c2ecf20Sopenharmony_ci * memory buffers is page-sized. Use set_fixmap(idx,phys)
338c2ecf20Sopenharmony_ci * to associate physical memory with a fixmap index.
348c2ecf20Sopenharmony_ci */
358c2ecf20Sopenharmony_cienum fixed_addresses {
368c2ecf20Sopenharmony_ci	FIX_HOLE,
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	/*
398c2ecf20Sopenharmony_ci	 * Reserve a virtual window for the FDT that is 2 MB larger than the
408c2ecf20Sopenharmony_ci	 * maximum supported size, and put it at the top of the fixmap region.
418c2ecf20Sopenharmony_ci	 * The additional space ensures that any FDT that does not exceed
428c2ecf20Sopenharmony_ci	 * MAX_FDT_SIZE can be mapped regardless of whether it crosses any
438c2ecf20Sopenharmony_ci	 * 2 MB alignment boundaries.
448c2ecf20Sopenharmony_ci	 *
458c2ecf20Sopenharmony_ci	 * Keep this at the top so it remains 2 MB aligned.
468c2ecf20Sopenharmony_ci	 */
478c2ecf20Sopenharmony_ci#define FIX_FDT_SIZE		(MAX_FDT_SIZE + SZ_2M)
488c2ecf20Sopenharmony_ci	FIX_FDT_END,
498c2ecf20Sopenharmony_ci	FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	FIX_EARLYCON_MEM_BASE,
528c2ecf20Sopenharmony_ci	FIX_TEXT_POKE0,
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI_APEI_GHES
558c2ecf20Sopenharmony_ci	/* Used for GHES mapping from assorted contexts */
568c2ecf20Sopenharmony_ci	FIX_APEI_GHES_IRQ,
578c2ecf20Sopenharmony_ci	FIX_APEI_GHES_SEA,
588c2ecf20Sopenharmony_ci#ifdef CONFIG_ARM_SDE_INTERFACE
598c2ecf20Sopenharmony_ci	FIX_APEI_GHES_SDEI_NORMAL,
608c2ecf20Sopenharmony_ci	FIX_APEI_GHES_SDEI_CRITICAL,
618c2ecf20Sopenharmony_ci#endif
628c2ecf20Sopenharmony_ci#endif /* CONFIG_ACPI_APEI_GHES */
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
658c2ecf20Sopenharmony_ci	FIX_ENTRY_TRAMP_TEXT3,
668c2ecf20Sopenharmony_ci	FIX_ENTRY_TRAMP_TEXT2,
678c2ecf20Sopenharmony_ci	FIX_ENTRY_TRAMP_TEXT1,
688c2ecf20Sopenharmony_ci	FIX_ENTRY_TRAMP_DATA,
698c2ecf20Sopenharmony_ci#define TRAMP_VALIAS		(__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1))
708c2ecf20Sopenharmony_ci#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
718c2ecf20Sopenharmony_ci	__end_of_permanent_fixed_addresses,
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	/*
748c2ecf20Sopenharmony_ci	 * Temporary boot-time mappings, used by early_ioremap(),
758c2ecf20Sopenharmony_ci	 * before ioremap() is functional.
768c2ecf20Sopenharmony_ci	 */
778c2ecf20Sopenharmony_ci#define NR_FIX_BTMAPS		(SZ_256K / PAGE_SIZE)
788c2ecf20Sopenharmony_ci#define FIX_BTMAPS_SLOTS	7
798c2ecf20Sopenharmony_ci#define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
828c2ecf20Sopenharmony_ci	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	/*
858c2ecf20Sopenharmony_ci	 * Used for kernel page table creation, so unmapped memory may be used
868c2ecf20Sopenharmony_ci	 * for tables.
878c2ecf20Sopenharmony_ci	 */
888c2ecf20Sopenharmony_ci	FIX_PTE,
898c2ecf20Sopenharmony_ci	FIX_PMD,
908c2ecf20Sopenharmony_ci	FIX_PUD,
918c2ecf20Sopenharmony_ci	FIX_PGD,
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	__end_of_fixed_addresses
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
978c2ecf20Sopenharmony_ci#define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_IO     __pgprot(PROT_DEVICE_nGnRE)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_civoid __init early_fixmap_init(void);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define __early_set_fixmap __set_fixmap
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci#define __late_set_fixmap __set_fixmap
1068c2ecf20Sopenharmony_ci#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciextern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#include <asm-generic/fixmap.h>
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */
1138c2ecf20Sopenharmony_ci#endif /* _ASM_ARM64_FIXMAP_H */
114