Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * fixmap.h: compile-time virtual memory allocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Copyright (C) 1998 Ingo Molnar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #ifndef _ASM_FIXMAP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define _ASM_FIXMAP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifdef CONFIG_HIGHMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/threads.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/kmap_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  * Here we define all the compile-time 'special' virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * addresses. The point is to have a constant address at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  * compile time, but to set the physical address only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  * in the boot process. We allocate these special addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  * from the start of the consistent memory region upwards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)  * Also this lets us do fail-safe vmalloc(), we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  * can guarantee that these special addresses and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)  * vmalloc()-ed addresses never overlap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)  * these 'compile-time allocated' memory buffers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  * fixed-size 4k pages. (or larger if used with an increment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)  * higher than 1) use fixmap_set(idx,phys) to associate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  * physical memory with fixmap indices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) enum fixed_addresses {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #ifdef CONFIG_HIGHMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	/* reserved pte's for temporary kernel mappings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	FIX_KMAP_BEGIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	FIX_KMAP_END = FIX_KMAP_BEGIN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		(KM_TYPE_NR * NR_CPUS * DCACHE_N_COLORS) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	__end_of_fixed_addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define FIXADDR_TOP     (XCHAL_KSEG_CACHED_VADDR - PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define FIXADDR_START	((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define __fix_to_virt(x)	(FIXADDR_START + ((x) << PAGE_SHIFT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define __virt_to_fix(x)	(((x) - FIXADDR_START) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)  * 'index to address' translation. If anyone tries to use the idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)  * directly without translation, we catch the bug with a NULL-deference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)  * kernel oops. Illegal ranges of incoming indices are caught too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static __always_inline unsigned long fix_to_virt(const unsigned int idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	/* Check if this memory layout is broken because fixmap overlaps page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	 * table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	BUILD_BUG_ON(FIXADDR_START <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		     TLBTEMP_BASE_1 + TLBTEMP_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	return __fix_to_virt(idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static inline unsigned long virt_to_fix(const unsigned long vaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	return __virt_to_fix(vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #endif