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 <linux/wait.h> 16 #include <linux/pgtable.h> 17 #include <asm/cacheflush.h> 18 #include <asm/fixmap.h> 19 20 #define PKMAP_BASE ((FIXADDR_START - \ 21 (LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK) 22 #define LAST_PKMAP (PTRS_PER_PTE * DCACHE_N_COLORS) 23 #define LAST_PKMAP_MASK (LAST_PKMAP - 1) 24 #define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT) 25 #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 26 27 #define kmap_prot PAGE_KERNEL_EXEC 28 29 #if DCACHE_WAY_SIZE > PAGE_SIZE 30 #define get_pkmap_color get_pkmap_color 31 static inline int get_pkmap_color(struct page *page) 32 { 33 return DCACHE_ALIAS(page_to_phys(page)); 34 } 35 36 extern unsigned int last_pkmap_nr_arr[]; 37 38 static inline unsigned int get_next_pkmap_nr(unsigned int color) 39 { 40 last_pkmap_nr_arr[color] = 41 (last_pkmap_nr_arr[color] + DCACHE_N_COLORS) & LAST_PKMAP_MASK; 42 return last_pkmap_nr_arr[color] + color; 43 } 44 45 static inline int no_more_pkmaps(unsigned int pkmap_nr, unsigned int color) 46 { 47 return pkmap_nr < DCACHE_N_COLORS; 48 } 49 50 static inline int get_pkmap_entries_count(unsigned int color) 51 { 52 return LAST_PKMAP / DCACHE_N_COLORS; 53 } 54 55 extern wait_queue_head_t pkmap_map_wait_arr[]; 56 57 static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color) 58 { 59 return pkmap_map_wait_arr + color; 60 } 61 #endif 62 63 extern pte_t *pkmap_page_table; 64 65 static inline void flush_cache_kmaps(void) 66 { 67 flush_cache_all(); 68 } 69 70 enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn); 71 #define arch_kmap_local_map_idx kmap_local_map_idx 72 73 enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr); 74 #define arch_kmap_local_unmap_idx kmap_local_unmap_idx 75 76 #define arch_kmap_local_post_unmap(vaddr) \ 77 local_flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE) 78 79 void kmap_init(void); 80 81 #endif 82