xref: /openbmc/linux/arch/sh/include/asm/fixmap.h (revision 673afbac)
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 
17f15cbe6fSPaul Mundt /*
18f15cbe6fSPaul Mundt  * Here we define all the compile-time 'special' virtual
19f15cbe6fSPaul Mundt  * addresses. The point is to have a constant address at
20f15cbe6fSPaul Mundt  * compile time, but to set the physical address only
21f15cbe6fSPaul Mundt  * in the boot process. We allocate these special  addresses
22f15cbe6fSPaul Mundt  * from the end of P3 backwards.
23f15cbe6fSPaul Mundt  * Also this lets us do fail-safe vmalloc(), we
24f15cbe6fSPaul Mundt  * can guarantee that these special addresses and
25f15cbe6fSPaul Mundt  * vmalloc()-ed addresses never overlap.
26f15cbe6fSPaul Mundt  *
27f15cbe6fSPaul Mundt  * these 'compile-time allocated' memory buffers are
28f15cbe6fSPaul Mundt  * fixed-size 4k pages. (or larger if used with an increment
29f15cbe6fSPaul Mundt  * highger than 1) use fixmap_set(idx,phys) to associate
30f15cbe6fSPaul Mundt  * physical memory with fixmap indices.
31f15cbe6fSPaul Mundt  *
32f15cbe6fSPaul Mundt  * TLB entries of such buffers will not be flushed across
33f15cbe6fSPaul Mundt  * task switches.
34f15cbe6fSPaul Mundt  */
35f15cbe6fSPaul Mundt 
36f15cbe6fSPaul Mundt /*
37f15cbe6fSPaul Mundt  * on UP currently we will have no trace of the fixmap mechanizm,
38f15cbe6fSPaul Mundt  * no page table allocations, etc. This might change in the
39f15cbe6fSPaul Mundt  * future, say framebuffers for the console driver(s) could be
40f15cbe6fSPaul Mundt  * fix-mapped?
41f15cbe6fSPaul Mundt  */
42f15cbe6fSPaul Mundt enum fixed_addresses {
4339ac11c1SStuart Menefy 	/*
4439ac11c1SStuart Menefy 	 * The FIX_CMAP entries are used by kmap_coherent() to get virtual
4539ac11c1SStuart Menefy 	 * addresses which are of a known color, and so their values are
4639ac11c1SStuart Menefy 	 * important. __fix_to_virt(FIX_CMAP_END - n) must give an address
4739ac11c1SStuart Menefy 	 * which is the same color as a page (n<<PAGE_SHIFT).
4839ac11c1SStuart Menefy 	 */
49f9e2bdfdSPaul Mundt #define FIX_N_COLOURS 8
50f15cbe6fSPaul Mundt 	FIX_CMAP_BEGIN,
5139ac11c1SStuart Menefy 	FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS) - 1,
522dc2f8e0SPaul Mundt 
53a077e916SPaul Mundt #ifdef CONFIG_IOREMAP_FIXED
544d35b93aSMatt Fleming 	/*
554d35b93aSMatt Fleming 	 * FIX_IOREMAP entries are useful for mapping physical address
564d35b93aSMatt Fleming 	 * space before ioremap() is useable, e.g. really early in boot
574d35b93aSMatt Fleming 	 * before kmalloc() is working.
584d35b93aSMatt Fleming 	 */
594d35b93aSMatt Fleming #define FIX_N_IOREMAPS	32
604d35b93aSMatt Fleming 	FIX_IOREMAP_BEGIN,
617210ed74SPaul Mundt 	FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1,
62a077e916SPaul Mundt #endif
632dc2f8e0SPaul Mundt 
64f15cbe6fSPaul Mundt 	__end_of_fixed_addresses
65f15cbe6fSPaul Mundt };
66f15cbe6fSPaul Mundt 
67f15cbe6fSPaul Mundt extern void __set_fixmap(enum fixed_addresses idx,
68f15cbe6fSPaul Mundt 			 unsigned long phys, pgprot_t flags);
6907cad4dcSMatt Fleming extern void __clear_fixmap(enum fixed_addresses idx, pgprot_t flags);
70f15cbe6fSPaul Mundt 
71f15cbe6fSPaul Mundt /*
72f15cbe6fSPaul Mundt  * used by vmalloc.c.
73f15cbe6fSPaul Mundt  *
74f15cbe6fSPaul Mundt  * Leave one empty page between vmalloc'ed areas and
75f15cbe6fSPaul Mundt  * the start of the fixmap, and leave one page empty
76f15cbe6fSPaul Mundt  * at the top of mem..
77f15cbe6fSPaul Mundt  */
78c3e0af98SPaul Mundt #define FIXADDR_TOP	(P4SEG - PAGE_SIZE)
79f15cbe6fSPaul Mundt #define FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
80f15cbe6fSPaul Mundt #define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
81f15cbe6fSPaul Mundt 
82083f7ba8SMark Salter #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
83f15cbe6fSPaul Mundt 
84083f7ba8SMark Salter #include <asm-generic/fixmap.h>
85f15cbe6fSPaul Mundt 
86f15cbe6fSPaul Mundt #endif
87