Commit 44cb1054 by Liangfu Chen Committed by Thierry Moreau

[VTA] improved virtual memory mapping (#4545)

* [VTA] improved virtual memory mapping

* Update virtual_memory.cc
parent 76076ec3
......@@ -66,9 +66,19 @@ void* VirtualMemoryManager::GetAddr(uint64_t phy_addr) {
vta_phy_addr_t VirtualMemoryManager::GetPhyAddr(void* buf) {
std::lock_guard<std::mutex> lock(mutex_);
auto it = pmap_.find(buf);
uint64_t offset = 0;
if (it == pmap_.end()) {
for (it = pmap_.begin(); it != pmap_.end(); it++) {
uint64_t bytes = it->second->num_pages << kPageBits;
if ((buf >= it->first) && (buf < static_cast<char*>(it->first) + bytes)) {
offset = static_cast<char*>(buf) - static_cast<char*>(it->first);
break;
}
}
CHECK(it != pmap_.end());
}
Page* p = it->second.get();
return (p->ptable_begin + 1) << kPageBits;
return ((p->ptable_begin + 1) << kPageBits) + offset;
}
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment