18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * fixmap.h: compile-time virtual memory allocation 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1998 Ingo Molnar 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _ASM_FIXMAP_H 118c2ecf20Sopenharmony_ci#define _ASM_FIXMAP_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/kernel.h> 148c2ecf20Sopenharmony_ci#include <linux/threads.h> 158c2ecf20Sopenharmony_ci#include <asm/page.h> 168c2ecf20Sopenharmony_ci#ifdef CONFIG_HIGHMEM 178c2ecf20Sopenharmony_ci#include <asm/kmap_types.h> 188c2ecf20Sopenharmony_ci#endif 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * Here we define all the compile-time 'special' virtual 228c2ecf20Sopenharmony_ci * addresses. The point is to have a constant address at 238c2ecf20Sopenharmony_ci * compile time, but to set the physical address only 248c2ecf20Sopenharmony_ci * in the boot process. We allocate these special addresses 258c2ecf20Sopenharmony_ci * from the end of P3 backwards. 268c2ecf20Sopenharmony_ci * Also this lets us do fail-safe vmalloc(), we 278c2ecf20Sopenharmony_ci * can guarantee that these special addresses and 288c2ecf20Sopenharmony_ci * vmalloc()-ed addresses never overlap. 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * these 'compile-time allocated' memory buffers are 318c2ecf20Sopenharmony_ci * fixed-size 4k pages. (or larger if used with an increment 328c2ecf20Sopenharmony_ci * highger than 1) use fixmap_set(idx,phys) to associate 338c2ecf20Sopenharmony_ci * physical memory with fixmap indices. 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * TLB entries of such buffers will not be flushed across 368c2ecf20Sopenharmony_ci * task switches. 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* 408c2ecf20Sopenharmony_ci * on UP currently we will have no trace of the fixmap mechanizm, 418c2ecf20Sopenharmony_ci * no page table allocations, etc. This might change in the 428c2ecf20Sopenharmony_ci * future, say framebuffers for the console driver(s) could be 438c2ecf20Sopenharmony_ci * fix-mapped? 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_cienum fixed_addresses { 468c2ecf20Sopenharmony_ci /* 478c2ecf20Sopenharmony_ci * The FIX_CMAP entries are used by kmap_coherent() to get virtual 488c2ecf20Sopenharmony_ci * addresses which are of a known color, and so their values are 498c2ecf20Sopenharmony_ci * important. __fix_to_virt(FIX_CMAP_END - n) must give an address 508c2ecf20Sopenharmony_ci * which is the same color as a page (n<<PAGE_SHIFT). 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci#define FIX_N_COLOURS 8 538c2ecf20Sopenharmony_ci FIX_CMAP_BEGIN, 548c2ecf20Sopenharmony_ci FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS) - 1, 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#ifdef CONFIG_HIGHMEM 578c2ecf20Sopenharmony_ci FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 588c2ecf20Sopenharmony_ci FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1, 598c2ecf20Sopenharmony_ci#endif 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#ifdef CONFIG_IOREMAP_FIXED 628c2ecf20Sopenharmony_ci /* 638c2ecf20Sopenharmony_ci * FIX_IOREMAP entries are useful for mapping physical address 648c2ecf20Sopenharmony_ci * space before ioremap() is useable, e.g. really early in boot 658c2ecf20Sopenharmony_ci * before kmalloc() is working. 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci#define FIX_N_IOREMAPS 32 688c2ecf20Sopenharmony_ci FIX_IOREMAP_BEGIN, 698c2ecf20Sopenharmony_ci FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1, 708c2ecf20Sopenharmony_ci#endif 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci __end_of_fixed_addresses 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciextern void __set_fixmap(enum fixed_addresses idx, 768c2ecf20Sopenharmony_ci unsigned long phys, pgprot_t flags); 778c2ecf20Sopenharmony_ciextern void __clear_fixmap(enum fixed_addresses idx, pgprot_t flags); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* 808c2ecf20Sopenharmony_ci * used by vmalloc.c. 818c2ecf20Sopenharmony_ci * 828c2ecf20Sopenharmony_ci * Leave one empty page between vmalloc'ed areas and 838c2ecf20Sopenharmony_ci * the start of the fixmap, and leave one page empty 848c2ecf20Sopenharmony_ci * at the top of mem.. 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_ci#define FIXADDR_TOP (P4SEG - PAGE_SIZE) 878c2ecf20Sopenharmony_ci#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 888c2ecf20Sopenharmony_ci#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#include <asm-generic/fixmap.h> 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#endif 95