physical.cc (10482:f1baf4f7723f) | physical.cc (10699:d0004c12d024) |
---|---|
1/* 2 * Copyright (c) 2012, 2014 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 46 unchanged lines hidden (view full) --- 55#include "debug/Checkpoint.hh" 56#include "mem/abstract_mem.hh" 57#include "mem/physical.hh" 58 59using namespace std; 60 61PhysicalMemory::PhysicalMemory(const string& _name, 62 const vector<AbstractMemory*>& _memories) : | 1/* 2 * Copyright (c) 2012, 2014 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 46 unchanged lines hidden (view full) --- 55#include "debug/Checkpoint.hh" 56#include "mem/abstract_mem.hh" 57#include "mem/physical.hh" 58 59using namespace std; 60 61PhysicalMemory::PhysicalMemory(const string& _name, 62 const vector<AbstractMemory*>& _memories) : |
63 _name(_name), size(0) | 63 _name(_name), rangeCache(addrMap.end()), size(0) |
64{ 65 // add the memories from the system to the address map as 66 // appropriate 67 for (const auto& m : _memories) { 68 // only add the memory if it is part of the global address map 69 if (m->isInAddrMap()) { 70 memories.push_back(m); 71 --- 104 unchanged lines hidden (view full) --- 176 for (auto& s : backingStore) 177 munmap((char*)s.second, s.first.size()); 178} 179 180bool 181PhysicalMemory::isMemAddr(Addr addr) const 182{ 183 // see if the address is within the last matched range | 64{ 65 // add the memories from the system to the address map as 66 // appropriate 67 for (const auto& m : _memories) { 68 // only add the memory if it is part of the global address map 69 if (m->isInAddrMap()) { 70 memories.push_back(m); 71 --- 104 unchanged lines hidden (view full) --- 176 for (auto& s : backingStore) 177 munmap((char*)s.second, s.first.size()); 178} 179 180bool 181PhysicalMemory::isMemAddr(Addr addr) const 182{ 183 // see if the address is within the last matched range |
184 if (!rangeCache.contains(addr)) { | 184 if (rangeCache != addrMap.end() && rangeCache->first.contains(addr)) { 185 return true; 186 } else { |
185 // lookup in the interval tree 186 const auto& r = addrMap.find(addr); 187 if (r == addrMap.end()) { 188 // not in the cache, and not in the tree 189 return false; 190 } 191 // the range is in the tree, update the cache | 187 // lookup in the interval tree 188 const auto& r = addrMap.find(addr); 189 if (r == addrMap.end()) { 190 // not in the cache, and not in the tree 191 return false; 192 } 193 // the range is in the tree, update the cache |
192 rangeCache = r->first; | 194 rangeCache = r; 195 return true; |
193 } | 196 } |
194 195 assert(addrMap.find(addr) != addrMap.end()); 196 197 // either matched the cache or found in the tree 198 return true; | |
199} 200 201AddrRangeList 202PhysicalMemory::getConfAddrRanges() const 203{ 204 // this could be done once in the constructor, but since it is unlikely to 205 // be called more than once the iteration should not be a problem 206 AddrRangeList ranges; --- 27 unchanged lines hidden (view full) --- 234 return ranges; 235} 236 237void 238PhysicalMemory::access(PacketPtr pkt) 239{ 240 assert(pkt->isRequest()); 241 Addr addr = pkt->getAddr(); | 197} 198 199AddrRangeList 200PhysicalMemory::getConfAddrRanges() const 201{ 202 // this could be done once in the constructor, but since it is unlikely to 203 // be called more than once the iteration should not be a problem 204 AddrRangeList ranges; --- 27 unchanged lines hidden (view full) --- 232 return ranges; 233} 234 235void 236PhysicalMemory::access(PacketPtr pkt) 237{ 238 assert(pkt->isRequest()); 239 Addr addr = pkt->getAddr(); |
242 const auto& m = addrMap.find(addr); 243 assert(m != addrMap.end()); 244 m->second->access(pkt); | 240 if (rangeCache != addrMap.end() && rangeCache->first.contains(addr)) { 241 rangeCache->second->access(pkt); 242 } else { 243 // do not update the cache here, as we typically call 244 // isMemAddr before calling access 245 const auto& m = addrMap.find(addr); 246 assert(m != addrMap.end()); 247 m->second->access(pkt); 248 } |
245} 246 247void 248PhysicalMemory::functionalAccess(PacketPtr pkt) 249{ 250 assert(pkt->isRequest()); 251 Addr addr = pkt->getAddr(); | 249} 250 251void 252PhysicalMemory::functionalAccess(PacketPtr pkt) 253{ 254 assert(pkt->isRequest()); 255 Addr addr = pkt->getAddr(); |
252 const auto& m = addrMap.find(addr); 253 assert(m != addrMap.end()); 254 m->second->functionalAccess(pkt); | 256 if (rangeCache != addrMap.end() && rangeCache->first.contains(addr)) { 257 rangeCache->second->functionalAccess(pkt); 258 } else { 259 // do not update the cache here, as we typically call 260 // isMemAddr before calling functionalAccess 261 const auto& m = addrMap.find(addr); 262 assert(m != addrMap.end()); 263 m->second->functionalAccess(pkt); 264 } |
255} 256 257void 258PhysicalMemory::serialize(ostream& os) 259{ 260 // serialize all the locked addresses and their context ids 261 vector<Addr> lal_addr; 262 vector<int> lal_cid; --- 153 unchanged lines hidden --- | 265} 266 267void 268PhysicalMemory::serialize(ostream& os) 269{ 270 // serialize all the locked addresses and their context ids 271 vector<Addr> lal_addr; 272 vector<int> lal_cid; --- 153 unchanged lines hidden --- |