16a0abce4SKuninori Morimoto /* SPDX-License-Identifier: GPL-2.0 2f15cbe6fSPaul Mundt * 36a0abce4SKuninori Morimoto * fixmap.h: compile-time virtual memory allocation 4f15cbe6fSPaul Mundt * 5f15cbe6fSPaul Mundt * Copyright (C) 1998 Ingo Molnar 6f15cbe6fSPaul Mundt * 7f15cbe6fSPaul Mundt * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 8f15cbe6fSPaul Mundt */ 9f15cbe6fSPaul Mundt 10f15cbe6fSPaul Mundt #ifndef _ASM_FIXMAP_H 11f15cbe6fSPaul Mundt #define _ASM_FIXMAP_H 12f15cbe6fSPaul Mundt 13f15cbe6fSPaul Mundt #include <linux/kernel.h> 14f9e2bdfdSPaul Mundt #include <linux/threads.h> 15f15cbe6fSPaul Mundt #include <asm/page.h> 16f15cbe6fSPaul Mundt #ifdef CONFIG_HIGHMEM 17f15cbe6fSPaul Mundt #include <asm/kmap_types.h> 18f15cbe6fSPaul Mundt #endif 19f15cbe6fSPaul Mundt 20f15cbe6fSPaul Mundt /* 21f15cbe6fSPaul Mundt * Here we define all the compile-time 'special' virtual 22f15cbe6fSPaul Mundt * addresses. The point is to have a constant address at 23f15cbe6fSPaul Mundt * compile time, but to set the physical address only 24f15cbe6fSPaul Mundt * in the boot process. We allocate these special addresses 25f15cbe6fSPaul Mundt * from the end of P3 backwards. 26f15cbe6fSPaul Mundt * Also this lets us do fail-safe vmalloc(), we 27f15cbe6fSPaul Mundt * can guarantee that these special addresses and 28f15cbe6fSPaul Mundt * vmalloc()-ed addresses never overlap. 29f15cbe6fSPaul Mundt * 30f15cbe6fSPaul Mundt * these 'compile-time allocated' memory buffers are 31f15cbe6fSPaul Mundt * fixed-size 4k pages. (or larger if used with an increment 32f15cbe6fSPaul Mundt * highger than 1) use fixmap_set(idx,phys) to associate 33f15cbe6fSPaul Mundt * physical memory with fixmap indices. 34f15cbe6fSPaul Mundt * 35f15cbe6fSPaul Mundt * TLB entries of such buffers will not be flushed across 36f15cbe6fSPaul Mundt * task switches. 37f15cbe6fSPaul Mundt */ 38f15cbe6fSPaul Mundt 39f15cbe6fSPaul Mundt /* 40f15cbe6fSPaul Mundt * on UP currently we will have no trace of the fixmap mechanizm, 41f15cbe6fSPaul Mundt * no page table allocations, etc. This might change in the 42f15cbe6fSPaul Mundt * future, say framebuffers for the console driver(s) could be 43f15cbe6fSPaul Mundt * fix-mapped? 44f15cbe6fSPaul Mundt */ 45f15cbe6fSPaul Mundt enum fixed_addresses { 4639ac11c1SStuart Menefy /* 4739ac11c1SStuart Menefy * The FIX_CMAP entries are used by kmap_coherent() to get virtual 4839ac11c1SStuart Menefy * addresses which are of a known color, and so their values are 4939ac11c1SStuart Menefy * important. __fix_to_virt(FIX_CMAP_END - n) must give an address 5039ac11c1SStuart Menefy * which is the same color as a page (n<<PAGE_SHIFT). 5139ac11c1SStuart Menefy */ 52f9e2bdfdSPaul Mundt #define FIX_N_COLOURS 8 53f15cbe6fSPaul Mundt FIX_CMAP_BEGIN, 5439ac11c1SStuart Menefy FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS) - 1, 552dc2f8e0SPaul Mundt 56f15cbe6fSPaul Mundt #ifdef CONFIG_HIGHMEM 57f15cbe6fSPaul Mundt FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 58f15cbe6fSPaul Mundt FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1, 59f15cbe6fSPaul Mundt #endif 602dc2f8e0SPaul Mundt 61a077e916SPaul Mundt #ifdef CONFIG_IOREMAP_FIXED 624d35b93aSMatt Fleming /* 634d35b93aSMatt Fleming * FIX_IOREMAP entries are useful for mapping physical address 644d35b93aSMatt Fleming * space before ioremap() is useable, e.g. really early in boot 654d35b93aSMatt Fleming * before kmalloc() is working. 664d35b93aSMatt Fleming */ 674d35b93aSMatt Fleming #define FIX_N_IOREMAPS 32 684d35b93aSMatt Fleming FIX_IOREMAP_BEGIN, 697210ed74SPaul Mundt FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1, 70a077e916SPaul Mundt #endif 712dc2f8e0SPaul Mundt 72f15cbe6fSPaul Mundt __end_of_fixed_addresses 73f15cbe6fSPaul Mundt }; 74f15cbe6fSPaul Mundt 75f15cbe6fSPaul Mundt extern void __set_fixmap(enum fixed_addresses idx, 76f15cbe6fSPaul Mundt unsigned long phys, pgprot_t flags); 7707cad4dcSMatt Fleming extern void __clear_fixmap(enum fixed_addresses idx, pgprot_t flags); 78f15cbe6fSPaul Mundt 79f15cbe6fSPaul Mundt /* 80f15cbe6fSPaul Mundt * used by vmalloc.c. 81f15cbe6fSPaul Mundt * 82f15cbe6fSPaul Mundt * Leave one empty page between vmalloc'ed areas and 83f15cbe6fSPaul Mundt * the start of the fixmap, and leave one page empty 84f15cbe6fSPaul Mundt * at the top of mem.. 85f15cbe6fSPaul Mundt */ 86f15cbe6fSPaul Mundt #ifdef CONFIG_SUPERH32 87c3e0af98SPaul Mundt #define FIXADDR_TOP (P4SEG - PAGE_SIZE) 88f15cbe6fSPaul Mundt #else 89e45af0e0SPaul Mundt #define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) 90f15cbe6fSPaul Mundt #endif 91f15cbe6fSPaul Mundt #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 92f15cbe6fSPaul Mundt #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 93f15cbe6fSPaul Mundt 94083f7ba8SMark Salter #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE 95f15cbe6fSPaul Mundt 96083f7ba8SMark Salter #include <asm-generic/fixmap.h> 97f15cbe6fSPaul Mundt 98f15cbe6fSPaul Mundt #endif 99