2 * linux/arch/m32r/mm/mmu.S
4 * Copyright (C) 2001 by Hiroyuki Kondo
7 #include <linux/linkage.h>
8 #include <asm/assembler.h>
14 #include <asm/mmu_context.h>
16 #include <asm/pgtable.h>
20 * TLB Miss Exception handler
24 .global tlb_entry_i_dat
25 .global tlb_entry_d_dat
27 SWITCH_TO_KERNEL_STACK
29 #if defined(CONFIG_ISA_M32R2)
35 seth r3, #high(MMU_REG_BASE)
36 ld r1, @(MESTS_offset, r3) ; r1: status (MESTS reg.)
37 ld r0, @(MDEVP_offset, r3) ; r0: PFN + ASID (MDEVP reg.)
38 st r1, @(MESTS_offset, r3) ; clear status (MESTS reg.)
39 and3 r1, r1, #(MESTS_IT)
40 bnez r1, 1f ; instruction TLB miss?
44 ;; r0: PFN + ASID (MDEVP reg.)
48 ;; r1: TLB entry base address
49 ;; r2: &tlb_entry_{i|d}_dat
53 seth r2, #high(tlb_entry_d_dat)
54 or3 r2, r2, #low(tlb_entry_d_dat)
55 #else /* CONFIG_SMP */
57 seth r2, #high(tlb_entry_d_dat)
58 or3 r2, r2, #low(tlb_entry_d_dat)
60 ld r1, @(16, r1) ; current_thread_info->cpu
63 #endif /* !CONFIG_SMP */
64 seth r1, #high(DTLB_BASE)
65 or3 r1, r1, #low(DTLB_BASE)
71 ;; instrucntion TLB miss
73 ;; r0: MDEVP reg. (included ASID)
77 ;; r1: TLB entry base address
78 ;; r2: &tlb_entry_{i|d}_dat
81 and3 r0, r0, #(MMU_CONTEXT_ASID_MASK)
84 or r0, r1 ; r0: PFN + ASID
86 seth r2, #high(tlb_entry_i_dat)
87 or3 r2, r2, #low(tlb_entry_i_dat)
88 #else /* CONFIG_SMP */
90 seth r2, #high(tlb_entry_i_dat)
91 or3 r2, r2, #low(tlb_entry_i_dat)
93 ld r1, @(16, r1) ; current_thread_info->cpu
96 #endif /* !CONFIG_SMP */
97 seth r1, #high(ITLB_BASE)
98 or3 r1, r1, #low(ITLB_BASE)
105 ;; r1: TLB entry base address
106 ;; r2: &tlb_entry_{i|d}_dat
110 ;; r1: TLB entry address
112 #ifdef CONFIG_ISA_DUAL_ISSUE
113 ld r3, @r2 || srli r1, #3
119 ; tlb_entry_{d|i}_dat++;
121 and3 r3, r3, #(NR_TLB_ENTRIES - 1)
122 #ifdef CONFIG_ISA_DUAL_ISSUE
123 st r3, @r2 || slli r1, #3
132 ;; r1: TLB entry address
136 ;; r1: TLB entry address
139 ; pgd = *(unsigned long *)MPTB;
140 ld24 r2, #(-MPTB - 1)
142 #ifdef CONFIG_ISA_DUAL_ISSUE
143 not r2, r2 || slli r3, #2 ; r3: pgd offset
148 ld r2, @r2 ; r2: pgd base addr (MPTB reg.)
149 or r3, r2 ; r3: pmd addr
151 ; pmd = pmd_offset(pgd, address);
152 ld r3, @r3 ; r3: pmd data
154 beqz r3, 3f ; pmd_none(*pmd) ?
156 ; pte = pte_offset(pmd, address);
157 and r2, r3 ; r2: pte base addr
159 and3 r3, r3, #0xffc ; r3: pte offset
162 or r3, r2 ; r3: pte addr
164 ; pte_data = (unsigned long)pte_val(*pte);
165 ld r2, @r3 ; r2: pte data
166 or3 r2, r2, #2 ; _PAGE_PRESENT(=2)
173 ;; r1: TLB entry address
176 st r0, @r1 ; set_tlb_tag(entry++, address);
177 st r2, @+r1 ; set_tlb_data(entry, pte_data);
192 ;; r1: TLB entry address
196 ;; r1: TLB entry address
199 #ifdef CONFIG_ISA_DUAL_ISSUE
202 ldi r2, #2 ; r2: pte_data = 0 | _PAGE_PRESENT(=2)
206 #elif defined (CONFIG_ISA_M32R)
215 seth r3, #high(MMU_REG_BASE)
216 ld r0, @(MDEVA_offset,r3) ; r0: address (MDEVA reg.)
217 mvfc r2, bpc ; r2: bpc
218 ld r1, @(MESTS_offset,r3) ; r1: status (MESTS reg.)
219 st r1, @(MESTS_offset,r3) ; clear status (MESTS reg.)
220 and3 r1, r1, #(MESTS_IT)
221 beqz r1, 1f ; data TLB miss?
223 ;; instrucntion TLB miss
224 mv r0, r2 ; address = bpc;
225 ; entry = (unsigned long *)ITLB_BASE+tlb_entry_i*2;
226 seth r3, #shigh(tlb_entry_i_dat)
227 ld r4, @(low(tlb_entry_i_dat),r3)
229 seth r1, #high(ITLB_BASE)
230 or3 r1, r1, #low(ITLB_BASE)
231 add r2, r1 ; r2: entry
232 addi r4, #1 ; tlb_entry_i++;
233 and3 r4, r4, #(NR_TLB_ENTRIES-1)
234 st r4, @(low(tlb_entry_i_dat),r3)
239 ; entry = (unsigned long *)DTLB_BASE+tlb_entry_d*2;
240 seth r3, #shigh(tlb_entry_d_dat)
241 ld r4, @(low(tlb_entry_d_dat),r3)
243 seth r1, #high(DTLB_BASE)
244 or3 r1, r1, #low(DTLB_BASE)
245 add r2, r1 ; r2: entry
246 addi r4, #1 ; tlb_entry_d++;
247 and3 r4, r4, #(NR_TLB_ENTRIES-1)
248 st r4, @(low(tlb_entry_d_dat),r3)
252 ; r0: address, r2: entry
254 ; pgd = *(unsigned long *)MPTB;
261 ; pmd = pmd_offset(pgd, address);
263 beqz r1, 3f ; pmd_none(*pmd) ?
266 ldi r4, #611 ; _KERNPG_TABLE(=611)
267 beq r1, r4, 4f ; !pmd_bad(*pmd) ?
270 ldi r1, #0 ; r1: pte_data = 0
274 ; pte = pte_offset(pmd, address);
283 ; pte_data = (unsigned long)pte_val(*pte);
284 ld r1, @r4 ; r1: pte_data
288 ; r0: address, r1: pte_data, r2: entry
291 ldi r3, #-4096 ; set_tlb_tag(entry++, address);
293 seth r4, #shigh(MASID)
294 ld r4, @(low(MASID),r4) ; r4: MASID
295 and3 r4, r4, #(MMU_CONTEXT_ASID_MASK)
298 or3 r4, r1, #2 ; _PAGE_PRESENT(=2)
299 st r4, @(4,r2) ; set_tlb_data(entry, pte_data);
310 #error unknown isa configuration
315 seth r0, #high(MMU_REG_BASE) ; Set MMU_REG_BASE higher
316 or3 r0, r0, #low(MMU_REG_BASE) ; Set MMU_REG_BASE lower
318 st r1, @(MPSZ_offset,r0) ; Set MPSZ Reg(Page size 4KB:0 16KB:1 64KB:2)
320 st r1, @(MASID_offset,r0) ; Set ASID Zero
323 seth r0, #high(ITLB_BASE) ; Set ITLB_BASE higher
324 or3 r0, r0, #low(ITLB_BASE) ; Set ITLB_BASE lower
325 seth r1, #high(DTLB_BASE) ; Set DTLB_BASE higher
326 or3 r1, r1, #low(DTLB_BASE) ; Set DTLB_BASE lower
328 ldi r3, #NR_TLB_ENTRIES
332 st r2, @+r0 ; VPA <- 0
333 st r2, @+r0 ; PPA <- 0
334 st r2, @+r1 ; VPA <- 0
335 st r2, @+r1 ; PPA <- 0
341 ENTRY(m32r_itlb_entrys)
342 ENTRY(m32r_otlb_entrys)
344 #endif /* CONFIG_MMU */