Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _PARISC_PAGE_H |
| 3 | #define _PARISC_PAGE_H |
| 4 | |
Sam Ravnborg | 1c59357 | 2007-10-18 00:04:34 -0700 | [diff] [blame] | 5 | #include <linux/const.h> |
| 6 | |
Helge Deller | 2fd8303 | 2006-04-20 20:40:23 +0000 | [diff] [blame] | 7 | #if defined(CONFIG_PARISC_PAGE_SIZE_4KB) |
Matthew Wilcox | ac7fb27 | 2006-09-18 20:12:27 -0700 | [diff] [blame] | 8 | # define PAGE_SHIFT 12 |
Helge Deller | 2fd8303 | 2006-04-20 20:40:23 +0000 | [diff] [blame] | 9 | #elif defined(CONFIG_PARISC_PAGE_SIZE_16KB) |
Matthew Wilcox | ac7fb27 | 2006-09-18 20:12:27 -0700 | [diff] [blame] | 10 | # define PAGE_SHIFT 14 |
Helge Deller | 2fd8303 | 2006-04-20 20:40:23 +0000 | [diff] [blame] | 11 | #elif defined(CONFIG_PARISC_PAGE_SIZE_64KB) |
Matthew Wilcox | ac7fb27 | 2006-09-18 20:12:27 -0700 | [diff] [blame] | 12 | # define PAGE_SHIFT 16 |
Helge Deller | 2fd8303 | 2006-04-20 20:40:23 +0000 | [diff] [blame] | 13 | #else |
| 14 | # error "unknown default kernel page size" |
| 15 | #endif |
Sam Ravnborg | 1c59357 | 2007-10-18 00:04:34 -0700 | [diff] [blame] | 16 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) |
Helge Deller | 2fd8303 | 2006-04-20 20:40:23 +0000 | [diff] [blame] | 17 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 18 | |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #ifndef __ASSEMBLY__ |
| 21 | |
| 22 | #include <asm/types.h> |
| 23 | #include <asm/cache.h> |
| 24 | |
John David Anglin | 7633453 | 2013-02-03 22:59:09 +0000 | [diff] [blame] | 25 | #define clear_page(page) clear_page_asm((void *)(page)) |
| 26 | #define copy_page(to, from) copy_page_asm((void *)(to), (void *)(from)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | struct page; |
| 29 | |
John David Anglin | 7633453 | 2013-02-03 22:59:09 +0000 | [diff] [blame] | 30 | void clear_page_asm(void *page); |
| 31 | void copy_page_asm(void *to, void *from); |
John David Anglin | f8dae00 | 2014-01-05 21:25:00 -0500 | [diff] [blame] | 32 | #define clear_user_page(vto, vaddr, page) clear_page_asm(vto) |
Helge Deller | 57737c4 | 2014-01-31 21:33:17 +0100 | [diff] [blame] | 33 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, |
| 34 | struct page *pg); |
John David Anglin | 7633453 | 2013-02-03 22:59:09 +0000 | [diff] [blame] | 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | /* |
| 37 | * These are used to make use of C type-checking.. |
| 38 | */ |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 39 | #define STRICT_MM_TYPECHECKS |
| 40 | #ifdef STRICT_MM_TYPECHECKS |
Helge Deller | 48d27cb | 2009-01-18 19:16:16 +0100 | [diff] [blame] | 41 | typedef struct { unsigned long pte; } pte_t; /* either 32 or 64bit */ |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 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 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 87 | typedef struct page *pgtable_t; |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Helge Deller | 513e7ec | 2007-01-28 15:09:20 +0100 | [diff] [blame] | 102 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | #define BITS_PER_PTE_ENTRY 3 |
| 104 | #define BITS_PER_PMD_ENTRY 2 |
| 105 | #define BITS_PER_PGD_ENTRY 2 |
| 106 | #else |
Helge Deller | 48d27cb | 2009-01-18 19:16:16 +0100 | [diff] [blame] | 107 | #define BITS_PER_PTE_ENTRY 2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ |
Kyle McMartin | caa451f | 2006-10-16 00:29:47 -0400 | [diff] [blame] | 120 | #ifdef CONFIG_64BIT |
Helge Deller | 34c201ae | 2018-10-15 22:14:01 +0200 | [diff] [blame] | 121 | #define __PAGE_OFFSET_DEFAULT (0x40000000) /* 1GB */ |
Kyle McMartin | caa451f | 2006-10-16 00:29:47 -0400 | [diff] [blame] | 122 | #else |
Helge Deller | 34c201ae | 2018-10-15 22:14:01 +0200 | [diff] [blame] | 123 | #define __PAGE_OFFSET_DEFAULT (0x10000000) /* 256MB */ |
Kyle McMartin | caa451f | 2006-10-16 00:29:47 -0400 | [diff] [blame] | 124 | #endif |
Helge Deller | 34c201ae | 2018-10-15 22:14:01 +0200 | [diff] [blame] | 125 | |
| 126 | #if defined(BOOTLOADER) |
| 127 | #define __PAGE_OFFSET (0) /* bootloader uses physical addresses */ |
| 128 | #else |
| 129 | #define __PAGE_OFFSET __PAGE_OFFSET_DEFAULT |
Helge Deller | f5213b2 | 2017-08-20 10:52:22 +0200 | [diff] [blame] | 130 | #endif /* BOOTLOADER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
| 132 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) |
| 133 | |
| 134 | /* The size of the gateway page (we leave lots of room for expansion) */ |
| 135 | #define GATEWAY_PAGE_SIZE 0x4000 |
| 136 | |
| 137 | /* The start of the actual kernel binary---used in vmlinux.lds.S |
| 138 | * Leave some space after __PAGE_OFFSET for detecting kernel null |
| 139 | * ptr derefs */ |
| 140 | #define KERNEL_BINARY_TEXT_START (__PAGE_OFFSET + 0x100000) |
| 141 | |
| 142 | /* These macros don't work for 64-bit C code -- don't allow in C at all */ |
| 143 | #ifdef __ASSEMBLY__ |
| 144 | # define PA(x) ((x)-__PAGE_OFFSET) |
| 145 | # define VA(x) ((x)+__PAGE_OFFSET) |
| 146 | #endif |
| 147 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) |
| 148 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
| 149 | |
Helge Deller | dbdf076 | 2019-04-09 21:52:35 +0200 | [diff] [blame] | 150 | #ifndef CONFIG_SPARSEMEM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | #define pfn_valid(pfn) ((pfn) < max_mapnr) |
Helge Deller | dbdf076 | 2019-04-09 21:52:35 +0200 | [diff] [blame] | 152 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Helge Deller | e8b736c | 2006-01-10 20:47:55 -0500 | [diff] [blame] | 154 | #ifdef CONFIG_HUGETLB_PAGE |
Helge Deller | 1f25ad2 | 2015-11-20 15:46:52 +0100 | [diff] [blame] | 155 | #define HPAGE_SHIFT PMD_SHIFT /* fixed for transparent huge pages */ |
Helge Deller | e8b736c | 2006-01-10 20:47:55 -0500 | [diff] [blame] | 156 | #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) |
| 157 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) |
| 158 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
Helge Deller | 1f25ad2 | 2015-11-20 15:46:52 +0100 | [diff] [blame] | 159 | |
| 160 | #if defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB) |
| 161 | # define REAL_HPAGE_SHIFT 20 /* 20 = 1MB */ |
| 162 | # define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_1M |
| 163 | #elif !defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB) |
| 164 | # define REAL_HPAGE_SHIFT 22 /* 22 = 4MB */ |
| 165 | # define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_4M |
| 166 | #else |
| 167 | # define REAL_HPAGE_SHIFT 24 /* 24 = 16MB */ |
| 168 | # define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_16M |
Helge Deller | e8b736c | 2006-01-10 20:47:55 -0500 | [diff] [blame] | 169 | #endif |
Helge Deller | 1f25ad2 | 2015-11-20 15:46:52 +0100 | [diff] [blame] | 170 | #endif /* CONFIG_HUGETLB_PAGE */ |
Helge Deller | e8b736c | 2006-01-10 20:47:55 -0500 | [diff] [blame] | 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 173 | |
| 174 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) |
| 175 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 176 | |
| 177 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 178 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 179 | |
KAMEZAWA Hiroyuki | 0d833b4 | 2006-03-27 01:15:43 -0800 | [diff] [blame] | 180 | #include <asm-generic/memory_model.h> |
Arnd Bergmann | 5b17e1c | 2009-05-13 22:56:30 +0000 | [diff] [blame] | 181 | #include <asm-generic/getorder.h> |
Rolf Eike Beer | 4a8a078 | 2012-05-10 23:08:17 +0200 | [diff] [blame] | 182 | #include <asm/pdc.h> |
| 183 | |
| 184 | #define PAGE0 ((struct zeropage *)__PAGE_OFFSET) |
| 185 | |
| 186 | /* DEFINITION OF THE ZERO-PAGE (PAG0) */ |
| 187 | /* based on work by Jason Eckhardt (jason@equator.com) */ |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | #endif /* _PARISC_PAGE_H */ |