summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-02-19 02:55:46 +0100
committerbunnei <bunneidev@gmail.com>2021-03-21 22:45:02 +0100
commita439867f2c09f536e01ffdd4da9c01604cb9df45 (patch)
tree06e421fed35157a81fd973567b095db8d024cac6 /src
parenthle: kernel: KMemoryManager: Add aliases. (diff)
downloadyuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar
yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.gz
yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.bz2
yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.lz
yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.xz
yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.zst
yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/k_memory_manager.cpp12
-rw-r--r--src/core/hle/kernel/k_memory_manager.h14
2 files changed, 26 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_memory_manager.cpp b/src/core/hle/kernel/k_memory_manager.cpp
index 9027602bf..aa71697b2 100644
--- a/src/core/hle/kernel/k_memory_manager.cpp
+++ b/src/core/hle/kernel/k_memory_manager.cpp
@@ -173,4 +173,16 @@ ResultCode KMemoryManager::Free(KPageLinkedList& page_list, std::size_t num_page
return RESULT_SUCCESS;
}
+std::size_t KMemoryManager::Impl::CalculateManagementOverheadSize(std::size_t region_size) {
+ const std::size_t ref_count_size = (region_size / PageSize) * sizeof(u16);
+ const std::size_t optimize_map_size =
+ (Common::AlignUp((region_size / PageSize), Common::BitSize<u64>()) /
+ Common::BitSize<u64>()) *
+ sizeof(u64);
+ const std::size_t manager_meta_size =
+ Common::AlignUp(optimize_map_size + ref_count_size, PageSize);
+ const std::size_t page_heap_size = KPageHeap::CalculateManagementOverheadSize(region_size);
+ return manager_meta_size + page_heap_size;
+}
+
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_memory_manager.h b/src/core/hle/kernel/k_memory_manager.h
index 587dad178..ac840b3d0 100644
--- a/src/core/hle/kernel/k_memory_manager.h
+++ b/src/core/hle/kernel/k_memory_manager.h
@@ -60,6 +60,10 @@ public:
static constexpr std::size_t MaxManagerCount = 10;
public:
+ static std::size_t CalculateManagementOverheadSize(std::size_t region_size) {
+ return Impl::CalculateManagementOverheadSize(region_size);
+ }
+
static constexpr u32 EncodeOption(Pool pool, Direction dir) {
return (static_cast<u32>(pool) << static_cast<u32>(Pool::Shift)) |
(static_cast<u32>(dir) << static_cast<u32>(Direction::Shift));
@@ -90,6 +94,16 @@ private:
Pool pool{};
public:
+ static std::size_t CalculateManagementOverheadSize(std::size_t region_size);
+
+ static constexpr std::size_t CalculateOptimizedProcessOverheadSize(
+ std::size_t region_size) {
+ return (Common::AlignUp((region_size / PageSize), Common::BitSize<u64>()) /
+ Common::BitSize<u64>()) *
+ sizeof(u64);
+ }
+
+ public:
Impl() = default;
std::size_t Initialize(Pool new_pool, u64 start_address, u64 end_address);