probetlb.s
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include <asm.h>
#include <regdef.h>
#include <R4300.h>
.set noreorder
/*
* void __osProbeTLB(void *vaddr);
*/
LEAF(__osProbeTLB)
mfc0 t0,C0_ENTRYHI # get current TLBPID
and t1,t0,TLBHI_PIDMASK # mask off unused bits
and t2,a0,TLBHI_VPN2MASK # get VPN2 bits of given vaddr
or t1,t1,t2 # create final ENTRYHI contents
mtc0 t1,C0_ENTRYHI # set ENTRYHI to probe
nop # 7-4-1 = 3 nop
nop
nop
tlbp # look for a match
nop # 7-4-1 = 2 nop
nop
mfc0 t3,C0_INX # result is in index register
and t3,TLBINX_PROBE # top bit is "found" bit
bnez t3,3f # found?
nop
tlbr # read the TLB
nop # 8-4-1 = 3 nop
nop
nop
mfc0 t3,C0_PAGEMASK # convert page mask to page size
add t3,0x2000 # by formula:
srl t3,1 # pageSize = (pageMask + 0x2000) >> 1
and t4,t3,a0 # was vaddr odd?
bnez t4,1f
sub t3,1 # BDELAY: convert pageSize to bit mask
mfc0 v0,C0_ENTRYLO0 # even page: use ENTRYLO0
b 2f
nop
1:
mfc0 v0,C0_ENTRYLO1 # odd page: use ENTRYLO1
2:
and t5,v0,TLBLO_V # was tlb entry valid?
beqz t5,3f
nop
and v0,TLBLO_PFNMASK # and off flag bits
sll v0,TLBLO_PFNSHIFT # shift to get physical page number
and t5,a0,t3 # get page offset
add v0,t5 # add to physical page number
b 4f
nop
3:
li v0,-1 # no mapping, return -1
4:
mtc0 t0,C0_ENTRYHI # restore TLBPID
j ra
nop
END(__osProbeTLB)