VMManager: remove all backing block related functions

The shared_ptr<vector> type backing memory is unused now, and is not expected to be used in the future
This commit is contained in:
Weiyi Wang
2018-11-08 14:13:23 -05:00
parent 7f9873d7ec
commit b6ab4e466b
4 changed files with 1 additions and 77 deletions

View File

@@ -28,10 +28,6 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const {
type != next.type) {
return false;
}
if (type == VMAType::AllocatedMemoryBlock &&
(backing_block != next.backing_block || offset + size != next.offset)) {
return false;
}
if (type == VMAType::BackingMemory && backing_memory + size != next.backing_memory) {
return false;
}
@@ -71,28 +67,6 @@ VMManager::VMAHandle VMManager::FindVMA(VAddr target) const {
}
}
ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
std::shared_ptr<std::vector<u8>> block,
std::size_t offset, u32 size,
MemoryState state) {
ASSERT(block != nullptr);
ASSERT(offset + size <= block->size());
// This is the appropriately sized VMA that will turn into our allocation.
CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size));
VirtualMemoryArea& final_vma = vma_handle->second;
ASSERT(final_vma.size == size);
final_vma.type = VMAType::AllocatedMemoryBlock;
final_vma.permissions = VMAPermission::ReadWrite;
final_vma.meminfo_state = state;
final_vma.backing_block = block;
final_vma.offset = offset;
UpdatePageTableForVMA(final_vma);
return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
}
ResultVal<VAddr> VMManager::MapBackingMemoryToBase(VAddr base, u32 region_size, u8* memory,
u32 size, MemoryState state) {
@@ -197,8 +171,6 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
vma.permissions = VMAPermission::None;
vma.meminfo_state = MemoryState::Free;
vma.backing_block = nullptr;
vma.offset = 0;
vma.backing_memory = nullptr;
vma.paddr = 0;
@@ -246,17 +218,6 @@ ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_p
return RESULT_SUCCESS;
}
void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) {
// If this ever proves to have a noticeable performance impact, allow users of the function to
// specify a specific range of addresses to limit the scan to.
for (const auto& p : vma_map) {
const VirtualMemoryArea& vma = p.second;
if (block == vma.backing_block.get()) {
UpdatePageTableForVMA(vma);
}
}
}
void VMManager::LogLayout(Log::Level log_level) const {
for (const auto& p : vma_map) {
const VirtualMemoryArea& vma = p.second;
@@ -355,9 +316,6 @@ VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u32 offset_in_vma) {
switch (new_vma.type) {
case VMAType::Free:
break;
case VMAType::AllocatedMemoryBlock:
new_vma.offset += offset_in_vma;
break;
case VMAType::BackingMemory:
new_vma.backing_memory += offset_in_vma;
break;
@@ -395,10 +353,6 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) {
case VMAType::Free:
Memory::UnmapRegion(page_table, vma.base, vma.size);
break;
case VMAType::AllocatedMemoryBlock:
Memory::MapMemoryRegion(page_table, vma.base, vma.size,
vma.backing_block->data() + vma.offset);
break;
case VMAType::BackingMemory:
Memory::MapMemoryRegion(page_table, vma.base, vma.size, vma.backing_memory);
break;