1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
3 
4 #ifndef _ASM_HIGHMEM_H
5 #define _ASM_HIGHMEM_H
6 
7 #include <asm/proc-fns.h>
8 #include <asm/kmap_types.h>
9 #include <asm/fixmap.h>
10 #include <asm/pgtable.h>
11 
12 /*
13  * Right now we initialize only a single pte table. It can be extended
14  * easily, subsequent pte tables have to be allocated in one physical
15  * chunk of RAM.
16  */
17 /*
18  * Ordering is (from lower to higher memory addresses):
19  *
20  * high_memory
21  *			Persistent kmap area
22  * PKMAP_BASE
23  *			fixed_addresses
24  * FIXADDR_START
25  * FIXADDR_TOP
26  *			Vmalloc area
27  * VMALLOC_START
28  * VMALLOC_END
29  */
30 #define PKMAP_BASE		((FIXADDR_START - PGDIR_SIZE) & (PGDIR_MASK))
31 #define LAST_PKMAP		PTRS_PER_PTE
32 #define LAST_PKMAP_MASK		(LAST_PKMAP - 1)
33 #define PKMAP_NR(virt)		(((virt) - (PKMAP_BASE)) >> PAGE_SHIFT)
34 #define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
35 #define kmap_prot		PAGE_KERNEL
36 
flush_cache_kmaps(void)37 static inline void flush_cache_kmaps(void)
38 {
39 	cpu_dcache_wbinval_all();
40 }
41 
42 /* declarations for highmem.c */
43 extern unsigned long highstart_pfn, highend_pfn;
44 
45 extern pte_t *pkmap_page_table;
46 
47 extern void *kmap_high(struct page *page);
48 extern void kunmap_high(struct page *page);
49 
50 extern void kmap_init(void);
51 
52 /*
53  * The following functions are already defined by <linux/highmem.h>
54  * when CONFIG_HIGHMEM is not set.
55  */
56 #ifdef CONFIG_HIGHMEM
57 extern void *kmap(struct page *page);
58 extern void kunmap(struct page *page);
59 extern void *kmap_atomic(struct page *page);
60 extern void __kunmap_atomic(void *kvaddr);
61 extern void *kmap_atomic_pfn(unsigned long pfn);
62 extern struct page *kmap_atomic_to_page(void *ptr);
63 #endif
64 
65 #endif
66