Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 1 | #ifndef _SPARC_PGTABLE_H |
| 2 | #define _SPARC_PGTABLE_H |
| 3 | |
| 4 | /* asm/pgtable.h: Defines and functions used to work |
| 5 | * with Sparc page tables. |
| 6 | * |
| 7 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) |
| 8 | * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 9 | */ |
| 10 | |
Sam Ravnborg | eb485d6 | 2011-04-21 15:48:39 -0700 | [diff] [blame] | 11 | #include <linux/const.h> |
| 12 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 13 | #ifndef __ASSEMBLY__ |
| 14 | #include <asm-generic/4level-fixup.h> |
| 15 | |
| 16 | #include <linux/spinlock.h> |
| 17 | #include <linux/swap.h> |
| 18 | #include <asm/types.h> |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 19 | #include <asm/pgtsrmmu.h> |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 20 | #include <asm/oplib.h> |
| 21 | #include <asm/btfixup.h> |
David Howells | d550bbd | 2012-03-28 18:30:03 +0100 | [diff] [blame] | 22 | #include <asm/cpu_type.h> |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 23 | |
| 24 | |
| 25 | struct vm_area_struct; |
| 26 | struct page; |
| 27 | |
| 28 | extern void load_mmu(void); |
| 29 | extern unsigned long calc_highpages(void); |
| 30 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 31 | #define pte_ERROR(e) __builtin_trap() |
| 32 | #define pmd_ERROR(e) __builtin_trap() |
| 33 | #define pgd_ERROR(e) __builtin_trap() |
| 34 | |
| 35 | BTFIXUPDEF_INT(page_none) |
| 36 | BTFIXUPDEF_INT(page_copy) |
| 37 | BTFIXUPDEF_INT(page_readonly) |
| 38 | BTFIXUPDEF_INT(page_kernel) |
| 39 | |
Sam Ravnborg | 1ee0e14 | 2012-05-10 23:12:10 +0200 | [diff] [blame] | 40 | #define PMD_SHIFT 22 |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 41 | #define PMD_SIZE (1UL << PMD_SHIFT) |
| 42 | #define PMD_MASK (~(PMD_SIZE-1)) |
| 43 | #define PMD_ALIGN(__addr) (((__addr) + ~PMD_MASK) & PMD_MASK) |
David S. Miller | 3d386c0 | 2012-05-12 12:02:02 -0700 | [diff] [blame^] | 44 | #define PGDIR_SHIFT SRMMU_PGDIR_SHIFT |
| 45 | #define PGDIR_SIZE SRMMU_PGDIR_SIZE |
| 46 | #define PGDIR_MASK SRMMU_PGDIR_MASK |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 47 | #define PTRS_PER_PTE 1024 |
David S. Miller | 3d386c0 | 2012-05-12 12:02:02 -0700 | [diff] [blame^] | 48 | #define PTRS_PER_PMD SRMMU_PTRS_PER_PMD |
| 49 | #define PTRS_PER_PGD SRMMU_PTRS_PER_PGD |
| 50 | #define USER_PTRS_PER_PGD PAGE_OFFSET / SRMMU_PGDIR_SIZE |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 51 | #define FIRST_USER_ADDRESS 0 |
| 52 | #define PTE_SIZE (PTRS_PER_PTE*4) |
| 53 | |
| 54 | #define PAGE_NONE __pgprot(BTFIXUP_INT(page_none)) |
| 55 | extern pgprot_t PAGE_SHARED; |
| 56 | #define PAGE_COPY __pgprot(BTFIXUP_INT(page_copy)) |
| 57 | #define PAGE_READONLY __pgprot(BTFIXUP_INT(page_readonly)) |
| 58 | |
| 59 | extern unsigned long page_kernel; |
| 60 | |
| 61 | #ifdef MODULE |
| 62 | #define PAGE_KERNEL page_kernel |
| 63 | #else |
| 64 | #define PAGE_KERNEL __pgprot(BTFIXUP_INT(page_kernel)) |
| 65 | #endif |
| 66 | |
| 67 | /* Top-level page directory */ |
| 68 | extern pgd_t swapper_pg_dir[1024]; |
| 69 | |
| 70 | extern void paging_init(void); |
| 71 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 72 | extern unsigned long ptr_in_current_pgd; |
| 73 | |
| 74 | /* Here is a trick, since mmap.c need the initializer elements for |
| 75 | * protection_map[] to be constant at compile time, I set the following |
| 76 | * to all zeros. I set it to the real values after I link in the |
| 77 | * appropriate MMU page table routines at boot time. |
| 78 | */ |
| 79 | #define __P000 __pgprot(0) |
| 80 | #define __P001 __pgprot(0) |
| 81 | #define __P010 __pgprot(0) |
| 82 | #define __P011 __pgprot(0) |
| 83 | #define __P100 __pgprot(0) |
| 84 | #define __P101 __pgprot(0) |
| 85 | #define __P110 __pgprot(0) |
| 86 | #define __P111 __pgprot(0) |
| 87 | |
| 88 | #define __S000 __pgprot(0) |
| 89 | #define __S001 __pgprot(0) |
| 90 | #define __S010 __pgprot(0) |
| 91 | #define __S011 __pgprot(0) |
| 92 | #define __S100 __pgprot(0) |
| 93 | #define __S101 __pgprot(0) |
| 94 | #define __S110 __pgprot(0) |
| 95 | #define __S111 __pgprot(0) |
| 96 | |
| 97 | extern int num_contexts; |
| 98 | |
| 99 | /* First physical page can be anywhere, the following is needed so that |
| 100 | * va-->pa and vice versa conversions work properly without performance |
| 101 | * hit for all __pa()/__va() operations. |
| 102 | */ |
| 103 | extern unsigned long phys_base; |
| 104 | extern unsigned long pfn_base; |
| 105 | |
| 106 | /* |
| 107 | * BAD_PAGETABLE is used when we need a bogus page-table, while |
| 108 | * BAD_PAGE is used for a bogus page. |
| 109 | * |
| 110 | * ZERO_PAGE is a global shared page that is always zero: used |
| 111 | * for zero-mapped memory areas etc.. |
| 112 | */ |
| 113 | extern pte_t * __bad_pagetable(void); |
| 114 | extern pte_t __bad_page(void); |
| 115 | extern unsigned long empty_zero_page; |
| 116 | |
| 117 | #define BAD_PAGETABLE __bad_pagetable() |
| 118 | #define BAD_PAGE __bad_page() |
| 119 | #define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page)) |
| 120 | |
| 121 | /* |
| 122 | */ |
| 123 | BTFIXUPDEF_CALL_CONST(struct page *, pmd_page, pmd_t) |
| 124 | BTFIXUPDEF_CALL_CONST(unsigned long, pgd_page_vaddr, pgd_t) |
| 125 | |
| 126 | #define pmd_page(pmd) BTFIXUP_CALL(pmd_page)(pmd) |
| 127 | #define pgd_page_vaddr(pgd) BTFIXUP_CALL(pgd_page_vaddr)(pgd) |
| 128 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 129 | BTFIXUPDEF_CALL_CONST(int, pte_present, pte_t) |
| 130 | BTFIXUPDEF_CALL(void, pte_clear, pte_t *) |
| 131 | |
| 132 | static inline int pte_none(pte_t pte) |
| 133 | { |
David S. Miller | c87fe1c | 2010-05-25 23:36:31 -0700 | [diff] [blame] | 134 | return !pte_val(pte); |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | #define pte_present(pte) BTFIXUP_CALL(pte_present)(pte) |
| 138 | #define pte_clear(mm,addr,pte) BTFIXUP_CALL(pte_clear)(pte) |
| 139 | |
| 140 | BTFIXUPDEF_CALL_CONST(int, pmd_bad, pmd_t) |
| 141 | BTFIXUPDEF_CALL_CONST(int, pmd_present, pmd_t) |
| 142 | BTFIXUPDEF_CALL(void, pmd_clear, pmd_t *) |
| 143 | |
| 144 | static inline int pmd_none(pmd_t pmd) |
| 145 | { |
David S. Miller | c87fe1c | 2010-05-25 23:36:31 -0700 | [diff] [blame] | 146 | return !pmd_val(pmd); |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | #define pmd_bad(pmd) BTFIXUP_CALL(pmd_bad)(pmd) |
| 150 | #define pmd_present(pmd) BTFIXUP_CALL(pmd_present)(pmd) |
| 151 | #define pmd_clear(pmd) BTFIXUP_CALL(pmd_clear)(pmd) |
| 152 | |
| 153 | BTFIXUPDEF_CALL_CONST(int, pgd_none, pgd_t) |
| 154 | BTFIXUPDEF_CALL_CONST(int, pgd_bad, pgd_t) |
| 155 | BTFIXUPDEF_CALL_CONST(int, pgd_present, pgd_t) |
| 156 | BTFIXUPDEF_CALL(void, pgd_clear, pgd_t *) |
| 157 | |
| 158 | #define pgd_none(pgd) BTFIXUP_CALL(pgd_none)(pgd) |
| 159 | #define pgd_bad(pgd) BTFIXUP_CALL(pgd_bad)(pgd) |
| 160 | #define pgd_present(pgd) BTFIXUP_CALL(pgd_present)(pgd) |
| 161 | #define pgd_clear(pgd) BTFIXUP_CALL(pgd_clear)(pgd) |
| 162 | |
| 163 | /* |
| 164 | * The following only work if pte_present() is true. |
| 165 | * Undefined behaviour if not.. |
| 166 | */ |
| 167 | BTFIXUPDEF_HALF(pte_writei) |
| 168 | BTFIXUPDEF_HALF(pte_dirtyi) |
| 169 | BTFIXUPDEF_HALF(pte_youngi) |
| 170 | |
| 171 | static int pte_write(pte_t pte) __attribute_const__; |
| 172 | static inline int pte_write(pte_t pte) |
| 173 | { |
| 174 | return pte_val(pte) & BTFIXUP_HALF(pte_writei); |
| 175 | } |
| 176 | |
| 177 | static int pte_dirty(pte_t pte) __attribute_const__; |
| 178 | static inline int pte_dirty(pte_t pte) |
| 179 | { |
| 180 | return pte_val(pte) & BTFIXUP_HALF(pte_dirtyi); |
| 181 | } |
| 182 | |
| 183 | static int pte_young(pte_t pte) __attribute_const__; |
| 184 | static inline int pte_young(pte_t pte) |
| 185 | { |
| 186 | return pte_val(pte) & BTFIXUP_HALF(pte_youngi); |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | * The following only work if pte_present() is not true. |
| 191 | */ |
| 192 | BTFIXUPDEF_HALF(pte_filei) |
| 193 | |
| 194 | static int pte_file(pte_t pte) __attribute_const__; |
| 195 | static inline int pte_file(pte_t pte) |
| 196 | { |
| 197 | return pte_val(pte) & BTFIXUP_HALF(pte_filei); |
| 198 | } |
| 199 | |
| 200 | static inline int pte_special(pte_t pte) |
| 201 | { |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | /* |
| 206 | */ |
| 207 | BTFIXUPDEF_HALF(pte_wrprotecti) |
| 208 | BTFIXUPDEF_HALF(pte_mkcleani) |
| 209 | BTFIXUPDEF_HALF(pte_mkoldi) |
| 210 | |
| 211 | static pte_t pte_wrprotect(pte_t pte) __attribute_const__; |
| 212 | static inline pte_t pte_wrprotect(pte_t pte) |
| 213 | { |
| 214 | return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_wrprotecti)); |
| 215 | } |
| 216 | |
| 217 | static pte_t pte_mkclean(pte_t pte) __attribute_const__; |
| 218 | static inline pte_t pte_mkclean(pte_t pte) |
| 219 | { |
| 220 | return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkcleani)); |
| 221 | } |
| 222 | |
| 223 | static pte_t pte_mkold(pte_t pte) __attribute_const__; |
| 224 | static inline pte_t pte_mkold(pte_t pte) |
| 225 | { |
| 226 | return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkoldi)); |
| 227 | } |
| 228 | |
| 229 | BTFIXUPDEF_CALL_CONST(pte_t, pte_mkwrite, pte_t) |
| 230 | BTFIXUPDEF_CALL_CONST(pte_t, pte_mkdirty, pte_t) |
| 231 | BTFIXUPDEF_CALL_CONST(pte_t, pte_mkyoung, pte_t) |
| 232 | |
| 233 | #define pte_mkwrite(pte) BTFIXUP_CALL(pte_mkwrite)(pte) |
| 234 | #define pte_mkdirty(pte) BTFIXUP_CALL(pte_mkdirty)(pte) |
| 235 | #define pte_mkyoung(pte) BTFIXUP_CALL(pte_mkyoung)(pte) |
| 236 | |
| 237 | #define pte_mkspecial(pte) (pte) |
| 238 | |
| 239 | #define pfn_pte(pfn, prot) mk_pte(pfn_to_page(pfn), prot) |
| 240 | |
| 241 | BTFIXUPDEF_CALL(unsigned long, pte_pfn, pte_t) |
| 242 | #define pte_pfn(pte) BTFIXUP_CALL(pte_pfn)(pte) |
| 243 | #define pte_page(pte) pfn_to_page(pte_pfn(pte)) |
| 244 | |
| 245 | /* |
| 246 | * Conversion functions: convert a page and protection to a page entry, |
| 247 | * and a page entry and page directory to the page they refer to. |
| 248 | */ |
| 249 | BTFIXUPDEF_CALL_CONST(pte_t, mk_pte, struct page *, pgprot_t) |
| 250 | |
| 251 | BTFIXUPDEF_CALL_CONST(pte_t, mk_pte_phys, unsigned long, pgprot_t) |
| 252 | BTFIXUPDEF_CALL_CONST(pte_t, mk_pte_io, unsigned long, pgprot_t, int) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 253 | |
| 254 | #define mk_pte(page,pgprot) BTFIXUP_CALL(mk_pte)(page,pgprot) |
| 255 | #define mk_pte_phys(page,pgprot) BTFIXUP_CALL(mk_pte_phys)(page,pgprot) |
| 256 | #define mk_pte_io(page,pgprot,space) BTFIXUP_CALL(mk_pte_io)(page,pgprot,space) |
| 257 | |
Sam Ravnborg | afaedde | 2012-05-11 11:35:17 +0000 | [diff] [blame] | 258 | #define pgprot_noncached pgprot_noncached |
| 259 | static inline pgprot_t pgprot_noncached(pgprot_t prot) |
| 260 | { |
| 261 | prot &= ~__pgprot(SRMMU_CACHE); |
| 262 | return prot; |
| 263 | } |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 264 | |
| 265 | BTFIXUPDEF_INT(pte_modify_mask) |
| 266 | |
| 267 | static pte_t pte_modify(pte_t pte, pgprot_t newprot) __attribute_const__; |
| 268 | static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) |
| 269 | { |
| 270 | return __pte((pte_val(pte) & BTFIXUP_INT(pte_modify_mask)) | |
| 271 | pgprot_val(newprot)); |
| 272 | } |
| 273 | |
| 274 | #define pgd_index(address) ((address) >> PGDIR_SHIFT) |
| 275 | |
| 276 | /* to find an entry in a page-table-directory */ |
| 277 | #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address)) |
| 278 | |
| 279 | /* to find an entry in a kernel page-table-directory */ |
| 280 | #define pgd_offset_k(address) pgd_offset(&init_mm, address) |
| 281 | |
| 282 | /* Find an entry in the second-level page table.. */ |
| 283 | BTFIXUPDEF_CALL(pmd_t *, pmd_offset, pgd_t *, unsigned long) |
| 284 | #define pmd_offset(dir,addr) BTFIXUP_CALL(pmd_offset)(dir,addr) |
| 285 | |
| 286 | /* Find an entry in the third-level page table.. */ |
| 287 | BTFIXUPDEF_CALL(pte_t *, pte_offset_kernel, pmd_t *, unsigned long) |
| 288 | #define pte_offset_kernel(dir,addr) BTFIXUP_CALL(pte_offset_kernel)(dir,addr) |
| 289 | |
| 290 | /* |
David S. Miller | ee906c9 | 2012-05-12 00:35:45 -0700 | [diff] [blame] | 291 | * This shortcut works on sun4m (and sun4d) because the nocache area is static. |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 292 | */ |
| 293 | #define pte_offset_map(d, a) pte_offset_kernel(d,a) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 294 | #define pte_unmap(pte) do{}while(0) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 295 | |
| 296 | /* Certain architectures need to do special things when pte's |
| 297 | * within a page table are directly modified. Thus, the following |
| 298 | * hook is made available. |
| 299 | */ |
| 300 | |
| 301 | BTFIXUPDEF_CALL(void, set_pte, pte_t *, pte_t) |
| 302 | |
| 303 | #define set_pte(ptep,pteval) BTFIXUP_CALL(set_pte)(ptep,pteval) |
| 304 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) |
| 305 | |
| 306 | struct seq_file; |
| 307 | BTFIXUPDEF_CALL(void, mmu_info, struct seq_file *) |
| 308 | |
| 309 | #define mmu_info(p) BTFIXUP_CALL(mmu_info)(p) |
| 310 | |
| 311 | /* Fault handler stuff... */ |
| 312 | #define FAULT_CODE_PROT 0x1 |
| 313 | #define FAULT_CODE_WRITE 0x2 |
| 314 | #define FAULT_CODE_USER 0x4 |
| 315 | |
Russell King | 4b3073e | 2009-12-18 16:40:18 +0000 | [diff] [blame] | 316 | BTFIXUPDEF_CALL(void, update_mmu_cache, struct vm_area_struct *, unsigned long, pte_t *) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 317 | |
Russell King | 4b3073e | 2009-12-18 16:40:18 +0000 | [diff] [blame] | 318 | #define update_mmu_cache(vma,addr,ptep) BTFIXUP_CALL(update_mmu_cache)(vma,addr,ptep) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 319 | |
| 320 | BTFIXUPDEF_CALL(void, sparc_mapiorange, unsigned int, unsigned long, |
| 321 | unsigned long, unsigned int) |
| 322 | BTFIXUPDEF_CALL(void, sparc_unmapiorange, unsigned long, unsigned int) |
| 323 | #define sparc_mapiorange(bus,pa,va,len) BTFIXUP_CALL(sparc_mapiorange)(bus,pa,va,len) |
| 324 | #define sparc_unmapiorange(va,len) BTFIXUP_CALL(sparc_unmapiorange)(va,len) |
| 325 | |
| 326 | extern int invalid_segment; |
| 327 | |
| 328 | /* Encode and de-code a swap entry */ |
| 329 | BTFIXUPDEF_CALL(unsigned long, __swp_type, swp_entry_t) |
| 330 | BTFIXUPDEF_CALL(unsigned long, __swp_offset, swp_entry_t) |
| 331 | BTFIXUPDEF_CALL(swp_entry_t, __swp_entry, unsigned long, unsigned long) |
| 332 | |
| 333 | #define __swp_type(__x) BTFIXUP_CALL(__swp_type)(__x) |
| 334 | #define __swp_offset(__x) BTFIXUP_CALL(__swp_offset)(__x) |
| 335 | #define __swp_entry(__type,__off) BTFIXUP_CALL(__swp_entry)(__type,__off) |
| 336 | |
| 337 | #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) |
| 338 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) |
| 339 | |
| 340 | /* file-offset-in-pte helpers */ |
Sam Ravnborg | afaedde | 2012-05-11 11:35:17 +0000 | [diff] [blame] | 341 | static inline unsigned long pte_to_pgoff(pte_t pte) |
| 342 | { |
| 343 | return pte_val(pte) >> SRMMU_PTE_FILE_SHIFT; |
| 344 | } |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 345 | |
Sam Ravnborg | afaedde | 2012-05-11 11:35:17 +0000 | [diff] [blame] | 346 | static inline pte_t pgoff_to_pte(unsigned long pgoff) |
| 347 | { |
| 348 | return __pte((pgoff << SRMMU_PTE_FILE_SHIFT) | SRMMU_FILE); |
| 349 | } |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 350 | |
| 351 | /* |
| 352 | * This is made a constant because mm/fremap.c required a constant. |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 353 | */ |
| 354 | #define PTE_FILE_MAX_BITS 24 |
| 355 | |
| 356 | /* |
| 357 | */ |
| 358 | struct ctx_list { |
| 359 | struct ctx_list *next; |
| 360 | struct ctx_list *prev; |
| 361 | unsigned int ctx_number; |
| 362 | struct mm_struct *ctx_mm; |
| 363 | }; |
| 364 | |
| 365 | extern struct ctx_list *ctx_list_pool; /* Dynamically allocated */ |
| 366 | extern struct ctx_list ctx_free; /* Head of free list */ |
| 367 | extern struct ctx_list ctx_used; /* Head of used contexts list */ |
| 368 | |
| 369 | #define NO_CONTEXT -1 |
| 370 | |
| 371 | static inline void remove_from_ctx_list(struct ctx_list *entry) |
| 372 | { |
| 373 | entry->next->prev = entry->prev; |
| 374 | entry->prev->next = entry->next; |
| 375 | } |
| 376 | |
| 377 | static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry) |
| 378 | { |
| 379 | entry->next = head; |
| 380 | (entry->prev = head->prev)->next = entry; |
| 381 | head->prev = entry; |
| 382 | } |
| 383 | #define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry) |
| 384 | #define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry) |
| 385 | |
| 386 | static inline unsigned long |
| 387 | __get_phys (unsigned long addr) |
| 388 | { |
| 389 | switch (sparc_cpu_model){ |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 390 | case sun4m: |
| 391 | case sun4d: |
| 392 | return ((srmmu_get_pte (addr) & 0xffffff00) << 4); |
| 393 | default: |
| 394 | return 0; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | static inline int |
| 399 | __get_iospace (unsigned long addr) |
| 400 | { |
| 401 | switch (sparc_cpu_model){ |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 402 | case sun4m: |
| 403 | case sun4d: |
| 404 | return (srmmu_get_pte (addr) >> 28); |
| 405 | default: |
| 406 | return -1; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | extern unsigned long *sparc_valid_addr_bitmap; |
| 411 | |
| 412 | /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ |
| 413 | #define kern_addr_valid(addr) \ |
| 414 | (test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap)) |
| 415 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 416 | /* |
| 417 | * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in |
| 418 | * its high 4 bits. These macros/functions put it there or get it from there. |
| 419 | */ |
| 420 | #define MK_IOSPACE_PFN(space, pfn) (pfn | (space << (BITS_PER_LONG - 4))) |
| 421 | #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) |
| 422 | #define GET_PFN(pfn) (pfn & 0x0fffffffUL) |
| 423 | |
David S. Miller | 3e37fd3 | 2011-11-17 18:17:59 -0800 | [diff] [blame] | 424 | extern int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, |
| 425 | unsigned long, pgprot_t); |
| 426 | |
| 427 | static inline int io_remap_pfn_range(struct vm_area_struct *vma, |
| 428 | unsigned long from, unsigned long pfn, |
| 429 | unsigned long size, pgprot_t prot) |
| 430 | { |
| 431 | unsigned long long offset, space, phys_base; |
| 432 | |
| 433 | offset = ((unsigned long long) GET_PFN(pfn)) << PAGE_SHIFT; |
| 434 | space = GET_IOSPACE(pfn); |
| 435 | phys_base = offset | (space << 32ULL); |
| 436 | |
| 437 | return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot); |
| 438 | } |
| 439 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 440 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS |
| 441 | #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \ |
| 442 | ({ \ |
| 443 | int __changed = !pte_same(*(__ptep), __entry); \ |
| 444 | if (__changed) { \ |
| 445 | set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry); \ |
| 446 | flush_tlb_page(__vma, __address); \ |
| 447 | } \ |
Sam Ravnborg | 1ee0e14 | 2012-05-10 23:12:10 +0200 | [diff] [blame] | 448 | __changed; \ |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 449 | }) |
| 450 | |
| 451 | #include <asm-generic/pgtable.h> |
| 452 | |
| 453 | #endif /* !(__ASSEMBLY__) */ |
| 454 | |
Sam Ravnborg | eb485d6 | 2011-04-21 15:48:39 -0700 | [diff] [blame] | 455 | #define VMALLOC_START _AC(0xfe600000,UL) |
Sam Ravnborg | eb485d6 | 2011-04-21 15:48:39 -0700 | [diff] [blame] | 456 | #define VMALLOC_END _AC(0xffc00000,UL) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 457 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 458 | /* We provide our own get_unmapped_area to cope with VA holes for userland */ |
| 459 | #define HAVE_ARCH_UNMAPPED_AREA |
| 460 | |
| 461 | /* |
| 462 | * No page table caches to initialise |
| 463 | */ |
| 464 | #define pgtable_cache_init() do { } while (0) |
| 465 | |
| 466 | #endif /* !(_SPARC_PGTABLE_H) */ |