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