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 * 1062306a36Sopenharmony_ci * Copyright 2008 Freescale Semiconductor Inc. 1162306a36Sopenharmony_ci * Port to powerpc added by Kumar Gala 1262306a36Sopenharmony_ci */ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#ifndef _ASM_FIXMAP_H 1562306a36Sopenharmony_ci#define _ASM_FIXMAP_H 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1862306a36Sopenharmony_ci#include <linux/sizes.h> 1962306a36Sopenharmony_ci#include <linux/pgtable.h> 2062306a36Sopenharmony_ci#include <asm/page.h> 2162306a36Sopenharmony_ci#ifdef CONFIG_HIGHMEM 2262306a36Sopenharmony_ci#include <linux/threads.h> 2362306a36Sopenharmony_ci#include <asm/kmap_size.h> 2462306a36Sopenharmony_ci#endif 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#ifdef CONFIG_PPC64 2762306a36Sopenharmony_ci#define FIXADDR_TOP (IOREMAP_END + FIXADDR_SIZE) 2862306a36Sopenharmony_ci#else 2962306a36Sopenharmony_ci#define FIXADDR_SIZE 0 3062306a36Sopenharmony_ci#ifdef CONFIG_KASAN 3162306a36Sopenharmony_ci#include <asm/kasan.h> 3262306a36Sopenharmony_ci#define FIXADDR_TOP (KASAN_SHADOW_START - PAGE_SIZE) 3362306a36Sopenharmony_ci#else 3462306a36Sopenharmony_ci#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) 3562306a36Sopenharmony_ci#endif 3662306a36Sopenharmony_ci#endif 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* 3962306a36Sopenharmony_ci * Here we define all the compile-time 'special' virtual 4062306a36Sopenharmony_ci * addresses. The point is to have a constant address at 4162306a36Sopenharmony_ci * compile time, but to set the physical address only 4262306a36Sopenharmony_ci * in the boot process. We allocate these special addresses 4362306a36Sopenharmony_ci * from the end of virtual memory (0xfffff000) backwards. 4462306a36Sopenharmony_ci * Also this lets us do fail-safe vmalloc(), we 4562306a36Sopenharmony_ci * can guarantee that these special addresses and 4662306a36Sopenharmony_ci * vmalloc()-ed addresses never overlap. 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * these 'compile-time allocated' memory buffers are 4962306a36Sopenharmony_ci * fixed-size 4k pages. (or larger if used with an increment 5062306a36Sopenharmony_ci * highger than 1) use fixmap_set(idx,phys) to associate 5162306a36Sopenharmony_ci * physical memory with fixmap indices. 5262306a36Sopenharmony_ci * 5362306a36Sopenharmony_ci * TLB entries of such buffers will not be flushed across 5462306a36Sopenharmony_ci * task switches. 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_cienum fixed_addresses { 5762306a36Sopenharmony_ci FIX_HOLE, 5862306a36Sopenharmony_ci#ifdef CONFIG_PPC32 5962306a36Sopenharmony_ci /* reserve the top 128K for early debugging purposes */ 6062306a36Sopenharmony_ci FIX_EARLY_DEBUG_TOP = FIX_HOLE, 6162306a36Sopenharmony_ci FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128K, PAGE_SIZE)/PAGE_SIZE)-1, 6262306a36Sopenharmony_ci#ifdef CONFIG_HIGHMEM 6362306a36Sopenharmony_ci FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 6462306a36Sopenharmony_ci FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * NR_CPUS) - 1, 6562306a36Sopenharmony_ci#endif 6662306a36Sopenharmony_ci#ifdef CONFIG_PPC_8xx 6762306a36Sopenharmony_ci /* For IMMR we need an aligned 512K area */ 6862306a36Sopenharmony_ci#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE) 6962306a36Sopenharmony_ci FIX_IMMR_START, 7062306a36Sopenharmony_ci FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 + 7162306a36Sopenharmony_ci FIX_IMMR_SIZE, 7262306a36Sopenharmony_ci#endif 7362306a36Sopenharmony_ci#ifdef CONFIG_PPC_83xx 7462306a36Sopenharmony_ci /* For IMMR we need an aligned 2M area */ 7562306a36Sopenharmony_ci#define FIX_IMMR_SIZE (SZ_2M / PAGE_SIZE) 7662306a36Sopenharmony_ci FIX_IMMR_START, 7762306a36Sopenharmony_ci FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 + 7862306a36Sopenharmony_ci FIX_IMMR_SIZE, 7962306a36Sopenharmony_ci#endif 8062306a36Sopenharmony_ci /* FIX_PCIE_MCFG, */ 8162306a36Sopenharmony_ci#endif /* CONFIG_PPC32 */ 8262306a36Sopenharmony_ci __end_of_permanent_fixed_addresses, 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) 8562306a36Sopenharmony_ci#define FIX_BTMAPS_SLOTS 16 8662306a36Sopenharmony_ci#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci FIX_BTMAP_END = __end_of_permanent_fixed_addresses, 8962306a36Sopenharmony_ci FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, 9062306a36Sopenharmony_ci __end_of_fixed_addresses 9162306a36Sopenharmony_ci}; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 9462306a36Sopenharmony_ci#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define FIXMAP_ALIGNED_SIZE (ALIGN(FIXADDR_TOP, PGDIR_SIZE) - \ 9762306a36Sopenharmony_ci ALIGN_DOWN(FIXADDR_START, PGDIR_SIZE)) 9862306a36Sopenharmony_ci#define FIXMAP_PTE_SIZE (FIXMAP_ALIGNED_SIZE / PGDIR_SIZE * PTE_TABLE_SIZE) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG 10162306a36Sopenharmony_ci#define FIXMAP_PAGE_IO PAGE_KERNEL_NCG 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#include <asm-generic/fixmap.h> 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cistatic inline void __set_fixmap(enum fixed_addresses idx, 10662306a36Sopenharmony_ci phys_addr_t phys, pgprot_t flags) 10762306a36Sopenharmony_ci{ 10862306a36Sopenharmony_ci BUILD_BUG_ON(IS_ENABLED(CONFIG_PPC64) && __FIXADDR_SIZE > FIXADDR_SIZE); 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci if (__builtin_constant_p(idx)) 11162306a36Sopenharmony_ci BUILD_BUG_ON(idx >= __end_of_fixed_addresses); 11262306a36Sopenharmony_ci else if (WARN_ON(idx >= __end_of_fixed_addresses)) 11362306a36Sopenharmony_ci return; 11462306a36Sopenharmony_ci if (pgprot_val(flags)) 11562306a36Sopenharmony_ci map_kernel_page(__fix_to_virt(idx), phys, flags); 11662306a36Sopenharmony_ci else 11762306a36Sopenharmony_ci unmap_kernel_page(__fix_to_virt(idx)); 11862306a36Sopenharmony_ci} 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define __early_set_fixmap __set_fixmap 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 12362306a36Sopenharmony_ci#endif 124