diff options
| author | 2021-06-23 14:18:27 -0700 | |
|---|---|---|
| committer | 2021-06-24 09:27:40 -0700 | |
| commit | 4569f39c7c1e3d7ce010f0b120e1f45dbba17b1c (patch) | |
| tree | 591792bc47e26bc812e753b0891aab94a8a88352 /src/core/hle/kernel | |
| parent | Merge pull request #6504 from Kelebek1/samples-played (diff) | |
| download | yuzu-4569f39c7c1e3d7ce010f0b120e1f45dbba17b1c.tar.gz yuzu-4569f39c7c1e3d7ce010f0b120e1f45dbba17b1c.tar.xz yuzu-4569f39c7c1e3d7ce010f0b120e1f45dbba17b1c.zip | |
common: Replace common_sizes into user-literals
Removes common_sizes.h in favor of having `_KiB`, `_MiB`, `_GiB`, etc
user-literals within literals.h.
To keep the global namespace clean, users will have to use:
```
using namespace Common::Literals;
```
to access these literals.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 37 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_address_space_info.cpp | 35 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_memory_layout.h | 27 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_page_table.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_trace.h | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 17 |
7 files changed, 74 insertions, 58 deletions
diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 86472b5ce..6f335c251 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | |||
| @@ -4,7 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include <random> | 5 | #include <random> |
| 6 | 6 | ||
| 7 | #include "common/common_sizes.h" | 7 | #include "common/literals.h" |
| 8 | |||
| 8 | #include "core/hle/kernel/board/nintendo/nx/k_system_control.h" | 9 | #include "core/hle/kernel/board/nintendo/nx/k_system_control.h" |
| 9 | #include "core/hle/kernel/board/nintendo/nx/secure_monitor.h" | 10 | #include "core/hle/kernel/board/nintendo/nx/secure_monitor.h" |
| 10 | #include "core/hle/kernel/k_trace.h" | 11 | #include "core/hle/kernel/k_trace.h" |
| @@ -25,6 +26,8 @@ constexpr const std::size_t RequiredNonSecureSystemMemorySize = | |||
| 25 | 26 | ||
| 26 | namespace { | 27 | namespace { |
| 27 | 28 | ||
| 29 | using namespace Common::Literals; | ||
| 30 | |||
| 28 | u32 GetMemoryModeForInit() { | 31 | u32 GetMemoryModeForInit() { |
| 29 | return 0x01; | 32 | return 0x01; |
| 30 | } | 33 | } |
| @@ -57,11 +60,11 @@ size_t KSystemControl::Init::GetIntendedMemorySize() { | |||
| 57 | switch (GetMemorySizeForInit()) { | 60 | switch (GetMemorySizeForInit()) { |
| 58 | case Smc::MemorySize_4GB: | 61 | case Smc::MemorySize_4GB: |
| 59 | default: // All invalid modes should go to 4GB. | 62 | default: // All invalid modes should go to 4GB. |
| 60 | return Common::Size_4_GB; | 63 | return 4_GiB; |
| 61 | case Smc::MemorySize_6GB: | 64 | case Smc::MemorySize_6GB: |
| 62 | return Common::Size_6_GB; | 65 | return 6_GiB; |
| 63 | case Smc::MemorySize_8GB: | 66 | case Smc::MemorySize_8GB: |
| 64 | return Common::Size_8_GB; | 67 | return 8_GiB; |
| 65 | } | 68 | } |
| 66 | } | 69 | } |
| 67 | 70 | ||
| @@ -79,17 +82,17 @@ std::size_t KSystemControl::Init::GetApplicationPoolSize() { | |||
| 79 | switch (GetMemoryArrangeForInit()) { | 82 | switch (GetMemoryArrangeForInit()) { |
| 80 | case Smc::MemoryArrangement_4GB: | 83 | case Smc::MemoryArrangement_4GB: |
| 81 | default: | 84 | default: |
| 82 | return Common::Size_3285_MB; | 85 | return 3285_MiB; |
| 83 | case Smc::MemoryArrangement_4GBForAppletDev: | 86 | case Smc::MemoryArrangement_4GBForAppletDev: |
| 84 | return Common::Size_2048_MB; | 87 | return 2048_MiB; |
| 85 | case Smc::MemoryArrangement_4GBForSystemDev: | 88 | case Smc::MemoryArrangement_4GBForSystemDev: |
| 86 | return Common::Size_3285_MB; | 89 | return 3285_MiB; |
| 87 | case Smc::MemoryArrangement_6GB: | 90 | case Smc::MemoryArrangement_6GB: |
| 88 | return Common::Size_4916_MB; | 91 | return 4916_MiB; |
| 89 | case Smc::MemoryArrangement_6GBForAppletDev: | 92 | case Smc::MemoryArrangement_6GBForAppletDev: |
| 90 | return Common::Size_3285_MB; | 93 | return 3285_MiB; |
| 91 | case Smc::MemoryArrangement_8GB: | 94 | case Smc::MemoryArrangement_8GB: |
| 92 | return Common::Size_4916_MB; | 95 | return 4916_MiB; |
| 93 | } | 96 | } |
| 94 | }(); | 97 | }(); |
| 95 | 98 | ||
| @@ -103,22 +106,22 @@ size_t KSystemControl::Init::GetAppletPoolSize() { | |||
| 103 | switch (GetMemoryArrangeForInit()) { | 106 | switch (GetMemoryArrangeForInit()) { |
| 104 | case Smc::MemoryArrangement_4GB: | 107 | case Smc::MemoryArrangement_4GB: |
| 105 | default: | 108 | default: |
| 106 | return Common::Size_507_MB; | 109 | return 507_MiB; |
| 107 | case Smc::MemoryArrangement_4GBForAppletDev: | 110 | case Smc::MemoryArrangement_4GBForAppletDev: |
| 108 | return Common::Size_1554_MB; | 111 | return 1554_MiB; |
| 109 | case Smc::MemoryArrangement_4GBForSystemDev: | 112 | case Smc::MemoryArrangement_4GBForSystemDev: |
| 110 | return Common::Size_448_MB; | 113 | return 448_MiB; |
| 111 | case Smc::MemoryArrangement_6GB: | 114 | case Smc::MemoryArrangement_6GB: |
| 112 | return Common::Size_562_MB; | 115 | return 562_MiB; |
| 113 | case Smc::MemoryArrangement_6GBForAppletDev: | 116 | case Smc::MemoryArrangement_6GBForAppletDev: |
| 114 | return Common::Size_2193_MB; | 117 | return 2193_MiB; |
| 115 | case Smc::MemoryArrangement_8GB: | 118 | case Smc::MemoryArrangement_8GB: |
| 116 | return Common::Size_2193_MB; | 119 | return 2193_MiB; |
| 117 | } | 120 | } |
| 118 | }(); | 121 | }(); |
| 119 | 122 | ||
| 120 | // Return (possibly) adjusted size. | 123 | // Return (possibly) adjusted size. |
| 121 | constexpr size_t ExtraSystemMemoryForAtmosphere = Common::Size_33_MB; | 124 | constexpr size_t ExtraSystemMemoryForAtmosphere = 33_MiB; |
| 122 | return base_pool_size - ExtraSystemMemoryForAtmosphere - KTraceBufferSize; | 125 | return base_pool_size - ExtraSystemMemoryForAtmosphere - KTraceBufferSize; |
| 123 | } | 126 | } |
| 124 | 127 | ||
diff --git a/src/core/hle/kernel/k_address_space_info.cpp b/src/core/hle/kernel/k_address_space_info.cpp index c7549f7a2..ca29edc88 100644 --- a/src/core/hle/kernel/k_address_space_info.cpp +++ b/src/core/hle/kernel/k_address_space_info.cpp | |||
| @@ -5,34 +5,37 @@ | |||
| 5 | #include <array> | 5 | #include <array> |
| 6 | 6 | ||
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/common_sizes.h" | 8 | #include "common/literals.h" |
| 9 | #include "core/hle/kernel/k_address_space_info.h" | 9 | #include "core/hle/kernel/k_address_space_info.h" |
| 10 | 10 | ||
| 11 | namespace Kernel { | 11 | namespace Kernel { |
| 12 | 12 | ||
| 13 | namespace { | 13 | namespace { |
| 14 | 14 | ||
| 15 | using namespace Common::Literals; | ||
| 16 | |||
| 17 | constexpr u64 Size_Invalid = UINT64_MAX; | ||
| 18 | |||
| 15 | // clang-format off | 19 | // clang-format off |
| 16 | constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{ | 20 | constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{ |
| 17 | { .bit_width = 32, .address = Common::Size_2_MB , .size = Common::Size_1_GB - Common::Size_2_MB , .type = KAddressSpaceInfo::Type::MapSmall, }, | 21 | { .bit_width = 32, .address = 2_MiB , .size = 1_GiB - 2_MiB , .type = KAddressSpaceInfo::Type::MapSmall, }, |
| 18 | { .bit_width = 32, .address = Common::Size_1_GB , .size = Common::Size_4_GB - Common::Size_1_GB , .type = KAddressSpaceInfo::Type::MapLarge, }, | 22 | { .bit_width = 32, .address = 1_GiB , .size = 4_GiB - 1_GiB , .type = KAddressSpaceInfo::Type::MapLarge, }, |
| 19 | { .bit_width = 32, .address = Common::Size_Invalid, .size = Common::Size_1_GB , .type = KAddressSpaceInfo::Type::Alias, }, | 23 | { .bit_width = 32, .address = Size_Invalid, .size = 1_GiB , .type = KAddressSpaceInfo::Type::Alias, }, |
| 20 | { .bit_width = 32, .address = Common::Size_Invalid, .size = Common::Size_1_GB , .type = KAddressSpaceInfo::Type::Heap, }, | 24 | { .bit_width = 32, .address = Size_Invalid, .size = 1_GiB , .type = KAddressSpaceInfo::Type::Heap, }, |
| 21 | { .bit_width = 36, .address = Common::Size_128_MB , .size = Common::Size_2_GB - Common::Size_128_MB, .type = KAddressSpaceInfo::Type::MapSmall, }, | 25 | { .bit_width = 36, .address = 128_MiB , .size = 2_GiB - 128_MiB, .type = KAddressSpaceInfo::Type::MapSmall, }, |
| 22 | { .bit_width = 36, .address = Common::Size_2_GB , .size = Common::Size_64_GB - Common::Size_2_GB , .type = KAddressSpaceInfo::Type::MapLarge, }, | 26 | { .bit_width = 36, .address = 2_GiB , .size = 64_GiB - 2_GiB , .type = KAddressSpaceInfo::Type::MapLarge, }, |
| 23 | { .bit_width = 36, .address = Common::Size_Invalid, .size = Common::Size_6_GB , .type = KAddressSpaceInfo::Type::Heap, }, | 27 | { .bit_width = 36, .address = Size_Invalid, .size = 6_GiB , .type = KAddressSpaceInfo::Type::Heap, }, |
| 24 | { .bit_width = 36, .address = Common::Size_Invalid, .size = Common::Size_6_GB , .type = KAddressSpaceInfo::Type::Alias, }, | 28 | { .bit_width = 36, .address = Size_Invalid, .size = 6_GiB , .type = KAddressSpaceInfo::Type::Alias, }, |
| 25 | { .bit_width = 39, .address = Common::Size_128_MB , .size = Common::Size_512_GB - Common::Size_128_MB, .type = KAddressSpaceInfo::Type::Map39Bit, }, | 29 | { .bit_width = 39, .address = 128_MiB , .size = 512_GiB - 128_MiB, .type = KAddressSpaceInfo::Type::Map39Bit, }, |
| 26 | { .bit_width = 39, .address = Common::Size_Invalid, .size = Common::Size_64_GB , .type = KAddressSpaceInfo::Type::MapSmall }, | 30 | { .bit_width = 39, .address = Size_Invalid, .size = 64_GiB , .type = KAddressSpaceInfo::Type::MapSmall }, |
| 27 | { .bit_width = 39, .address = Common::Size_Invalid, .size = Common::Size_6_GB , .type = KAddressSpaceInfo::Type::Heap, }, | 31 | { .bit_width = 39, .address = Size_Invalid, .size = 6_GiB , .type = KAddressSpaceInfo::Type::Heap, }, |
| 28 | { .bit_width = 39, .address = Common::Size_Invalid, .size = Common::Size_64_GB , .type = KAddressSpaceInfo::Type::Alias, }, | 32 | { .bit_width = 39, .address = Size_Invalid, .size = 64_GiB , .type = KAddressSpaceInfo::Type::Alias, }, |
| 29 | { .bit_width = 39, .address = Common::Size_Invalid, .size = Common::Size_2_GB , .type = KAddressSpaceInfo::Type::Stack, }, | 33 | { .bit_width = 39, .address = Size_Invalid, .size = 2_GiB , .type = KAddressSpaceInfo::Type::Stack, }, |
| 30 | }}; | 34 | }}; |
| 31 | // clang-format on | 35 | // clang-format on |
| 32 | 36 | ||
| 33 | constexpr bool IsAllowedIndexForAddress(std::size_t index) { | 37 | constexpr bool IsAllowedIndexForAddress(std::size_t index) { |
| 34 | return index < AddressSpaceInfos.size() && | 38 | return index < AddressSpaceInfos.size() && AddressSpaceInfos[index].address != Size_Invalid; |
| 35 | AddressSpaceInfos[index].address != Common::Size_Invalid; | ||
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | using IndexArray = | 41 | using IndexArray = |
diff --git a/src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp b/src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp index a78551291..af652af58 100644 --- a/src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp +++ b/src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/alignment.h" | 5 | #include "common/alignment.h" |
| 6 | #include "common/literals.h" | ||
| 6 | #include "core/hle/kernel/k_memory_layout.h" | 7 | #include "core/hle/kernel/k_memory_layout.h" |
| 7 | #include "core/hle/kernel/k_memory_manager.h" | 8 | #include "core/hle/kernel/k_memory_manager.h" |
| 8 | #include "core/hle/kernel/k_system_control.h" | 9 | #include "core/hle/kernel/k_system_control.h" |
| @@ -12,8 +13,10 @@ namespace Kernel { | |||
| 12 | 13 | ||
| 13 | namespace { | 14 | namespace { |
| 14 | 15 | ||
| 16 | using namespace Common::Literals; | ||
| 17 | |||
| 15 | constexpr size_t CarveoutAlignment = 0x20000; | 18 | constexpr size_t CarveoutAlignment = 0x20000; |
| 16 | constexpr size_t CarveoutSizeMax = (512ULL * 1024 * 1024) - CarveoutAlignment; | 19 | constexpr size_t CarveoutSizeMax = (512_MiB) - CarveoutAlignment; |
| 17 | 20 | ||
| 18 | bool SetupPowerManagementControllerMemoryRegion(KMemoryLayout& memory_layout) { | 21 | bool SetupPowerManagementControllerMemoryRegion(KMemoryLayout& memory_layout) { |
| 19 | // Above firmware 2.0.0, the PMC is not mappable. | 22 | // Above firmware 2.0.0, the PMC is not mappable. |
diff --git a/src/core/hle/kernel/k_memory_layout.h b/src/core/hle/kernel/k_memory_layout.h index 288642d9a..57ff538cc 100644 --- a/src/core/hle/kernel/k_memory_layout.h +++ b/src/core/hle/kernel/k_memory_layout.h | |||
| @@ -7,8 +7,7 @@ | |||
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | 8 | ||
| 9 | #include "common/alignment.h" | 9 | #include "common/alignment.h" |
| 10 | #include "common/common_sizes.h" | 10 | #include "common/literals.h" |
| 11 | #include "common/common_types.h" | ||
| 12 | #include "core/device_memory.h" | 11 | #include "core/device_memory.h" |
| 13 | #include "core/hle/kernel/k_memory_region.h" | 12 | #include "core/hle/kernel/k_memory_region.h" |
| 14 | #include "core/hle/kernel/k_memory_region_type.h" | 13 | #include "core/hle/kernel/k_memory_region_type.h" |
| @@ -16,20 +15,22 @@ | |||
| 16 | 15 | ||
| 17 | namespace Kernel { | 16 | namespace Kernel { |
| 18 | 17 | ||
| 19 | constexpr std::size_t L1BlockSize = Common::Size_1_GB; | 18 | using namespace Common::Literals; |
| 20 | constexpr std::size_t L2BlockSize = Common::Size_2_MB; | 19 | |
| 20 | constexpr std::size_t L1BlockSize = 1_GiB; | ||
| 21 | constexpr std::size_t L2BlockSize = 2_MiB; | ||
| 21 | 22 | ||
| 22 | constexpr std::size_t GetMaximumOverheadSize(std::size_t size) { | 23 | constexpr std::size_t GetMaximumOverheadSize(std::size_t size) { |
| 23 | return (Common::DivideUp(size, L1BlockSize) + Common::DivideUp(size, L2BlockSize)) * PageSize; | 24 | return (Common::DivideUp(size, L1BlockSize) + Common::DivideUp(size, L2BlockSize)) * PageSize; |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | constexpr std::size_t MainMemorySize = Common::Size_4_GB; | 27 | constexpr std::size_t MainMemorySize = 4_GiB; |
| 27 | constexpr std::size_t MainMemorySizeMax = Common::Size_8_GB; | 28 | constexpr std::size_t MainMemorySizeMax = 8_GiB; |
| 28 | 29 | ||
| 29 | constexpr std::size_t ReservedEarlyDramSize = 0x60000; | 30 | constexpr std::size_t ReservedEarlyDramSize = 384_KiB; |
| 30 | constexpr std::size_t DramPhysicalAddress = 0x80000000; | 31 | constexpr std::size_t DramPhysicalAddress = 0x80000000; |
| 31 | 32 | ||
| 32 | constexpr std::size_t KernelAslrAlignment = Common::Size_2_MB; | 33 | constexpr std::size_t KernelAslrAlignment = 2_MiB; |
| 33 | constexpr std::size_t KernelVirtualAddressSpaceWidth = 1ULL << 39; | 34 | constexpr std::size_t KernelVirtualAddressSpaceWidth = 1ULL << 39; |
| 34 | constexpr std::size_t KernelPhysicalAddressSpaceWidth = 1ULL << 48; | 35 | constexpr std::size_t KernelPhysicalAddressSpaceWidth = 1ULL << 48; |
| 35 | 36 | ||
| @@ -40,7 +41,7 @@ constexpr std::size_t KernelVirtualAddressSpaceLast = KernelVirtualAddressSpaceE | |||
| 40 | constexpr std::size_t KernelVirtualAddressSpaceSize = | 41 | constexpr std::size_t KernelVirtualAddressSpaceSize = |
| 41 | KernelVirtualAddressSpaceEnd - KernelVirtualAddressSpaceBase; | 42 | KernelVirtualAddressSpaceEnd - KernelVirtualAddressSpaceBase; |
| 42 | constexpr std::size_t KernelVirtualAddressCodeBase = KernelVirtualAddressSpaceBase; | 43 | constexpr std::size_t KernelVirtualAddressCodeBase = KernelVirtualAddressSpaceBase; |
| 43 | constexpr std::size_t KernelVirtualAddressCodeSize = 0x62000; | 44 | constexpr std::size_t KernelVirtualAddressCodeSize = 392_KiB; |
| 44 | constexpr std::size_t KernelVirtualAddressCodeEnd = | 45 | constexpr std::size_t KernelVirtualAddressCodeEnd = |
| 45 | KernelVirtualAddressCodeBase + KernelVirtualAddressCodeSize; | 46 | KernelVirtualAddressCodeBase + KernelVirtualAddressCodeSize; |
| 46 | 47 | ||
| @@ -53,14 +54,14 @@ constexpr std::size_t KernelPhysicalAddressSpaceSize = | |||
| 53 | constexpr std::size_t KernelPhysicalAddressCodeBase = DramPhysicalAddress + ReservedEarlyDramSize; | 54 | constexpr std::size_t KernelPhysicalAddressCodeBase = DramPhysicalAddress + ReservedEarlyDramSize; |
| 54 | 55 | ||
| 55 | constexpr std::size_t KernelPageTableHeapSize = GetMaximumOverheadSize(MainMemorySizeMax); | 56 | constexpr std::size_t KernelPageTableHeapSize = GetMaximumOverheadSize(MainMemorySizeMax); |
| 56 | constexpr std::size_t KernelInitialPageHeapSize = Common::Size_128_KB; | 57 | constexpr std::size_t KernelInitialPageHeapSize = 128_KiB; |
| 57 | 58 | ||
| 58 | constexpr std::size_t KernelSlabHeapDataSize = Common::Size_5_MB; | 59 | constexpr std::size_t KernelSlabHeapDataSize = 5_MiB; |
| 59 | constexpr std::size_t KernelSlabHeapGapsSize = Common::Size_2_MB - Common::Size_64_KB; | 60 | constexpr std::size_t KernelSlabHeapGapsSize = 2_MiB - 64_KiB; |
| 60 | constexpr std::size_t KernelSlabHeapSize = KernelSlabHeapDataSize + KernelSlabHeapGapsSize; | 61 | constexpr std::size_t KernelSlabHeapSize = KernelSlabHeapDataSize + KernelSlabHeapGapsSize; |
| 61 | 62 | ||
| 62 | // NOTE: This is calculated from KThread slab counts, assuming KThread size <= 0x860. | 63 | // NOTE: This is calculated from KThread slab counts, assuming KThread size <= 0x860. |
| 63 | constexpr std::size_t KernelSlabHeapAdditionalSize = 0x68000ULL; | 64 | constexpr std::size_t KernelSlabHeapAdditionalSize = 416_KiB; |
| 64 | 65 | ||
| 65 | constexpr std::size_t KernelResourceSize = | 66 | constexpr std::size_t KernelResourceSize = |
| 66 | KernelPageTableHeapSize + KernelInitialPageHeapSize + KernelSlabHeapSize; | 67 | KernelPageTableHeapSize + KernelInitialPageHeapSize + KernelSlabHeapSize; |
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 66d260635..701268545 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/alignment.h" | 5 | #include "common/alignment.h" |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/literals.h" | ||
| 7 | #include "common/scope_exit.h" | 8 | #include "common/scope_exit.h" |
| 8 | #include "core/core.h" | 9 | #include "core/core.h" |
| 9 | #include "core/hle/kernel/k_address_space_info.h" | 10 | #include "core/hle/kernel/k_address_space_info.h" |
| @@ -23,6 +24,8 @@ namespace Kernel { | |||
| 23 | 24 | ||
| 24 | namespace { | 25 | namespace { |
| 25 | 26 | ||
| 27 | using namespace Common::Literals; | ||
| 28 | |||
| 26 | constexpr std::size_t GetAddressSpaceWidthFromType(FileSys::ProgramAddressSpaceType as_type) { | 29 | constexpr std::size_t GetAddressSpaceWidthFromType(FileSys::ProgramAddressSpaceType as_type) { |
| 27 | switch (as_type) { | 30 | switch (as_type) { |
| 28 | case FileSys::ProgramAddressSpaceType::Is32Bit: | 31 | case FileSys::ProgramAddressSpaceType::Is32Bit: |
| @@ -89,7 +92,7 @@ ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_ | |||
| 89 | } | 92 | } |
| 90 | 93 | ||
| 91 | // Set code regions and determine remaining | 94 | // Set code regions and determine remaining |
| 92 | constexpr std::size_t RegionAlignment{2 * 1024 * 1024}; | 95 | constexpr std::size_t RegionAlignment{2_MiB}; |
| 93 | VAddr process_code_start{}; | 96 | VAddr process_code_start{}; |
| 94 | VAddr process_code_end{}; | 97 | VAddr process_code_end{}; |
| 95 | std::size_t stack_region_size{}; | 98 | std::size_t stack_region_size{}; |
diff --git a/src/core/hle/kernel/k_trace.h b/src/core/hle/kernel/k_trace.h index 91ebf9ab2..79391bccb 100644 --- a/src/core/hle/kernel/k_trace.h +++ b/src/core/hle/kernel/k_trace.h | |||
| @@ -4,9 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_funcs.h" | ||
| 8 | |||
| 7 | namespace Kernel { | 9 | namespace Kernel { |
| 8 | 10 | ||
| 11 | using namespace Common::Literals; | ||
| 12 | |||
| 9 | constexpr bool IsKTraceEnabled = false; | 13 | constexpr bool IsKTraceEnabled = false; |
| 10 | constexpr std::size_t KTraceBufferSize = IsKTraceEnabled ? 16 * 1024 * 1024 : 0; | 14 | constexpr std::size_t KTraceBufferSize = IsKTraceEnabled ? 16_MiB : 0; |
| 11 | 15 | ||
| 12 | } // namespace Kernel | 16 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 2ceeaeb5f..64bd0c494 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include <utility> | 12 | #include <utility> |
| 13 | 13 | ||
| 14 | #include "common/assert.h" | 14 | #include "common/assert.h" |
| 15 | #include "common/common_sizes.h" | ||
| 16 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 17 | #include "common/microprofile.h" | 16 | #include "common/microprofile.h" |
| 18 | #include "common/thread.h" | 17 | #include "common/thread.h" |
| @@ -180,7 +179,7 @@ struct KernelCore::Impl { | |||
| 180 | system_resource_limit->Reserve(LimitableResource::PhysicalMemory, kernel_size); | 179 | system_resource_limit->Reserve(LimitableResource::PhysicalMemory, kernel_size); |
| 181 | 180 | ||
| 182 | // Reserve secure applet memory, introduced in firmware 5.0.0 | 181 | // Reserve secure applet memory, introduced in firmware 5.0.0 |
| 183 | constexpr u64 secure_applet_memory_size{Common::Size_4_MB}; | 182 | constexpr u64 secure_applet_memory_size{4_MiB}; |
| 184 | ASSERT(system_resource_limit->Reserve(LimitableResource::PhysicalMemory, | 183 | ASSERT(system_resource_limit->Reserve(LimitableResource::PhysicalMemory, |
| 185 | secure_applet_memory_size)); | 184 | secure_applet_memory_size)); |
| 186 | 185 | ||
| @@ -320,8 +319,8 @@ struct KernelCore::Impl { | |||
| 320 | const VAddr code_end_virt_addr = KernelVirtualAddressCodeEnd; | 319 | const VAddr code_end_virt_addr = KernelVirtualAddressCodeEnd; |
| 321 | 320 | ||
| 322 | // Setup the containing kernel region. | 321 | // Setup the containing kernel region. |
| 323 | constexpr size_t KernelRegionSize = Common::Size_1_GB; | 322 | constexpr size_t KernelRegionSize = 1_GiB; |
| 324 | constexpr size_t KernelRegionAlign = Common::Size_1_GB; | 323 | constexpr size_t KernelRegionAlign = 1_GiB; |
| 325 | constexpr VAddr kernel_region_start = | 324 | constexpr VAddr kernel_region_start = |
| 326 | Common::AlignDown(code_start_virt_addr, KernelRegionAlign); | 325 | Common::AlignDown(code_start_virt_addr, KernelRegionAlign); |
| 327 | size_t kernel_region_size = KernelRegionSize; | 326 | size_t kernel_region_size = KernelRegionSize; |
| @@ -368,7 +367,7 @@ struct KernelCore::Impl { | |||
| 368 | 367 | ||
| 369 | // Decide on the actual size for the misc region. | 368 | // Decide on the actual size for the misc region. |
| 370 | constexpr size_t MiscRegionAlign = KernelAslrAlignment; | 369 | constexpr size_t MiscRegionAlign = KernelAslrAlignment; |
| 371 | constexpr size_t MiscRegionMinimumSize = Common::Size_32_MB; | 370 | constexpr size_t MiscRegionMinimumSize = 32_MiB; |
| 372 | const size_t misc_region_size = Common::AlignUp( | 371 | const size_t misc_region_size = Common::AlignUp( |
| 373 | std::max(misc_region_needed_size, MiscRegionMinimumSize), MiscRegionAlign); | 372 | std::max(misc_region_needed_size, MiscRegionMinimumSize), MiscRegionAlign); |
| 374 | ASSERT(misc_region_size > 0); | 373 | ASSERT(misc_region_size > 0); |
| @@ -381,7 +380,7 @@ struct KernelCore::Impl { | |||
| 381 | misc_region_start, misc_region_size, KMemoryRegionType_KernelMisc)); | 380 | misc_region_start, misc_region_size, KMemoryRegionType_KernelMisc)); |
| 382 | 381 | ||
| 383 | // Setup the stack region. | 382 | // Setup the stack region. |
| 384 | constexpr size_t StackRegionSize = Common::Size_14_MB; | 383 | constexpr size_t StackRegionSize = 14_MiB; |
| 385 | constexpr size_t StackRegionAlign = KernelAslrAlignment; | 384 | constexpr size_t StackRegionAlign = KernelAslrAlignment; |
| 386 | const VAddr stack_region_start = | 385 | const VAddr stack_region_start = |
| 387 | memory_layout.GetVirtualMemoryRegionTree().GetRandomAlignedRegion( | 386 | memory_layout.GetVirtualMemoryRegionTree().GetRandomAlignedRegion( |
| @@ -414,7 +413,7 @@ struct KernelCore::Impl { | |||
| 414 | slab_region_start, slab_region_size, KMemoryRegionType_KernelSlab)); | 413 | slab_region_start, slab_region_size, KMemoryRegionType_KernelSlab)); |
| 415 | 414 | ||
| 416 | // Setup the temp region. | 415 | // Setup the temp region. |
| 417 | constexpr size_t TempRegionSize = Common::Size_128_MB; | 416 | constexpr size_t TempRegionSize = 128_MiB; |
| 418 | constexpr size_t TempRegionAlign = KernelAslrAlignment; | 417 | constexpr size_t TempRegionAlign = KernelAslrAlignment; |
| 419 | const VAddr temp_region_start = | 418 | const VAddr temp_region_start = |
| 420 | memory_layout.GetVirtualMemoryRegionTree().GetRandomAlignedRegion( | 419 | memory_layout.GetVirtualMemoryRegionTree().GetRandomAlignedRegion( |
| @@ -470,7 +469,7 @@ struct KernelCore::Impl { | |||
| 470 | // Determine size available for kernel page table heaps, requiring > 8 MB. | 469 | // Determine size available for kernel page table heaps, requiring > 8 MB. |
| 471 | const PAddr resource_end_phys_addr = slab_start_phys_addr + resource_region_size; | 470 | const PAddr resource_end_phys_addr = slab_start_phys_addr + resource_region_size; |
| 472 | const size_t page_table_heap_size = resource_end_phys_addr - slab_end_phys_addr; | 471 | const size_t page_table_heap_size = resource_end_phys_addr - slab_end_phys_addr; |
| 473 | ASSERT(page_table_heap_size / Common::Size_4_MB > 2); | 472 | ASSERT(page_table_heap_size / 4_MiB > 2); |
| 474 | 473 | ||
| 475 | // Insert a physical region for the kernel page table heap region | 474 | // Insert a physical region for the kernel page table heap region |
| 476 | ASSERT(memory_layout.GetPhysicalMemoryRegionTree().Insert( | 475 | ASSERT(memory_layout.GetPhysicalMemoryRegionTree().Insert( |
| @@ -495,7 +494,7 @@ struct KernelCore::Impl { | |||
| 495 | ASSERT(linear_extents.GetEndAddress() != 0); | 494 | ASSERT(linear_extents.GetEndAddress() != 0); |
| 496 | 495 | ||
| 497 | // Setup the linear mapping region. | 496 | // Setup the linear mapping region. |
| 498 | constexpr size_t LinearRegionAlign = Common::Size_1_GB; | 497 | constexpr size_t LinearRegionAlign = 1_GiB; |
| 499 | const PAddr aligned_linear_phys_start = | 498 | const PAddr aligned_linear_phys_start = |
| 500 | Common::AlignDown(linear_extents.GetAddress(), LinearRegionAlign); | 499 | Common::AlignDown(linear_extents.GetAddress(), LinearRegionAlign); |
| 501 | const size_t linear_region_size = | 500 | const size_t linear_region_size = |