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/config.h> /* CONFIG_MMU */
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
17 #include <asm/mmu_context.h>
19 #include <asm/pgtable.h>
23 * TLB Miss Exception handler
27 .global tlb_entry_i_dat
28 .global tlb_entry_d_dat
30 SWITCH_TO_KERNEL_STACK
32 #if defined(CONFIG_ISA_M32R2)
38 seth r3, #high(MMU_REG_BASE)
39 ld r1, @(MESTS_offset, r3) ; r1: status (MESTS reg.)
40 ld r0, @(MDEVP_offset, r3) ; r0: PFN + ASID (MDEVP reg.)
41 st r1, @(MESTS_offset, r3) ; clear status (MESTS reg.)
42 and3 r1, r1, #(MESTS_IT)
43 bnez r1, 1f ; instruction TLB miss?
47 ;; r0: PFN + ASID (MDEVP reg.)
51 ;; r1: TLB entry base address
52 ;; r2: &tlb_entry_{i|d}_dat
56 seth r2, #high(tlb_entry_d_dat)
57 or3 r2, r2, #low(tlb_entry_d_dat)
58 #else /* CONFIG_SMP */
60 seth r2, #high(tlb_entry_d_dat)
61 or3 r2, r2, #low(tlb_entry_d_dat)
63 ld r1, @(16, r1) ; current_thread_info->cpu
66 #endif /* !CONFIG_SMP */
67 seth r1, #high(DTLB_BASE)
68 or3 r1, r1, #low(DTLB_BASE)
74 ;; instrucntion TLB miss
76 ;; r0: MDEVP reg. (included ASID)
80 ;; r1: TLB entry base address
81 ;; r2: &tlb_entry_{i|d}_dat
84 and3 r0, r0, #(MMU_CONTEXT_ASID_MASK)
87 or r0, r1 ; r0: PFN + ASID
89 seth r2, #high(tlb_entry_i_dat)
90 or3 r2, r2, #low(tlb_entry_i_dat)
91 #else /* CONFIG_SMP */
93 seth r2, #high(tlb_entry_i_dat)
94 or3 r2, r2, #low(tlb_entry_i_dat)
96 ld r1, @(16, r1) ; current_thread_info->cpu
99 #endif /* !CONFIG_SMP */
100 seth r1, #high(ITLB_BASE)
101 or3 r1, r1, #low(ITLB_BASE)
108 ;; r1: TLB entry base address
109 ;; r2: &tlb_entry_{i|d}_dat
113 ;; r1: TLB entry address
115 #ifdef CONFIG_ISA_DUAL_ISSUE
116 ld r3, @r2 || srli r1, #3
122 ; tlb_entry_{d|i}_dat++;
124 and3 r3, r3, #(NR_TLB_ENTRIES - 1)
125 #ifdef CONFIG_ISA_DUAL_ISSUE
126 st r3, @r2 || slli r1, #3
135 ;; r1: TLB entry address
139 ;; r1: TLB entry address
142 ; pgd = *(unsigned long *)MPTB;
143 ld24 r2, #(-MPTB - 1)
145 #ifdef CONFIG_ISA_DUAL_ISSUE
146 not r2, r2 || slli r3, #2 ; r3: pgd offset
151 ld r2, @r2 ; r2: pgd base addr (MPTB reg.)
152 or r3, r2 ; r3: pmd addr
154 ; pmd = pmd_offset(pgd, address);
155 ld r3, @r3 ; r3: pmd data
157 beqz r3, 3f ; pmd_none(*pmd) ?
159 ; pte = pte_offset(pmd, address);
160 and r2, r3 ; r2: pte base addr
162 and3 r3, r3, #0xffc ; r3: pte offset
165 or r3, r2 ; r3: pte addr
167 ; pte_data = (unsigned long)pte_val(*pte);
168 ld r2, @r3 ; r2: pte data
169 or3 r2, r2, #2 ; _PAGE_PRESENT(=2)
176 ;; r1: TLB entry address
179 st r0, @r1 ; set_tlb_tag(entry++, address);
180 st r2, @+r1 ; set_tlb_data(entry, pte_data);
195 ;; r1: TLB entry address
199 ;; r1: TLB entry address
202 #ifdef CONFIG_ISA_DUAL_ISSUE
205 ldi r2, #2 ; r2: pte_data = 0 | _PAGE_PRESENT(=2)
209 #elif defined (CONFIG_ISA_M32R)
218 seth r3, #high(MMU_REG_BASE)
219 ld r0, @(MDEVA_offset,r3) ; r0: address (MDEVA reg.)
220 mvfc r2, bpc ; r2: bpc
221 ld r1, @(MESTS_offset,r3) ; r1: status (MESTS reg.)
222 st r1, @(MESTS_offset,r3) ; clear status (MESTS reg.)
223 and3 r1, r1, #(MESTS_IT)
224 beqz r1, 1f ; data TLB miss?
226 ;; instrucntion TLB miss
227 mv r0, r2 ; address = bpc;
228 ; entry = (unsigned long *)ITLB_BASE+tlb_entry_i*2;
229 seth r3, #shigh(tlb_entry_i_dat)
230 ld r4, @(low(tlb_entry_i_dat),r3)
232 seth r1, #high(ITLB_BASE)
233 or3 r1, r1, #low(ITLB_BASE)
234 add r2, r1 ; r2: entry
235 addi r4, #1 ; tlb_entry_i++;
236 and3 r4, r4, #(NR_TLB_ENTRIES-1)
237 st r4, @(low(tlb_entry_i_dat),r3)
242 ; entry = (unsigned long *)DTLB_BASE+tlb_entry_d*2;
243 seth r3, #shigh(tlb_entry_d_dat)
244 ld r4, @(low(tlb_entry_d_dat),r3)
246 seth r1, #high(DTLB_BASE)
247 or3 r1, r1, #low(DTLB_BASE)
248 add r2, r1 ; r2: entry
249 addi r4, #1 ; tlb_entry_d++;
250 and3 r4, r4, #(NR_TLB_ENTRIES-1)
251 st r4, @(low(tlb_entry_d_dat),r3)
255 ; r0: address, r2: entry
257 ; pgd = *(unsigned long *)MPTB;
264 ; pmd = pmd_offset(pgd, address);
266 beqz r1, 3f ; pmd_none(*pmd) ?
269 ldi r4, #611 ; _KERNPG_TABLE(=611)
270 beq r1, r4, 4f ; !pmd_bad(*pmd) ?
273 ldi r1, #0 ; r1: pte_data = 0
277 ; pte = pte_offset(pmd, address);
286 ; pte_data = (unsigned long)pte_val(*pte);
287 ld r1, @r4 ; r1: pte_data
291 ; r0: address, r1: pte_data, r2: entry
294 ldi r3, #-4096 ; set_tlb_tag(entry++, address);
296 seth r4, #shigh(MASID)
297 ld r4, @(low(MASID),r4) ; r4: MASID
298 and3 r4, r4, #(MMU_CONTEXT_ASID_MASK)
301 or3 r4, r1, #2 ; _PAGE_PRESENT(=2)
302 st r4, @(4,r2) ; set_tlb_data(entry, pte_data);
313 #error unknown isa configuration
318 seth r0, #high(MMU_REG_BASE) ; Set MMU_REG_BASE higher
319 or3 r0, r0, #low(MMU_REG_BASE) ; Set MMU_REG_BASE lower
321 st r1, @(MPSZ_offset,r0) ; Set MPSZ Reg(Page size 4KB:0 16KB:1 64KB:2)
323 st r1, @(MASID_offset,r0) ; Set ASID Zero
326 seth r0, #high(ITLB_BASE) ; Set ITLB_BASE higher
327 or3 r0, r0, #low(ITLB_BASE) ; Set ITLB_BASE lower
328 seth r1, #high(DTLB_BASE) ; Set DTLB_BASE higher
329 or3 r1, r1, #low(DTLB_BASE) ; Set DTLB_BASE lower
331 ldi r3, #NR_TLB_ENTRIES
335 st r2, @+r0 ; VPA <- 0
336 st r2, @+r0 ; PPA <- 0
337 st r2, @+r1 ; VPA <- 0
338 st r2, @+r1 ; PPA <- 0
344 ENTRY(m32r_itlb_entrys)
345 ENTRY(m32r_otlb_entrys)
347 #endif /* CONFIG_MMU */