2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2000 Silicon Graphics, Inc.
7 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
8 * Copyright (C) 2002 Maciej W. Rozycki
10 #include <linux/config.h>
11 #include <linux/init.h>
12 #include <linux/threads.h>
15 #include <asm/hazards.h>
16 #include <asm/regdef.h>
17 #include <asm/mipsregs.h>
18 #include <asm/stackframe.h>
21 #define _VMALLOC_START 0xc000000000000000
26 * Fixme - this is b0rked for pgd_current outside of CKSEG0
28 dmfc0 \ptr, CP0_CONTEXT
29 dsra \ptr, 23 # get pgd_current[cpu]
37 * After this macro runs we have a pointer to the pte of the address
38 * that caused the fault in PTR. Expects register containing the
39 * the pagetable root pointer as the ptr argument and c0_badvaddr
40 * passed as tmp argument.
42 .macro LOAD_PTE2, ptr, tmp
43 dsrl \tmp, (_PGDIR_SHIFT-3) # get pgd offset in bytes
44 andi \tmp, ((_PTRS_PER_PGD - 1)<<3)
45 daddu \ptr, \tmp # add in pgd offset
46 dmfc0 \tmp, CP0_BADVADDR
47 ld \ptr, (\ptr) # get pmd pointer
48 dsrl \tmp, (_PMD_SHIFT-3) # get pmd offset in bytes
49 andi \tmp, ((_PTRS_PER_PMD - 1)<<3)
50 daddu \ptr, \tmp # add in pmd offset
51 dmfc0 \tmp, CP0_XCONTEXT
52 ld \ptr, (\ptr) # get pte pointer
53 andi \tmp, 0xff0 # get pte offset
58 * This places the even/odd pte pair in the page table at the pte
59 * entry pointed to by PTE into ENTRYLO0 and ENTRYLO1.
61 .macro PTE_RELOAD, pte0, pte1
62 dsrl \pte0, 6 # convert to entrylo0
63 dmtc0 \pte0, CP0_ENTRYLO0 # load it
64 dsrl \pte1, 6 # convert to entrylo1
65 dmtc0 \pte1, CP0_ENTRYLO1 # load it
76 * TLB refill handlers for the R4000 and SB1.
77 * Attention: We may only use 32 instructions / 128 bytes.
82 dla k0, handle_vec1_r4k
89 dmfc0 k0, CP0_BADVADDR
92 dsrl k0, k0, _PAGE_SHIFT+1
96 dla k0, handle_vec1_r4k
107 LEAF(handle_vec1_r4k)
109 dmfc0 k0, CP0_BADVADDR
112 GET_PGD k1 # pointer to root of pgd
114 ld k0, 0(k1) # get even pte
115 ld k1, 8(k1) # get odd pte
122 9: # handle the vmalloc range
123 dli k1, _VMALLOC_START
125 dla k1, swapper_pg_dir # pointer to root of pgd
127 ld k0, 0(k1) # get even pte
128 ld k1, 8(k1) # get odd pte