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