diff options
| author | 2018-09-29 18:47:00 -0400 | |
|---|---|---|
| committer | 2018-09-30 02:30:01 -0400 | |
| commit | cf9d6c6f526fffb2bf414ff774c5d0281a73ecf4 (patch) | |
| tree | a9e0bbc02013f0dbc6409af9c8685a8b8b9e9f32 | |
| parent | arm_interface: Add missing fpsr/tpidr members to the ThreadContext struct (diff) | |
| download | yuzu-cf9d6c6f526fffb2bf414ff774c5d0281a73ecf4.tar.gz yuzu-cf9d6c6f526fffb2bf414ff774c5d0281a73ecf4.tar.xz yuzu-cf9d6c6f526fffb2bf414ff774c5d0281a73ecf4.zip | |
kernel/process: Make data member variables private
Makes the public interface consistent in terms of how accesses are done
on a process object. It also makes it slightly nicer to reason about the
logic of the process class, as we don't want to expose everything to
external code.
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 2 | ||||
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.h | 97 | ||||
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 30 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/fatal/fatal.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/ns/pl_u.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 2 | ||||
| -rw-r--r-- | src/core/loader/elf.cpp | 2 | ||||
| -rw-r--r-- | src/core/loader/nro.cpp | 2 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 2 | ||||
| -rw-r--r-- | src/core/memory.cpp | 14 | ||||
| -rw-r--r-- | src/tests/core/arm/arm_test_common.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 4 |
18 files changed, 120 insertions, 75 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 9ea87cdbe..05cc84458 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -130,7 +130,7 @@ public: | |||
| 130 | 130 | ||
| 131 | std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { | 131 | std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { |
| 132 | auto& current_process = Core::CurrentProcess(); | 132 | auto& current_process = Core::CurrentProcess(); |
| 133 | auto** const page_table = current_process->vm_manager.page_table.pointers.data(); | 133 | auto** const page_table = current_process->VMManager().page_table.pointers.data(); |
| 134 | 134 | ||
| 135 | Dynarmic::A64::UserConfig config; | 135 | Dynarmic::A64::UserConfig config; |
| 136 | 136 | ||
| @@ -139,7 +139,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { | |||
| 139 | 139 | ||
| 140 | // Memory | 140 | // Memory |
| 141 | config.page_table = reinterpret_cast<void**>(page_table); | 141 | config.page_table = reinterpret_cast<void**>(page_table); |
| 142 | config.page_table_address_space_bits = current_process->vm_manager.GetAddressSpaceWidth(); | 142 | config.page_table_address_space_bits = current_process->VMManager().GetAddressSpaceWidth(); |
| 143 | config.silently_mirror_page_table = false; | 143 | config.silently_mirror_page_table = false; |
| 144 | 144 | ||
| 145 | // Multi-process state | 145 | // Multi-process state |
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 3d1a3685e..d027a8d59 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -34,7 +34,7 @@ ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { | |||
| 34 | if (!updatable) | 34 | if (!updatable) |
| 35 | return MakeResult<VirtualFile>(file); | 35 | return MakeResult<VirtualFile>(file); |
| 36 | 36 | ||
| 37 | const PatchManager patch_manager(Core::CurrentProcess()->program_id); | 37 | const PatchManager patch_manager(Core::CurrentProcess()->GetTitleID()); |
| 38 | return MakeResult<VirtualFile>(patch_manager.PatchRomFS(file, ivfc_offset)); | 38 | return MakeResult<VirtualFile>(patch_manager.PatchRomFS(file, ivfc_offset)); |
| 39 | } | 39 | } |
| 40 | 40 | ||
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index 9b2c51bbd..47f2ab9e0 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -81,7 +81,7 @@ std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType typ | |||
| 81 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | 81 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should |
| 82 | // be interpreted as the title id of the current process. | 82 | // be interpreted as the title id of the current process. |
| 83 | if (type == SaveDataType::SaveData && title_id == 0) | 83 | if (type == SaveDataType::SaveData && title_id == 0) |
| 84 | title_id = Core::CurrentProcess()->program_id; | 84 | title_id = Core::CurrentProcess()->GetTitleID(); |
| 85 | 85 | ||
| 86 | std::string out; | 86 | std::string out; |
| 87 | 87 | ||
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index ae88440c2..5bc947010 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -587,7 +587,7 @@ static void HandleQuery() { | |||
| 587 | strlen("Xfer:features:read:target.xml:")) == 0) { | 587 | strlen("Xfer:features:read:target.xml:")) == 0) { |
| 588 | SendReply(target_xml); | 588 | SendReply(target_xml); |
| 589 | } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) { | 589 | } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) { |
| 590 | const VAddr base_address = Core::CurrentProcess()->vm_manager.GetCodeRegionBaseAddress(); | 590 | const VAddr base_address = Core::CurrentProcess()->VMManager().GetCodeRegionBaseAddress(); |
| 591 | std::string buffer = fmt::format("TextSeg={:0x}", base_address); | 591 | std::string buffer = fmt::format("TextSeg={:0x}", base_address); |
| 592 | SendReply(buffer.c_str()); | 592 | SendReply(buffer.c_str()); |
| 593 | } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { | 593 | } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { |
| @@ -909,7 +909,7 @@ static void ReadMemory() { | |||
| 909 | SendReply("E01"); | 909 | SendReply("E01"); |
| 910 | } | 910 | } |
| 911 | 911 | ||
| 912 | const auto& vm_manager = Core::CurrentProcess()->vm_manager; | 912 | const auto& vm_manager = Core::CurrentProcess()->VMManager(); |
| 913 | if (addr < vm_manager.GetCodeRegionBaseAddress() || | 913 | if (addr < vm_manager.GetCodeRegionBaseAddress() || |
| 914 | addr >= vm_manager.GetMapRegionEndAddress()) { | 914 | addr >= vm_manager.GetMapRegionEndAddress()) { |
| 915 | return SendReply("E00"); | 915 | return SendReply("E00"); |
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index adb03c228..2dfb88fa9 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -135,6 +135,16 @@ public: | |||
| 135 | return HANDLE_TYPE; | 135 | return HANDLE_TYPE; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | /// Gets a reference to the process' memory manager. | ||
| 139 | Kernel::VMManager& VMManager() { | ||
| 140 | return vm_manager; | ||
| 141 | } | ||
| 142 | |||
| 143 | /// Gets a const reference to the process' memory manager. | ||
| 144 | const Kernel::VMManager& VMManager() const { | ||
| 145 | return vm_manager; | ||
| 146 | } | ||
| 147 | |||
| 138 | /// Gets the current status of the process | 148 | /// Gets the current status of the process |
| 139 | ProcessStatus GetStatus() const { | 149 | ProcessStatus GetStatus() const { |
| 140 | return status; | 150 | return status; |
| @@ -145,6 +155,40 @@ public: | |||
| 145 | return process_id; | 155 | return process_id; |
| 146 | } | 156 | } |
| 147 | 157 | ||
| 158 | /// Gets the title ID corresponding to this process. | ||
| 159 | u64 GetTitleID() const { | ||
| 160 | return program_id; | ||
| 161 | } | ||
| 162 | |||
| 163 | /// Gets the resource limit descriptor for this process | ||
| 164 | ResourceLimit& GetResourceLimit() { | ||
| 165 | return *resource_limit; | ||
| 166 | } | ||
| 167 | |||
| 168 | /// Gets the resource limit descriptor for this process | ||
| 169 | const ResourceLimit& GetResourceLimit() const { | ||
| 170 | return *resource_limit; | ||
| 171 | } | ||
| 172 | |||
| 173 | /// Gets the default CPU ID for this process | ||
| 174 | u8 GetDefaultProcessorID() const { | ||
| 175 | return ideal_processor; | ||
| 176 | } | ||
| 177 | |||
| 178 | /// Gets the bitmask of allowed CPUs that this process' threads can run on. | ||
| 179 | u32 GetAllowedProcessorMask() const { | ||
| 180 | return allowed_processor_mask; | ||
| 181 | } | ||
| 182 | |||
| 183 | /// Gets the bitmask of allowed thread priorities. | ||
| 184 | u32 GetAllowedThreadPriorityMask() const { | ||
| 185 | return allowed_thread_priority_mask; | ||
| 186 | } | ||
| 187 | |||
| 188 | u32 IsVirtualMemoryEnabled() const { | ||
| 189 | return is_virtual_address_memory_enabled; | ||
| 190 | } | ||
| 191 | |||
| 148 | /** | 192 | /** |
| 149 | * Loads process-specifics configuration info with metadata provided | 193 | * Loads process-specifics configuration info with metadata provided |
| 150 | * by an executable. | 194 | * by an executable. |
| @@ -153,30 +197,6 @@ public: | |||
| 153 | */ | 197 | */ |
| 154 | void LoadFromMetadata(const FileSys::ProgramMetadata& metadata); | 198 | void LoadFromMetadata(const FileSys::ProgramMetadata& metadata); |
| 155 | 199 | ||
| 156 | /// Title ID corresponding to the process | ||
| 157 | u64 program_id; | ||
| 158 | |||
| 159 | /// Resource limit descriptor for this process | ||
| 160 | SharedPtr<ResourceLimit> resource_limit; | ||
| 161 | |||
| 162 | /// The process may only call SVCs which have the corresponding bit set. | ||
| 163 | std::bitset<0x80> svc_access_mask; | ||
| 164 | /// Maximum size of the handle table for the process. | ||
| 165 | unsigned int handle_table_size = 0x200; | ||
| 166 | /// Special memory ranges mapped into this processes address space. This is used to give | ||
| 167 | /// processes access to specific I/O regions and device memory. | ||
| 168 | boost::container::static_vector<AddressMapping, 8> address_mappings; | ||
| 169 | ProcessFlags flags; | ||
| 170 | /// Kernel compatibility version for this process | ||
| 171 | u16 kernel_version = 0; | ||
| 172 | /// The default CPU for this process, threads are scheduled on this cpu by default. | ||
| 173 | u8 ideal_processor = 0; | ||
| 174 | /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse | ||
| 175 | /// this value from the process header. | ||
| 176 | u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK; | ||
| 177 | u32 allowed_thread_priority_mask = 0xFFFFFFFF; | ||
| 178 | u32 is_virtual_address_memory_enabled = 0; | ||
| 179 | |||
| 180 | /** | 200 | /** |
| 181 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them | 201 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them |
| 182 | * to this process. | 202 | * to this process. |
| @@ -212,18 +232,43 @@ public: | |||
| 212 | 232 | ||
| 213 | ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); | 233 | ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); |
| 214 | 234 | ||
| 215 | VMManager vm_manager; | ||
| 216 | |||
| 217 | private: | 235 | private: |
| 218 | explicit Process(KernelCore& kernel); | 236 | explicit Process(KernelCore& kernel); |
| 219 | ~Process() override; | 237 | ~Process() override; |
| 220 | 238 | ||
| 239 | /// Memory manager for this process. | ||
| 240 | Kernel::VMManager vm_manager; | ||
| 241 | |||
| 221 | /// Current status of the process | 242 | /// Current status of the process |
| 222 | ProcessStatus status; | 243 | ProcessStatus status; |
| 223 | 244 | ||
| 224 | /// The ID of this process | 245 | /// The ID of this process |
| 225 | u32 process_id = 0; | 246 | u32 process_id = 0; |
| 226 | 247 | ||
| 248 | /// Title ID corresponding to the process | ||
| 249 | u64 program_id; | ||
| 250 | |||
| 251 | /// Resource limit descriptor for this process | ||
| 252 | SharedPtr<ResourceLimit> resource_limit; | ||
| 253 | |||
| 254 | /// The process may only call SVCs which have the corresponding bit set. | ||
| 255 | std::bitset<0x80> svc_access_mask; | ||
| 256 | /// Maximum size of the handle table for the process. | ||
| 257 | u32 handle_table_size = 0x200; | ||
| 258 | /// Special memory ranges mapped into this processes address space. This is used to give | ||
| 259 | /// processes access to specific I/O regions and device memory. | ||
| 260 | boost::container::static_vector<AddressMapping, 8> address_mappings; | ||
| 261 | ProcessFlags flags; | ||
| 262 | /// Kernel compatibility version for this process | ||
| 263 | u16 kernel_version = 0; | ||
| 264 | /// The default CPU for this process, threads are scheduled on this cpu by default. | ||
| 265 | u8 ideal_processor = 0; | ||
| 266 | /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse | ||
| 267 | /// this value from the process header. | ||
| 268 | u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK; | ||
| 269 | u32 allowed_thread_priority_mask = 0xFFFFFFFF; | ||
| 270 | u32 is_virtual_address_memory_enabled = 0; | ||
| 271 | |||
| 227 | // Memory used to back the allocations in the regular heap. A single vector is used to cover | 272 | // Memory used to back the allocations in the regular heap. A single vector is used to cover |
| 228 | // the entire virtual address space extents that bound the allocations, including any holes. | 273 | // the entire virtual address space extents that bound the allocations, including any holes. |
| 229 | // This makes deallocation and reallocation of holes fast and keeps process memory contiguous | 274 | // This makes deallocation and reallocation of holes fast and keeps process memory contiguous |
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 9faf903cf..1e82cfffb 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -88,7 +88,7 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 88 | 88 | ||
| 89 | if (previous_process != current_thread->owner_process) { | 89 | if (previous_process != current_thread->owner_process) { |
| 90 | Core::CurrentProcess() = current_thread->owner_process; | 90 | Core::CurrentProcess() = current_thread->owner_process; |
| 91 | SetCurrentPageTable(&Core::CurrentProcess()->vm_manager.page_table); | 91 | SetCurrentPageTable(&Core::CurrentProcess()->VMManager().page_table); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | cpu_core.LoadContext(new_thread->context); | 94 | cpu_core.LoadContext(new_thread->context); |
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 9b78c8cb5..d061e6155 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -35,11 +35,11 @@ SharedPtr<SharedMemory> SharedMemory::Create(KernelCore& kernel, SharedPtr<Proce | |||
| 35 | 35 | ||
| 36 | // Refresh the address mappings for the current process. | 36 | // Refresh the address mappings for the current process. |
| 37 | if (Core::CurrentProcess() != nullptr) { | 37 | if (Core::CurrentProcess() != nullptr) { |
| 38 | Core::CurrentProcess()->vm_manager.RefreshMemoryBlockMappings( | 38 | Core::CurrentProcess()->VMManager().RefreshMemoryBlockMappings( |
| 39 | shared_memory->backing_block.get()); | 39 | shared_memory->backing_block.get()); |
| 40 | } | 40 | } |
| 41 | } else { | 41 | } else { |
| 42 | auto& vm_manager = shared_memory->owner_process->vm_manager; | 42 | auto& vm_manager = shared_memory->owner_process->VMManager(); |
| 43 | 43 | ||
| 44 | // The memory is already available and mapped in the owner process. | 44 | // The memory is already available and mapped in the owner process. |
| 45 | auto vma = vm_manager.FindVMA(address); | 45 | auto vma = vm_manager.FindVMA(address); |
| @@ -73,7 +73,7 @@ SharedPtr<SharedMemory> SharedMemory::CreateForApplet( | |||
| 73 | shared_memory->backing_block = std::move(heap_block); | 73 | shared_memory->backing_block = std::move(heap_block); |
| 74 | shared_memory->backing_block_offset = offset; | 74 | shared_memory->backing_block_offset = offset; |
| 75 | shared_memory->base_address = | 75 | shared_memory->base_address = |
| 76 | kernel.CurrentProcess()->vm_manager.GetHeapRegionBaseAddress() + offset; | 76 | kernel.CurrentProcess()->VMManager().GetHeapRegionBaseAddress() + offset; |
| 77 | 77 | ||
| 78 | return shared_memory; | 78 | return shared_memory; |
| 79 | } | 79 | } |
| @@ -107,7 +107,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 107 | VAddr target_address = address; | 107 | VAddr target_address = address; |
| 108 | 108 | ||
| 109 | // Map the memory block into the target process | 109 | // Map the memory block into the target process |
| 110 | auto result = target_process->vm_manager.MapMemoryBlock( | 110 | auto result = target_process->VMManager().MapMemoryBlock( |
| 111 | target_address, backing_block, backing_block_offset, size, MemoryState::Shared); | 111 | target_address, backing_block, backing_block_offset, size, MemoryState::Shared); |
| 112 | if (result.Failed()) { | 112 | if (result.Failed()) { |
| 113 | LOG_ERROR( | 113 | LOG_ERROR( |
| @@ -117,14 +117,14 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 117 | return result.Code(); | 117 | return result.Code(); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | return target_process->vm_manager.ReprotectRange(target_address, size, | 120 | return target_process->VMManager().ReprotectRange(target_address, size, |
| 121 | ConvertPermissions(permissions)); | 121 | ConvertPermissions(permissions)); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | ResultCode SharedMemory::Unmap(Process* target_process, VAddr address) { | 124 | ResultCode SharedMemory::Unmap(Process* target_process, VAddr address) { |
| 125 | // TODO(Subv): Verify what happens if the application tries to unmap an address that is not | 125 | // TODO(Subv): Verify what happens if the application tries to unmap an address that is not |
| 126 | // mapped to a SharedMemory. | 126 | // mapped to a SharedMemory. |
| 127 | return target_process->vm_manager.UnmapRange(address, size); | 127 | return target_process->VMManager().UnmapRange(address, size); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | VMAPermission SharedMemory::ConvertPermissions(MemoryPermission permission) { | 130 | VMAPermission SharedMemory::ConvertPermissions(MemoryPermission permission) { |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 44bbaf0c8..b76280456 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -51,7 +51,7 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | auto& process = *Core::CurrentProcess(); | 53 | auto& process = *Core::CurrentProcess(); |
| 54 | const VAddr heap_base = process.vm_manager.GetHeapRegionBaseAddress(); | 54 | const VAddr heap_base = process.VMManager().GetHeapRegionBaseAddress(); |
| 55 | CASCADE_RESULT(*heap_addr, | 55 | CASCADE_RESULT(*heap_addr, |
| 56 | process.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite)); | 56 | process.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite)); |
| 57 | return RESULT_SUCCESS; | 57 | return RESULT_SUCCESS; |
| @@ -327,14 +327,14 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 327 | info_sub_id, handle); | 327 | info_sub_id, handle); |
| 328 | 328 | ||
| 329 | const auto& current_process = Core::CurrentProcess(); | 329 | const auto& current_process = Core::CurrentProcess(); |
| 330 | const auto& vm_manager = current_process->vm_manager; | 330 | const auto& vm_manager = current_process->VMManager(); |
| 331 | 331 | ||
| 332 | switch (static_cast<GetInfoType>(info_id)) { | 332 | switch (static_cast<GetInfoType>(info_id)) { |
| 333 | case GetInfoType::AllowedCpuIdBitmask: | 333 | case GetInfoType::AllowedCpuIdBitmask: |
| 334 | *result = current_process->allowed_processor_mask; | 334 | *result = current_process->GetAllowedProcessorMask(); |
| 335 | break; | 335 | break; |
| 336 | case GetInfoType::AllowedThreadPrioBitmask: | 336 | case GetInfoType::AllowedThreadPrioBitmask: |
| 337 | *result = current_process->allowed_thread_priority_mask; | 337 | *result = current_process->GetAllowedThreadPriorityMask(); |
| 338 | break; | 338 | break; |
| 339 | case GetInfoType::MapRegionBaseAddr: | 339 | case GetInfoType::MapRegionBaseAddr: |
| 340 | *result = vm_manager.GetMapRegionBaseAddress(); | 340 | *result = vm_manager.GetMapRegionBaseAddress(); |
| @@ -386,10 +386,10 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 386 | *result = vm_manager.GetNewMapRegionSize(); | 386 | *result = vm_manager.GetNewMapRegionSize(); |
| 387 | break; | 387 | break; |
| 388 | case GetInfoType::IsVirtualAddressMemoryEnabled: | 388 | case GetInfoType::IsVirtualAddressMemoryEnabled: |
| 389 | *result = current_process->is_virtual_address_memory_enabled; | 389 | *result = current_process->IsVirtualMemoryEnabled(); |
| 390 | break; | 390 | break; |
| 391 | case GetInfoType::TitleId: | 391 | case GetInfoType::TitleId: |
| 392 | *result = current_process->program_id; | 392 | *result = current_process->GetTitleID(); |
| 393 | break; | 393 | break; |
| 394 | case GetInfoType::PrivilegedProcessId: | 394 | case GetInfoType::PrivilegedProcessId: |
| 395 | LOG_WARNING(Kernel_SVC, | 395 | LOG_WARNING(Kernel_SVC, |
| @@ -444,8 +444,8 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) { | |||
| 444 | 444 | ||
| 445 | // Note: The kernel uses the current process's resource limit instead of | 445 | // Note: The kernel uses the current process's resource limit instead of |
| 446 | // the one from the thread owner's resource limit. | 446 | // the one from the thread owner's resource limit. |
| 447 | SharedPtr<ResourceLimit>& resource_limit = Core::CurrentProcess()->resource_limit; | 447 | const ResourceLimit& resource_limit = Core::CurrentProcess()->GetResourceLimit(); |
| 448 | if (resource_limit->GetMaxResourceValue(ResourceType::Priority) > priority) { | 448 | if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { |
| 449 | return ERR_NOT_AUTHORIZED; | 449 | return ERR_NOT_AUTHORIZED; |
| 450 | } | 450 | } |
| 451 | 451 | ||
| @@ -519,9 +519,9 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i | |||
| 519 | if (!process) { | 519 | if (!process) { |
| 520 | return ERR_INVALID_HANDLE; | 520 | return ERR_INVALID_HANDLE; |
| 521 | } | 521 | } |
| 522 | auto vma = process->vm_manager.FindVMA(addr); | 522 | auto vma = process->VMManager().FindVMA(addr); |
| 523 | memory_info->attributes = 0; | 523 | memory_info->attributes = 0; |
| 524 | if (vma == Core::CurrentProcess()->vm_manager.vma_map.end()) { | 524 | if (vma == Core::CurrentProcess()->VMManager().vma_map.end()) { |
| 525 | memory_info->base_address = 0; | 525 | memory_info->base_address = 0; |
| 526 | memory_info->permission = static_cast<u32>(VMAPermission::None); | 526 | memory_info->permission = static_cast<u32>(VMAPermission::None); |
| 527 | memory_info->size = 0; | 527 | memory_info->size = 0; |
| @@ -568,14 +568,14 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V | |||
| 568 | return ERR_INVALID_THREAD_PRIORITY; | 568 | return ERR_INVALID_THREAD_PRIORITY; |
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | SharedPtr<ResourceLimit>& resource_limit = Core::CurrentProcess()->resource_limit; | 571 | const ResourceLimit& resource_limit = Core::CurrentProcess()->GetResourceLimit(); |
| 572 | if (resource_limit->GetMaxResourceValue(ResourceType::Priority) > priority) { | 572 | if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { |
| 573 | return ERR_NOT_AUTHORIZED; | 573 | return ERR_NOT_AUTHORIZED; |
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | if (processor_id == THREADPROCESSORID_DEFAULT) { | 576 | if (processor_id == THREADPROCESSORID_DEFAULT) { |
| 577 | // Set the target CPU to the one specified in the process' exheader. | 577 | // Set the target CPU to the one specified in the process' exheader. |
| 578 | processor_id = Core::CurrentProcess()->ideal_processor; | 578 | processor_id = Core::CurrentProcess()->GetDefaultProcessorID(); |
| 579 | ASSERT(processor_id != THREADPROCESSORID_DEFAULT); | 579 | ASSERT(processor_id != THREADPROCESSORID_DEFAULT); |
| 580 | } | 580 | } |
| 581 | 581 | ||
| @@ -902,10 +902,10 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | |||
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | if (core == static_cast<u32>(THREADPROCESSORID_DEFAULT)) { | 904 | if (core == static_cast<u32>(THREADPROCESSORID_DEFAULT)) { |
| 905 | ASSERT(thread->owner_process->ideal_processor != | 905 | ASSERT(thread->owner_process->GetDefaultProcessorID() != |
| 906 | static_cast<u8>(THREADPROCESSORID_DEFAULT)); | 906 | static_cast<u8>(THREADPROCESSORID_DEFAULT)); |
| 907 | // Set the target CPU to the one specified in the process' exheader. | 907 | // Set the target CPU to the one specified in the process' exheader. |
| 908 | core = thread->owner_process->ideal_processor; | 908 | core = thread->owner_process->GetDefaultProcessorID(); |
| 909 | mask = 1ull << core; | 909 | mask = 1ull << core; |
| 910 | } | 910 | } |
| 911 | 911 | ||
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 064ed908d..b5c16cfbb 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -259,10 +259,10 @@ void Thread::BoostPriority(u32 priority) { | |||
| 259 | SharedPtr<Thread> SetupMainThread(KernelCore& kernel, VAddr entry_point, u32 priority, | 259 | SharedPtr<Thread> SetupMainThread(KernelCore& kernel, VAddr entry_point, u32 priority, |
| 260 | Process& owner_process) { | 260 | Process& owner_process) { |
| 261 | // Setup page table so we can write to memory | 261 | // Setup page table so we can write to memory |
| 262 | SetCurrentPageTable(&owner_process.vm_manager.page_table); | 262 | SetCurrentPageTable(&owner_process.VMManager().page_table); |
| 263 | 263 | ||
| 264 | // Initialize new "main" thread | 264 | // Initialize new "main" thread |
| 265 | const VAddr stack_top = owner_process.vm_manager.GetTLSIORegionEndAddress(); | 265 | const VAddr stack_top = owner_process.VMManager().GetTLSIORegionEndAddress(); |
| 266 | auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, THREADPROCESSORID_0, | 266 | auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, THREADPROCESSORID_0, |
| 267 | stack_top, &owner_process); | 267 | stack_top, &owner_process); |
| 268 | 268 | ||
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index 2212b2cdd..2f15ac2a6 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp | |||
| @@ -51,7 +51,7 @@ enum class FatalType : u32 { | |||
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) { | 53 | static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) { |
| 54 | const auto title_id = Core::CurrentProcess()->program_id; | 54 | const auto title_id = Core::CurrentProcess()->GetTitleID(); |
| 55 | std::string crash_report = | 55 | std::string crash_report = |
| 56 | fmt::format("Yuzu {}-{} crash report\n" | 56 | fmt::format("Yuzu {}-{} crash report\n" |
| 57 | "Title ID: {:016x}\n" | 57 | "Title ID: {:016x}\n" |
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 1069d103f..4b2f758a8 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp | |||
| @@ -317,9 +317,9 @@ void PL_U::GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx) { | |||
| 317 | 317 | ||
| 318 | void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { | 318 | void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { |
| 319 | // Map backing memory for the font data | 319 | // Map backing memory for the font data |
| 320 | Core::CurrentProcess()->vm_manager.MapMemoryBlock(SHARED_FONT_MEM_VADDR, impl->shared_font, 0, | 320 | Core::CurrentProcess()->VMManager().MapMemoryBlock(SHARED_FONT_MEM_VADDR, impl->shared_font, 0, |
| 321 | SHARED_FONT_MEM_SIZE, | 321 | SHARED_FONT_MEM_SIZE, |
| 322 | Kernel::MemoryState::Shared); | 322 | Kernel::MemoryState::Shared); |
| 323 | 323 | ||
| 324 | // Create shared font memory object | 324 | // Create shared font memory object |
| 325 | auto& kernel = Core::System::GetInstance().Kernel(); | 325 | auto& kernel = Core::System::GetInstance().Kernel(); |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 1b198cc5c..c1824b9c3 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -132,7 +132,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process) | |||
| 132 | process.LoadFromMetadata(metadata); | 132 | process.LoadFromMetadata(metadata); |
| 133 | 133 | ||
| 134 | // Load NSO modules | 134 | // Load NSO modules |
| 135 | const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); | 135 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 136 | VAddr next_load_addr = base_address; | 136 | VAddr next_load_addr = base_address; |
| 137 | for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", | 137 | for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", |
| 138 | "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { | 138 | "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { |
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 5712a2a11..e67b49fc9 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp | |||
| @@ -395,7 +395,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::Process& process) { | |||
| 395 | if (buffer.size() != file->GetSize()) | 395 | if (buffer.size() != file->GetSize()) |
| 396 | return ResultStatus::ErrorIncorrectELFFileSize; | 396 | return ResultStatus::ErrorIncorrectELFFileSize; |
| 397 | 397 | ||
| 398 | const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); | 398 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 399 | ElfReader elf_reader(&buffer[0]); | 399 | ElfReader elf_reader(&buffer[0]); |
| 400 | SharedPtr<CodeSet> codeset = elf_reader.LoadInto(base_address); | 400 | SharedPtr<CodeSet> codeset = elf_reader.LoadInto(base_address); |
| 401 | codeset->name = file->GetName(); | 401 | codeset->name = file->GetName(); |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 8ad973c3a..c10f826a4 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -181,7 +181,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { | |||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | // Load NRO | 183 | // Load NRO |
| 184 | const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); | 184 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 185 | 185 | ||
| 186 | if (!LoadNro(file, base_address)) { | 186 | if (!LoadNro(file, base_address)) { |
| 187 | return ResultStatus::ErrorLoadingNRO; | 187 | return ResultStatus::ErrorLoadingNRO; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 6fe3e17a7..cbe2a3e53 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -159,7 +159,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) { | |||
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | // Load module | 161 | // Load module |
| 162 | const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); | 162 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 163 | LoadModule(file, base_address); | 163 | LoadModule(file, base_address); |
| 164 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); | 164 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); |
| 165 | 165 | ||
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 6430daad4..014298ed6 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -119,7 +119,7 @@ void RemoveDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPoin | |||
| 119 | static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { | 119 | static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { |
| 120 | u8* direct_pointer = nullptr; | 120 | u8* direct_pointer = nullptr; |
| 121 | 121 | ||
| 122 | auto& vm_manager = process.vm_manager; | 122 | auto& vm_manager = process.VMManager(); |
| 123 | 123 | ||
| 124 | auto it = vm_manager.FindVMA(vaddr); | 124 | auto it = vm_manager.FindVMA(vaddr); |
| 125 | ASSERT(it != vm_manager.vma_map.end()); | 125 | ASSERT(it != vm_manager.vma_map.end()); |
| @@ -214,7 +214,7 @@ void Write(const VAddr vaddr, const T data) { | |||
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { | 216 | bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { |
| 217 | auto& page_table = process.vm_manager.page_table; | 217 | const auto& page_table = process.VMManager().page_table; |
| 218 | 218 | ||
| 219 | const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS]; | 219 | const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS]; |
| 220 | if (page_pointer) | 220 | if (page_pointer) |
| @@ -363,7 +363,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) { | |||
| 363 | } | 363 | } |
| 364 | }; | 364 | }; |
| 365 | 365 | ||
| 366 | const auto& vm_manager = Core::CurrentProcess()->vm_manager; | 366 | const auto& vm_manager = Core::CurrentProcess()->VMManager(); |
| 367 | 367 | ||
| 368 | CheckRegion(vm_manager.GetCodeRegionBaseAddress(), vm_manager.GetCodeRegionEndAddress()); | 368 | CheckRegion(vm_manager.GetCodeRegionBaseAddress(), vm_manager.GetCodeRegionEndAddress()); |
| 369 | CheckRegion(vm_manager.GetHeapRegionBaseAddress(), vm_manager.GetHeapRegionEndAddress()); | 369 | CheckRegion(vm_manager.GetHeapRegionBaseAddress(), vm_manager.GetHeapRegionEndAddress()); |
| @@ -387,7 +387,7 @@ u64 Read64(const VAddr addr) { | |||
| 387 | 387 | ||
| 388 | void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_buffer, | 388 | void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_buffer, |
| 389 | const std::size_t size) { | 389 | const std::size_t size) { |
| 390 | auto& page_table = process.vm_manager.page_table; | 390 | const auto& page_table = process.VMManager().page_table; |
| 391 | 391 | ||
| 392 | std::size_t remaining_size = size; | 392 | std::size_t remaining_size = size; |
| 393 | std::size_t page_index = src_addr >> PAGE_BITS; | 393 | std::size_t page_index = src_addr >> PAGE_BITS; |
| @@ -452,7 +452,7 @@ void Write64(const VAddr addr, const u64 data) { | |||
| 452 | 452 | ||
| 453 | void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const void* src_buffer, | 453 | void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const void* src_buffer, |
| 454 | const std::size_t size) { | 454 | const std::size_t size) { |
| 455 | auto& page_table = process.vm_manager.page_table; | 455 | const auto& page_table = process.VMManager().page_table; |
| 456 | std::size_t remaining_size = size; | 456 | std::size_t remaining_size = size; |
| 457 | std::size_t page_index = dest_addr >> PAGE_BITS; | 457 | std::size_t page_index = dest_addr >> PAGE_BITS; |
| 458 | std::size_t page_offset = dest_addr & PAGE_MASK; | 458 | std::size_t page_offset = dest_addr & PAGE_MASK; |
| @@ -498,7 +498,7 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t | |||
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { | 500 | void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { |
| 501 | auto& page_table = process.vm_manager.page_table; | 501 | const auto& page_table = process.VMManager().page_table; |
| 502 | std::size_t remaining_size = size; | 502 | std::size_t remaining_size = size; |
| 503 | std::size_t page_index = dest_addr >> PAGE_BITS; | 503 | std::size_t page_index = dest_addr >> PAGE_BITS; |
| 504 | std::size_t page_offset = dest_addr & PAGE_MASK; | 504 | std::size_t page_offset = dest_addr & PAGE_MASK; |
| @@ -540,7 +540,7 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std: | |||
| 540 | 540 | ||
| 541 | void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, | 541 | void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, |
| 542 | const std::size_t size) { | 542 | const std::size_t size) { |
| 543 | auto& page_table = process.vm_manager.page_table; | 543 | const auto& page_table = process.VMManager().page_table; |
| 544 | std::size_t remaining_size = size; | 544 | std::size_t remaining_size = size; |
| 545 | std::size_t page_index = src_addr >> PAGE_BITS; | 545 | std::size_t page_index = src_addr >> PAGE_BITS; |
| 546 | std::size_t page_offset = src_addr & PAGE_MASK; | 546 | std::size_t page_offset = src_addr & PAGE_MASK; |
diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp index c17a122cd..c0a57e71f 100644 --- a/src/tests/core/arm/arm_test_common.cpp +++ b/src/tests/core/arm/arm_test_common.cpp | |||
| @@ -16,7 +16,7 @@ TestEnvironment::TestEnvironment(bool mutable_memory_) | |||
| 16 | : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) { | 16 | : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) { |
| 17 | 17 | ||
| 18 | Core::CurrentProcess() = Kernel::Process::Create(kernel, ""); | 18 | Core::CurrentProcess() = Kernel::Process::Create(kernel, ""); |
| 19 | page_table = &Core::CurrentProcess()->vm_manager.page_table; | 19 | page_table = &Core::CurrentProcess()->VMManager().page_table; |
| 20 | 20 | ||
| 21 | std::fill(page_table->pointers.begin(), page_table->pointers.end(), nullptr); | 21 | std::fill(page_table->pointers.begin(), page_table->pointers.end(), nullptr); |
| 22 | page_table->special_regions.clear(); | 22 | page_table->special_regions.clear(); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index d74489935..681758ad2 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -622,9 +622,9 @@ void GMainWindow::BootGame(const QString& filename) { | |||
| 622 | std::string title_name; | 622 | std::string title_name; |
| 623 | const auto res = Core::System::GetInstance().GetGameName(title_name); | 623 | const auto res = Core::System::GetInstance().GetGameName(title_name); |
| 624 | if (res != Loader::ResultStatus::Success) { | 624 | if (res != Loader::ResultStatus::Success) { |
| 625 | const u64 program_id = Core::System::GetInstance().CurrentProcess()->program_id; | 625 | const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 626 | 626 | ||
| 627 | const auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata(); | 627 | const auto [nacp, icon_file] = FileSys::PatchManager(title_id).GetControlMetadata(); |
| 628 | if (nacp != nullptr) | 628 | if (nacp != nullptr) |
| 629 | title_name = nacp->GetApplicationName(); | 629 | title_name = nacp->GetApplicationName(); |
| 630 | 630 | ||