page_table.cc (10558:426665ec11a9) | page_table.cc (10905:a6ca6831e775) |
---|---|
1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2003 The Regents of The University of Michigan 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 */ 33 34/** 35 * @file 36 * Definitions of functional page table. 37 */ 38#include <fstream> 39#include <map> | 1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2003 The Regents of The University of Michigan 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 */ 33 34/** 35 * @file 36 * Definitions of functional page table. 37 */ 38#include <fstream> 39#include <map> |
40#include <memory> |
|
40#include <string> 41 42#include "base/bitfield.hh" 43#include "base/intmath.hh" 44#include "base/trace.hh" 45#include "config/the_isa.hh" 46#include "debug/MMU.hh" 47#include "mem/page_table.hh" --- 143 unchanged lines hidden (view full) --- 191 if ((paddr & (pageSize - 1)) + req->getSize() > pageSize) { 192 panic("Request spans page boundaries!\n"); 193 return NoFault; 194 } 195 return NoFault; 196} 197 198void | 41#include <string> 42 43#include "base/bitfield.hh" 44#include "base/intmath.hh" 45#include "base/trace.hh" 46#include "config/the_isa.hh" 47#include "debug/MMU.hh" 48#include "mem/page_table.hh" --- 143 unchanged lines hidden (view full) --- 192 if ((paddr & (pageSize - 1)) + req->getSize() > pageSize) { 193 panic("Request spans page boundaries!\n"); 194 return NoFault; 195 } 196 return NoFault; 197} 198 199void |
199FuncPageTable::serialize(std::ostream &os) | 200FuncPageTable::serialize(CheckpointOut &cp) const |
200{ | 201{ |
201 paramOut(os, "ptable.size", pTable.size()); | 202 paramOut(cp, "ptable.size", pTable.size()); |
202 203 PTable::size_type count = 0; | 203 204 PTable::size_type count = 0; |
205 for (auto &pte : pTable) { 206 ScopedCheckpointSection sec(cp, csprintf("Entry%d", count++)); |
|
204 | 207 |
205 PTableItr iter = pTable.begin(); 206 PTableItr end = pTable.end(); 207 while (iter != end) { 208 os << "\n[" << csprintf("%s.Entry%d", name(), count) << "]\n"; 209 210 paramOut(os, "vaddr", iter->first); 211 iter->second.serialize(os); 212 213 ++iter; 214 ++count; | 208 paramOut(cp, "vaddr", pte.first); 209 pte.second.serialize(cp); |
215 } 216 assert(count == pTable.size()); 217} 218 219void | 210 } 211 assert(count == pTable.size()); 212} 213 214void |
220FuncPageTable::unserialize(Checkpoint *cp, const std::string §ion) | 215FuncPageTable::unserialize(CheckpointIn &cp) |
221{ | 216{ |
222 int i = 0, count; 223 paramIn(cp, section, "ptable.size", count); | 217 int count; 218 paramIn(cp, "ptable.size", count); |
224 | 219 |
225 pTable.clear(); | 220 for (int i = 0; i < count; ++i) { 221 ScopedCheckpointSection sec(cp, csprintf("Entry%d", i)); |
226 | 222 |
227 while (i < count) { 228 TheISA::TlbEntry *entry; | 223 std::unique_ptr<TheISA::TlbEntry> entry; |
229 Addr vaddr; 230 | 224 Addr vaddr; 225 |
231 paramIn(cp, csprintf("%s.Entry%d", name(), i), "vaddr", vaddr); 232 entry = new TheISA::TlbEntry(); 233 entry->unserialize(cp, csprintf("%s.Entry%d", name(), i)); | 226 paramIn(cp, "vaddr", vaddr); 227 entry.reset(new TheISA::TlbEntry()); 228 entry->unserialize(cp); 229 |
234 pTable[vaddr] = *entry; | 230 pTable[vaddr] = *entry; |
235 delete entry; 236 ++i; | |
237 } 238} 239 | 231 } 232} 233 |