diff options
| author | 2019-10-06 20:47:48 -0400 | |
|---|---|---|
| committer | 2019-10-06 20:47:48 -0400 | |
| commit | 5326d3cb3a75a1f7df531e47cf0acadc3c5db32b (patch) | |
| tree | 83697ca2dba90470ba59eff2f56e71769b03e3d9 /src | |
| parent | Merge pull request #2952 from lioncash/warning (diff) | |
| parent | core/core: Remove unused header (diff) | |
| download | yuzu-5326d3cb3a75a1f7df531e47cf0acadc3c5db32b.tar.gz yuzu-5326d3cb3a75a1f7df531e47cf0acadc3c5db32b.tar.xz yuzu-5326d3cb3a75a1f7df531e47cf0acadc3c5db32b.zip | |
Merge pull request #2951 from lioncash/global
core: Remove Core::CurrentProcess()
Diffstat (limited to '')
| -rw-r--r-- | src/core/core.cpp | 7 | ||||
| -rw-r--r-- | src/core/core.h | 11 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 5 | ||||
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/handle_table.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/bcat.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/bcat.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/module.cpp | 34 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/module.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/fatal/fatal.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/ldr/ldr.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/ns/pl_u.cpp | 8 | ||||
| -rw-r--r-- | src/core/memory.cpp | 10 |
18 files changed, 87 insertions, 65 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 75a7ffb97..a58ceb703 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -111,7 +111,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 111 | } | 111 | } |
| 112 | struct System::Impl { | 112 | struct System::Impl { |
| 113 | explicit Impl(System& system) | 113 | explicit Impl(System& system) |
| 114 | : kernel{system}, cpu_core_manager{system}, applet_manager{system}, reporter{system} {} | 114 | : kernel{system}, fs_controller{system}, cpu_core_manager{system}, |
| 115 | applet_manager{system}, reporter{system} {} | ||
| 115 | 116 | ||
| 116 | Cpu& CurrentCpuCore() { | 117 | Cpu& CurrentCpuCore() { |
| 117 | return cpu_core_manager.GetCurrentCore(); | 118 | return cpu_core_manager.GetCurrentCore(); |
| @@ -641,11 +642,11 @@ bool System::GetExitLock() const { | |||
| 641 | return impl->exit_lock; | 642 | return impl->exit_lock; |
| 642 | } | 643 | } |
| 643 | 644 | ||
| 644 | void System::SetCurrentProcessBuildID(std::array<u8, 32> id) { | 645 | void System::SetCurrentProcessBuildID(const CurrentBuildProcessID& id) { |
| 645 | impl->build_id = id; | 646 | impl->build_id = id; |
| 646 | } | 647 | } |
| 647 | 648 | ||
| 648 | const std::array<u8, 32>& System::GetCurrentProcessBuildID() const { | 649 | const System::CurrentBuildProcessID& System::GetCurrentProcessBuildID() const { |
| 649 | return impl->build_id; | 650 | return impl->build_id; |
| 650 | } | 651 | } |
| 651 | 652 | ||
diff --git a/src/core/core.h b/src/core/core.h index f49b7fbf9..d13b6aa5e 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <string> | 9 | #include <string> |
| 10 | 10 | ||
| 11 | #include <map> | ||
| 12 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 13 | #include "core/file_sys/vfs_types.h" | 12 | #include "core/file_sys/vfs_types.h" |
| 14 | #include "core/hle/kernel/object.h" | 13 | #include "core/hle/kernel/object.h" |
| @@ -98,6 +97,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 98 | 97 | ||
| 99 | class System { | 98 | class System { |
| 100 | public: | 99 | public: |
| 100 | using CurrentBuildProcessID = std::array<u8, 0x20>; | ||
| 101 | |||
| 101 | System(const System&) = delete; | 102 | System(const System&) = delete; |
| 102 | System& operator=(const System&) = delete; | 103 | System& operator=(const System&) = delete; |
| 103 | 104 | ||
| @@ -330,9 +331,9 @@ public: | |||
| 330 | 331 | ||
| 331 | bool GetExitLock() const; | 332 | bool GetExitLock() const; |
| 332 | 333 | ||
| 333 | void SetCurrentProcessBuildID(std::array<u8, 0x20> id); | 334 | void SetCurrentProcessBuildID(const CurrentBuildProcessID& id); |
| 334 | 335 | ||
| 335 | const std::array<u8, 0x20>& GetCurrentProcessBuildID() const; | 336 | const CurrentBuildProcessID& GetCurrentProcessBuildID() const; |
| 336 | 337 | ||
| 337 | private: | 338 | private: |
| 338 | System(); | 339 | System(); |
| @@ -357,8 +358,4 @@ private: | |||
| 357 | static System s_instance; | 358 | static System s_instance; |
| 358 | }; | 359 | }; |
| 359 | 360 | ||
| 360 | inline Kernel::Process* CurrentProcess() { | ||
| 361 | return System::GetInstance().CurrentProcess(); | ||
| 362 | } | ||
| 363 | |||
| 364 | } // namespace Core | 361 | } // namespace Core |
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 84cd4684c..4bd2e6183 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -35,11 +35,11 @@ void RomFSFactory::SetPackedUpdate(VirtualFile update_raw) { | |||
| 35 | this->update_raw = std::move(update_raw); | 35 | this->update_raw = std::move(update_raw); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() const { | 38 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_title_id) const { |
| 39 | if (!updatable) | 39 | if (!updatable) |
| 40 | return MakeResult<VirtualFile>(file); | 40 | return MakeResult<VirtualFile>(file); |
| 41 | 41 | ||
| 42 | const PatchManager patch_manager(Core::CurrentProcess()->GetTitleID()); | 42 | const PatchManager patch_manager(current_process_title_id); |
| 43 | return MakeResult<VirtualFile>( | 43 | return MakeResult<VirtualFile>( |
| 44 | patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw)); | 44 | patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw)); |
| 45 | } | 45 | } |
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h index da63a313a..c5d40285c 100644 --- a/src/core/file_sys/romfs_factory.h +++ b/src/core/file_sys/romfs_factory.h | |||
| @@ -33,7 +33,7 @@ public: | |||
| 33 | ~RomFSFactory(); | 33 | ~RomFSFactory(); |
| 34 | 34 | ||
| 35 | void SetPackedUpdate(VirtualFile update_raw); | 35 | void SetPackedUpdate(VirtualFile update_raw); |
| 36 | ResultVal<VirtualFile> OpenCurrentProcess() const; | 36 | ResultVal<VirtualFile> OpenCurrentProcess(u64 current_process_title_id) const; |
| 37 | ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type) const; | 37 | ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type) const; |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index f77cc02ac..fc8755c78 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -127,8 +127,9 @@ std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType typ | |||
| 127 | u128 user_id, u64 save_id) { | 127 | u128 user_id, u64 save_id) { |
| 128 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | 128 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should |
| 129 | // be interpreted as the title id of the current process. | 129 | // be interpreted as the title id of the current process. |
| 130 | if (type == SaveDataType::SaveData && title_id == 0) | 130 | if (type == SaveDataType::SaveData && title_id == 0) { |
| 131 | title_id = Core::CurrentProcess()->GetTitleID(); | 131 | title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 132 | } | ||
| 132 | 133 | ||
| 133 | std::string out = GetSaveDataSpaceIdPath(space); | 134 | std::string out = GetSaveDataSpaceIdPath(space); |
| 134 | 135 | ||
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index afa812598..db51d722f 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -641,7 +641,8 @@ static void HandleQuery() { | |||
| 641 | strlen("Xfer:features:read:target.xml:")) == 0) { | 641 | strlen("Xfer:features:read:target.xml:")) == 0) { |
| 642 | SendReply(target_xml); | 642 | SendReply(target_xml); |
| 643 | } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) { | 643 | } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) { |
| 644 | const VAddr base_address = Core::CurrentProcess()->VMManager().GetCodeRegionBaseAddress(); | 644 | const VAddr base_address = |
| 645 | Core::System::GetInstance().CurrentProcess()->VMManager().GetCodeRegionBaseAddress(); | ||
| 645 | std::string buffer = fmt::format("TextSeg={:0x}", base_address); | 646 | std::string buffer = fmt::format("TextSeg={:0x}", base_address); |
| 646 | SendReply(buffer.c_str()); | 647 | SendReply(buffer.c_str()); |
| 647 | } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { | 648 | } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { |
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index bdfaa977f..2cc5d536b 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -103,7 +103,7 @@ SharedPtr<Object> HandleTable::GetGeneric(Handle handle) const { | |||
| 103 | if (handle == CurrentThread) { | 103 | if (handle == CurrentThread) { |
| 104 | return GetCurrentThread(); | 104 | return GetCurrentThread(); |
| 105 | } else if (handle == CurrentProcess) { | 105 | } else if (handle == CurrentProcess) { |
| 106 | return Core::CurrentProcess(); | 106 | return Core::System::GetInstance().CurrentProcess(); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | if (!IsValid(handle)) { | 109 | if (!IsValid(handle)) { |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 34409e0c3..941ebc93a 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -1142,12 +1142,12 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { | |||
| 1142 | if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) { | 1142 | if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) { |
| 1143 | const auto backend = BCAT::CreateBackendFromSettings( | 1143 | const auto backend = BCAT::CreateBackendFromSettings( |
| 1144 | [this](u64 tid) { return system.GetFileSystemController().GetBCATDirectory(tid); }); | 1144 | [this](u64 tid) { return system.GetFileSystemController().GetBCATDirectory(tid); }); |
| 1145 | const auto build_id_full = Core::System::GetInstance().GetCurrentProcessBuildID(); | 1145 | const auto build_id_full = system.GetCurrentProcessBuildID(); |
| 1146 | u64 build_id{}; | 1146 | u64 build_id{}; |
| 1147 | std::memcpy(&build_id, build_id_full.data(), sizeof(u64)); | 1147 | std::memcpy(&build_id, build_id_full.data(), sizeof(u64)); |
| 1148 | 1148 | ||
| 1149 | const auto data = | 1149 | const auto data = |
| 1150 | backend->GetLaunchParameter({Core::CurrentProcess()->GetTitleID(), build_id}); | 1150 | backend->GetLaunchParameter({system.CurrentProcess()->GetTitleID(), build_id}); |
| 1151 | 1151 | ||
| 1152 | if (data.has_value()) { | 1152 | if (data.has_value()) { |
| 1153 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 1153 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| @@ -1200,7 +1200,7 @@ void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) { | |||
| 1200 | LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]); | 1200 | LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]); |
| 1201 | 1201 | ||
| 1202 | FileSys::SaveDataDescriptor descriptor{}; | 1202 | FileSys::SaveDataDescriptor descriptor{}; |
| 1203 | descriptor.title_id = Core::CurrentProcess()->GetTitleID(); | 1203 | descriptor.title_id = system.CurrentProcess()->GetTitleID(); |
| 1204 | descriptor.user_id = user_id; | 1204 | descriptor.user_id = user_id; |
| 1205 | descriptor.type = FileSys::SaveDataType::SaveData; | 1205 | descriptor.type = FileSys::SaveDataType::SaveData; |
| 1206 | const auto res = system.GetFileSystemController().CreateSaveData( | 1206 | const auto res = system.GetFileSystemController().CreateSaveData( |
diff --git a/src/core/hle/service/bcat/bcat.cpp b/src/core/hle/service/bcat/bcat.cpp index c2f946424..8bb2528c9 100644 --- a/src/core/hle/service/bcat/bcat.cpp +++ b/src/core/hle/service/bcat/bcat.cpp | |||
| @@ -6,8 +6,9 @@ | |||
| 6 | 6 | ||
| 7 | namespace Service::BCAT { | 7 | namespace Service::BCAT { |
| 8 | 8 | ||
| 9 | BCAT::BCAT(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc, const char* name) | 9 | BCAT::BCAT(Core::System& system, std::shared_ptr<Module> module, |
| 10 | : Module::Interface(std::move(module), fsc, name) { | 10 | FileSystem::FileSystemController& fsc, const char* name) |
| 11 | : Interface(system, std::move(module), fsc, name) { | ||
| 11 | // clang-format off | 12 | // clang-format off |
| 12 | static const FunctionInfo functions[] = { | 13 | static const FunctionInfo functions[] = { |
| 13 | {0, &BCAT::CreateBcatService, "CreateBcatService"}, | 14 | {0, &BCAT::CreateBcatService, "CreateBcatService"}, |
diff --git a/src/core/hle/service/bcat/bcat.h b/src/core/hle/service/bcat/bcat.h index 813073658..6354465fc 100644 --- a/src/core/hle/service/bcat/bcat.h +++ b/src/core/hle/service/bcat/bcat.h | |||
| @@ -6,12 +6,16 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/bcat/module.h" | 7 | #include "core/hle/service/bcat/module.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace Service::BCAT { | 13 | namespace Service::BCAT { |
| 10 | 14 | ||
| 11 | class BCAT final : public Module::Interface { | 15 | class BCAT final : public Module::Interface { |
| 12 | public: | 16 | public: |
| 13 | explicit BCAT(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc, | 17 | explicit BCAT(Core::System& system, std::shared_ptr<Module> module, |
| 14 | const char* name); | 18 | FileSystem::FileSystemController& fsc, const char* name); |
| 15 | ~BCAT() override; | 19 | ~BCAT() override; |
| 16 | }; | 20 | }; |
| 17 | 21 | ||
diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index 1f21b0434..4e4aa758b 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp | |||
| @@ -35,8 +35,7 @@ using BCATDigest = std::array<u8, 0x10>; | |||
| 35 | 35 | ||
| 36 | namespace { | 36 | namespace { |
| 37 | 37 | ||
| 38 | u64 GetCurrentBuildID() { | 38 | u64 GetCurrentBuildID(const Core::System::CurrentBuildProcessID& id) { |
| 39 | const auto& id = Core::System::GetInstance().GetCurrentProcessBuildID(); | ||
| 40 | u64 out{}; | 39 | u64 out{}; |
| 41 | std::memcpy(&out, id.data(), sizeof(u64)); | 40 | std::memcpy(&out, id.data(), sizeof(u64)); |
| 42 | return out; | 41 | return out; |
| @@ -125,7 +124,8 @@ private: | |||
| 125 | 124 | ||
| 126 | class IBcatService final : public ServiceFramework<IBcatService> { | 125 | class IBcatService final : public ServiceFramework<IBcatService> { |
| 127 | public: | 126 | public: |
| 128 | IBcatService(Backend& backend) : ServiceFramework("IBcatService"), backend(backend) { | 127 | explicit IBcatService(Core::System& system_, Backend& backend_) |
| 128 | : ServiceFramework("IBcatService"), system{system_}, backend{backend_} { | ||
| 129 | // clang-format off | 129 | // clang-format off |
| 130 | static const FunctionInfo functions[] = { | 130 | static const FunctionInfo functions[] = { |
| 131 | {10100, &IBcatService::RequestSyncDeliveryCache, "RequestSyncDeliveryCache"}, | 131 | {10100, &IBcatService::RequestSyncDeliveryCache, "RequestSyncDeliveryCache"}, |
| @@ -163,7 +163,8 @@ private: | |||
| 163 | void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { | 163 | void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { |
| 164 | LOG_DEBUG(Service_BCAT, "called"); | 164 | LOG_DEBUG(Service_BCAT, "called"); |
| 165 | 165 | ||
| 166 | backend.Synchronize({Core::CurrentProcess()->GetTitleID(), GetCurrentBuildID()}, | 166 | backend.Synchronize({system.CurrentProcess()->GetTitleID(), |
| 167 | GetCurrentBuildID(system.GetCurrentProcessBuildID())}, | ||
| 167 | progress.at(static_cast<std::size_t>(SyncType::Normal))); | 168 | progress.at(static_cast<std::size_t>(SyncType::Normal))); |
| 168 | 169 | ||
| 169 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 170 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| @@ -179,7 +180,8 @@ private: | |||
| 179 | 180 | ||
| 180 | LOG_DEBUG(Service_BCAT, "called, name={}", name); | 181 | LOG_DEBUG(Service_BCAT, "called, name={}", name); |
| 181 | 182 | ||
| 182 | backend.SynchronizeDirectory({Core::CurrentProcess()->GetTitleID(), GetCurrentBuildID()}, | 183 | backend.SynchronizeDirectory({system.CurrentProcess()->GetTitleID(), |
| 184 | GetCurrentBuildID(system.GetCurrentProcessBuildID())}, | ||
| 183 | name, | 185 | name, |
| 184 | progress.at(static_cast<std::size_t>(SyncType::Directory))); | 186 | progress.at(static_cast<std::size_t>(SyncType::Directory))); |
| 185 | 187 | ||
| @@ -244,6 +246,7 @@ private: | |||
| 244 | rb.Push(RESULT_SUCCESS); | 246 | rb.Push(RESULT_SUCCESS); |
| 245 | } | 247 | } |
| 246 | 248 | ||
| 249 | Core::System& system; | ||
| 247 | Backend& backend; | 250 | Backend& backend; |
| 248 | 251 | ||
| 249 | std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress{ | 252 | std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress{ |
| @@ -257,7 +260,7 @@ void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { | |||
| 257 | 260 | ||
| 258 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 261 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 259 | rb.Push(RESULT_SUCCESS); | 262 | rb.Push(RESULT_SUCCESS); |
| 260 | rb.PushIpcInterface<IBcatService>(*backend); | 263 | rb.PushIpcInterface<IBcatService>(system, *backend); |
| 261 | } | 264 | } |
| 262 | 265 | ||
| 263 | class IDeliveryCacheFileService final : public ServiceFramework<IDeliveryCacheFileService> { | 266 | class IDeliveryCacheFileService final : public ServiceFramework<IDeliveryCacheFileService> { |
| @@ -539,7 +542,7 @@ void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestCont | |||
| 539 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 542 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 540 | rb.Push(RESULT_SUCCESS); | 543 | rb.Push(RESULT_SUCCESS); |
| 541 | rb.PushIpcInterface<IDeliveryCacheStorageService>( | 544 | rb.PushIpcInterface<IDeliveryCacheStorageService>( |
| 542 | fsc.GetBCATDirectory(Core::CurrentProcess()->GetTitleID())); | 545 | fsc.GetBCATDirectory(system.CurrentProcess()->GetTitleID())); |
| 543 | } | 546 | } |
| 544 | 547 | ||
| 545 | void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId( | 548 | void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId( |
| @@ -565,22 +568,23 @@ std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) { | |||
| 565 | return std::make_unique<NullBackend>(std::move(getter)); | 568 | return std::make_unique<NullBackend>(std::move(getter)); |
| 566 | } | 569 | } |
| 567 | 570 | ||
| 568 | Module::Interface::Interface(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc, | 571 | Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_, |
| 569 | const char* name) | 572 | FileSystem::FileSystemController& fsc_, const char* name) |
| 570 | : ServiceFramework(name), fsc(fsc), module(std::move(module)), | 573 | : ServiceFramework(name), fsc{fsc_}, module{std::move(module_)}, |
| 571 | backend(CreateBackendFromSettings([&fsc](u64 tid) { return fsc.GetBCATDirectory(tid); })) {} | 574 | backend{CreateBackendFromSettings([&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })}, |
| 575 | system{system_} {} | ||
| 572 | 576 | ||
| 573 | Module::Interface::~Interface() = default; | 577 | Module::Interface::~Interface() = default; |
| 574 | 578 | ||
| 575 | void InstallInterfaces(Core::System& system) { | 579 | void InstallInterfaces(Core::System& system) { |
| 576 | auto module = std::make_shared<Module>(); | 580 | auto module = std::make_shared<Module>(); |
| 577 | std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:a") | 581 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:a") |
| 578 | ->InstallAsService(system.ServiceManager()); | 582 | ->InstallAsService(system.ServiceManager()); |
| 579 | std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:m") | 583 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:m") |
| 580 | ->InstallAsService(system.ServiceManager()); | 584 | ->InstallAsService(system.ServiceManager()); |
| 581 | std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:u") | 585 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:u") |
| 582 | ->InstallAsService(system.ServiceManager()); | 586 | ->InstallAsService(system.ServiceManager()); |
| 583 | std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:s") | 587 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:s") |
| 584 | ->InstallAsService(system.ServiceManager()); | 588 | ->InstallAsService(system.ServiceManager()); |
| 585 | } | 589 | } |
| 586 | 590 | ||
diff --git a/src/core/hle/service/bcat/module.h b/src/core/hle/service/bcat/module.h index 27469926a..e4ba23ba0 100644 --- a/src/core/hle/service/bcat/module.h +++ b/src/core/hle/service/bcat/module.h | |||
| @@ -6,6 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace Service { | 13 | namespace Service { |
| 10 | 14 | ||
| 11 | namespace FileSystem { | 15 | namespace FileSystem { |
| @@ -20,8 +24,8 @@ class Module final { | |||
| 20 | public: | 24 | public: |
| 21 | class Interface : public ServiceFramework<Interface> { | 25 | class Interface : public ServiceFramework<Interface> { |
| 22 | public: | 26 | public: |
| 23 | explicit Interface(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc, | 27 | explicit Interface(Core::System& system_, std::shared_ptr<Module> module_, |
| 24 | const char* name); | 28 | FileSystem::FileSystemController& fsc_, const char* name); |
| 25 | ~Interface() override; | 29 | ~Interface() override; |
| 26 | 30 | ||
| 27 | void CreateBcatService(Kernel::HLERequestContext& ctx); | 31 | void CreateBcatService(Kernel::HLERequestContext& ctx); |
| @@ -33,6 +37,9 @@ public: | |||
| 33 | 37 | ||
| 34 | std::shared_ptr<Module> module; | 38 | std::shared_ptr<Module> module; |
| 35 | std::unique_ptr<Backend> backend; | 39 | std::unique_ptr<Backend> backend; |
| 40 | |||
| 41 | private: | ||
| 42 | Core::System& system; | ||
| 36 | }; | 43 | }; |
| 37 | }; | 44 | }; |
| 38 | 45 | ||
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index b2ebf6240..2546d7595 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp | |||
| @@ -66,7 +66,7 @@ enum class FatalType : u32 { | |||
| 66 | 66 | ||
| 67 | static void GenerateErrorReport(Core::System& system, ResultCode error_code, | 67 | static void GenerateErrorReport(Core::System& system, ResultCode error_code, |
| 68 | const FatalInfo& info) { | 68 | const FatalInfo& info) { |
| 69 | const auto title_id = Core::CurrentProcess()->GetTitleID(); | 69 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| 70 | std::string crash_report = fmt::format( | 70 | std::string crash_report = fmt::format( |
| 71 | "Yuzu {}-{} crash report\n" | 71 | "Yuzu {}-{} crash report\n" |
| 72 | "Title ID: {:016x}\n" | 72 | "Title ID: {:016x}\n" |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 7fa4e820b..11e5c56b7 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -241,7 +241,7 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( | |||
| 241 | return FileSys::ERROR_PATH_NOT_FOUND; | 241 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | FileSystemController::FileSystemController() = default; | 244 | FileSystemController::FileSystemController(Core::System& system_) : system{system_} {} |
| 245 | 245 | ||
| 246 | FileSystemController::~FileSystemController() = default; | 246 | FileSystemController::~FileSystemController() = default; |
| 247 | 247 | ||
| @@ -290,7 +290,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess() | |||
| 290 | return ResultCode(-1); | 290 | return ResultCode(-1); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | return romfs_factory->OpenCurrentProcess(); | 293 | return romfs_factory->OpenCurrentProcess(system.CurrentProcess()->GetTitleID()); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS( | 296 | ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS( |
| @@ -447,10 +447,10 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy | |||
| 447 | FileSys::SaveDataSize new_size{SUFFICIENT_SAVE_DATA_SIZE, SUFFICIENT_SAVE_DATA_SIZE}; | 447 | FileSys::SaveDataSize new_size{SUFFICIENT_SAVE_DATA_SIZE, SUFFICIENT_SAVE_DATA_SIZE}; |
| 448 | 448 | ||
| 449 | FileSys::NACP nacp; | 449 | FileSys::NACP nacp; |
| 450 | const auto res = Core::System::GetInstance().GetAppLoader().ReadControlData(nacp); | 450 | const auto res = system.GetAppLoader().ReadControlData(nacp); |
| 451 | 451 | ||
| 452 | if (res != Loader::ResultStatus::Success) { | 452 | if (res != Loader::ResultStatus::Success) { |
| 453 | FileSys::PatchManager pm{Core::CurrentProcess()->GetTitleID()}; | 453 | FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()}; |
| 454 | auto [nacp_unique, discard] = pm.GetControlMetadata(); | 454 | auto [nacp_unique, discard] = pm.GetControlMetadata(); |
| 455 | 455 | ||
| 456 | if (nacp_unique != nullptr) { | 456 | if (nacp_unique != nullptr) { |
| @@ -702,10 +702,10 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove | |||
| 702 | if (bis_factory == nullptr) { | 702 | if (bis_factory == nullptr) { |
| 703 | bis_factory = | 703 | bis_factory = |
| 704 | std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); | 704 | std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); |
| 705 | Core::System::GetInstance().RegisterContentProvider( | 705 | system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::SysNAND, |
| 706 | FileSys::ContentProviderUnionSlot::SysNAND, bis_factory->GetSystemNANDContents()); | 706 | bis_factory->GetSystemNANDContents()); |
| 707 | Core::System::GetInstance().RegisterContentProvider( | 707 | system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::UserNAND, |
| 708 | FileSys::ContentProviderUnionSlot::UserNAND, bis_factory->GetUserNANDContents()); | 708 | bis_factory->GetUserNANDContents()); |
| 709 | } | 709 | } |
| 710 | 710 | ||
| 711 | if (save_data_factory == nullptr) { | 711 | if (save_data_factory == nullptr) { |
| @@ -714,8 +714,8 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove | |||
| 714 | 714 | ||
| 715 | if (sdmc_factory == nullptr) { | 715 | if (sdmc_factory == nullptr) { |
| 716 | sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); | 716 | sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); |
| 717 | Core::System::GetInstance().RegisterContentProvider(FileSys::ContentProviderUnionSlot::SDMC, | 717 | system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::SDMC, |
| 718 | sdmc_factory->GetSDMCContents()); | 718 | sdmc_factory->GetSDMCContents()); |
| 719 | } | 719 | } |
| 720 | } | 720 | } |
| 721 | 721 | ||
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index e6b49d8a2..1b0a6a949 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | #include "core/file_sys/vfs.h" | 10 | #include "core/file_sys/vfs.h" |
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | 12 | ||
| 13 | namespace Core { | ||
| 14 | class System; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace FileSys { | 17 | namespace FileSys { |
| 14 | class BISFactory; | 18 | class BISFactory; |
| 15 | class RegisteredCache; | 19 | class RegisteredCache; |
| @@ -52,7 +56,7 @@ enum class ImageDirectoryId : u32 { | |||
| 52 | 56 | ||
| 53 | class FileSystemController { | 57 | class FileSystemController { |
| 54 | public: | 58 | public: |
| 55 | FileSystemController(); | 59 | explicit FileSystemController(Core::System& system_); |
| 56 | ~FileSystemController(); | 60 | ~FileSystemController(); |
| 57 | 61 | ||
| 58 | ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory); | 62 | ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory); |
| @@ -125,6 +129,8 @@ private: | |||
| 125 | std::unique_ptr<FileSys::XCI> gamecard; | 129 | std::unique_ptr<FileSys::XCI> gamecard; |
| 126 | std::unique_ptr<FileSys::RegisteredCache> gamecard_registered; | 130 | std::unique_ptr<FileSys::RegisteredCache> gamecard_registered; |
| 127 | std::unique_ptr<FileSys::PlaceholderCache> gamecard_placeholder; | 131 | std::unique_ptr<FileSys::PlaceholderCache> gamecard_placeholder; |
| 132 | |||
| 133 | Core::System& system; | ||
| 128 | }; | 134 | }; |
| 129 | 135 | ||
| 130 | void InstallInterfaces(Core::System& system); | 136 | void InstallInterfaces(Core::System& system); |
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index 3164ca26e..499376bfc 100644 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp | |||
| @@ -163,7 +163,7 @@ public: | |||
| 163 | return; | 163 | return; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | if (Core::CurrentProcess()->GetTitleID() != header.title_id) { | 166 | if (system.CurrentProcess()->GetTitleID() != header.title_id) { |
| 167 | LOG_ERROR(Service_LDR, | 167 | LOG_ERROR(Service_LDR, |
| 168 | "Attempting to load NRR with title ID other than current process. (actual " | 168 | "Attempting to load NRR with title ID other than current process. (actual " |
| 169 | "{:016X})!", | 169 | "{:016X})!", |
| @@ -327,7 +327,7 @@ public: | |||
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | // Load NRO as new executable module | 329 | // Load NRO as new executable module |
| 330 | auto* process = Core::CurrentProcess(); | 330 | auto* process = system.CurrentProcess(); |
| 331 | auto& vm_manager = process->VMManager(); | 331 | auto& vm_manager = process->VMManager(); |
| 332 | auto map_address = vm_manager.FindFreeRegion(nro_size + bss_size); | 332 | auto map_address = vm_manager.FindFreeRegion(nro_size + bss_size); |
| 333 | 333 | ||
| @@ -411,7 +411,7 @@ public: | |||
| 411 | return; | 411 | return; |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | auto& vm_manager = Core::CurrentProcess()->VMManager(); | 414 | auto& vm_manager = system.CurrentProcess()->VMManager(); |
| 415 | const auto& nro_info = iter->second; | 415 | const auto& nro_info = iter->second; |
| 416 | 416 | ||
| 417 | // Unmap the mirrored memory | 417 | // Unmap the mirrored memory |
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 7dcdb4a07..f64535237 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp | |||
| @@ -324,14 +324,14 @@ void PL_U::GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx) { | |||
| 324 | void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { | 324 | void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { |
| 325 | // Map backing memory for the font data | 325 | // Map backing memory for the font data |
| 326 | LOG_DEBUG(Service_NS, "called"); | 326 | LOG_DEBUG(Service_NS, "called"); |
| 327 | Core::CurrentProcess()->VMManager().MapMemoryBlock(SHARED_FONT_MEM_VADDR, impl->shared_font, 0, | 327 | system.CurrentProcess()->VMManager().MapMemoryBlock(SHARED_FONT_MEM_VADDR, impl->shared_font, 0, |
| 328 | SHARED_FONT_MEM_SIZE, | 328 | SHARED_FONT_MEM_SIZE, |
| 329 | Kernel::MemoryState::Shared); | 329 | Kernel::MemoryState::Shared); |
| 330 | 330 | ||
| 331 | // Create shared font memory object | 331 | // Create shared font memory object |
| 332 | auto& kernel = system.Kernel(); | 332 | auto& kernel = system.Kernel(); |
| 333 | impl->shared_font_mem = Kernel::SharedMemory::Create( | 333 | impl->shared_font_mem = Kernel::SharedMemory::Create( |
| 334 | kernel, Core::CurrentProcess(), SHARED_FONT_MEM_SIZE, Kernel::MemoryPermission::ReadWrite, | 334 | kernel, system.CurrentProcess(), SHARED_FONT_MEM_SIZE, Kernel::MemoryPermission::ReadWrite, |
| 335 | Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE, | 335 | Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE, |
| 336 | "PL_U:shared_font_mem"); | 336 | "PL_U:shared_font_mem"); |
| 337 | 337 | ||
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 9e030789d..fa49f3dd0 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -146,7 +146,7 @@ static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { | |||
| 146 | * using a VMA from the current process. | 146 | * using a VMA from the current process. |
| 147 | */ | 147 | */ |
| 148 | static u8* GetPointerFromVMA(VAddr vaddr) { | 148 | static u8* GetPointerFromVMA(VAddr vaddr) { |
| 149 | return GetPointerFromVMA(*Core::CurrentProcess(), vaddr); | 149 | return GetPointerFromVMA(*Core::System::GetInstance().CurrentProcess(), vaddr); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | template <typename T> | 152 | template <typename T> |
| @@ -226,7 +226,7 @@ bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { | |||
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | bool IsValidVirtualAddress(const VAddr vaddr) { | 228 | bool IsValidVirtualAddress(const VAddr vaddr) { |
| 229 | return IsValidVirtualAddress(*Core::CurrentProcess(), vaddr); | 229 | return IsValidVirtualAddress(*Core::System::GetInstance().CurrentProcess(), vaddr); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | bool IsKernelVirtualAddress(const VAddr vaddr) { | 232 | bool IsKernelVirtualAddress(const VAddr vaddr) { |
| @@ -387,7 +387,7 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_ | |||
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) { | 389 | void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) { |
| 390 | ReadBlock(*Core::CurrentProcess(), src_addr, dest_buffer, size); | 390 | ReadBlock(*Core::System::GetInstance().CurrentProcess(), src_addr, dest_buffer, size); |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | void Write8(const VAddr addr, const u8 data) { | 393 | void Write8(const VAddr addr, const u8 data) { |
| @@ -450,7 +450,7 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi | |||
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { | 452 | void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { |
| 453 | WriteBlock(*Core::CurrentProcess(), dest_addr, src_buffer, size); | 453 | WriteBlock(*Core::System::GetInstance().CurrentProcess(), dest_addr, src_buffer, size); |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { | 456 | void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { |
| @@ -539,7 +539,7 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, | |||
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | void CopyBlock(VAddr dest_addr, VAddr src_addr, std::size_t size) { | 541 | void CopyBlock(VAddr dest_addr, VAddr src_addr, std::size_t size) { |
| 542 | CopyBlock(*Core::CurrentProcess(), dest_addr, src_addr, size); | 542 | CopyBlock(*Core::System::GetInstance().CurrentProcess(), dest_addr, src_addr, size); |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | } // namespace Memory | 545 | } // namespace Memory |