diff options
Diffstat (limited to 'arch/sh/mm/init.c')
-rw-r--r-- | arch/sh/mm/init.c | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 7154d1ce9785..59f4cc18235b 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c | |||
@@ -84,30 +84,22 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) | |||
84 | pmd_t *pmd; | 84 | pmd_t *pmd; |
85 | pte_t *pte; | 85 | pte_t *pte; |
86 | 86 | ||
87 | pgd = swapper_pg_dir + pgd_index(addr); | 87 | pgd = pgd_offset_k(addr); |
88 | if (pgd_none(*pgd)) { | 88 | if (pgd_none(*pgd)) { |
89 | pgd_ERROR(*pgd); | 89 | pgd_ERROR(*pgd); |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | 92 | ||
93 | pud = pud_offset(pgd, addr); | 93 | pud = pud_alloc(NULL, pgd, addr); |
94 | if (pud_none(*pud)) { | 94 | if (unlikely(!pud)) { |
95 | pmd = (pmd_t *)get_zeroed_page(GFP_ATOMIC); | 95 | pud_ERROR(*pud); |
96 | set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER)); | 96 | return; |
97 | if (pmd != pmd_offset(pud, 0)) { | ||
98 | pud_ERROR(*pud); | ||
99 | return; | ||
100 | } | ||
101 | } | 97 | } |
102 | 98 | ||
103 | pmd = pmd_offset(pud, addr); | 99 | pmd = pmd_alloc(NULL, pud, addr); |
104 | if (pmd_none(*pmd)) { | 100 | if (unlikely(!pmd)) { |
105 | pte = (pte_t *)get_zeroed_page(GFP_ATOMIC); | 101 | pmd_ERROR(*pmd); |
106 | set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER)); | 102 | return; |
107 | if (pte != pte_offset_kernel(pmd, 0)) { | ||
108 | pmd_ERROR(*pmd); | ||
109 | return; | ||
110 | } | ||
111 | } | 103 | } |
112 | 104 | ||
113 | pte = pte_offset_kernel(pmd, addr); | 105 | pte = pte_offset_kernel(pmd, addr); |
@@ -155,9 +147,6 @@ extern char __init_begin, __init_end; | |||
155 | 147 | ||
156 | /* | 148 | /* |
157 | * paging_init() sets up the page tables | 149 | * paging_init() sets up the page tables |
158 | * | ||
159 | * This routines also unmaps the page at virtual kernel address 0, so | ||
160 | * that we can trap those pesky NULL-reference errors in the kernel. | ||
161 | */ | 150 | */ |
162 | void __init paging_init(void) | 151 | void __init paging_init(void) |
163 | { | 152 | { |
@@ -180,14 +169,11 @@ void __init paging_init(void) | |||
180 | */ | 169 | */ |
181 | { | 170 | { |
182 | unsigned long max_dma, low, start_pfn; | 171 | unsigned long max_dma, low, start_pfn; |
183 | pgd_t *pg_dir; | ||
184 | int i; | ||
185 | |||
186 | /* We don't need kernel mapping as hardware support that. */ | ||
187 | pg_dir = swapper_pg_dir; | ||
188 | 172 | ||
189 | for (i = 0; i < PTRS_PER_PGD; i++) | 173 | /* We don't need to map the kernel through the TLB, as |
190 | pgd_val(pg_dir[i]) = 0; | 174 | * it is permanatly mapped using P1. So clear the |
175 | * entire pgd. */ | ||
176 | memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir)); | ||
191 | 177 | ||
192 | /* Turn on the MMU */ | 178 | /* Turn on the MMU */ |
193 | enable_mmu(); | 179 | enable_mmu(); |
@@ -206,6 +192,10 @@ void __init paging_init(void) | |||
206 | } | 192 | } |
207 | } | 193 | } |
208 | 194 | ||
195 | /* Set an initial value for the MMU.TTB so we don't have to | ||
196 | * check for a null value. */ | ||
197 | set_TTB(swapper_pg_dir); | ||
198 | |||
209 | #elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4) | 199 | #elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4) |
210 | /* | 200 | /* |
211 | * If we don't have CONFIG_MMU set and the processor in question | 201 | * If we don't have CONFIG_MMU set and the processor in question |
@@ -227,7 +217,6 @@ static struct kcore_list kcore_mem, kcore_vmalloc; | |||
227 | 217 | ||
228 | void __init mem_init(void) | 218 | void __init mem_init(void) |
229 | { | 219 | { |
230 | extern unsigned long empty_zero_page[1024]; | ||
231 | int codesize, reservedpages, datasize, initsize; | 220 | int codesize, reservedpages, datasize, initsize; |
232 | int tmp; | 221 | int tmp; |
233 | extern unsigned long memory_start; | 222 | extern unsigned long memory_start; |