summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2021-02-12 15:47:05 -0800
committerGravatar bunnei2021-02-18 16:16:25 -0800
commit7ed5dd0d62347054d5a03a24354cd43bec1184ba (patch)
treeedfa5254f60164dbdc498380a820980e8b4deb1d /src
parenthle: kernel: memory_manager: Rename AllocateContinuous to AllocateContinuous. (diff)
downloadyuzu-7ed5dd0d62347054d5a03a24354cd43bec1184ba.tar.gz
yuzu-7ed5dd0d62347054d5a03a24354cd43bec1184ba.tar.xz
yuzu-7ed5dd0d62347054d5a03a24354cd43bec1184ba.zip
hle: kernel: Migrate AddressSpaceInfo to KAddressSpaceInfo.
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/kernel/k_address_space_info.cpp (renamed from src/core/hle/kernel/memory/address_space_info.cpp)60
-rw-r--r--src/core/hle/kernel/k_address_space_info.h (renamed from src/core/hle/kernel/memory/address_space_info.h)15
-rw-r--r--src/core/hle/kernel/memory/page_table.cpp34
4 files changed, 54 insertions, 59 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 8aad9cb41..442618e90 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -156,6 +156,8 @@ add_library(core STATIC
156 hle/kernel/hle_ipc.h 156 hle/kernel/hle_ipc.h
157 hle/kernel/k_address_arbiter.cpp 157 hle/kernel/k_address_arbiter.cpp
158 hle/kernel/k_address_arbiter.h 158 hle/kernel/k_address_arbiter.h
159 hle/kernel/k_address_space_info.cpp
160 hle/kernel/k_address_space_info.h
159 hle/kernel/k_affinity_mask.h 161 hle/kernel/k_affinity_mask.h
160 hle/kernel/k_condition_variable.cpp 162 hle/kernel/k_condition_variable.cpp
161 hle/kernel/k_condition_variable.h 163 hle/kernel/k_condition_variable.h
@@ -191,8 +193,6 @@ add_library(core STATIC
191 hle/kernel/k_writable_event.h 193 hle/kernel/k_writable_event.h
192 hle/kernel/kernel.cpp 194 hle/kernel/kernel.cpp
193 hle/kernel/kernel.h 195 hle/kernel/kernel.h
194 hle/kernel/memory/address_space_info.cpp
195 hle/kernel/memory/address_space_info.h
196 hle/kernel/memory/memory_block.h 196 hle/kernel/memory/memory_block.h
197 hle/kernel/memory/memory_block_manager.cpp 197 hle/kernel/memory/memory_block_manager.cpp
198 hle/kernel/memory/memory_block_manager.h 198 hle/kernel/memory/memory_block_manager.h
diff --git a/src/core/hle/kernel/memory/address_space_info.cpp b/src/core/hle/kernel/k_address_space_info.cpp
index 6cf43ba24..24944d15b 100644
--- a/src/core/hle/kernel/memory/address_space_info.cpp
+++ b/src/core/hle/kernel/k_address_space_info.cpp
@@ -2,15 +2,12 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5// This file references various implementation details from Atmosphere, an open-source firmware for
6// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
7
8#include <array> 5#include <array>
9 6
10#include "common/assert.h" 7#include "common/assert.h"
11#include "core/hle/kernel/memory/address_space_info.h" 8#include "core/hle/kernel/k_address_space_info.h"
12 9
13namespace Kernel::Memory { 10namespace Kernel {
14 11
15namespace { 12namespace {
16 13
@@ -28,20 +25,20 @@ enum : u64 {
28}; 25};
29 26
30// clang-format off 27// clang-format off
31constexpr std::array<AddressSpaceInfo, 13> AddressSpaceInfos{{ 28constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{
32 { .bit_width = 32, .address = Size_2_MB , .size = Size_1_GB - Size_2_MB , .type = AddressSpaceInfo::Type::Is32Bit, }, 29 { .bit_width = 32, .address = Size_2_MB , .size = Size_1_GB - Size_2_MB , .type = KAddressSpaceInfo::Type::MapSmall, },
33 { .bit_width = 32, .address = Size_1_GB , .size = Size_4_GB - Size_1_GB , .type = AddressSpaceInfo::Type::Small64Bit, }, 30 { .bit_width = 32, .address = Size_1_GB , .size = Size_4_GB - Size_1_GB , .type = KAddressSpaceInfo::Type::MapLarge, },
34 { .bit_width = 32, .address = Invalid , .size = Size_1_GB , .type = AddressSpaceInfo::Type::Heap, }, 31 { .bit_width = 32, .address = Invalid , .size = Size_1_GB , .type = KAddressSpaceInfo::Type::Heap, },
35 { .bit_width = 32, .address = Invalid , .size = Size_1_GB , .type = AddressSpaceInfo::Type::Alias, }, 32 { .bit_width = 32, .address = Invalid , .size = Size_1_GB , .type = KAddressSpaceInfo::Type::Alias, },
36 { .bit_width = 36, .address = Size_128_MB, .size = Size_2_GB - Size_128_MB, .type = AddressSpaceInfo::Type::Is32Bit, }, 33 { .bit_width = 36, .address = Size_128_MB, .size = Size_2_GB - Size_128_MB, .type = KAddressSpaceInfo::Type::MapSmall, },
37 { .bit_width = 36, .address = Size_2_GB , .size = Size_64_GB - Size_2_GB , .type = AddressSpaceInfo::Type::Small64Bit, }, 34 { .bit_width = 36, .address = Size_2_GB , .size = Size_64_GB - Size_2_GB , .type = KAddressSpaceInfo::Type::MapLarge, },
38 { .bit_width = 36, .address = Invalid , .size = Size_6_GB , .type = AddressSpaceInfo::Type::Heap, }, 35 { .bit_width = 36, .address = Invalid , .size = Size_6_GB , .type = KAddressSpaceInfo::Type::Heap, },
39 { .bit_width = 36, .address = Invalid , .size = Size_6_GB , .type = AddressSpaceInfo::Type::Alias, }, 36 { .bit_width = 36, .address = Invalid , .size = Size_6_GB , .type = KAddressSpaceInfo::Type::Alias, },
40 { .bit_width = 39, .address = Size_128_MB, .size = Size_512_GB - Size_128_MB, .type = AddressSpaceInfo::Type::Large64Bit, }, 37 { .bit_width = 39, .address = Size_128_MB, .size = Size_512_GB - Size_128_MB, .type = KAddressSpaceInfo::Type::Map39Bit, },
41 { .bit_width = 39, .address = Invalid , .size = Size_64_GB , .type = AddressSpaceInfo::Type::Is32Bit }, 38 { .bit_width = 39, .address = Invalid , .size = Size_64_GB , .type = KAddressSpaceInfo::Type::MapSmall },
42 { .bit_width = 39, .address = Invalid , .size = Size_6_GB , .type = AddressSpaceInfo::Type::Heap, }, 39 { .bit_width = 39, .address = Invalid , .size = Size_6_GB , .type = KAddressSpaceInfo::Type::Heap, },
43 { .bit_width = 39, .address = Invalid , .size = Size_64_GB , .type = AddressSpaceInfo::Type::Alias, }, 40 { .bit_width = 39, .address = Invalid , .size = Size_64_GB , .type = KAddressSpaceInfo::Type::Alias, },
44 { .bit_width = 39, .address = Invalid , .size = Size_2_GB , .type = AddressSpaceInfo::Type::Stack, }, 41 { .bit_width = 39, .address = Invalid , .size = Size_2_GB , .type = KAddressSpaceInfo::Type::Stack, },
45}}; 42}};
46// clang-format on 43// clang-format on
47 44
@@ -49,7 +46,8 @@ constexpr bool IsAllowedIndexForAddress(std::size_t index) {
49 return index < AddressSpaceInfos.size() && AddressSpaceInfos[index].address != Invalid; 46 return index < AddressSpaceInfos.size() && AddressSpaceInfos[index].address != Invalid;
50} 47}
51 48
52using IndexArray = std::array<std::size_t, static_cast<std::size_t>(AddressSpaceInfo::Type::Count)>; 49using IndexArray =
50 std::array<std::size_t, static_cast<std::size_t>(KAddressSpaceInfo::Type::Count)>;
53 51
54constexpr IndexArray AddressSpaceIndices32Bit{ 52constexpr IndexArray AddressSpaceIndices32Bit{
55 0, 1, 0, 2, 0, 3, 53 0, 1, 0, 2, 0, 3,
@@ -63,23 +61,23 @@ constexpr IndexArray AddressSpaceIndices39Bit{
63 9, 8, 8, 10, 12, 11, 61 9, 8, 8, 10, 12, 11,
64}; 62};
65 63
66constexpr bool IsAllowed32BitType(AddressSpaceInfo::Type type) { 64constexpr bool IsAllowed32BitType(KAddressSpaceInfo::Type type) {
67 return type < AddressSpaceInfo::Type::Count && type != AddressSpaceInfo::Type::Large64Bit && 65 return type < KAddressSpaceInfo::Type::Count && type != KAddressSpaceInfo::Type::Map39Bit &&
68 type != AddressSpaceInfo::Type::Stack; 66 type != KAddressSpaceInfo::Type::Stack;
69} 67}
70 68
71constexpr bool IsAllowed36BitType(AddressSpaceInfo::Type type) { 69constexpr bool IsAllowed36BitType(KAddressSpaceInfo::Type type) {
72 return type < AddressSpaceInfo::Type::Count && type != AddressSpaceInfo::Type::Large64Bit && 70 return type < KAddressSpaceInfo::Type::Count && type != KAddressSpaceInfo::Type::Map39Bit &&
73 type != AddressSpaceInfo::Type::Stack; 71 type != KAddressSpaceInfo::Type::Stack;
74} 72}
75 73
76constexpr bool IsAllowed39BitType(AddressSpaceInfo::Type type) { 74constexpr bool IsAllowed39BitType(KAddressSpaceInfo::Type type) {
77 return type < AddressSpaceInfo::Type::Count && type != AddressSpaceInfo::Type::Small64Bit; 75 return type < KAddressSpaceInfo::Type::Count && type != KAddressSpaceInfo::Type::MapLarge;
78} 76}
79 77
80} // namespace 78} // namespace
81 79
82u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) { 80u64 KAddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) {
83 const std::size_t index{static_cast<std::size_t>(type)}; 81 const std::size_t index{static_cast<std::size_t>(type)};
84 switch (width) { 82 switch (width) {
85 case 32: 83 case 32:
@@ -99,7 +97,7 @@ u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) {
99 return 0; 97 return 0;
100} 98}
101 99
102std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) { 100std::size_t KAddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) {
103 const std::size_t index{static_cast<std::size_t>(type)}; 101 const std::size_t index{static_cast<std::size_t>(type)};
104 switch (width) { 102 switch (width) {
105 case 32: 103 case 32:
@@ -116,4 +114,4 @@ std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type)
116 return 0; 114 return 0;
117} 115}
118 116
119} // namespace Kernel::Memory 117} // namespace Kernel
diff --git a/src/core/hle/kernel/memory/address_space_info.h b/src/core/hle/kernel/k_address_space_info.h
index a4e6e91e5..06f31c6d5 100644
--- a/src/core/hle/kernel/memory/address_space_info.h
+++ b/src/core/hle/kernel/k_address_space_info.h
@@ -2,20 +2,17 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5// This file references various implementation details from Atmosphere, an open-source firmware for
6// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
7
8#pragma once 5#pragma once
9 6
10#include "common/common_types.h" 7#include "common/common_types.h"
11 8
12namespace Kernel::Memory { 9namespace Kernel {
13 10
14struct AddressSpaceInfo final { 11struct KAddressSpaceInfo final {
15 enum class Type : u32 { 12 enum class Type : u32 {
16 Is32Bit = 0, 13 MapSmall = 0,
17 Small64Bit = 1, 14 MapLarge = 1,
18 Large64Bit = 2, 15 Map39Bit = 2,
19 Heap = 3, 16 Heap = 3,
20 Stack = 4, 17 Stack = 4,
21 Alias = 5, 18 Alias = 5,
@@ -31,4 +28,4 @@ struct AddressSpaceInfo final {
31 const Type type{}; 28 const Type type{};
32}; 29};
33 30
34} // namespace Kernel::Memory 31} // namespace Kernel
diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp
index 034d43ecd..02a17a695 100644
--- a/src/core/hle/kernel/memory/page_table.cpp
+++ b/src/core/hle/kernel/memory/page_table.cpp
@@ -6,11 +6,11 @@
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/scope_exit.h" 7#include "common/scope_exit.h"
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/kernel/k_address_space_info.h"
9#include "core/hle/kernel/k_resource_limit.h" 10#include "core/hle/kernel/k_resource_limit.h"
10#include "core/hle/kernel/k_scoped_resource_reservation.h" 11#include "core/hle/kernel/k_scoped_resource_reservation.h"
11#include "core/hle/kernel/k_system_control.h" 12#include "core/hle/kernel/k_system_control.h"
12#include "core/hle/kernel/kernel.h" 13#include "core/hle/kernel/kernel.h"
13#include "core/hle/kernel/memory/address_space_info.h"
14#include "core/hle/kernel/memory/memory_block.h" 14#include "core/hle/kernel/memory/memory_block.h"
15#include "core/hle/kernel/memory/memory_block_manager.h" 15#include "core/hle/kernel/memory/memory_block_manager.h"
16#include "core/hle/kernel/memory/page_linked_list.h" 16#include "core/hle/kernel/memory/page_linked_list.h"
@@ -64,19 +64,19 @@ ResultCode PageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_t
64 bool enable_aslr, VAddr code_addr, std::size_t code_size, 64 bool enable_aslr, VAddr code_addr, std::size_t code_size,
65 Memory::MemoryManager::Pool pool) { 65 Memory::MemoryManager::Pool pool) {
66 66
67 const auto GetSpaceStart = [this](AddressSpaceInfo::Type type) { 67 const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) {
68 return AddressSpaceInfo::GetAddressSpaceStart(address_space_width, type); 68 return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type);
69 }; 69 };
70 const auto GetSpaceSize = [this](AddressSpaceInfo::Type type) { 70 const auto GetSpaceSize = [this](KAddressSpaceInfo::Type type) {
71 return AddressSpaceInfo::GetAddressSpaceSize(address_space_width, type); 71 return KAddressSpaceInfo::GetAddressSpaceSize(address_space_width, type);
72 }; 72 };
73 73
74 // Set our width and heap/alias sizes 74 // Set our width and heap/alias sizes
75 address_space_width = GetAddressSpaceWidthFromType(as_type); 75 address_space_width = GetAddressSpaceWidthFromType(as_type);
76 const VAddr start = 0; 76 const VAddr start = 0;
77 const VAddr end{1ULL << address_space_width}; 77 const VAddr end{1ULL << address_space_width};
78 std::size_t alias_region_size{GetSpaceSize(AddressSpaceInfo::Type::Alias)}; 78 std::size_t alias_region_size{GetSpaceSize(KAddressSpaceInfo::Type::Alias)};
79 std::size_t heap_region_size{GetSpaceSize(AddressSpaceInfo::Type::Heap)}; 79 std::size_t heap_region_size{GetSpaceSize(KAddressSpaceInfo::Type::Heap)};
80 80
81 ASSERT(start <= code_addr); 81 ASSERT(start <= code_addr);
82 ASSERT(code_addr < code_addr + code_size); 82 ASSERT(code_addr < code_addr + code_size);
@@ -96,12 +96,12 @@ ResultCode PageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_t
96 std::size_t kernel_map_region_size{}; 96 std::size_t kernel_map_region_size{};
97 97
98 if (address_space_width == 39) { 98 if (address_space_width == 39) {
99 alias_region_size = GetSpaceSize(AddressSpaceInfo::Type::Alias); 99 alias_region_size = GetSpaceSize(KAddressSpaceInfo::Type::Alias);
100 heap_region_size = GetSpaceSize(AddressSpaceInfo::Type::Heap); 100 heap_region_size = GetSpaceSize(KAddressSpaceInfo::Type::Heap);
101 stack_region_size = GetSpaceSize(AddressSpaceInfo::Type::Stack); 101 stack_region_size = GetSpaceSize(KAddressSpaceInfo::Type::Stack);
102 kernel_map_region_size = GetSpaceSize(AddressSpaceInfo::Type::Is32Bit); 102 kernel_map_region_size = GetSpaceSize(KAddressSpaceInfo::Type::MapSmall);
103 code_region_start = GetSpaceStart(AddressSpaceInfo::Type::Large64Bit); 103 code_region_start = GetSpaceStart(KAddressSpaceInfo::Type::Map39Bit);
104 code_region_end = code_region_start + GetSpaceSize(AddressSpaceInfo::Type::Large64Bit); 104 code_region_end = code_region_start + GetSpaceSize(KAddressSpaceInfo::Type::Map39Bit);
105 alias_code_region_start = code_region_start; 105 alias_code_region_start = code_region_start;
106 alias_code_region_end = code_region_end; 106 alias_code_region_end = code_region_end;
107 process_code_start = Common::AlignDown(code_addr, RegionAlignment); 107 process_code_start = Common::AlignDown(code_addr, RegionAlignment);
@@ -109,12 +109,12 @@ ResultCode PageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_t
109 } else { 109 } else {
110 stack_region_size = 0; 110 stack_region_size = 0;
111 kernel_map_region_size = 0; 111 kernel_map_region_size = 0;
112 code_region_start = GetSpaceStart(AddressSpaceInfo::Type::Is32Bit); 112 code_region_start = GetSpaceStart(KAddressSpaceInfo::Type::MapSmall);
113 code_region_end = code_region_start + GetSpaceSize(AddressSpaceInfo::Type::Is32Bit); 113 code_region_end = code_region_start + GetSpaceSize(KAddressSpaceInfo::Type::MapSmall);
114 stack_region_start = code_region_start; 114 stack_region_start = code_region_start;
115 alias_code_region_start = code_region_start; 115 alias_code_region_start = code_region_start;
116 alias_code_region_end = GetSpaceStart(AddressSpaceInfo::Type::Small64Bit) + 116 alias_code_region_end = GetSpaceStart(KAddressSpaceInfo::Type::MapLarge) +
117 GetSpaceSize(AddressSpaceInfo::Type::Small64Bit); 117 GetSpaceSize(KAddressSpaceInfo::Type::MapLarge);
118 stack_region_end = code_region_end; 118 stack_region_end = code_region_end;
119 kernel_map_region_start = code_region_start; 119 kernel_map_region_start = code_region_start;
120 kernel_map_region_end = code_region_end; 120 kernel_map_region_end = code_region_end;