gem5  v22.0.0.1
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 
34 #include "arch/sparc/pagetable.hh"
35 
36 namespace gem5
37 {
38 
39 namespace SparcISA
40 {
41 
42 class TlbMap
43 {
44  private:
45  typedef std::map<TlbRange, TlbEntry*> RangeMap;
47 
48  public:
49  typedef RangeMap::iterator iterator;
50 
51  iterator
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 
96  iterator
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 
129  iterator
131  {
132  return tree.begin();
133  }
134 
135  iterator
136  end()
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__
gem5::SparcISA::TlbMap::end
iterator end()
Definition: tlb_map.hh:136
gem5::VegaISA::r
Bitfield< 5 > r
Definition: pagetable.hh:60
gem5::SparcISA::TlbMap::insert
iterator insert(TlbRange &r, TlbEntry *d)
Definition: tlb_map.hh:97
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::SparcISA::TlbMap::clear
void clear()
Definition: tlb_map.hh:124
gem5::SparcISA::TlbMap::find
iterator find(const TlbRange &r)
Definition: tlb_map.hh:52
gem5::SparcISA::TlbMap
Definition: tlb_map.hh:42
gem5::SparcISA::TlbMap::erase
size_t erase(TlbRange k)
Definition: tlb_map.hh:106
gem5::SparcISA::TlbRange
Definition: pagetable.hh:180
gem5::SparcISA::TlbMap::intersect
bool intersect(const TlbRange &r)
Definition: tlb_map.hh:86
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::ArmISA::d
Bitfield< 9 > d
Definition: misc_types.hh:64
gem5::SparcISA::TlbMap::erase
void erase(iterator p)
Definition: tlb_map.hh:112
gem5::SparcISA::TlbMap::empty
bool empty()
Definition: tlb_map.hh:148
gem5::SparcISA::TlbMap::erase
void erase(iterator p, iterator q)
Definition: tlb_map.hh:118
gem5::SparcISA::TlbMap::tree
RangeMap tree
Definition: tlb_map.hh:46
gem5::ArmISA::q
Bitfield< 27 > q
Definition: misc_types.hh:55
gem5::SparcISA::TlbMap::size
size_t size()
Definition: tlb_map.hh:142
gem5::SparcISA::TlbMap::print
void print()
Definition: tlb_map.hh:154
gem5::MipsISA::k
Bitfield< 23 > k
Definition: dt_constants.hh:81
gem5::SparcISA::TlbMap::iterator
RangeMap::iterator iterator
Definition: tlb_map.hh:49
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
pagetable.hh
gem5::SparcISA::TlbMap::begin
iterator begin()
Definition: tlb_map.hh:130
gem5::SparcISA::TlbEntry
Definition: pagetable.hh:225
gem5::SparcISA::TlbMap::RangeMap
std::map< TlbRange, TlbEntry * > RangeMap
Definition: tlb_map.hh:45

Generated on Sat Jun 18 2022 08:12:17 for gem5 by doxygen 1.8.17