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 * Authors: Ali Saidi 29 */ 30 31#ifndef __ARCH_SPARC_PAGETABLE_HH__ 32#define __ARCH_SPARC_PAGETABLE_HH__ 33 34#include "arch/sparc/isa_traits.hh"
| 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 * Authors: Ali Saidi 29 */ 30 31#ifndef __ARCH_SPARC_PAGETABLE_HH__ 32#define __ARCH_SPARC_PAGETABLE_HH__ 33 34#include "arch/sparc/isa_traits.hh"
|
37namespace SparcISA 38{ 39struct VAddr 40{ 41 VAddr(Addr a) { panic("not implemented yet."); } 42}; 43 44class PageTableEntry 45{ 46 public: 47 enum EntryType { 48 sun4v, 49 sun4u, 50 invalid 51 }; 52 53 private: 54 uint64_t entry; 55 EntryType type; 56 uint64_t entry4u; 57 bool populated; 58 59 60 public: 61 PageTableEntry() : entry(0), type(invalid), populated(false) {} 62 63 PageTableEntry(uint64_t e, EntryType t = sun4u) 64 : entry(e), type(t), populated(true) 65 66 { 67 populate(entry, type); 68 } 69 70 void populate(uint64_t e, EntryType t = sun4u) 71 { 72 entry = e; 73 type = t; 74 populated = true; 75 76 // If we get a sun4v format TTE, turn it into a sun4u 77 if (type == sun4u) 78 entry4u = entry; 79 else { 80 uint64_t entry4u = 0; 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] 87 //diag? 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 94 } 95 } 96 97 void clear() 98 { 99 populated = false; 100 } 101 102 static int pageSizes[6]; 103 104 105 uint64_t operator()() const { assert(populated); return entry4u; } 106 const PageTableEntry &operator=(uint64_t e) { populated = true; 107 entry4u = e; return *this; } 108 109 const PageTableEntry &operator=(const PageTableEntry &e) 110 { populated = true; entry4u = e.entry4u; return *this; } 111 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; } 136}; 137 138struct TlbRange { 139 Addr va; 140 Addr size; 141 int contextId; 142 int partitionId; 143 bool real; 144 145 inline bool operator<(const TlbRange &r2) const 146 { 147 if (real && !r2.real) 148 return true; 149 if (!real && r2.real) 150 return false; 151 152 if (!real && !r2.real) { 153 if (contextId < r2.contextId) 154 return true; 155 else if (contextId > r2.contextId) 156 return false; 157 } 158 159 if (partitionId < r2.partitionId) 160 return true; 161 else if (partitionId > r2.partitionId) 162 return false; 163 164 if (va < r2.va) 165 return true; 166 return false; 167 } 168 inline bool operator==(const TlbRange &r2) const 169 { 170 return va == r2.va && 171 size == r2.size && 172 contextId == r2.contextId && 173 partitionId == r2.partitionId && 174 real == r2.real; 175 } 176}; 177 178 179struct TlbEntry { 180 TlbRange range; 181 PageTableEntry pte; 182 bool used; 183 bool valid; 184 185 void serialize(std::ostream &os); 186 void unserialize(Checkpoint *cp, const std::string §ion); 187 188}; 189 190 191}; // namespace SparcISA 192 193#endif // __ARCH_SPARC_PAGE_TABLE_HH__ 194
| 40namespace SparcISA 41{ 42struct VAddr 43{ 44 VAddr(Addr a) { panic("not implemented yet."); } 45}; 46 47class PageTableEntry 48{ 49 public: 50 enum EntryType { 51 sun4v, 52 sun4u, 53 invalid 54 }; 55 56 private: 57 uint64_t entry; 58 EntryType type; 59 uint64_t entry4u; 60 bool populated; 61 62 63 public: 64 PageTableEntry() : entry(0), type(invalid), populated(false) {} 65 66 PageTableEntry(uint64_t e, EntryType t = sun4u) 67 : entry(e), type(t), populated(true) 68 69 { 70 populate(entry, type); 71 } 72 73 void populate(uint64_t e, EntryType t = sun4u) 74 { 75 entry = e; 76 type = t; 77 populated = true; 78 79 // If we get a sun4v format TTE, turn it into a sun4u 80 if (type == sun4u) 81 entry4u = entry; 82 else { 83 uint64_t entry4u = 0; 84 entry4u |= entry & ULL(0x8000000000000000); //valid 85 entry4u |= (entry & 0x3) << 61; //size[1:0] 86 entry4u |= (entry & ULL(0x4000000000000000)) >> 2; //nfo 87 entry4u |= (entry & 0x1000) << 47; //ie 88 //entry4u |= (entry & 0x3F00000000000000) >> 7; //soft2 89 entry4u |= (entry & 0x4) << 48; //size[2] 90 //diag? 91 entry4u |= (entry & ULL(0x0000FFFFFFFFE000)); //paddr 92 entry4u |= (entry & 0x400) >> 5; //cp 93 entry4u |= (entry & 0x200) >> 5; //cv 94 entry4u |= (entry & 0x800) >> 8; //e 95 entry4u |= (entry & 0x100) >> 6; //p 96 entry4u |= (entry & 0x40) >> 5; //w 97 } 98 } 99 100 void clear() 101 { 102 populated = false; 103 } 104 105 static int pageSizes[6]; 106 107 108 uint64_t operator()() const { assert(populated); return entry4u; } 109 const PageTableEntry &operator=(uint64_t e) { populated = true; 110 entry4u = e; return *this; } 111 112 const PageTableEntry &operator=(const PageTableEntry &e) 113 { populated = true; entry4u = e.entry4u; return *this; } 114 115 bool valid() const { return entry4u & ULL(0x8000000000000000) && populated; } 116 uint8_t _size() const { assert(populated); 117 return ((entry4u & 0x6) >> 61) | 118 ((entry4u & ULL(0x000080000000000)) >> 46); } 119 Addr size() const { return pageSizes[_size()]; } 120 bool ie() const { return entry4u >> 59 & 0x1; } 121 Addr pfn() const { assert(populated); 122 return entry4u >> 13 & ULL(0xFFFFFFFFFF); } 123 Addr paddr() const { assert(populated); 124 return entry4u & ULL(0x0000FFFFFFFFE000); } 125 bool locked() const { assert(populated); 126 return entry4u & 0x40; } 127 bool cv() const { assert(populated); 128 return entry4u & 0x10; } 129 bool cp() const { assert(populated); 130 return entry4u & 0x20; } 131 bool priv() const { assert(populated); 132 return entry4u & 0x4; } 133 bool writable() const { assert(populated); 134 return entry4u & 0x2; } 135 bool nofault() const { assert(populated); 136 return entry4u & ULL(0x1000000000000000); } 137 bool sideffect() const { assert(populated); 138 return entry4u & 0x8; } 139}; 140 141struct TlbRange { 142 Addr va; 143 Addr size; 144 int contextId; 145 int partitionId; 146 bool real; 147 148 inline bool operator<(const TlbRange &r2) const 149 { 150 if (real && !r2.real) 151 return true; 152 if (!real && r2.real) 153 return false; 154 155 if (!real && !r2.real) { 156 if (contextId < r2.contextId) 157 return true; 158 else if (contextId > r2.contextId) 159 return false; 160 } 161 162 if (partitionId < r2.partitionId) 163 return true; 164 else if (partitionId > r2.partitionId) 165 return false; 166 167 if (va < r2.va) 168 return true; 169 return false; 170 } 171 inline bool operator==(const TlbRange &r2) const 172 { 173 return va == r2.va && 174 size == r2.size && 175 contextId == r2.contextId && 176 partitionId == r2.partitionId && 177 real == r2.real; 178 } 179}; 180 181 182struct TlbEntry { 183 TlbRange range; 184 PageTableEntry pte; 185 bool used; 186 bool valid; 187 188 void serialize(std::ostream &os); 189 void unserialize(Checkpoint *cp, const std::string §ion); 190 191}; 192 193 194}; // namespace SparcISA 195 196#endif // __ARCH_SPARC_PAGE_TABLE_HH__ 197
|