2 * arch/score/mm/tlbex.S
4 * Score Processor version.
6 * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
7 * Lennox Wu <lennox.wu@sunplusct.com>
8 * Chen Liqin <liqin.chen@sunplusct.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see the file COPYING, or write
22 * to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <asm/asmmacro.h>
27 #include <asm/pgtable-bits.h>
28 #include <asm/scoreregs.h>
31 * After this macro runs, the pte faulted on is
32 * in register PTE, a ptr into the table in which
33 * the pte belongs is in PTR.
35 .macro load_pte, pte, ptr
50 .macro pte_reload, ptr
60 .macro do_fault, write
70 .macro pte_writable, pte, ptr, label
74 lw \pte, [\ptr, 0] /*reload PTE*/
78 * Make PTE writable, update software status bits as well,
81 .macro pte_makewrite, pte, ptr
87 ENTRY(score7_FTLB_refill_Handler)
88 la r31, pgd_current /* get pgd pointer */
89 lw r31, [r31, 0] /* get the address of PGD */
91 srli r30, r30, 22 /* PGDIR_SHIFT = 22*/
94 lw r31, [r31, 0] /* get the address of the start address of PTE table */
97 andi r30, 0xfff /* equivalent to get PET index and right shift 2 bits */
99 lw r30, [r31, 0] /* load pte entry */
112 rte /* 6 cycles to make sure tlb entry works */
114 ENTRY(score7_KSEG_refill_Handler)
115 la r31, pgd_current /* get pgd pointer */
116 lw r31, [r31, 0] /* get the address of PGD */
118 srli r30, r30, 22 /* PGDIR_SHIFT = 22 */
121 lw r31, [r31, 0] /* get the address of the start address of PTE table */
123 mfcr r30, cr6 /* get Bad VPN */
125 andi r30, 0xffc /* PTE VPN mask (bit 11~2) */
128 lw r30, [r31, 0] /* load pte entry */
141 rte /* 6 cycles to make sure tlb entry works */
144 do_fault 0 /* Read */
146 ENTRY(handle_tlb_refill)
148 pte_writable r30, r31, handle_tlb_refill_nopage
149 pte_makewrite r30, r31 /* Access|Modify|Dirty|Valid */
158 handle_tlb_refill_nopage:
159 do_fault 0 /* Read */
161 ENTRY(handle_tlb_invaild)
163 stlb /* find faulting entry */
164 pte_writable r30, r31, handle_tlb_invaild_nopage
165 pte_makewrite r30, r31 /* Access|Modify|Dirty|Valid */
174 handle_tlb_invaild_nopage:
175 do_fault 0 /* Read */
179 stlb /* find faulting entry */
180 andi r30, _PAGE_WRITE /* Writable? */
183 lw r30, [r31, 0] /* reload into r30 */
185 /* Present and writable bits set, set accessed and dirty bits. */
186 pte_makewrite r30, r31
188 /* Now reload the entry into the tlb. */
199 do_fault 1 /* Write */