diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/memory/address_space_info.cpp | 44 | ||||
| -rw-r--r-- | src/core/hle/kernel/memory/address_space_info.h | 29 |
2 files changed, 27 insertions, 46 deletions
diff --git a/src/core/hle/kernel/memory/address_space_info.cpp b/src/core/hle/kernel/memory/address_space_info.cpp index a523a2502..6f7f1614b 100644 --- a/src/core/hle/kernel/memory/address_space_info.cpp +++ b/src/core/hle/kernel/memory/address_space_info.cpp | |||
| @@ -29,24 +29,24 @@ enum : u64 { | |||
| 29 | 29 | ||
| 30 | // clang-format off | 30 | // clang-format off |
| 31 | constexpr std::array<AddressSpaceInfo, 13> AddressSpaceInfos{{ | 31 | constexpr std::array<AddressSpaceInfo, 13> AddressSpaceInfos{{ |
| 32 | { 32 /*bit_width*/, Size_2_MB /*addr*/, Size_1_GB - Size_2_MB /*size*/, AddressSpaceInfo::Type::Is32Bit, }, | 32 | { .bit_width = 32, .address = Size_2_MB , .size = Size_1_GB - Size_2_MB , .type = AddressSpaceInfo::Type::Is32Bit, }, |
| 33 | { 32 /*bit_width*/, Size_1_GB /*addr*/, Size_4_GB - Size_1_GB /*size*/, AddressSpaceInfo::Type::Small64Bit, }, | 33 | { .bit_width = 32, .address = Size_1_GB , .size = Size_4_GB - Size_1_GB , .type = AddressSpaceInfo::Type::Small64Bit, }, |
| 34 | { 32 /*bit_width*/, Invalid /*addr*/, Size_1_GB /*size*/, AddressSpaceInfo::Type::Heap, }, | 34 | { .bit_width = 32, .address = Invalid , .size = Size_1_GB , .type = AddressSpaceInfo::Type::Heap, }, |
| 35 | { 32 /*bit_width*/, Invalid /*addr*/, Size_1_GB /*size*/, AddressSpaceInfo::Type::Alias, }, | 35 | { .bit_width = 32, .address = Invalid , .size = Size_1_GB , .type = AddressSpaceInfo::Type::Alias, }, |
| 36 | { 36 /*bit_width*/, Size_128_MB /*addr*/, Size_2_GB - Size_128_MB /*size*/, AddressSpaceInfo::Type::Is32Bit, }, | 36 | { .bit_width = 36, .address = Size_128_MB, .size = Size_2_GB - Size_128_MB, .type = AddressSpaceInfo::Type::Is32Bit, }, |
| 37 | { 36 /*bit_width*/, Size_2_GB /*addr*/, Size_64_GB - Size_2_GB /*size*/, AddressSpaceInfo::Type::Small64Bit, }, | 37 | { .bit_width = 36, .address = Size_2_GB , .size = Size_64_GB - Size_2_GB , .type = AddressSpaceInfo::Type::Small64Bit, }, |
| 38 | { 36 /*bit_width*/, Invalid /*addr*/, Size_6_GB /*size*/, AddressSpaceInfo::Type::Heap, }, | 38 | { .bit_width = 36, .address = Invalid , .size = Size_6_GB , .type = AddressSpaceInfo::Type::Heap, }, |
| 39 | { 36 /*bit_width*/, Invalid /*addr*/, Size_6_GB /*size*/, AddressSpaceInfo::Type::Alias, }, | 39 | { .bit_width = 36, .address = Invalid , .size = Size_6_GB , .type = AddressSpaceInfo::Type::Alias, }, |
| 40 | { 39 /*bit_width*/, Size_128_MB /*addr*/, Size_512_GB - Size_128_MB /*size*/, AddressSpaceInfo::Type::Large64Bit, }, | 40 | { .bit_width = 39, .address = Size_128_MB, .size = Size_512_GB - Size_128_MB, .type = AddressSpaceInfo::Type::Large64Bit, }, |
| 41 | { 39 /*bit_width*/, Invalid /*addr*/, Size_64_GB /*size*/, AddressSpaceInfo::Type::Is32Bit }, | 41 | { .bit_width = 39, .address = Invalid , .size = Size_64_GB , .type = AddressSpaceInfo::Type::Is32Bit }, |
| 42 | { 39 /*bit_width*/, Invalid /*addr*/, Size_6_GB /*size*/, AddressSpaceInfo::Type::Heap, }, | 42 | { .bit_width = 39, .address = Invalid , .size = Size_6_GB , .type = AddressSpaceInfo::Type::Heap, }, |
| 43 | { 39 /*bit_width*/, Invalid /*addr*/, Size_64_GB /*size*/, AddressSpaceInfo::Type::Alias, }, | 43 | { .bit_width = 39, .address = Invalid , .size = Size_64_GB , .type = AddressSpaceInfo::Type::Alias, }, |
| 44 | { 39 /*bit_width*/, Invalid /*addr*/, Size_2_GB /*size*/, AddressSpaceInfo::Type::Stack, }, | 44 | { .bit_width = 39, .address = Invalid , .size = Size_2_GB , .type = AddressSpaceInfo::Type::Stack, }, |
| 45 | }}; | 45 | }}; |
| 46 | // clang-format on | 46 | // clang-format on |
| 47 | 47 | ||
| 48 | constexpr bool IsAllowedIndexForAddress(std::size_t index) { | 48 | constexpr bool IsAllowedIndexForAddress(std::size_t index) { |
| 49 | return index < std::size(AddressSpaceInfos) && AddressSpaceInfos[index].GetAddress() != Invalid; | 49 | return index < AddressSpaceInfos.size() && AddressSpaceInfos[index].address != Invalid; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | constexpr std::array<std::size_t, static_cast<std::size_t>(AddressSpaceInfo::Type::Count)> | 52 | constexpr std::array<std::size_t, static_cast<std::size_t>(AddressSpaceInfo::Type::Count)> |
| @@ -80,37 +80,37 @@ constexpr bool IsAllowed39BitType(AddressSpaceInfo::Type type) { | |||
| 80 | 80 | ||
| 81 | } // namespace | 81 | } // namespace |
| 82 | 82 | ||
| 83 | u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, AddressSpaceInfo::Type type) { | 83 | u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) { |
| 84 | const std::size_t index{static_cast<std::size_t>(type)}; | 84 | const std::size_t index{static_cast<std::size_t>(type)}; |
| 85 | switch (width) { | 85 | switch (width) { |
| 86 | case 32: | 86 | case 32: |
| 87 | ASSERT(IsAllowed32BitType(type)); | 87 | ASSERT(IsAllowed32BitType(type)); |
| 88 | ASSERT(IsAllowedIndexForAddress(AddressSpaceIndices32Bit[index])); | 88 | ASSERT(IsAllowedIndexForAddress(AddressSpaceIndices32Bit[index])); |
| 89 | return AddressSpaceInfos[AddressSpaceIndices32Bit[index]].GetAddress(); | 89 | return AddressSpaceInfos[AddressSpaceIndices32Bit[index]].address; |
| 90 | case 36: | 90 | case 36: |
| 91 | ASSERT(IsAllowed36BitType(type)); | 91 | ASSERT(IsAllowed36BitType(type)); |
| 92 | ASSERT(IsAllowedIndexForAddress(AddressSpaceIndices36Bit[index])); | 92 | ASSERT(IsAllowedIndexForAddress(AddressSpaceIndices36Bit[index])); |
| 93 | return AddressSpaceInfos[AddressSpaceIndices36Bit[index]].GetAddress(); | 93 | return AddressSpaceInfos[AddressSpaceIndices36Bit[index]].address; |
| 94 | case 39: | 94 | case 39: |
| 95 | ASSERT(IsAllowed39BitType(type)); | 95 | ASSERT(IsAllowed39BitType(type)); |
| 96 | ASSERT(IsAllowedIndexForAddress(AddressSpaceIndices39Bit[index])); | 96 | ASSERT(IsAllowedIndexForAddress(AddressSpaceIndices39Bit[index])); |
| 97 | return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].GetAddress(); | 97 | return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].address; |
| 98 | } | 98 | } |
| 99 | UNREACHABLE(); | 99 | UNREACHABLE(); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, AddressSpaceInfo::Type type) { | 102 | std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) { |
| 103 | const std::size_t index{static_cast<std::size_t>(type)}; | 103 | const std::size_t index{static_cast<std::size_t>(type)}; |
| 104 | switch (width) { | 104 | switch (width) { |
| 105 | case 32: | 105 | case 32: |
| 106 | ASSERT(IsAllowed32BitType(type)); | 106 | ASSERT(IsAllowed32BitType(type)); |
| 107 | return AddressSpaceInfos[AddressSpaceIndices32Bit[index]].GetSize(); | 107 | return AddressSpaceInfos[AddressSpaceIndices32Bit[index]].size; |
| 108 | case 36: | 108 | case 36: |
| 109 | ASSERT(IsAllowed36BitType(type)); | 109 | ASSERT(IsAllowed36BitType(type)); |
| 110 | return AddressSpaceInfos[AddressSpaceIndices36Bit[index]].GetSize(); | 110 | return AddressSpaceInfos[AddressSpaceIndices36Bit[index]].size; |
| 111 | case 39: | 111 | case 39: |
| 112 | ASSERT(IsAllowed39BitType(type)); | 112 | ASSERT(IsAllowed39BitType(type)); |
| 113 | return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].GetSize(); | 113 | return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].size; |
| 114 | } | 114 | } |
| 115 | UNREACHABLE(); | 115 | UNREACHABLE(); |
| 116 | } | 116 | } |
diff --git a/src/core/hle/kernel/memory/address_space_info.h b/src/core/hle/kernel/memory/address_space_info.h index c479890be..a4e6e91e5 100644 --- a/src/core/hle/kernel/memory/address_space_info.h +++ b/src/core/hle/kernel/memory/address_space_info.h | |||
| @@ -11,8 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | namespace Kernel::Memory { | 12 | namespace Kernel::Memory { |
| 13 | 13 | ||
| 14 | class AddressSpaceInfo final : NonCopyable { | 14 | struct AddressSpaceInfo final { |
| 15 | public: | ||
| 16 | enum class Type : u32 { | 15 | enum class Type : u32 { |
| 17 | Is32Bit = 0, | 16 | Is32Bit = 0, |
| 18 | Small64Bit = 1, | 17 | Small64Bit = 1, |
| @@ -23,31 +22,13 @@ public: | |||
| 23 | Count, | 22 | Count, |
| 24 | }; | 23 | }; |
| 25 | 24 | ||
| 26 | private: | ||
| 27 | std::size_t bit_width{}; | ||
| 28 | std::size_t addr{}; | ||
| 29 | std::size_t size{}; | ||
| 30 | Type type{}; | ||
| 31 | |||
| 32 | public: | ||
| 33 | static u64 GetAddressSpaceStart(std::size_t width, Type type); | 25 | static u64 GetAddressSpaceStart(std::size_t width, Type type); |
| 34 | static std::size_t GetAddressSpaceSize(std::size_t width, Type type); | 26 | static std::size_t GetAddressSpaceSize(std::size_t width, Type type); |
| 35 | 27 | ||
| 36 | constexpr AddressSpaceInfo(std::size_t bit_width, std::size_t addr, std::size_t size, Type type) | 28 | const std::size_t bit_width{}; |
| 37 | : bit_width{bit_width}, addr{addr}, size{size}, type{type} {} | 29 | const std::size_t address{}; |
| 38 | 30 | const std::size_t size{}; | |
| 39 | constexpr std::size_t GetWidth() const { | 31 | const Type type{}; |
| 40 | return bit_width; | ||
| 41 | } | ||
| 42 | constexpr std::size_t GetAddress() const { | ||
| 43 | return addr; | ||
| 44 | } | ||
| 45 | constexpr std::size_t GetSize() const { | ||
| 46 | return size; | ||
| 47 | } | ||
| 48 | constexpr Type GetType() const { | ||
| 49 | return type; | ||
| 50 | } | ||
| 51 | }; | 32 | }; |
| 52 | 33 | ||
| 53 | } // namespace Kernel::Memory | 34 | } // namespace Kernel::Memory |