diff options
author | bunnei <bunneidev@gmail.com> | 2020-04-23 17:37:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 17:37:12 +0200 |
commit | ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c (patch) | |
tree | f3108877d77c64d4456b7ad27d500aa1e82da33d /src/core/hle/kernel/memory/memory_block_manager.cpp | |
parent | Merge pull request #3730 from lioncash/time (diff) | |
download | yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.gz yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.bz2 yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.lz yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.xz yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.zst yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.zip |
Diffstat (limited to 'src/core/hle/kernel/memory/memory_block_manager.cpp')
-rw-r--r-- | src/core/hle/kernel/memory/memory_block_manager.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/hle/kernel/memory/memory_block_manager.cpp b/src/core/hle/kernel/memory/memory_block_manager.cpp index 1ebc126c0..900395c37 100644 --- a/src/core/hle/kernel/memory/memory_block_manager.cpp +++ b/src/core/hle/kernel/memory/memory_block_manager.cpp @@ -143,6 +143,42 @@ void MemoryBlockManager::Update(VAddr addr, std::size_t num_pages, MemoryState s } } +void MemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc&& lock_func, + MemoryPermission perm) { + const std::size_t prev_count{memory_block_tree.size()}; + const VAddr end_addr{addr + num_pages * PageSize}; + iterator node{memory_block_tree.begin()}; + + while (node != memory_block_tree.end()) { + MemoryBlock* block{&(*node)}; + iterator next_node{std::next(node)}; + const VAddr cur_addr{block->GetAddress()}; + const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr}; + + if (addr < cur_end_addr && cur_addr < end_addr) { + iterator new_node{node}; + + if (addr > cur_addr) { + memory_block_tree.insert(node, block->Split(addr)); + } + + if (end_addr < cur_end_addr) { + new_node = memory_block_tree.insert(node, block->Split(end_addr)); + } + + lock_func(new_node, perm); + + MergeAdjacent(new_node, next_node); + } + + if (cur_end_addr - 1 >= end_addr - 1) { + break; + } + + node = next_node; + } +} + void MemoryBlockManager::IterateForRange(VAddr start, VAddr end, IterateFunc&& func) { const_iterator it{FindIterator(start)}; MemoryInfo info{}; |