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 and3 r3, r2, #2 ; _PAGE_PRESENT(=2) check
174 ;; r1: TLB entry address
177 st r0, @r1 ; set_tlb_tag(entry++, address);
178 st r2, @+r1 ; set_tlb_data(entry, pte_data);
193 ;; r1: TLB entry address
197 ;; r1: TLB entry address
200 #ifdef CONFIG_ISA_DUAL_ISSUE
203 ldi r2, #2 ; r2: pte_data = 0 | _PAGE_PRESENT(=2)
207 #elif defined (CONFIG_ISA_M32R)
216 seth r3, #high(MMU_REG_BASE)
217 ld r0, @(MDEVA_offset,r3) ; r0: address (MDEVA reg.)
218 mvfc r2, bpc ; r2: bpc
219 ld r1, @(MESTS_offset,r3) ; r1: status (MESTS reg.)
220 st r1, @(MESTS_offset,r3) ; clear status (MESTS reg.)
221 and3 r1, r1, #(MESTS_IT)
222 beqz r1, 1f ; data TLB miss?
224 ;; instrucntion TLB miss
225 mv r0, r2 ; address = bpc;
226 ; entry = (unsigned long *)ITLB_BASE+tlb_entry_i*2;
227 seth r3, #shigh(tlb_entry_i_dat)
228 ld r4, @(low(tlb_entry_i_dat),r3)
230 seth r1, #high(ITLB_BASE)
231 or3 r1, r1, #low(ITLB_BASE)
232 add r2, r1 ; r2: entry
233 addi r4, #1 ; tlb_entry_i++;
234 and3 r4, r4, #(NR_TLB_ENTRIES-1)
235 st r4, @(low(tlb_entry_i_dat),r3)
240 ; entry = (unsigned long *)DTLB_BASE+tlb_entry_d*2;
241 seth r3, #shigh(tlb_entry_d_dat)
242 ld r4, @(low(tlb_entry_d_dat),r3)
244 seth r1, #high(DTLB_BASE)
245 or3 r1, r1, #low(DTLB_BASE)
246 add r2, r1 ; r2: entry
247 addi r4, #1 ; tlb_entry_d++;
248 and3 r4, r4, #(NR_TLB_ENTRIES-1)
249 st r4, @(low(tlb_entry_d_dat),r3)
253 ; r0: address, r2: entry
255 ; pgd = *(unsigned long *)MPTB;
262 ; pmd = pmd_offset(pgd, address);
264 beqz r1, 3f ; pmd_none(*pmd) ?
267 ldi r4, #611 ; _KERNPG_TABLE(=611)
268 bne r1, r4, 3f ; !pmd_bad(*pmd) ?
272 ; pte = pte_offset(pmd, address);
281 ; pte_data = (unsigned long)pte_val(*pte);
282 ld r1, @r4 ; r1: pte_data
283 and3 r3, r1, #2 ; _PAGE_PRESENT(=2) check
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 st r1, @(4,r2) ; set_tlb_data(entry, pte_data);
310 ldi r1, #2 ; r1: pte_data = 0 | _PAGE_PRESENT(=2)
314 #error unknown isa configuration
319 seth r0, #high(MMU_REG_BASE) ; Set MMU_REG_BASE higher
320 or3 r0, r0, #low(MMU_REG_BASE) ; Set MMU_REG_BASE lower
322 st r1, @(MPSZ_offset,r0) ; Set MPSZ Reg(Page size 4KB:0 16KB:1 64KB:2)
324 st r1, @(MASID_offset,r0) ; Set ASID Zero
327 seth r0, #high(ITLB_BASE) ; Set ITLB_BASE higher
328 or3 r0, r0, #low(ITLB_BASE) ; Set ITLB_BASE lower
329 seth r1, #high(DTLB_BASE) ; Set DTLB_BASE higher
330 or3 r1, r1, #low(DTLB_BASE) ; Set DTLB_BASE lower
332 ldi r3, #NR_TLB_ENTRIES
336 st r2, @+r0 ; VPA <- 0
337 st r2, @+r0 ; PPA <- 0
338 st r2, @+r1 ; VPA <- 0
339 st r2, @+r1 ; PPA <- 0
345 ENTRY(m32r_itlb_entrys)
346 ENTRY(m32r_otlb_entrys)
348 #endif /* CONFIG_MMU */