diff options
| author | 2021-02-12 15:29:25 -0800 | |
|---|---|---|
| committer | 2021-02-18 16:16:24 -0800 | |
| commit | 701ef616b265d8914f77a399d9a1f41e68683a72 (patch) | |
| tree | 6aeef88a010acd35a15f421fffedbc70605251b7 /src/core/hle/kernel | |
| parent | hle: kernel: KSystemControl does not belong in Memory namespace. (diff) | |
| download | yuzu-701ef616b265d8914f77a399d9a1f41e68683a72.tar.gz yuzu-701ef616b265d8914f77a399d9a1f41e68683a72.tar.xz yuzu-701ef616b265d8914f77a399d9a1f41e68683a72.zip | |
hle: kernel: memory_manager: Rename AllocateContinuous to AllocateContinuous.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/memory/memory_manager.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/memory/memory_manager.h | 27 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/core/hle/kernel/memory/memory_manager.cpp b/src/core/hle/kernel/memory/memory_manager.cpp index c373d9947..ffda77374 100644 --- a/src/core/hle/kernel/memory/memory_manager.cpp +++ b/src/core/hle/kernel/memory/memory_manager.cpp | |||
| @@ -46,14 +46,15 @@ void MemoryManager::InitializeManager(Pool pool, u64 start_address, u64 end_addr | |||
| 46 | managers[static_cast<std::size_t>(pool)].Initialize(pool, start_address, end_address); | 46 | managers[static_cast<std::size_t>(pool)].Initialize(pool, start_address, end_address); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | VAddr MemoryManager::AllocateContinuous(std::size_t num_pages, std::size_t align_pages, Pool pool, | 49 | VAddr MemoryManager::AllocateAndOpenContinuous(std::size_t num_pages, std::size_t align_pages, |
| 50 | Direction dir) { | 50 | u32 option) { |
| 51 | // Early return if we're allocating no pages | 51 | // Early return if we're allocating no pages |
| 52 | if (num_pages == 0) { | 52 | if (num_pages == 0) { |
| 53 | return {}; | 53 | return {}; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | // Lock the pool that we're allocating from | 56 | // Lock the pool that we're allocating from |
| 57 | const auto [pool, dir] = DecodeOption(option); | ||
| 57 | const auto pool_index{static_cast<std::size_t>(pool)}; | 58 | const auto pool_index{static_cast<std::size_t>(pool)}; |
| 58 | std::lock_guard lock{pool_locks[pool_index]}; | 59 | std::lock_guard lock{pool_locks[pool_index]}; |
| 59 | 60 | ||
diff --git a/src/core/hle/kernel/memory/memory_manager.h b/src/core/hle/kernel/memory/memory_manager.h index 00c04eebd..80dfbc8c2 100644 --- a/src/core/hle/kernel/memory/memory_manager.h +++ b/src/core/hle/kernel/memory/memory_manager.h | |||
| @@ -6,7 +6,9 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <mutex> | 8 | #include <mutex> |
| 9 | #include <tuple> | ||
| 9 | 10 | ||
| 11 | #include "common/common_funcs.h" | ||
| 10 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 11 | #include "core/hle/kernel/memory/page_heap.h" | 13 | #include "core/hle/kernel/memory/page_heap.h" |
| 12 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| @@ -44,8 +46,8 @@ public: | |||
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | void InitializeManager(Pool pool, u64 start_address, u64 end_address); | 48 | void InitializeManager(Pool pool, u64 start_address, u64 end_address); |
| 47 | VAddr AllocateContinuous(std::size_t num_pages, std::size_t align_pages, Pool pool, | 49 | |
| 48 | Direction dir = Direction::FromFront); | 50 | VAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option); |
| 49 | ResultCode Allocate(PageLinkedList& page_list, std::size_t num_pages, Pool pool, | 51 | ResultCode Allocate(PageLinkedList& page_list, std::size_t num_pages, Pool pool, |
| 50 | Direction dir = Direction::FromFront); | 52 | Direction dir = Direction::FromFront); |
| 51 | ResultCode Free(PageLinkedList& page_list, std::size_t num_pages, Pool pool, | 53 | ResultCode Free(PageLinkedList& page_list, std::size_t num_pages, Pool pool, |
| @@ -53,6 +55,27 @@ public: | |||
| 53 | 55 | ||
| 54 | static constexpr std::size_t MaxManagerCount = 10; | 56 | static constexpr std::size_t MaxManagerCount = 10; |
| 55 | 57 | ||
| 58 | public: | ||
| 59 | static constexpr u32 EncodeOption(Pool pool, Direction dir) { | ||
| 60 | return (static_cast<u32>(pool) << static_cast<u32>(Pool::Shift)) | | ||
| 61 | (static_cast<u32>(dir) << static_cast<u32>(Direction::Shift)); | ||
| 62 | } | ||
| 63 | |||
| 64 | static constexpr Pool GetPool(u32 option) { | ||
| 65 | return static_cast<Pool>((static_cast<u32>(option) & static_cast<u32>(Pool::Mask)) >> | ||
| 66 | static_cast<u32>(Pool::Shift)); | ||
| 67 | } | ||
| 68 | |||
| 69 | static constexpr Direction GetDirection(u32 option) { | ||
| 70 | return static_cast<Direction>( | ||
| 71 | (static_cast<u32>(option) & static_cast<u32>(Direction::Mask)) >> | ||
| 72 | static_cast<u32>(Direction::Shift)); | ||
| 73 | } | ||
| 74 | |||
| 75 | static constexpr std::tuple<Pool, Direction> DecodeOption(u32 option) { | ||
| 76 | return std::make_tuple(GetPool(option), GetDirection(option)); | ||
| 77 | } | ||
| 78 | |||
| 56 | private: | 79 | private: |
| 57 | class Impl final : NonCopyable { | 80 | class Impl final : NonCopyable { |
| 58 | private: | 81 | private: |