Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 1 | /* |
| 2 | * This file contains the functions and defines necessary to modify and |
| 3 | * use the SuperH page table tree. |
| 4 | * |
| 5 | * Copyright (C) 1999 Niibe Yutaka |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 6 | * Copyright (C) 2002 - 2007 Paul Mundt |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU General |
| 9 | * Public License. See the file "COPYING" in the main directory of this |
| 10 | * archive for more details. |
| 11 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #ifndef __ASM_SH_PGTABLE_H |
| 13 | #define __ASM_SH_PGTABLE_H |
| 14 | |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 15 | #include <asm-generic/pgtable-nopmd.h> |
| 16 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #ifndef __ASSEMBLY__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/addrspace.h> |
| 20 | #include <asm/fixmap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | * ZERO_PAGE is a global shared page that is always zero: used |
| 24 | * for zero-mapped memory areas etc.. |
| 25 | */ |
Paul Mundt | 26ff6c1 | 2006-09-27 15:13:36 +0900 | [diff] [blame] | 26 | extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) |
| 28 | |
| 29 | #endif /* !__ASSEMBLY__ */ |
| 30 | |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 31 | /* |
Paul Mundt | 36bcd39 | 2007-11-10 19:16:55 +0900 | [diff] [blame] | 32 | * Effective and physical address definitions, to aid with sign |
| 33 | * extension. |
| 34 | */ |
| 35 | #define NEFF 32 |
| 36 | #define NEFF_SIGN (1LL << (NEFF - 1)) |
| 37 | #define NEFF_MASK (-1LL << NEFF) |
| 38 | |
| 39 | #ifdef CONFIG_29BIT |
| 40 | #define NPHYS 29 |
| 41 | #else |
| 42 | #define NPHYS 32 |
| 43 | #endif |
| 44 | |
| 45 | #define NPHYS_SIGN (1LL << (NPHYS - 1)) |
| 46 | #define NPHYS_MASK (-1LL << NPHYS) |
| 47 | |
| 48 | /* |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 49 | * traditional two-level paging structure |
| 50 | */ |
| 51 | /* PTE bits */ |
Paul Mundt | 55183e9 | 2007-11-21 16:19:12 +0900 | [diff] [blame^] | 52 | #if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64) |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 53 | # define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */ |
| 54 | #else |
| 55 | # define PTE_MAGNITUDE 2 /* 32-bit PTEs */ |
| 56 | #endif |
| 57 | #define PTE_SHIFT PAGE_SHIFT |
| 58 | #define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE) |
| 59 | |
| 60 | /* PGD bits */ |
| 61 | #define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS) |
Paul Mundt | db2e1fa | 2007-02-14 14:13:10 +0900 | [diff] [blame] | 62 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) |
| 64 | |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 65 | /* Entries per level */ |
Paul Mundt | 7a847f8 | 2006-12-26 15:29:19 +0900 | [diff] [blame] | 66 | #define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE)) |
Paul Mundt | d04a0f7 | 2007-09-21 11:55:03 +0900 | [diff] [blame] | 67 | #define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t)) |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) |
Hugh Dickins | d455a36 | 2005-04-19 13:29:23 -0700 | [diff] [blame] | 70 | #define FIRST_USER_ADDRESS 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
Paul Mundt | 7a847f8 | 2006-12-26 15:29:19 +0900 | [diff] [blame] | 72 | #define PTE_PHYS_MASK (0x20000000 - PAGE_SIZE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Paul Mundt | 0468b4b | 2007-11-10 20:39:06 +0900 | [diff] [blame] | 74 | #ifdef CONFIG_SUPERH32 |
Paul Mundt | f0b859e | 2007-07-25 10:43:47 +0900 | [diff] [blame] | 75 | #define VMALLOC_START (P3SEG) |
Paul Mundt | 0468b4b | 2007-11-10 20:39:06 +0900 | [diff] [blame] | 76 | #else |
| 77 | #define VMALLOC_START (0xf0000000) |
| 78 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) |
| 80 | |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 81 | #if defined(CONFIG_SUPERH32) |
| 82 | #include <asm/pgtable_32.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #else |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 84 | #include <asm/pgtable_64.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | #endif |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | /* |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 88 | * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page |
| 89 | * protection for execute, and considers it the same as a read. Also, write |
| 90 | * permission implies read permission. This is the closest we can get.. |
| 91 | * |
| 92 | * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme, |
| 93 | * not only supporting separate execute, read, and write bits, but having |
| 94 | * completely separate permission bits for user and kernel space. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | */ |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 96 | /*xwr*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | #define __P000 PAGE_NONE |
| 98 | #define __P001 PAGE_READONLY |
| 99 | #define __P010 PAGE_COPY |
| 100 | #define __P011 PAGE_COPY |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 101 | #define __P100 PAGE_EXECREAD |
| 102 | #define __P101 PAGE_EXECREAD |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | #define __P110 PAGE_COPY |
| 104 | #define __P111 PAGE_COPY |
| 105 | |
| 106 | #define __S000 PAGE_NONE |
| 107 | #define __S001 PAGE_READONLY |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 108 | #define __S010 PAGE_WRITEONLY |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | #define __S011 PAGE_SHARED |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 110 | #define __S100 PAGE_EXECREAD |
| 111 | #define __S101 PAGE_EXECREAD |
| 112 | #define __S110 PAGE_RWX |
| 113 | #define __S111 PAGE_RWX |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | typedef pte_t *pte_addr_t; |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | #define kern_addr_valid(addr) (1) |
| 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ |
| 120 | remap_pfn_range(vma, vaddr, pfn, size, prot) |
| 121 | |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 122 | #define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT))) |
Tim Schmielau | 8c65b4a | 2005-11-07 00:59:43 -0800 | [diff] [blame] | 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | /* |
| 125 | * No page table caches to initialise |
| 126 | */ |
| 127 | #define pgtable_cache_init() do { } while (0) |
| 128 | |
Paul Mundt | e7bd34a | 2007-07-31 17:07:28 +0900 | [diff] [blame] | 129 | #if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \ |
| 130 | defined(CONFIG_SH7705_CACHE_32KB)) |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 131 | struct mm_struct; |
Paul Mundt | 39e688a | 2007-03-05 19:46:47 +0900 | [diff] [blame] | 132 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 133 | pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); |
Paul Mundt | 39e688a | 2007-03-05 19:46:47 +0900 | [diff] [blame] | 134 | #endif |
| 135 | |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 136 | struct vm_area_struct; |
| 137 | extern void update_mmu_cache(struct vm_area_struct * vma, |
| 138 | unsigned long address, pte_t pte); |
Paul Mundt | 21440cf | 2006-11-20 14:30:26 +0900 | [diff] [blame] | 139 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; |
| 140 | extern void paging_init(void); |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | #include <asm-generic/pgtable.h> |
| 143 | |
Paul Mundt | 249cfea | 2007-11-19 18:26:19 +0900 | [diff] [blame] | 144 | #endif /* __ASM_SH_PGTABLE_H */ |