xref: /openbmc/linux/arch/xtensa/include/asm/highmem.h (revision 65559100)
1 /*
2  * include/asm-xtensa/highmem.h
3  *
4  * This file is subject to the terms and conditions of the GNU General
5  * Public License.  See the file "COPYING" in the main directory of
6  * this archive for more details.
7  *
8  * Copyright (C) 2003 - 2005 Tensilica Inc.
9  * Copyright (C) 2014 Cadence Design Systems Inc.
10  */
11 
12 #ifndef _XTENSA_HIGHMEM_H
13 #define _XTENSA_HIGHMEM_H
14 
15 #include <asm/cacheflush.h>
16 #include <asm/fixmap.h>
17 #include <asm/kmap_types.h>
18 #include <asm/pgtable.h>
19 
20 #define PKMAP_BASE		(FIXADDR_START - PMD_SIZE)
21 #define LAST_PKMAP		PTRS_PER_PTE
22 #define LAST_PKMAP_MASK		(LAST_PKMAP - 1)
23 #define PKMAP_NR(virt)		(((virt) - PKMAP_BASE) >> PAGE_SHIFT)
24 #define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
25 
26 #define kmap_prot		PAGE_KERNEL
27 
28 extern pte_t *pkmap_page_table;
29 
30 void *kmap_high(struct page *page);
31 void kunmap_high(struct page *page);
32 
33 static inline void *kmap(struct page *page)
34 {
35 	BUG_ON(in_interrupt());
36 	if (!PageHighMem(page))
37 		return page_address(page);
38 	return kmap_high(page);
39 }
40 
41 static inline void kunmap(struct page *page)
42 {
43 	BUG_ON(in_interrupt());
44 	if (!PageHighMem(page))
45 		return;
46 	kunmap_high(page);
47 }
48 
49 static inline void flush_cache_kmaps(void)
50 {
51 	flush_cache_all();
52 }
53 
54 void *kmap_atomic(struct page *page);
55 void __kunmap_atomic(void *kvaddr);
56 
57 void kmap_init(void);
58 
59 #endif
60