page_table.cc (8763:509e9bb84dfa) page_table.cc (8766:b0773af78423)
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;

--- 38 unchanged lines hidden (view full) ---

47#include "sim/faults.hh"
48#include "sim/process.hh"
49#include "sim/sim_object.hh"
50#include "sim/system.hh"
51
52using namespace std;
53using namespace TheISA;
54
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;

--- 38 unchanged lines hidden (view full) ---

47#include "sim/faults.hh"
48#include "sim/process.hh"
49#include "sim/sim_object.hh"
50#include "sim/system.hh"
51
52using namespace std;
53using namespace TheISA;
54
55PageTable::PageTable(
56#if !FULL_SYSTEM
57 Process *_process,
58#endif
59 Addr _pageSize)
60 : pageSize(_pageSize), offsetMask(mask(floorLog2(_pageSize)))
61#if !FULL_SYSTEM
62 , process(_process)
63#endif
55PageTable::PageTable(Process *_process, Addr _pageSize)
56 : pageSize(_pageSize), offsetMask(mask(floorLog2(_pageSize))),
57 process(_process)
64{
65 assert(isPowerOf2(pageSize));
66 pTableCache[0].vaddr = 0;
67 pTableCache[1].vaddr = 0;
68 pTableCache[2].vaddr = 0;
69}
70
71PageTable::~PageTable()

--- 12 unchanged lines hidden (view full) ---

84 PTableItr iter = pTable.find(vaddr);
85
86 if (iter != pTable.end()) {
87 // already mapped
88 fatal("PageTable::allocate: address 0x%x already mapped",
89 vaddr);
90 }
91
58{
59 assert(isPowerOf2(pageSize));
60 pTableCache[0].vaddr = 0;
61 pTableCache[1].vaddr = 0;
62 pTableCache[2].vaddr = 0;
63}
64
65PageTable::~PageTable()

--- 12 unchanged lines hidden (view full) ---

78 PTableItr iter = pTable.find(vaddr);
79
80 if (iter != pTable.end()) {
81 // already mapped
82 fatal("PageTable::allocate: address 0x%x already mapped",
83 vaddr);
84 }
85
92#if !FULL_SYSTEM
93 pTable[vaddr] = TheISA::TlbEntry(process->M5_pid, vaddr,
94 process->system->new_page());
95 updateCache(vaddr, pTable[vaddr]);
86 pTable[vaddr] = TheISA::TlbEntry(process->M5_pid, vaddr,
87 process->system->new_page());
88 updateCache(vaddr, pTable[vaddr]);
96#endif
97 }
98}
99
100void
101PageTable::remap(Addr vaddr, int64_t size, Addr new_vaddr)
102{
103 assert(pageOffset(vaddr) == 0);
104 assert(pageOffset(new_vaddr) == 0);

--- 94 unchanged lines hidden (view full) ---

199{
200 paramOut(os, "ptable.size", pTable.size());
201
202 PTable::size_type count = 0;
203
204 PTableItr iter = pTable.begin();
205 PTableItr end = pTable.end();
206 while (iter != end) {
89 }
90}
91
92void
93PageTable::remap(Addr vaddr, int64_t size, Addr new_vaddr)
94{
95 assert(pageOffset(vaddr) == 0);
96 assert(pageOffset(new_vaddr) == 0);

--- 94 unchanged lines hidden (view full) ---

191{
192 paramOut(os, "ptable.size", pTable.size());
193
194 PTable::size_type count = 0;
195
196 PTableItr iter = pTable.begin();
197 PTableItr end = pTable.end();
198 while (iter != end) {
207#if !FULL_SYSTEM
208 os << "\n[" << csprintf("%s.Entry%d", process->name(), count) << "]\n";
199 os << "\n[" << csprintf("%s.Entry%d", process->name(), count) << "]\n";
209#endif
210
211 paramOut(os, "vaddr", iter->first);
212 iter->second.serialize(os);
213
214 ++iter;
215 ++count;
216 }
217 assert(count == pTable.size());
218}
219
220void
221PageTable::unserialize(Checkpoint *cp, const std::string &section)
222{
223 int i = 0, count;
224 paramIn(cp, section, "ptable.size", count);
225
226 pTable.clear();
227
228 while (i < count) {
200
201 paramOut(os, "vaddr", iter->first);
202 iter->second.serialize(os);
203
204 ++iter;
205 ++count;
206 }
207 assert(count == pTable.size());
208}
209
210void
211PageTable::unserialize(Checkpoint *cp, const std::string &section)
212{
213 int i = 0, count;
214 paramIn(cp, section, "ptable.size", count);
215
216 pTable.clear();
217
218 while (i < count) {
229#if !FULL_SYSTEM
230 TheISA::TlbEntry *entry;
231 Addr vaddr;
232
233 paramIn(cp, csprintf("%s.Entry%d", process->name(), i), "vaddr", vaddr);
234 entry = new TheISA::TlbEntry();
235 entry->unserialize(cp, csprintf("%s.Entry%d", process->name(), i));
236 pTable[vaddr] = *entry;
237 ++i;
219 TheISA::TlbEntry *entry;
220 Addr vaddr;
221
222 paramIn(cp, csprintf("%s.Entry%d", process->name(), i), "vaddr", vaddr);
223 entry = new TheISA::TlbEntry();
224 entry->unserialize(cp, csprintf("%s.Entry%d", process->name(), i));
225 pTable[vaddr] = *entry;
226 ++i;
238#endif
239 }
240}
241
227 }
228}
229