Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/arch/mips/include/tlb.h
2096 views
1
/*
2
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
3
* The President and Fellows of Harvard College.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the University nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
#ifndef _MIPS_TLB_H_
31
#define _MIPS_TLB_H_
32
33
/*
34
* MIPS-specific TLB access functions.
35
*
36
* tlb_random: write the TLB entry specified by ENTRYHI and ENTRYLO
37
* into a "random" TLB slot chosen by the processor.
38
*
39
* IMPORTANT NOTE: never write more than one TLB entry with the
40
* same virtual page field.
41
*
42
* tlb_write: same as tlb_random, but you choose the slot.
43
*
44
* tlb_read: read a TLB entry out of the TLB into ENTRYHI and ENTRYLO.
45
* INDEX specifies which one to get.
46
*
47
* tlb_probe: look for an entry matching the virtual page in ENTRYHI.
48
* Returns the index, or a negative number if no matching entry
49
* was found. ENTRYLO is not actually used, but must be set; 0
50
* should be passed.
51
*
52
* IMPORTANT NOTE: An entry may be matching even if the valid bit
53
* is not set. To completely invalidate the TLB, load it with
54
* translations for addresses in one of the unmapped address
55
* ranges - these will never be matched.
56
*/
57
58
void tlb_random(uint32_t entryhi, uint32_t entrylo);
59
void tlb_write(uint32_t entryhi, uint32_t entrylo, uint32_t index);
60
void tlb_read(uint32_t *entryhi, uint32_t *entrylo, uint32_t index);
61
int tlb_probe(uint32_t entryhi, uint32_t entrylo);
62
63
void tlb_unmap( vaddr_t );
64
void tlb_invalidate( int );
65
void tlb_clear(void);
66
void tlb_invalidate_coremap_entry( unsigned );
67
int tlb_get_free_slot(void);
68
int tlb_evict(void);
69
void tlb_shootdown_wait( void );
70
71
/*
72
* TLB entry fields.
73
*
74
* Note that the MIPS has support for a 6-bit address space ID. In the
75
* interests of simplicity, we don't use it. The fields related to it
76
* (TLBLO_GLOBAL and TLBHI_PID) can be left always zero, as can the
77
* bits that aren't assigned a meaning.
78
*
79
* The TLBLO_DIRTY bit is actually a write privilege bit - it is not
80
* ever set by the processor. If you set it, writes are permitted. If
81
* you don't set it, you'll get a "TLB Modify" exception when a write
82
* is attempted.
83
*
84
* There is probably no reason in the course of CS161 to use TLBLO_NOCACHE.
85
*/
86
87
/* Fields in the high-order word */
88
#define TLBHI_VPAGE 0xfffff000
89
/* TLBHI_PID 0x00000fc0 */
90
91
/* Fields in the low-order word */
92
#define TLBLO_PPAGE 0xfffff000
93
#define TLBLO_NOCACHE 0x00000800
94
#define TLBLO_DIRTY 0x00000400
95
#define TLBLO_VALID 0x00000200
96
/* TLBLO_GLOBAL 0x00000100 */
97
98
/*
99
* Values for completely invalid TLB entries. The TLB entry index should
100
* be passed to TLBHI_INVALID; this prevents loading the same invalid
101
* entry into multiple TLB slots.
102
*/
103
#define TLBHI_INVALID(entryno) ((0x80000+(entryno))<<12)
104
#define TLBLO_INVALID() (0)
105
106
/*
107
* Number of TLB entries in the processor.
108
*/
109
110
#define NUM_TLB 64
111
112
113
#endif /* _MIPS_TLB_H_ */
114
115