xref: /openbmc/linux/arch/powerpc/include/asm/highmem.h (revision 78502582)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2b8b572e1SStephen Rothwell /*
3b8b572e1SStephen Rothwell  * highmem.h: virtual kernel memory mappings for high memory
4b8b572e1SStephen Rothwell  *
5b8b572e1SStephen Rothwell  * PowerPC version, stolen from the i386 version.
6b8b572e1SStephen Rothwell  *
7b8b572e1SStephen Rothwell  * Used in CONFIG_HIGHMEM systems for memory pages which
8b8b572e1SStephen Rothwell  * are not addressable by direct kernel virtual addresses.
9b8b572e1SStephen Rothwell  *
10b8b572e1SStephen Rothwell  * Copyright (C) 1999 Gerhard Wichert, Siemens AG
11b8b572e1SStephen Rothwell  *		      Gerhard.Wichert@pdb.siemens.de
12b8b572e1SStephen Rothwell  *
13b8b572e1SStephen Rothwell  *
14b8b572e1SStephen Rothwell  * Redesigned the x86 32-bit VM architecture to deal with
15b8b572e1SStephen Rothwell  * up to 16 Terrabyte physical memory. With current x86 CPUs
16b8b572e1SStephen Rothwell  * we now support up to 64 Gigabytes physical RAM.
17b8b572e1SStephen Rothwell  *
18b8b572e1SStephen Rothwell  * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
19b8b572e1SStephen Rothwell  */
20b8b572e1SStephen Rothwell 
21b8b572e1SStephen Rothwell #ifndef _ASM_HIGHMEM_H
22b8b572e1SStephen Rothwell #define _ASM_HIGHMEM_H
23b8b572e1SStephen Rothwell 
24b8b572e1SStephen Rothwell #ifdef __KERNEL__
25b8b572e1SStephen Rothwell 
26b8b572e1SStephen Rothwell #include <linux/interrupt.h>
2745ef5992SChristophe Leroy #include <asm/cacheflush.h>
28b8b572e1SStephen Rothwell #include <asm/page.h>
29b8b572e1SStephen Rothwell #include <asm/fixmap.h>
30b8b572e1SStephen Rothwell 
31b8b572e1SStephen Rothwell extern pte_t *pkmap_page_table;
32b8b572e1SStephen Rothwell 
33b8b572e1SStephen Rothwell /*
34b8b572e1SStephen Rothwell  * Right now we initialize only a single pte table. It can be extended
35b8b572e1SStephen Rothwell  * easily, subsequent pte tables have to be allocated in one physical
36b8b572e1SStephen Rothwell  * chunk of RAM.
37b8b572e1SStephen Rothwell  */
38ca9153a3SIlya Yanok /*
39e1240122SYuri Tikhonov  * We use one full pte table with 4K pages. And with 16K/64K/256K pages pte
40e1240122SYuri Tikhonov  * table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP
41e1240122SYuri Tikhonov  * and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP
42e1240122SYuri Tikhonov  * in case of 16K/64K/256K page sizes.
43ca9153a3SIlya Yanok  */
44ca9153a3SIlya Yanok #ifdef CONFIG_PPC_4K_PAGES
45ca9153a3SIlya Yanok #define PKMAP_ORDER	PTE_SHIFT
46ca9153a3SIlya Yanok #else
47e1240122SYuri Tikhonov #define PKMAP_ORDER	9
48ca9153a3SIlya Yanok #endif
49ca9153a3SIlya Yanok #define LAST_PKMAP	(1 << PKMAP_ORDER)
50ca9153a3SIlya Yanok #ifndef CONFIG_PPC_4K_PAGES
51ca9153a3SIlya Yanok #define PKMAP_BASE	(FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1))
52ca9153a3SIlya Yanok #else
53b8b572e1SStephen Rothwell #define PKMAP_BASE	((FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK)
54ca9153a3SIlya Yanok #endif
55ca9153a3SIlya Yanok #define LAST_PKMAP_MASK	(LAST_PKMAP-1)
56b8b572e1SStephen Rothwell #define PKMAP_NR(virt)  ((virt-PKMAP_BASE) >> PAGE_SHIFT)
57b8b572e1SStephen Rothwell #define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))
58b8b572e1SStephen Rothwell 
59b8b572e1SStephen Rothwell #define flush_cache_kmaps()	flush_cache_all()
60b8b572e1SStephen Rothwell 
61*78502582SThomas Gleixner #define arch_kmap_local_set_pte(mm, vaddr, ptep, ptev)	\
62*78502582SThomas Gleixner 	__set_pte_at(mm, vaddr, ptep, ptev, 1)
6347da42b2SThomas Gleixner #define arch_kmap_local_post_map(vaddr, pteval)	\
6447da42b2SThomas Gleixner 	local_flush_tlb_page(NULL, vaddr)
6547da42b2SThomas Gleixner #define arch_kmap_local_post_unmap(vaddr)	\
6647da42b2SThomas Gleixner 	local_flush_tlb_page(NULL, vaddr)
6747da42b2SThomas Gleixner 
68b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
69b8b572e1SStephen Rothwell 
70b8b572e1SStephen Rothwell #endif /* _ASM_HIGHMEM_H */
71