2 * Copyright (c) 2006 The Regents of The University of Michigan
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.
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.
31 #ifndef __ARCH_SPARC_PAGETABLE_HH__
32 #define __ARCH_SPARC_PAGETABLE_HH__
34 #include "arch/sparc/isa_traits.hh"
35 #include "base/bitfield.hh"
36 #include "base/misc.hh"
37 #include "config/full_system.hh"
45 VAddr(Addr a) { panic("not implemented yet."); }
65 PageTableEntry() : entry(0), type(invalid), populated(false) {}
67 PageTableEntry(uint64_t e, EntryType t = sun4u)
68 : entry(e), type(t), populated(true)
71 populate(entry, type);
74 void populate(uint64_t e, EntryType t = sun4u)
80 // If we get a sun4v format TTE, turn it into a sun4u
85 entry4u |= mbits(entry,63,63); //valid
86 entry4u |= bits(entry,1,0) << 61; //size[1:0]
87 entry4u |= bits(entry,62,62) << 60; //nfo
88 entry4u |= bits(entry,12,12) << 59; //ie
89 entry4u |= bits(entry,2,2) << 48; //size[2]
90 entry4u |= mbits(entry,39,13); //paddr
91 entry4u |= bits(entry,61,61) << 6;; // locked
92 entry4u |= bits(entry,10,10) << 5; //cp
93 entry4u |= bits(entry,9,9) << 4; //cv
94 entry4u |= bits(entry,11,11) << 3; //e
95 entry4u |= bits(entry,8,8) << 2; //p
96 entry4u |= bits(entry,6,6) << 1; //w
105 static int pageSizes[6];
108 uint64_t operator()() const { assert(populated); return entry4u; }
109 const PageTableEntry &operator=(uint64_t e) { populated = true;
110 entry4u = e; return *this; }
112 const PageTableEntry &operator=(const PageTableEntry &e)
113 { populated = true; entry4u = e.entry4u; return *this; }
115 bool valid() const { return bits(entry4u,63,63) && populated; }
116 uint8_t _size() const { assert(populated);
117 return bits(entry4u, 62,61) |
118 bits(entry4u, 48,48) << 2; }
119 Addr size() const { assert(_size() < 6); return pageSizes[_size()]; }
120 bool ie() const { return bits(entry4u, 59,59); }
121 Addr pfn() const { assert(populated); return bits(entry4u,39,13); }
122 Addr paddr() const { assert(populated); return mbits(entry4u, 39,13);}
123 bool locked() const { assert(populated); return bits(entry4u,6,6); }
124 bool cv() const { assert(populated); return bits(entry4u,4,4); }
125 bool cp() const { assert(populated); return bits(entry4u,5,5); }
126 bool priv() const { assert(populated); return bits(entry4u,2,2); }
127 bool writable() const { assert(populated); return bits(entry4u,1,1); }
128 bool nofault() const { assert(populated); return bits(entry4u,60,60); }
129 bool sideffect() const { assert(populated); return bits(entry4u,3,3); }
139 inline bool operator<(const TlbRange &r2) const
141 if (real && !r2.real)
143 if (!real && r2.real)
146 if (!real && !r2.real) {
147 if (contextId < r2.contextId)
149 else if (contextId > r2.contextId)
153 if (partitionId < r2.partitionId)
155 else if (partitionId > r2.partitionId)
162 inline bool operator==(const TlbRange &r2) const
164 return va == r2.va &&
166 contextId == r2.contextId &&
167 partitionId == r2.partitionId &&
179 void serialize(std::ostream &os);
180 void unserialize(Checkpoint *cp, const std::string §ion);
185 }; // namespace SparcISA
187 #endif // __ARCH_SPARC_PAGE_TABLE_HH__