mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
common/memory: provide findPath() to get a path of address spaces
This commit is contained in:
parent
cea353aa7f
commit
1470490747
2 changed files with 30 additions and 0 deletions
|
@ -192,6 +192,9 @@ public:
|
|||
AddressSpaceId
|
||||
findAddressSpace(const std::string& name);
|
||||
|
||||
std::list<AddressSpaceId>
|
||||
findPath(AddressSpaceId fromAddrSpaceId, AddressSpaceId toAddrSpaceId);
|
||||
|
||||
MemoryTranslation
|
||||
getTranslation(AddressSpaceId fromAddrSpaceId, AddressSpaceId toAddrSpaceId);
|
||||
|
||||
|
|
|
@ -73,6 +73,33 @@ MemoryManager::findAddressSpace(const std::string& name)
|
|||
});
|
||||
}
|
||||
|
||||
std::list<MemoryManager::AddressSpaceId>
|
||||
MemoryManager::findPath(MemoryManager::AddressSpaceId fromAddrSpaceId,
|
||||
MemoryManager::AddressSpaceId toAddrSpaceId)
|
||||
{
|
||||
std::list<AddressSpaceId> path;
|
||||
|
||||
auto fromAddrSpace = memoryGraph.getVertex(fromAddrSpaceId);
|
||||
auto toAddrSpace = memoryGraph.getVertex(toAddrSpaceId);
|
||||
|
||||
// find a path through the memory graph
|
||||
MemoryGraph::Path pathGraph;
|
||||
if(not memoryGraph.getPath(fromAddrSpaceId, toAddrSpaceId, pathGraph, pathCheckFunc)) {
|
||||
|
||||
logger->debug("No translation found from ({}) to ({})",
|
||||
*fromAddrSpace, *toAddrSpace);
|
||||
|
||||
throw std::out_of_range("no translation found");
|
||||
}
|
||||
|
||||
for(auto& mappingId : pathGraph) {
|
||||
auto mapping = memoryGraph.getEdge(mappingId);
|
||||
path.push_back(mapping->getVertexTo());
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
MemoryTranslation
|
||||
MemoryManager::getTranslation(MemoryManager::AddressSpaceId fromAddrSpaceId,
|
||||
MemoryManager::AddressSpaceId toAddrSpaceId)
|
||||
|
|
Loading…
Add table
Reference in a new issue