2 * linux/arch/m32r/mm/mmu.S
4 * Copyright (C) 2001 by Hiroyuki Kondo
7 /* $Id: mmu.S,v 1.15 2004/03/16 02:56:27 takata Exp $ */
9 #include <linux/linkage.h>
10 #include <asm/assembler.h>
16 #include <asm/mmu_context.h>
18 #include <asm/pgtable.h>
22 * TLB Miss Exception handler
26 .global tlb_entry_i_dat
27 .global tlb_entry_d_dat
29 SWITCH_TO_KERNEL_STACK
31 #if defined(CONFIG_ISA_M32R2)
37 seth r3, #high(MMU_REG_BASE)
38 ld r1, @(MESTS_offset, r3) ; r1: status (MESTS reg.)
39 ld r0, @(MDEVP_offset, r3) ; r0: PFN + ASID (MDEVP reg.)
40 st r1, @(MESTS_offset, r3) ; clear status (MESTS reg.)
41 and3 r1, r1, #(MESTS_IT)
42 bnez r1, 1f ; instruction TLB miss?
46 ;; r0: PFN + ASID (MDEVP reg.)
50 ;; r1: TLB entry base address
51 ;; r2: &tlb_entry_{i|d}_dat
55 seth r2, #high(tlb_entry_d_dat)
56 or3 r2, r2, #low(tlb_entry_d_dat)
57 #else /* CONFIG_SMP */
59 seth r2, #high(tlb_entry_d_dat)
60 or3 r2, r2, #low(tlb_entry_d_dat)
62 ld r1, @(16, r1) ; current_thread_info->cpu
65 #endif /* !CONFIG_SMP */
66 seth r1, #high(DTLB_BASE)
67 or3 r1, r1, #low(DTLB_BASE)
73 ;; instrucntion TLB miss
75 ;; r0: MDEVP reg. (included ASID)
79 ;; r1: TLB entry base address
80 ;; r2: &tlb_entry_{i|d}_dat
83 and3 r0, r0, #(MMU_CONTEXT_ASID_MASK)
86 or r0, r1 ; r0: PFN + ASID
88 seth r2, #high(tlb_entry_i_dat)
89 or3 r2, r2, #low(tlb_entry_i_dat)
90 #else /* CONFIG_SMP */
92 seth r2, #high(tlb_entry_i_dat)
93 or3 r2, r2, #low(tlb_entry_i_dat)
95 ld r1, @(16, r1) ; current_thread_info->cpu
98 #endif /* !CONFIG_SMP */
99 seth r1, #high(ITLB_BASE)
100 or3 r1, r1, #low(ITLB_BASE)
107 ;; r1: TLB entry base address
108 ;; r2: &tlb_entry_{i|d}_dat
112 ;; r1: TLB entry address
114 #ifdef CONFIG_ISA_DUAL_ISSUE
115 ld r3, @r2 || srli r1, #3
121 ; tlb_entry_{d|i}_dat++;
123 and3 r3, r3, #(NR_TLB_ENTRIES - 1)
124 #ifdef CONFIG_ISA_DUAL_ISSUE
125 st r3, @r2 || slli r1, #3
134 ;; r1: TLB entry address
138 ;; r1: TLB entry address
141 ; pgd = *(unsigned long *)MPTB;
142 ld24 r2, #(-MPTB - 1)
144 #ifdef CONFIG_ISA_DUAL_ISSUE
145 not r2, r2 || slli r3, #2 ; r3: pgd offset
150 ld r2, @r2 ; r2: pgd base addr (MPTB reg.)
151 or r3, r2 ; r3: pmd addr
153 ; pmd = pmd_offset(pgd, address);
154 ld r3, @r3 ; r3: pmd data
156 beqz r3, 3f ; pmd_none(*pmd) ?
158 ; pte = pte_offset(pmd, address);
159 and r2, r3 ; r2: pte base addr
161 and3 r3, r3, #0xffc ; r3: pte offset
164 or r3, r2 ; r3: pte addr
166 ; pte_data = (unsigned long)pte_val(*pte);
167 ld r2, @r3 ; r2: pte data
168 or3 r2, r2, #2 ; _PAGE_PRESENT(=2)
175 ;; r1: TLB entry address
178 st r0, @r1 ; set_tlb_tag(entry++, address);
179 st r2, @+r1 ; set_tlb_data(entry, pte_data);
194 ;; r1: TLB entry address
198 ;; r1: TLB entry address
201 #ifdef CONFIG_ISA_DUAL_ISSUE
204 ldi r2, #2 ; r2: pte_data = 0 | _PAGE_PRESENT(=2)
208 #elif defined (CONFIG_ISA_M32R)
217 seth r3, #high(MMU_REG_BASE)
218 ld r0, @(MDEVA_offset,r3) ; r0: address (MDEVA reg.)
219 mvfc r2, bpc ; r2: bpc
220 ld r1, @(MESTS_offset,r3) ; r1: status (MESTS reg.)
221 st r1, @(MESTS_offset,r3) ; clear status (MESTS reg.)
222 and3 r1, r1, #(MESTS_IT)
223 beqz r1, 1f ; data TLB miss?
225 ;; instrucntion TLB miss
226 mv r0, r2 ; address = bpc;
227 ; entry = (unsigned long *)ITLB_BASE+tlb_entry_i*2;
228 seth r3, #shigh(tlb_entry_i_dat)
229 ld r4, @(low(tlb_entry_i_dat),r3)
231 seth r1, #high(ITLB_BASE)
232 or3 r1, r1, #low(ITLB_BASE)
233 add r2, r1 ; r2: entry
234 addi r4, #1 ; tlb_entry_i++;
235 and3 r4, r4, #(NR_TLB_ENTRIES-1)
236 st r4, @(low(tlb_entry_i_dat),r3)
241 ; entry = (unsigned long *)DTLB_BASE+tlb_entry_d*2;
242 seth r3, #shigh(tlb_entry_d_dat)
243 ld r4, @(low(tlb_entry_d_dat),r3)
245 seth r1, #high(DTLB_BASE)
246 or3 r1, r1, #low(DTLB_BASE)
247 add r2, r1 ; r2: entry
248 addi r4, #1 ; tlb_entry_d++;
249 and3 r4, r4, #(NR_TLB_ENTRIES-1)
250 st r4, @(low(tlb_entry_d_dat),r3)
254 ; r0: address, r2: entry
256 ; pgd = *(unsigned long *)MPTB;
263 ; pmd = pmd_offset(pgd, address);
265 beqz r1, 3f ; pmd_none(*pmd) ?
268 ldi r4, #611 ; _KERNPG_TABLE(=611)
269 beq r1, r4, 4f ; !pmd_bad(*pmd) ?
272 ldi r1, #0 ; r1: pte_data = 0
276 ; pte = pte_offset(pmd, address);
285 ; pte_data = (unsigned long)pte_val(*pte);
286 ld r1, @r4 ; r1: pte_data
290 ; r0: address, r1: pte_data, r2: entry
293 ldi r3, #-4096 ; set_tlb_tag(entry++, address);
295 seth r4, #shigh(MASID)
296 ld r4, @(low(MASID),r4) ; r4: MASID
297 and3 r4, r4, #(MMU_CONTEXT_ASID_MASK)
300 or3 r4, r1, #2 ; _PAGE_PRESENT(=2)
301 st r4, @(4,r2) ; set_tlb_data(entry, pte_data);
312 #error unknown isa configuration
317 seth r0, #high(MMU_REG_BASE) ; Set MMU_REG_BASE higher
318 or3 r0, r0, #low(MMU_REG_BASE) ; Set MMU_REG_BASE lower
320 st r1, @(MPSZ_offset,r0) ; Set MPSZ Reg(Page size 4KB:0 16KB:1 64KB:2)
322 st r1, @(MASID_offset,r0) ; Set ASID Zero
325 seth r0, #high(ITLB_BASE) ; Set ITLB_BASE higher
326 or3 r0, r0, #low(ITLB_BASE) ; Set ITLB_BASE lower
327 seth r1, #high(DTLB_BASE) ; Set DTLB_BASE higher
328 or3 r1, r1, #low(DTLB_BASE) ; Set DTLB_BASE lower
330 ldi r3, #NR_TLB_ENTRIES
334 st r2, @+r0 ; VPA <- 0
335 st r2, @+r0 ; PPA <- 0
336 st r2, @+r1 ; VPA <- 0
337 st r2, @+r1 ; PPA <- 0
343 ENTRY(m32r_itlb_entrys)
344 ENTRY(m32r_otlb_entrys)
346 #endif /* CONFIG_MMU */