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
153 beqz r3, 3f ; pmd_none(*pmd) ?
156 add3 r2, r2, #-355 ; _KERNPG_TABLE(=0x163)
157 bnez r2, 3f ; pmd_bad(*pmd) ?
160 ; pte = pte_offset(pmd, address);
161 and r2, r3 ; r2: pte base addr
163 and3 r3, r3, #0xffc ; r3: pte offset
166 or r3, r2 ; r3: pte addr
168 ; pte_data = (unsigned long)pte_val(*pte);
169 ld r2, @r3 ; r2: pte data
170 and3 r3, r2, #2 ; _PAGE_PRESENT(=2) check
178 ;; r1: TLB entry address
181 st r0, @r1 ; set_tlb_tag(entry++, address);
182 st r2, @+r1 ; set_tlb_data(entry, pte_data);
197 ;; r1: TLB entry address
201 ;; r1: TLB entry address
204 #ifdef CONFIG_ISA_DUAL_ISSUE
207 ldi r2, #2 ; r2: pte_data = 0 | _PAGE_PRESENT(=2)
211 #elif defined (CONFIG_ISA_M32R)
220 seth r3, #high(MMU_REG_BASE)
221 ld r0, @(MDEVA_offset,r3) ; r0: address (MDEVA reg.)
222 mvfc r2, bpc ; r2: bpc
223 ld r1, @(MESTS_offset,r3) ; r1: status (MESTS reg.)
224 st r1, @(MESTS_offset,r3) ; clear status (MESTS reg.)
225 and3 r1, r1, #(MESTS_IT)
226 beqz r1, 1f ; data TLB miss?
228 ;; instrucntion TLB miss
229 mv r0, r2 ; address = bpc;
230 ; entry = (unsigned long *)ITLB_BASE+tlb_entry_i*2;
231 seth r3, #shigh(tlb_entry_i_dat)
232 ld r4, @(low(tlb_entry_i_dat),r3)
234 seth r1, #high(ITLB_BASE)
235 or3 r1, r1, #low(ITLB_BASE)
236 add r2, r1 ; r2: entry
237 addi r4, #1 ; tlb_entry_i++;
238 and3 r4, r4, #(NR_TLB_ENTRIES-1)
239 st r4, @(low(tlb_entry_i_dat),r3)
244 ; entry = (unsigned long *)DTLB_BASE+tlb_entry_d*2;
245 seth r3, #shigh(tlb_entry_d_dat)
246 ld r4, @(low(tlb_entry_d_dat),r3)
248 seth r1, #high(DTLB_BASE)
249 or3 r1, r1, #low(DTLB_BASE)
250 add r2, r1 ; r2: entry
251 addi r4, #1 ; tlb_entry_d++;
252 and3 r4, r4, #(NR_TLB_ENTRIES-1)
253 st r4, @(low(tlb_entry_d_dat),r3)
257 ; r0: address, r2: entry
259 ; pgd = *(unsigned long *)MPTB;
266 ; pmd = pmd_offset(pgd, address);
268 beqz r1, 3f ; pmd_none(*pmd) ?
271 ldi r4, #0x163 ; _KERNPG_TABLE(=0x163)
272 bne r1, r4, 3f ; pmd_bad(*pmd) ?
276 ; pte = pte_offset(pmd, address);
285 ; pte_data = (unsigned long)pte_val(*pte);
286 ld r1, @r4 ; r1: pte_data
287 and3 r3, r1, #2 ; _PAGE_PRESENT(=2) check
292 ; r0: address, r1: pte_data, r2: entry
295 ldi r3, #-4096 ; set_tlb_tag(entry++, address);
297 seth r4, #shigh(MASID)
298 ld r4, @(low(MASID),r4) ; r4: MASID
299 and3 r4, r4, #(MMU_CONTEXT_ASID_MASK)
302 st r1, @(4,r2) ; set_tlb_data(entry, pte_data);
314 ldi r1, #2 ; r1: pte_data = 0 | _PAGE_PRESENT(=2)
318 #error unknown isa configuration
323 seth r0, #high(MMU_REG_BASE) ; Set MMU_REG_BASE higher
324 or3 r0, r0, #low(MMU_REG_BASE) ; Set MMU_REG_BASE lower
326 st r1, @(MPSZ_offset,r0) ; Set MPSZ Reg(Page size 4KB:0 16KB:1 64KB:2)
328 st r1, @(MASID_offset,r0) ; Set ASID Zero
331 seth r0, #high(ITLB_BASE) ; Set ITLB_BASE higher
332 or3 r0, r0, #low(ITLB_BASE) ; Set ITLB_BASE lower
333 seth r1, #high(DTLB_BASE) ; Set DTLB_BASE higher
334 or3 r1, r1, #low(DTLB_BASE) ; Set DTLB_BASE lower
336 ldi r3, #NR_TLB_ENTRIES
340 st r2, @+r0 ; VPA <- 0
341 st r2, @+r0 ; PPA <- 0
342 st r2, @+r1 ; VPA <- 0
343 st r2, @+r1 ; PPA <- 0
349 ENTRY(m32r_itlb_entrys)
350 ENTRY(m32r_otlb_entrys)
352 #endif /* CONFIG_MMU */