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