gem5 v24.0.0.0
Loading...
Searching...
No Matches
tlb_map.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __ARCH_SPARC_TLB_MAP_HH__
30#define __ARCH_SPARC_TLB_MAP_HH__
31
32#include <map>
33
35
36namespace gem5
37{
38
39namespace SparcISA
40{
41
42class TlbMap
43{
44 private:
45 typedef std::map<TlbRange, TlbEntry*> RangeMap;
47
48 public:
49 typedef RangeMap::iterator iterator;
50
52 find(const TlbRange &r)
53 {
54 iterator i;
55
56 i = tree.upper_bound(r);
57
58 if (i == tree.begin()) {
59 if (r.real == i->first.real &&
60 r.partitionId == i->first.partitionId &&
61 i->first.va < r.va + r.size &&
62 i->first.va+i->first.size >= r.va &&
63 (r.real || r.contextId == i->first.contextId))
64 return i;
65 else
66 // Nothing could match, so return end()
67 return tree.end();
68 }
69
70 i--;
71
72 if (r.real != i->first.real)
73 return tree.end();
74 if (!r.real && r.contextId != i->first.contextId)
75 return tree.end();
76 if (r.partitionId != i->first.partitionId)
77 return tree.end();
78 if (i->first.va <= r.va+r.size &&
79 i->first.va+i->first.size >= r.va)
80 return i;
81
82 return tree.end();
83 }
84
85 bool
87 {
88 iterator i;
89 i = find(r);
90 if (i != tree.end())
91 return true;
92 return false;
93 }
94
95
98 {
99 if (intersect(r))
100 return tree.end();
101
102 return tree.insert(std::make_pair(r, d)).first;
103 }
104
105 size_t
107 {
108 return tree.erase(k);
109 }
110
111 void
113 {
114 tree.erase(p);
115 }
116
117 void
119 {
120 tree.erase(p,q);
121 }
122
123 void
125 {
126 tree.erase(tree.begin(), tree.end());
127 }
128
131 {
132 return tree.begin();
133 }
134
137 {
138 return tree.end();
139 }
140
141 size_t
143 {
144 return tree.size();
145 }
146
147 bool
149 {
150 return tree.empty();
151 }
152
153 void
155 {
156 iterator i;
157 i = tree.begin();
158 while (i != tree.end()) {
159 std::cout << std::hex << i->first.va << " " << i->first.size << " " <<
160 i->first.contextId << " " << i->first.partitionId << " " <<
161 i->first.real << " " << i->second << std::endl;
162 i++;
163 }
164 }
165
166};
167
168} // namespace SparcISA
169} // namespace gem5
170
171#endif // __ARCH_SPARC_TLB_MAP_HH__
iterator insert(TlbRange &r, TlbEntry *d)
Definition tlb_map.hh:97
iterator find(const TlbRange &r)
Definition tlb_map.hh:52
void erase(iterator p)
Definition tlb_map.hh:112
std::map< TlbRange, TlbEntry * > RangeMap
Definition tlb_map.hh:45
bool intersect(const TlbRange &r)
Definition tlb_map.hh:86
size_t erase(TlbRange k)
Definition tlb_map.hh:106
RangeMap::iterator iterator
Definition tlb_map.hh:49
void erase(iterator p, iterator q)
Definition tlb_map.hh:118
Bitfield< 27 > q
Definition misc_types.hh:55
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 9 > d
Definition misc_types.hh:64
Bitfield< 0 > p
Bitfield< 23 > k
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0