diff options
| author | 2021-02-18 17:55:46 -0800 | |
|---|---|---|
| committer | 2021-03-21 14:45:02 -0700 | |
| commit | a439867f2c09f536e01ffdd4da9c01604cb9df45 (patch) | |
| tree | 06e421fed35157a81fd973567b095db8d024cac6 /src | |
| parent | hle: kernel: KMemoryManager: Add aliases. (diff) | |
| download | yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.gz yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.tar.xz yuzu-a439867f2c09f536e01ffdd4da9c01604cb9df45.zip | |
hle: kernel: KMemoryManager: Add CalculateManagementOverheadSize.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/k_memory_manager.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_memory_manager.h | 14 |
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 | |||
| 173 | return RESULT_SUCCESS; | 173 | return RESULT_SUCCESS; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | std::size_t KMemoryManager::Impl::CalculateManagementOverheadSize(std::size_t region_size) { | ||
| 177 | const std::size_t ref_count_size = (region_size / PageSize) * sizeof(u16); | ||
| 178 | const std::size_t optimize_map_size = | ||
| 179 | (Common::AlignUp((region_size / PageSize), Common::BitSize<u64>()) / | ||
| 180 | Common::BitSize<u64>()) * | ||
| 181 | sizeof(u64); | ||
| 182 | const std::size_t manager_meta_size = | ||
| 183 | Common::AlignUp(optimize_map_size + ref_count_size, PageSize); | ||
| 184 | const std::size_t page_heap_size = KPageHeap::CalculateManagementOverheadSize(region_size); | ||
| 185 | return manager_meta_size + page_heap_size; | ||
| 186 | } | ||
| 187 | |||
| 176 | } // namespace Kernel | 188 | } // 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: | |||
| 60 | static constexpr std::size_t MaxManagerCount = 10; | 60 | static constexpr std::size_t MaxManagerCount = 10; |
| 61 | 61 | ||
| 62 | public: | 62 | public: |
| 63 | static std::size_t CalculateManagementOverheadSize(std::size_t region_size) { | ||
| 64 | return Impl::CalculateManagementOverheadSize(region_size); | ||
| 65 | } | ||
| 66 | |||
| 63 | static constexpr u32 EncodeOption(Pool pool, Direction dir) { | 67 | static constexpr u32 EncodeOption(Pool pool, Direction dir) { |
| 64 | return (static_cast<u32>(pool) << static_cast<u32>(Pool::Shift)) | | 68 | return (static_cast<u32>(pool) << static_cast<u32>(Pool::Shift)) | |
| 65 | (static_cast<u32>(dir) << static_cast<u32>(Direction::Shift)); | 69 | (static_cast<u32>(dir) << static_cast<u32>(Direction::Shift)); |
| @@ -90,6 +94,16 @@ private: | |||
| 90 | Pool pool{}; | 94 | Pool pool{}; |
| 91 | 95 | ||
| 92 | public: | 96 | public: |
| 97 | static std::size_t CalculateManagementOverheadSize(std::size_t region_size); | ||
| 98 | |||
| 99 | static constexpr std::size_t CalculateOptimizedProcessOverheadSize( | ||
| 100 | std::size_t region_size) { | ||
| 101 | return (Common::AlignUp((region_size / PageSize), Common::BitSize<u64>()) / | ||
| 102 | Common::BitSize<u64>()) * | ||
| 103 | sizeof(u64); | ||
| 104 | } | ||
| 105 | |||
| 106 | public: | ||
| 93 | Impl() = default; | 107 | Impl() = default; |
| 94 | 108 | ||
| 95 | std::size_t Initialize(Pool new_pool, u64 start_address, u64 end_address); | 109 | std::size_t Initialize(Pool new_pool, u64 start_address, u64 end_address); |