xref: /openbmc/linux/arch/xtensa/include/asm/highmem.h (revision 1eb0616c)
1367b8112SChris Zankel /*
2367b8112SChris Zankel  * include/asm-xtensa/highmem.h
3367b8112SChris Zankel  *
4367b8112SChris Zankel  * This file is subject to the terms and conditions of the GNU General
5367b8112SChris Zankel  * Public License.  See the file "COPYING" in the main directory of
6367b8112SChris Zankel  * this archive for more details.
7367b8112SChris Zankel  *
8367b8112SChris Zankel  * Copyright (C) 2003 - 2005 Tensilica Inc.
965559100SMax Filippov  * Copyright (C) 2014 Cadence Design Systems Inc.
10367b8112SChris Zankel  */
11367b8112SChris Zankel 
12367b8112SChris Zankel #ifndef _XTENSA_HIGHMEM_H
13367b8112SChris Zankel #define _XTENSA_HIGHMEM_H
14367b8112SChris Zankel 
15*1eb0616cSThomas Gleixner #ifdef CONFIG_HIGHMEM
168504b503SMax Filippov #include <linux/wait.h>
1765fddcfcSMike Rapoport #include <linux/pgtable.h>
1865559100SMax Filippov #include <asm/cacheflush.h>
1965559100SMax Filippov #include <asm/fixmap.h>
2065559100SMax Filippov 
218504b503SMax Filippov #define PKMAP_BASE		((FIXADDR_START -			\
228504b503SMax Filippov 				  (LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
238504b503SMax Filippov #define LAST_PKMAP		(PTRS_PER_PTE * DCACHE_N_COLORS)
2465559100SMax Filippov #define LAST_PKMAP_MASK		(LAST_PKMAP - 1)
2565559100SMax Filippov #define PKMAP_NR(virt)		(((virt) - PKMAP_BASE) >> PAGE_SHIFT)
2665559100SMax Filippov #define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
2765559100SMax Filippov 
28ff009ab6SMax Filippov #define kmap_prot		PAGE_KERNEL_EXEC
2965559100SMax Filippov 
308504b503SMax Filippov #if DCACHE_WAY_SIZE > PAGE_SIZE
318504b503SMax Filippov #define get_pkmap_color get_pkmap_color
get_pkmap_color(struct page * page)328504b503SMax Filippov static inline int get_pkmap_color(struct page *page)
338504b503SMax Filippov {
348504b503SMax Filippov 	return DCACHE_ALIAS(page_to_phys(page));
358504b503SMax Filippov }
368504b503SMax Filippov 
378504b503SMax Filippov extern unsigned int last_pkmap_nr_arr[];
388504b503SMax Filippov 
get_next_pkmap_nr(unsigned int color)398504b503SMax Filippov static inline unsigned int get_next_pkmap_nr(unsigned int color)
408504b503SMax Filippov {
418504b503SMax Filippov 	last_pkmap_nr_arr[color] =
428504b503SMax Filippov 		(last_pkmap_nr_arr[color] + DCACHE_N_COLORS) & LAST_PKMAP_MASK;
438504b503SMax Filippov 	return last_pkmap_nr_arr[color] + color;
448504b503SMax Filippov }
458504b503SMax Filippov 
no_more_pkmaps(unsigned int pkmap_nr,unsigned int color)468504b503SMax Filippov static inline int no_more_pkmaps(unsigned int pkmap_nr, unsigned int color)
478504b503SMax Filippov {
488504b503SMax Filippov 	return pkmap_nr < DCACHE_N_COLORS;
498504b503SMax Filippov }
508504b503SMax Filippov 
get_pkmap_entries_count(unsigned int color)518504b503SMax Filippov static inline int get_pkmap_entries_count(unsigned int color)
528504b503SMax Filippov {
538504b503SMax Filippov 	return LAST_PKMAP / DCACHE_N_COLORS;
548504b503SMax Filippov }
558504b503SMax Filippov 
568504b503SMax Filippov extern wait_queue_head_t pkmap_map_wait_arr[];
578504b503SMax Filippov 
get_pkmap_wait_queue_head(unsigned int color)588504b503SMax Filippov static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color)
598504b503SMax Filippov {
608504b503SMax Filippov 	return pkmap_map_wait_arr + color;
618504b503SMax Filippov }
62*1eb0616cSThomas Gleixner 
63*1eb0616cSThomas Gleixner enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn);
64*1eb0616cSThomas Gleixner #define arch_kmap_local_map_idx		kmap_local_map_idx
65*1eb0616cSThomas Gleixner 
66*1eb0616cSThomas Gleixner enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr);
67*1eb0616cSThomas Gleixner #define arch_kmap_local_unmap_idx	kmap_local_unmap_idx
68*1eb0616cSThomas Gleixner 
698504b503SMax Filippov #endif
708504b503SMax Filippov 
7165559100SMax Filippov extern pte_t *pkmap_page_table;
7265559100SMax Filippov 
flush_cache_kmaps(void)7365559100SMax Filippov static inline void flush_cache_kmaps(void)
7465559100SMax Filippov {
7565559100SMax Filippov 	flush_cache_all();
7665559100SMax Filippov }
7765559100SMax Filippov 
78629ed3f7SThomas Gleixner #define arch_kmap_local_post_unmap(vaddr)	\
79629ed3f7SThomas Gleixner 	local_flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE)
80629ed3f7SThomas Gleixner 
8165559100SMax Filippov void kmap_init(void);
82367b8112SChris Zankel 
83*1eb0616cSThomas Gleixner #endif /* CONFIG_HIGHMEM */
84367b8112SChris Zankel #endif
85