osMapTLB.3p
2.87 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
.TH osMapTLB 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
osMapTLB, osUnmapTLB, osUnmapTLBAll, osSetTLBASID \- manage CPU virtual address mapping
.SH SYNOPSIS
.nf
\f3
.Op c
#include <ultra64.h>
.sp .8v
void osMapTLB(s32 index, OSPageMask pm, void \(**vaddr, u32 evenpaddr,
u32 oddpaddr, s32 asid);
.sp .8v
void osUnmapTLB(s32 index);
.sp .8v
void osUnmapTLBAll(void);
.sp .8v
void osSetTLBASID(s32 asid);
.Op
\f1
.fi
.SH DESCRIPTION
These calls provide low level access to the CPU Translation Lookaside Buffer,
or TLB.
The remainder of the CPU virtual address space outside of the direct mapped
address spaces KSEG0 and KSEG1 are mapped address spaces that use the TLB to
specify the mapping to physical memory on a per-page basis.
The CPU TLB consists of 32 entries, which provide mapping to 32 odd/even
physical page pairs,
or 64 total pages.
Each TLB entry is associated with a particular page size that varies from
4096 bytes to as much as 16 megabytes.
.PP
The
.I osMapTLB
call sets the TLB entry
.IR index ,
where
.I index
ranges from 0 to 31.
The
.I pm
argument specifies the page size;
it may be one of the following defined constants:
.PP
.nf
.ta 5 18
OS_PM_4K 4096 byte page size
OS_PM_16K 16384 byte page size
OS_PM_64K 65536 byte page size
OS_PM_256K 262144 byte page size
OS_PM_1M 1048576 byte page size
OS_PM_4M 4194304 byte page size
OS_PM_16M 16777216 byte page size
.fi
.PP
The
.I vaddr
argument specifies the beginning virtual address to map,
while
.I evenpaddr
and
.I oddpaddr
arguments specify the corresponding odd and even physical page addresses.
A value of -1 for
.I evenpaddr
or
.I oddpaddr
indicates that no mapping is to be made for the even or odd page,
respectively.
The
.I asid
argument specifies an address space identifier that makes the mappings valid
only when a specific address space identifier register is loaded.
(See
.I osSetTLBASID
below.)
A value of -1 for
.I asid
specifies a global mapping that is always valid.
As an example,
the following call specifies a global mapping of the virtual address range
.I "[0x2000, 0x3000]"
to the physical address range
.I "[0xab000, 0xac000]"
and the virtual address range
.I "[0x3000, 0x4000]"
to the physical address range
.IR "[0xcd000, 0xce000]" :
.PP
.Ex
osMapTLB(0, (void *)0x2000, 0xab000, 0xcd000, -1);
.Ee
.PP
The
.I osUnmapTLB
call removes any existing even or odd page mapping for the TLB entry
.IR index .
The
.I osUnmapTLBAll
call removes all mappings at all indexes (invalidates the entire TLB).
.I osUnmapTLBAll
should be called
.IR before
using any other TLB calls to remove any stale mappings.
.PP
The
.I osSetTLBASID
call sets a system-wide address space identifier register that makes valid
only mappings of the given address space identifier
(as well as global mappings).
This feature can be useful for detection of address errors that may lead
to unpredictable results.
.SH "SEE ALSO"
.IR osVirtualToPhysical (3P)