162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * fixmap.h: compile-time virtual memory allocation 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 562306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 662306a36Sopenharmony_ci * for more details. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright (C) 1998 Ingo Molnar 962306a36Sopenharmony_ci * Copyright (C) 2013 Mark Salter <msalter@redhat.com> 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * Adapted from arch/x86 version. 1262306a36Sopenharmony_ci * 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#ifndef _ASM_ARM64_FIXMAP_H 1662306a36Sopenharmony_ci#define _ASM_ARM64_FIXMAP_H 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1962306a36Sopenharmony_ci#include <linux/kernel.h> 2062306a36Sopenharmony_ci#include <linux/math.h> 2162306a36Sopenharmony_ci#include <linux/sizes.h> 2262306a36Sopenharmony_ci#include <asm/boot.h> 2362306a36Sopenharmony_ci#include <asm/page.h> 2462306a36Sopenharmony_ci#include <asm/pgtable-prot.h> 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * Here we define all the compile-time 'special' virtual 2862306a36Sopenharmony_ci * addresses. The point is to have a constant address at 2962306a36Sopenharmony_ci * compile time, but to set the physical address only 3062306a36Sopenharmony_ci * in the boot process. 3162306a36Sopenharmony_ci * 3262306a36Sopenharmony_ci * Each enum increment in these 'compile-time allocated' 3362306a36Sopenharmony_ci * memory buffers is page-sized. Use set_fixmap(idx,phys) 3462306a36Sopenharmony_ci * to associate physical memory with a fixmap index. 3562306a36Sopenharmony_ci */ 3662306a36Sopenharmony_cienum fixed_addresses { 3762306a36Sopenharmony_ci FIX_HOLE, 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci /* 4062306a36Sopenharmony_ci * Reserve a virtual window for the FDT that is a page bigger than the 4162306a36Sopenharmony_ci * maximum supported size. The additional space ensures that any FDT 4262306a36Sopenharmony_ci * that does not exceed MAX_FDT_SIZE can be mapped regardless of 4362306a36Sopenharmony_ci * whether it crosses any page boundary. 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_ci FIX_FDT_END, 4662306a36Sopenharmony_ci FIX_FDT = FIX_FDT_END + DIV_ROUND_UP(MAX_FDT_SIZE, PAGE_SIZE) + 1, 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci FIX_EARLYCON_MEM_BASE, 4962306a36Sopenharmony_ci FIX_TEXT_POKE0, 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#ifdef CONFIG_ACPI_APEI_GHES 5262306a36Sopenharmony_ci /* Used for GHES mapping from assorted contexts */ 5362306a36Sopenharmony_ci FIX_APEI_GHES_IRQ, 5462306a36Sopenharmony_ci FIX_APEI_GHES_SEA, 5562306a36Sopenharmony_ci#ifdef CONFIG_ARM_SDE_INTERFACE 5662306a36Sopenharmony_ci FIX_APEI_GHES_SDEI_NORMAL, 5762306a36Sopenharmony_ci FIX_APEI_GHES_SDEI_CRITICAL, 5862306a36Sopenharmony_ci#endif 5962306a36Sopenharmony_ci#endif /* CONFIG_ACPI_APEI_GHES */ 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 6262306a36Sopenharmony_ci#ifdef CONFIG_RELOCATABLE 6362306a36Sopenharmony_ci FIX_ENTRY_TRAMP_TEXT4, /* one extra slot for the data page */ 6462306a36Sopenharmony_ci#endif 6562306a36Sopenharmony_ci FIX_ENTRY_TRAMP_TEXT3, 6662306a36Sopenharmony_ci FIX_ENTRY_TRAMP_TEXT2, 6762306a36Sopenharmony_ci FIX_ENTRY_TRAMP_TEXT1, 6862306a36Sopenharmony_ci#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1)) 6962306a36Sopenharmony_ci#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ 7062306a36Sopenharmony_ci __end_of_permanent_fixed_addresses, 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci /* 7362306a36Sopenharmony_ci * Temporary boot-time mappings, used by early_ioremap(), 7462306a36Sopenharmony_ci * before ioremap() is functional. 7562306a36Sopenharmony_ci */ 7662306a36Sopenharmony_ci#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) 7762306a36Sopenharmony_ci#define FIX_BTMAPS_SLOTS 7 7862306a36Sopenharmony_ci#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci FIX_BTMAP_END = __end_of_permanent_fixed_addresses, 8162306a36Sopenharmony_ci FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci /* 8462306a36Sopenharmony_ci * Used for kernel page table creation, so unmapped memory may be used 8562306a36Sopenharmony_ci * for tables. 8662306a36Sopenharmony_ci */ 8762306a36Sopenharmony_ci FIX_PTE, 8862306a36Sopenharmony_ci FIX_PMD, 8962306a36Sopenharmony_ci FIX_PUD, 9062306a36Sopenharmony_ci FIX_PGD, 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci __end_of_fixed_addresses 9362306a36Sopenharmony_ci}; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) 9662306a36Sopenharmony_ci#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 9762306a36Sopenharmony_ci#define FIXADDR_TOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 9862306a36Sopenharmony_ci#define FIXADDR_TOT_START (FIXADDR_TOP - FIXADDR_TOT_SIZE) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define FIXMAP_PAGE_IO __pgprot(PROT_DEVICE_nGnRE) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_civoid __init early_fixmap_init(void); 10362306a36Sopenharmony_civoid __init fixmap_copy(pgd_t *pgdir); 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define __early_set_fixmap __set_fixmap 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#define __late_set_fixmap __set_fixmap 10862306a36Sopenharmony_ci#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ciextern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#include <asm-generic/fixmap.h> 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 11562306a36Sopenharmony_ci#endif /* _ASM_ARM64_FIXMAP_H */ 116