• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * fixmap.h: compile-time virtual memory allocation
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License.  See the file "COPYING" in the main directory of this archive
7  * for more details.
8  *
9  * Copyright (C) 2020 Loongson Technology Co., Ltd.
10  */
11 
12 #ifndef _ASM_FIXMAP_H
13 #define _ASM_FIXMAP_H
14 
15 #include <asm/page.h>
16 #ifdef CONFIG_HIGHMEM
17 #include <linux/threads.h>
18 #include <asm/kmap_types.h>
19 #endif
20 
21 /*
22  * Here we define all the compile-time 'special' virtual
23  * addresses. The point is to have a constant address at
24  * compile time, but to set the physical address only
25  * in the boot process. We allocate these special  addresses
26  * from the end of virtual memory (0xfffff000) backwards.
27  * Also this lets us do fail-safe vmalloc(), we
28  * can guarantee that these special addresses and
29  * vmalloc()-ed addresses never overlap.
30  *
31  * these 'compile-time allocated' memory buffers are
32  * fixed-size 4k pages. (or larger if used with an increment
33  * highger than 1) use fixmap_set(idx,phys) to associate
34  * physical memory with fixmap indices.
35  *
36  * TLB entries of such buffers will not be flushed across
37  * task switches.
38  */
39 
40 #define NR_FIX_BTMAPS 64
41 
42 /*
43  * on UP currently we will have no trace of the fixmap mechanizm,
44  * no page table allocations, etc. This might change in the
45  * future, say framebuffers for the console driver(s) could be
46  * fix-mapped?
47  */
48 enum fixed_addresses {
49 	FIX_HOLE,
50 #define FIX_N_COLOURS 8
51 	FIX_CMAP_BEGIN,
52 	FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * 2),
53 #ifdef CONFIG_HIGHMEM
54 	/* reserved pte's for temporary kernel mappings */
55 	FIX_KMAP_BEGIN = FIX_CMAP_END + 1,
56 	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
57 #endif
58 	FIX_EARLYCON_MEM_BASE,
59 	__end_of_fixed_addresses
60 };
61 
62 /*
63  * used by vmalloc.c.
64  *
65  * Leave one empty page between vmalloc'ed areas and
66  * the start of the fixmap, and leave one page empty
67  * at the top of mem..
68  */
69 #define FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
70 #define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
71 #define FIXMAP_PAGE_IO	PAGE_KERNEL_SUC
72 
73 extern void __set_fixmap(enum fixed_addresses idx,
74 			 phys_addr_t phys, pgprot_t flags);
75 
76 #include <asm-generic/fixmap.h>
77 
78 /*
79  * Called from pgtable_init()
80  */
81 extern void fixrange_init(unsigned long start, unsigned long end,
82 	pgd_t *pgd_base);
83 
84 
85 #endif
86