1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * highmem.h: virtual kernel memory mappings for high memory 4 * 5 * Used in CONFIG_HIGHMEM systems for memory pages which 6 * are not addressable by direct kernel virtual addresses. 7 * 8 * Copyright (C) 2020 Loongson Technology Co., Ltd. 9 */ 10 #ifndef _ASM_HIGHMEM_H 11 #define _ASM_HIGHMEM_H 12 13 #ifdef __KERNEL__ 14 15 #include <linux/bug.h> 16 #include <linux/interrupt.h> 17 #include <linux/uaccess.h> 18 #include <asm/cpu-features.h> 19 #include <asm/kmap_types.h> 20 21 /* declarations for highmem.c */ 22 extern unsigned long highstart_pfn, highend_pfn; 23 24 extern pte_t *pkmap_page_table; 25 26 /* 27 * Right now we initialize only a single pte table. It can be extended 28 * easily, subsequent pte tables have to be allocated in one physical 29 * chunk of RAM. 30 */ 31 #define LAST_PKMAP 1024 32 33 #define LAST_PKMAP_MASK (LAST_PKMAP-1) 34 #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) 35 #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 36 37 extern void *kmap_high(struct page *page); 38 extern void kunmap_high(struct page *page); 39 40 extern void *kmap(struct page *page); 41 extern void kunmap(struct page *page); 42 extern void *kmap_atomic(struct page *page); 43 extern void *kmap_atomic_pfn(unsigned long pfn); 44 45 #define flush_cache_kmaps() BUG_ON(cpu_has_dc_aliases) 46 47 extern void kmap_init(void); 48 49 #define kmap_prot PAGE_KERNEL 50 51 #endif /* __KERNEL__ */ 52 53 #endif /* _ASM_HIGHMEM_H */ 54