1/* 2 * Copyright (c) 2003 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; --- 13 unchanged lines hidden (view full) --- 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: Steve Reinhardt 29 * Ron Dreslinski |
30 * Ali Saidi |
31 */ 32 33/** 34 * @file 35 * Definitions of page table. 36 */ 37#include <string> 38#include <map> --- 54 unchanged lines hidden (view full) --- 93 94 95void 96PageTable::allocate(Addr vaddr, int64_t size) 97{ 98 // starting address must be page aligned 99 assert(pageOffset(vaddr) == 0); 100 |
101 DPRINTF(MMU, "Allocating Page: %#x-%#x\n", vaddr, vaddr+ size); 102 |
103 for (; size > 0; size -= pageSize, vaddr += pageSize) { 104 m5::hash_map<Addr,Addr>::iterator iter = pTable.find(vaddr); 105 106 if (iter != pTable.end()) { 107 // already mapped 108 fatal("PageTable::allocate: address 0x%x already mapped", vaddr); 109 } 110 --- 46 unchanged lines hidden (view full) --- 157 assert(pageAlign(req->getVaddr() + req->getSize() - 1) 158 == pageAlign(req->getVaddr())); 159 if (!translate(req->getVaddr(), paddr)) { 160 return genPageTableFault(req->getVaddr()); 161 } 162 req->setPaddr(paddr); 163 return page_check(req->getPaddr(), req->getSize()); 164} |
165 166void 167PageTable::serialize(std::ostream &os) 168{ 169 paramOut(os, "ptable.size", pTable.size()); 170 int count = 0; 171 172 m5::hash_map<Addr,Addr>::iterator iter; 173 while (iter != pTable.end()) { 174 paramOut(os, csprintf("ptable.entry%dvaddr", count),iter->first); 175 paramOut(os, csprintf("ptable.entry%dpaddr", count),iter->second); 176 ++count; 177 } 178 assert(count == pTable.size()); 179} 180 181void 182PageTable::unserialize(Checkpoint *cp, const std::string §ion) 183{ 184 int i = 0, count; 185 paramIn(cp, section, "ptable.size", count); 186 Addr vaddr, paddr; 187 188 pTable.clear(); 189 190 while(i < count) { 191 paramIn(cp, section, csprintf("ptable.entry%dvaddr", i), vaddr); 192 paramIn(cp, section, csprintf("ptable.entry%dpaddr", i), paddr); 193 pTable[vaddr] = paddr; 194 ++i; 195 } 196 197} 198 |