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 | |
| 24 | #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) |
| 25 | #define copy_page(to,from) copy_user_page_asm((void *)(to), (void *)(from)) |
| 26 | |
| 27 | struct page; |
| 28 | |
James Bottomley | 20f4d3c | 2006-08-23 09:00:04 -0700 | [diff] [blame] | 29 | void copy_user_page_asm(void *to, void *from); |
| 30 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, |
| 31 | struct page *pg); |
| 32 | void clear_user_page(void *page, unsigned long vaddr, struct page *pg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
| 34 | /* |
| 35 | * These are used to make use of C type-checking.. |
| 36 | */ |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 37 | #define STRICT_MM_TYPECHECKS |
| 38 | #ifdef STRICT_MM_TYPECHECKS |
| 39 | typedef struct { unsigned long pte; |
| 40 | #if !defined(CONFIG_64BIT) |
| 41 | unsigned long future_flags; |
| 42 | /* XXX: it's possible to remove future_flags and change BITS_PER_PTE_ENTRY |
| 43 | to 2, but then strangely the identical 32bit kernel boots on a |
| 44 | c3000(pa20), but not any longer on a 715(pa11). |
| 45 | Still investigating... HelgeD. |
| 46 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #endif |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 48 | } pte_t; /* either 32 or 64bit */ |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | /* NOTE: even on 64 bits, these entries are __u32 because we allocate |
| 51 | * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */ |
| 52 | typedef struct { __u32 pmd; } pmd_t; |
| 53 | typedef struct { __u32 pgd; } pgd_t; |
| 54 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 55 | |
| 56 | #define pte_val(x) ((x).pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | /* These do not work lvalues, so make sure we don't use them as such. */ |
| 58 | #define pmd_val(x) ((x).pmd + 0) |
| 59 | #define pgd_val(x) ((x).pgd + 0) |
| 60 | #define pgprot_val(x) ((x).pgprot) |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #define __pte(x) ((pte_t) { (x) } ) |
| 63 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 64 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 65 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 66 | |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 67 | #define __pmd_val_set(x,n) (x).pmd = (n) |
| 68 | #define __pgd_val_set(x,n) (x).pgd = (n) |
| 69 | |
| 70 | #else |
| 71 | /* |
| 72 | * .. while these make it easier on the compiler |
| 73 | */ |
| 74 | typedef unsigned long pte_t; |
| 75 | typedef __u32 pmd_t; |
| 76 | typedef __u32 pgd_t; |
| 77 | typedef unsigned long pgprot_t; |
| 78 | |
| 79 | #define pte_val(x) (x) |
| 80 | #define pmd_val(x) (x) |
| 81 | #define pgd_val(x) (x) |
| 82 | #define pgprot_val(x) (x) |
| 83 | |
| 84 | #define __pte(x) (x) |
| 85 | #define __pmd(x) (x) |
| 86 | #define __pgd(x) (x) |
| 87 | #define __pgprot(x) (x) |
| 88 | |
| 89 | #define __pmd_val_set(x,n) (x) = (n) |
| 90 | #define __pgd_val_set(x,n) (x) = (n) |
| 91 | |
| 92 | #endif /* STRICT_MM_TYPECHECKS */ |
| 93 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 94 | typedef struct page *pgtable_t; |
Helge Deller | b31059f | 2006-03-23 15:48:15 -0700 | [diff] [blame] | 95 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | typedef struct __physmem_range { |
| 97 | unsigned long start_pfn; |
| 98 | unsigned long pages; /* PAGE_SIZE pages */ |
| 99 | } physmem_range_t; |
| 100 | |
| 101 | extern physmem_range_t pmem_ranges[]; |
| 102 | extern int npmem_ranges; |
| 103 | |
| 104 | #endif /* !__ASSEMBLY__ */ |
| 105 | |
| 106 | /* WARNING: The definitions below must match exactly to sizeof(pte_t) |
| 107 | * etc |
| 108 | */ |
Helge Deller | 513e7ec | 2007-01-28 15:09:20 +0100 | [diff] [blame] | 109 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #define BITS_PER_PTE_ENTRY 3 |
| 111 | #define BITS_PER_PMD_ENTRY 2 |
| 112 | #define BITS_PER_PGD_ENTRY 2 |
| 113 | #else |
| 114 | #define BITS_PER_PTE_ENTRY 3 |
| 115 | #define BITS_PER_PMD_ENTRY 2 |
| 116 | #define BITS_PER_PGD_ENTRY BITS_PER_PMD_ENTRY |
| 117 | #endif |
| 118 | #define PGD_ENTRY_SIZE (1UL << BITS_PER_PGD_ENTRY) |
| 119 | #define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY) |
| 120 | #define PTE_ENTRY_SIZE (1UL << BITS_PER_PTE_ENTRY) |
| 121 | |
| 122 | /* to align the pointer to the (next) page boundary */ |
| 123 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 124 | |
| 125 | |
| 126 | #define LINUX_GATEWAY_SPACE 0 |
| 127 | |
| 128 | /* This governs the relationship between virtual and physical addresses. |
| 129 | * If you alter it, make sure to take care of our various fixed mapping |
| 130 | * segments in fixmap.h */ |
Kyle McMartin | caa451f | 2006-10-16 00:29:47 -0400 | [diff] [blame] | 131 | #ifdef CONFIG_64BIT |
| 132 | #define __PAGE_OFFSET (0x40000000) /* 1GB */ |
| 133 | #else |
| 134 | #define __PAGE_OFFSET (0x10000000) /* 256MB */ |
| 135 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
| 137 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) |
| 138 | |
| 139 | /* The size of the gateway page (we leave lots of room for expansion) */ |
| 140 | #define GATEWAY_PAGE_SIZE 0x4000 |
| 141 | |
| 142 | /* The start of the actual kernel binary---used in vmlinux.lds.S |
| 143 | * Leave some space after __PAGE_OFFSET for detecting kernel null |
| 144 | * ptr derefs */ |
| 145 | #define KERNEL_BINARY_TEXT_START (__PAGE_OFFSET + 0x100000) |
| 146 | |
| 147 | /* These macros don't work for 64-bit C code -- don't allow in C at all */ |
| 148 | #ifdef __ASSEMBLY__ |
| 149 | # define PA(x) ((x)-__PAGE_OFFSET) |
| 150 | # define VA(x) ((x)+__PAGE_OFFSET) |
| 151 | #endif |
| 152 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) |
| 153 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
| 154 | |
| 155 | #ifndef CONFIG_DISCONTIGMEM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | #define pfn_valid(pfn) ((pfn) < max_mapnr) |
| 157 | #endif /* CONFIG_DISCONTIGMEM */ |
| 158 | |
Helge Deller | e8b736c | 2006-01-10 20:47:55 -0500 | [diff] [blame] | 159 | #ifdef CONFIG_HUGETLB_PAGE |
| 160 | #define HPAGE_SHIFT 22 /* 4MB (is this fixed?) */ |
| 161 | #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) |
| 162 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) |
| 163 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
| 164 | #endif |
| 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 167 | |
| 168 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) |
| 169 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 170 | |
| 171 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 172 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 173 | |
KAMEZAWA Hiroyuki | 0d833b4 | 2006-03-27 01:15:43 -0800 | [diff] [blame] | 174 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 175 | #include <asm-generic/page.h> |
| 176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | #endif /* _PARISC_PAGE_H */ |