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 "config/full_system.hh"
41 VAddr(Addr a) { panic("not implemented yet."); }
61 PageTableEntry() : entry(0), type(invalid), populated(false) {}
63 PageTableEntry(uint64_t e, EntryType t = sun4u)
64 : entry(e), type(t), populated(true)
67 populate(entry, type);
70 void populate(uint64_t e, EntryType t = sun4u)
76 // If we get a sun4v format TTE, turn it into a sun4u
81 entry4u |= entry & ULL(0x8000000000000000); //valid
82 entry4u |= (entry & 0x3) << 61; //size[1:0]
83 entry4u |= (entry & ULL(0x4000000000000000)) >> 2; //nfo
84 entry4u |= (entry & 0x1000) << 47; //ie
85 //entry4u |= (entry & 0x3F00000000000000) >> 7; //soft2
86 entry4u |= (entry & 0x4) << 48; //size[2]
88 entry4u |= (entry & ULL(0x0000FFFFFFFFE000)); //paddr
89 entry4u |= (entry & 0x400) >> 5; //cp
90 entry4u |= (entry & 0x200) >> 5; //cv
91 entry4u |= (entry & 0x800) >> 8; //e
92 entry4u |= (entry & 0x100) >> 6; //p
93 entry4u |= (entry & 0x40) >> 5; //w
102 static int pageSizes[6];
105 uint64_t operator()() const { assert(populated); return entry4u; }
106 const PageTableEntry &operator=(uint64_t e) { populated = true;
107 entry4u = e; return *this; }
109 const PageTableEntry &operator=(const PageTableEntry &e)
110 { populated = true; entry4u = e.entry4u; return *this; }
112 bool valid() const { return entry4u & ULL(0x8000000000000000) && populated; }
113 uint8_t _size() const { assert(populated);
114 return ((entry4u & 0x6) >> 61) |
115 ((entry4u & ULL(0x000080000000000)) >> 46); }
116 Addr size() const { return pageSizes[_size()]; }
117 bool ie() const { return entry4u >> 59 & 0x1; }
118 Addr pfn() const { assert(populated);
119 return entry4u >> 13 & ULL(0xFFFFFFFFFF); }
120 Addr paddr() const { assert(populated);
121 return entry4u & ULL(0x0000FFFFFFFFE000); }
122 bool locked() const { assert(populated);
123 return entry4u & 0x40; }
124 bool cv() const { assert(populated);
125 return entry4u & 0x10; }
126 bool cp() const { assert(populated);
127 return entry4u & 0x20; }
128 bool priv() const { assert(populated);
129 return entry4u & 0x4; }
130 bool writable() const { assert(populated);
131 return entry4u & 0x2; }
132 bool nofault() const { assert(populated);
133 return entry4u & ULL(0x1000000000000000); }
134 bool sideffect() const { assert(populated);
135 return entry4u & 0x8; }
145 inline bool operator<(const TlbRange &r2) const
147 if (real && !r2.real)
149 if (!real && r2.real)
152 if (!real && !r2.real) {
153 if (contextId < r2.contextId)
155 else if (contextId > r2.contextId)
159 if (partitionId < r2.partitionId)
161 else if (partitionId > r2.partitionId)
168 inline bool operator==(const TlbRange &r2) const
170 return va == r2.va &&
172 contextId == r2.contextId &&
173 partitionId == r2.partitionId &&
185 void serialize(std::ostream &os);
186 void unserialize(Checkpoint *cp, const std::string §ion);
191 }; // namespace SparcISA
193 #endif // __ARCH_SPARC_PAGE_TABLE_HH__