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) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _PARISC_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _PARISC_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/const.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) # define PAGE_SHIFT	12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) # define PAGE_SHIFT	14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) # define PAGE_SHIFT	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) # error "unknown default kernel page size"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define PAGE_MASK	(~(PAGE_SIZE-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <asm/cache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define clear_page(page)	clear_page_asm((void *)(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define copy_page(to, from)	copy_page_asm((void *)(to), (void *)(from))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) void clear_page_asm(void *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) void copy_page_asm(void *to, void *from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define clear_user_page(vto, vaddr, page) clear_page_asm(vto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 			struct page *pg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * These are used to make use of C type-checking..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define STRICT_MM_TYPECHECKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #ifdef STRICT_MM_TYPECHECKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) typedef struct { unsigned long pte; } pte_t; /* either 32 or 64bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /* NOTE: even on 64 bits, these entries are __u32 because we allocate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) typedef struct { __u32 pgd; } pgd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) typedef struct { unsigned long pgprot; } pgprot_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #if CONFIG_PGTABLE_LEVELS == 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) typedef struct { __u32 pmd; } pmd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define __pmd(x)	((pmd_t) { (x) } )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) /* pXd_val() do not work as lvalues, so make sure we don't use them as such. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define pmd_val(x)	((x).pmd + 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define pte_val(x)	((x).pte)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define pgd_val(x)	((x).pgd + 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define pgprot_val(x)	((x).pgprot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define __pte(x)	((pte_t) { (x) } )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define __pgd(x)	((pgd_t) { (x) } )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define __pgprot(x)	((pgprot_t) { (x) } )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * .. while these make it easier on the compiler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) typedef unsigned long pte_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #if CONFIG_PGTABLE_LEVELS == 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) typedef         __u32 pmd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define pmd_val(x)      (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define __pmd(x)	(x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) typedef         __u32 pgd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) typedef unsigned long pgprot_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define pte_val(x)      (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #define pgd_val(x)      (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define pgprot_val(x)   (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define __pte(x)        (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define __pgd(x)        (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #define __pgprot(x)     (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #endif /* STRICT_MM_TYPECHECKS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #if CONFIG_PGTABLE_LEVELS == 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define set_pud(pudptr, pudval) (*(pudptr) = (pudval))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) typedef struct page *pgtable_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) typedef struct __physmem_range {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	unsigned long start_pfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	unsigned long pages;       /* PAGE_SIZE pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) } physmem_range_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) extern physmem_range_t pmem_ranges[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) extern int npmem_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #endif /* !__ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* WARNING: The definitions below must match exactly to sizeof(pte_t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * etc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #ifdef CONFIG_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define BITS_PER_PTE_ENTRY	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define BITS_PER_PMD_ENTRY	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define BITS_PER_PGD_ENTRY	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define BITS_PER_PTE_ENTRY	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define BITS_PER_PMD_ENTRY	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define BITS_PER_PGD_ENTRY	BITS_PER_PMD_ENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define PGD_ENTRY_SIZE	(1UL << BITS_PER_PGD_ENTRY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define PMD_ENTRY_SIZE	(1UL << BITS_PER_PMD_ENTRY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define PTE_ENTRY_SIZE	(1UL << BITS_PER_PTE_ENTRY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define LINUX_GATEWAY_SPACE     0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* This governs the relationship between virtual and physical addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * If you alter it, make sure to take care of our various fixed mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * segments in fixmap.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #ifdef CONFIG_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define __PAGE_OFFSET_DEFAULT	(0x40000000)	/* 1GB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define __PAGE_OFFSET_DEFAULT	(0x10000000)	/* 256MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #if defined(BOOTLOADER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define __PAGE_OFFSET	(0)	/* bootloader uses physical addresses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define __PAGE_OFFSET	__PAGE_OFFSET_DEFAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #endif /* BOOTLOADER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /* The size of the gateway page (we leave lots of room for expansion) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define GATEWAY_PAGE_SIZE	0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* The start of the actual kernel binary---used in vmlinux.lds.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * Leave some space after __PAGE_OFFSET for detecting kernel null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * ptr derefs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define KERNEL_BINARY_TEXT_START	(__PAGE_OFFSET + 0x100000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* These macros don't work for 64-bit C code -- don't allow in C at all */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #ifdef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #   define PA(x)	((x)-__PAGE_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #   define VA(x)	((x)+__PAGE_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #ifndef CONFIG_SPARSEMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define pfn_valid(pfn)		((pfn) < max_mapnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #ifdef CONFIG_HUGETLB_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define HPAGE_SHIFT		PMD_SHIFT /* fixed for transparent huge pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define HPAGE_SIZE      	((1UL) << HPAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define HPAGE_MASK		(~(HPAGE_SIZE - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #if defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) # define REAL_HPAGE_SHIFT	20 /* 20 = 1MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) # define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_1M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #elif !defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) # define REAL_HPAGE_SHIFT	22 /* 22 = 4MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) # define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_4M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) # define REAL_HPAGE_SHIFT	24 /* 24 = 16MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) # define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_16M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #endif /* CONFIG_HUGETLB_PAGE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #define virt_to_page(kaddr)     pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #include <asm-generic/memory_model.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #include <asm-generic/getorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #include <asm/pdc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) #define PAGE0   ((struct zeropage *)absolute_pointer(__PAGE_OFFSET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* DEFINITION OF THE ZERO-PAGE (PAG0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* based on work by Jason Eckhardt (jason@equator.com) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #endif /* _PARISC_PAGE_H */