diff options
Diffstat (limited to 'include/asm-sh/pgtable.h')
-rw-r--r-- | include/asm-sh/pgtable.h | 154 |
1 files changed, 96 insertions, 58 deletions
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h index 40d41a78041e..2c8682ad1012 100644 --- a/include/asm-sh/pgtable.h +++ b/include/asm-sh/pgtable.h | |||
@@ -1,42 +1,42 @@ | |||
1 | #ifndef __ASM_SH_PGTABLE_H | ||
2 | #define __ASM_SH_PGTABLE_H | ||
3 | |||
4 | #include <asm-generic/4level-fixup.h> | ||
5 | |||
6 | /* | 1 | /* |
2 | * This file contains the functions and defines necessary to modify and | ||
3 | * use the SuperH page table tree. | ||
4 | * | ||
7 | * Copyright (C) 1999 Niibe Yutaka | 5 | * Copyright (C) 1999 Niibe Yutaka |
8 | * Copyright (C) 2002, 2003, 2004 Paul Mundt | 6 | * Copyright (C) 2002 - 2005 Paul Mundt |
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. | ||
9 | */ | 11 | */ |
12 | #ifndef __ASM_SH_PGTABLE_H | ||
13 | #define __ASM_SH_PGTABLE_H | ||
10 | 14 | ||
11 | #include <asm/pgtable-2level.h> | 15 | #include <asm-generic/pgtable-nopmd.h> |
16 | #include <asm/page.h> | ||
17 | |||
18 | #define PTRS_PER_PGD 1024 | ||
12 | 19 | ||
13 | /* | ||
14 | * This file contains the functions and defines necessary to modify and use | ||
15 | * the SuperH page table tree. | ||
16 | */ | ||
17 | #ifndef __ASSEMBLY__ | 20 | #ifndef __ASSEMBLY__ |
18 | #include <asm/processor.h> | ||
19 | #include <asm/addrspace.h> | 21 | #include <asm/addrspace.h> |
20 | #include <asm/fixmap.h> | 22 | #include <asm/fixmap.h> |
21 | #include <linux/threads.h> | ||
22 | 23 | ||
23 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; | 24 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; |
24 | extern void paging_init(void); | 25 | extern void paging_init(void); |
25 | 26 | ||
26 | /* | 27 | /* |
27 | * Basically we have the same two-level (which is the logical three level | ||
28 | * Linux page table layout folded) page tables as the i386. | ||
29 | */ | ||
30 | |||
31 | /* | ||
32 | * ZERO_PAGE is a global shared page that is always zero: used | 28 | * ZERO_PAGE is a global shared page that is always zero: used |
33 | * for zero-mapped memory areas etc.. | 29 | * for zero-mapped memory areas etc.. |
34 | */ | 30 | */ |
35 | extern unsigned long empty_zero_page[1024]; | 31 | extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; |
36 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) | 32 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) |
37 | 33 | ||
38 | #endif /* !__ASSEMBLY__ */ | 34 | #endif /* !__ASSEMBLY__ */ |
39 | 35 | ||
36 | /* traditional two-level paging structure */ | ||
37 | #define PGDIR_SHIFT 22 | ||
38 | #define PTRS_PER_PMD 1 | ||
39 | #define PTRS_PER_PTE 1024 | ||
40 | #define PMD_SIZE (1UL << PMD_SHIFT) | 40 | #define PMD_SIZE (1UL << PMD_SHIFT) |
41 | #define PMD_MASK (~(PMD_SIZE-1)) | 41 | #define PMD_MASK (~(PMD_SIZE-1)) |
42 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) | 42 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) |
@@ -47,7 +47,6 @@ extern unsigned long empty_zero_page[1024]; | |||
47 | 47 | ||
48 | #define PTE_PHYS_MASK 0x1ffff000 | 48 | #define PTE_PHYS_MASK 0x1ffff000 |
49 | 49 | ||
50 | #ifndef __ASSEMBLY__ | ||
51 | /* | 50 | /* |
52 | * First 1MB map is used by fixed purpose. | 51 | * First 1MB map is used by fixed purpose. |
53 | * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c) | 52 | * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c) |
@@ -55,20 +54,41 @@ extern unsigned long empty_zero_page[1024]; | |||
55 | #define VMALLOC_START (P3SEG+0x00100000) | 54 | #define VMALLOC_START (P3SEG+0x00100000) |
56 | #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) | 55 | #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) |
57 | 56 | ||
58 | #define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */ | 57 | /* |
59 | #define _PAGE_HW_SHARED 0x002 /* SH-bit : page is shared among processes */ | 58 | * Linux PTEL encoding. |
60 | #define _PAGE_DIRTY 0x004 /* D-bit : page changed */ | 59 | * |
61 | #define _PAGE_CACHABLE 0x008 /* C-bit : cachable */ | 60 | * Hardware and software bit definitions for the PTEL value: |
62 | #define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */ | 61 | * |
63 | #define _PAGE_RW 0x020 /* PR0-bit : write access allowed */ | 62 | * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4). |
64 | #define _PAGE_USER 0x040 /* PR1-bit : user space access allowed */ | 63 | * |
65 | #define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ | 64 | * - Bit 1 is the SH-bit, but is unused on SH-3 due to an MMU bug (the |
66 | #define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ | 65 | * hardware PTEL value can't have the SH-bit set when MMUCR.IX is set, |
67 | #define _PAGE_PROTNONE 0x200 /* software: if not present */ | 66 | * which is the default in cpu-sh3/mmu_context.h:MMU_CONTROL_INIT). |
68 | #define _PAGE_ACCESSED 0x400 /* software: page referenced */ | 67 | * |
69 | #define _PAGE_U0_SHARED 0x800 /* software: page is shared in user space */ | 68 | * In order to keep this relatively clean, do not use these for defining |
70 | 69 | * SH-3 specific flags until all of the other unused bits have been | |
71 | #define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ | 70 | * exhausted. |
71 | * | ||
72 | * - Bit 9 is reserved by everyone and used by _PAGE_PROTNONE. | ||
73 | * | ||
74 | * - Bits 10 and 11 are low bits of the PPN that are reserved on >= 4K pages. | ||
75 | * Bit 10 is used for _PAGE_ACCESSED, bit 11 remains unused. | ||
76 | * | ||
77 | * - Bits 31, 30, and 29 remain unused by everyone and can be used for future | ||
78 | * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS. | ||
79 | */ | ||
80 | #define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */ | ||
81 | #define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */ | ||
82 | #define _PAGE_DIRTY 0x004 /* D-bit : page changed */ | ||
83 | #define _PAGE_CACHABLE 0x008 /* C-bit : cachable */ | ||
84 | #define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */ | ||
85 | #define _PAGE_RW 0x020 /* PR0-bit : write access allowed */ | ||
86 | #define _PAGE_USER 0x040 /* PR1-bit : user space access allowed */ | ||
87 | #define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ | ||
88 | #define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ | ||
89 | #define _PAGE_PROTNONE 0x200 /* software: if not present */ | ||
90 | #define _PAGE_ACCESSED 0x400 /* software: page referenced */ | ||
91 | #define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ | ||
72 | 92 | ||
73 | /* software: moves to PTEA.TC (Timing Control) */ | 93 | /* software: moves to PTEA.TC (Timing Control) */ |
74 | #define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */ | 94 | #define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */ |
@@ -83,23 +103,17 @@ extern unsigned long empty_zero_page[1024]; | |||
83 | #define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */ | 103 | #define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */ |
84 | #define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */ | 104 | #define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */ |
85 | 105 | ||
86 | 106 | /* Mask which drops unused bits from the PTEL value */ | |
87 | /* Mask which drop software flags | 107 | #ifdef CONFIG_CPU_SH3 |
88 | * We also drop WT bit since it is used for _PAGE_FILE | 108 | #define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED| \ |
89 | * bit in this implementation. | 109 | _PAGE_FILE | _PAGE_SZ1 | \ |
90 | */ | 110 | _PAGE_HW_SHARED) |
91 | #define _PAGE_CLEAR_FLAGS (_PAGE_WT | _PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_U0_SHARED) | ||
92 | |||
93 | #if defined(CONFIG_CPU_SH3) | ||
94 | /* | ||
95 | * MMU on SH-3 has bug on SH-bit: We can't use it if MMUCR.IX=1. | ||
96 | * Work around: Just drop SH-bit. | ||
97 | */ | ||
98 | #define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS | _PAGE_HW_SHARED)) | ||
99 | #else | 111 | #else |
100 | #define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) | 112 | #define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE) |
101 | #endif | 113 | #endif |
102 | 114 | ||
115 | #define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) | ||
116 | |||
103 | /* Hardware flags: SZ0=1 (4k-byte) */ | 117 | /* Hardware flags: SZ0=1 (4k-byte) */ |
104 | #define _PAGE_FLAGS_HARD _PAGE_SZ0 | 118 | #define _PAGE_FLAGS_HARD _PAGE_SZ0 |
105 | 119 | ||
@@ -109,15 +123,15 @@ extern unsigned long empty_zero_page[1024]; | |||
109 | #define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1) | 123 | #define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1) |
110 | #endif | 124 | #endif |
111 | 125 | ||
112 | #define _PAGE_SHARED _PAGE_U0_SHARED | ||
113 | |||
114 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) | 126 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) |
115 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) | 127 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) |
116 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_SHARED) | 128 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY) |
129 | |||
130 | #ifndef __ASSEMBLY__ | ||
117 | 131 | ||
118 | #ifdef CONFIG_MMU | 132 | #ifdef CONFIG_MMU |
119 | #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) | 133 | #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) |
120 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_SHARED | _PAGE_FLAGS_HARD) | 134 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) |
121 | #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) | 135 | #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) |
122 | #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) | 136 | #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) |
123 | #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) | 137 | #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) |
@@ -137,12 +151,13 @@ extern unsigned long empty_zero_page[1024]; | |||
137 | #define PAGE_KERNEL_PCC __pgprot(0) | 151 | #define PAGE_KERNEL_PCC __pgprot(0) |
138 | #endif | 152 | #endif |
139 | 153 | ||
154 | #endif /* __ASSEMBLY__ */ | ||
155 | |||
140 | /* | 156 | /* |
141 | * As i386 and MIPS, SuperH can't do page protection for execute, and | 157 | * As i386 and MIPS, SuperH can't do page protection for execute, and |
142 | * considers that the same as a read. Also, write permissions imply | 158 | * considers that the same as a read. Also, write permissions imply |
143 | * read permissions. This is the closest we can get.. | 159 | * read permissions. This is the closest we can get.. |
144 | */ | 160 | */ |
145 | |||
146 | #define __P000 PAGE_NONE | 161 | #define __P000 PAGE_NONE |
147 | #define __P001 PAGE_READONLY | 162 | #define __P001 PAGE_READONLY |
148 | #define __P010 PAGE_COPY | 163 | #define __P010 PAGE_COPY |
@@ -161,6 +176,26 @@ extern unsigned long empty_zero_page[1024]; | |||
161 | #define __S110 PAGE_SHARED | 176 | #define __S110 PAGE_SHARED |
162 | #define __S111 PAGE_SHARED | 177 | #define __S111 PAGE_SHARED |
163 | 178 | ||
179 | #ifndef __ASSEMBLY__ | ||
180 | |||
181 | /* | ||
182 | * Certain architectures need to do special things when PTEs | ||
183 | * within a page table are directly modified. Thus, the following | ||
184 | * hook is made available. | ||
185 | */ | ||
186 | #define set_pte(pteptr, pteval) (*(pteptr) = pteval) | ||
187 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | ||
188 | |||
189 | /* | ||
190 | * (pmds are folded into pgds so this doesn't get actually called, | ||
191 | * but the define is needed for a generic inline function.) | ||
192 | */ | ||
193 | #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval) | ||
194 | |||
195 | #define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT))) | ||
196 | #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) | ||
197 | #define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) | ||
198 | |||
164 | #define pte_none(x) (!pte_val(x)) | 199 | #define pte_none(x) (!pte_val(x)) |
165 | #define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) | 200 | #define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) |
166 | #define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) | 201 | #define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) |
@@ -171,7 +206,7 @@ extern unsigned long empty_zero_page[1024]; | |||
171 | #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) | 206 | #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) |
172 | 207 | ||
173 | #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) | 208 | #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) |
174 | #define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) | 209 | #define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) |
175 | 210 | ||
176 | /* | 211 | /* |
177 | * The following only work if pte_present() is true. | 212 | * The following only work if pte_present() is true. |
@@ -248,6 +283,11 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) | |||
248 | #define pte_unmap(pte) do { } while (0) | 283 | #define pte_unmap(pte) do { } while (0) |
249 | #define pte_unmap_nested(pte) do { } while (0) | 284 | #define pte_unmap_nested(pte) do { } while (0) |
250 | 285 | ||
286 | #define pte_ERROR(e) \ | ||
287 | printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) | ||
288 | #define pgd_ERROR(e) \ | ||
289 | printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) | ||
290 | |||
251 | struct vm_area_struct; | 291 | struct vm_area_struct; |
252 | extern void update_mmu_cache(struct vm_area_struct * vma, | 292 | extern void update_mmu_cache(struct vm_area_struct * vma, |
253 | unsigned long address, pte_t pte); | 293 | unsigned long address, pte_t pte); |
@@ -272,8 +312,6 @@ extern void update_mmu_cache(struct vm_area_struct * vma, | |||
272 | 312 | ||
273 | typedef pte_t *pte_addr_t; | 313 | typedef pte_t *pte_addr_t; |
274 | 314 | ||
275 | #endif /* !__ASSEMBLY__ */ | ||
276 | |||
277 | #define kern_addr_valid(addr) (1) | 315 | #define kern_addr_valid(addr) (1) |
278 | 316 | ||
279 | #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ | 317 | #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ |
@@ -301,5 +339,5 @@ extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t | |||
301 | 339 | ||
302 | #include <asm-generic/pgtable.h> | 340 | #include <asm-generic/pgtable.h> |
303 | 341 | ||
342 | #endif /* !__ASSEMBLY__ */ | ||
304 | #endif /* __ASM_SH_PAGE_H */ | 343 | #endif /* __ASM_SH_PAGE_H */ |
305 | |||