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