diff options
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index c00dfd33c..2d7e83522 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include "core/hle/kernel/scheduler.h" | 25 | #include "core/hle/kernel/scheduler.h" |
| 26 | #include "core/hle/kernel/thread.h" | 26 | #include "core/hle/kernel/thread.h" |
| 27 | #include "core/hle/service/am/applets/applets.h" | 27 | #include "core/hle/service/am/applets/applets.h" |
| 28 | #include "core/hle/service/glue/manager.h" | ||
| 28 | #include "core/hle/service/service.h" | 29 | #include "core/hle/service/service.h" |
| 29 | #include "core/hle/service/sm/sm.h" | 30 | #include "core/hle/service/sm/sm.h" |
| 30 | #include "core/loader/loader.h" | 31 | #include "core/loader/loader.h" |
| @@ -33,12 +34,39 @@ | |||
| 33 | #include "core/settings.h" | 34 | #include "core/settings.h" |
| 34 | #include "core/telemetry_session.h" | 35 | #include "core/telemetry_session.h" |
| 35 | #include "file_sys/cheat_engine.h" | 36 | #include "file_sys/cheat_engine.h" |
| 37 | #include "file_sys/patch_manager.h" | ||
| 36 | #include "video_core/debug_utils/debug_utils.h" | 38 | #include "video_core/debug_utils/debug_utils.h" |
| 37 | #include "video_core/renderer_base.h" | 39 | #include "video_core/renderer_base.h" |
| 38 | #include "video_core/video_core.h" | 40 | #include "video_core/video_core.h" |
| 39 | 41 | ||
| 40 | namespace Core { | 42 | namespace Core { |
| 41 | 43 | ||
| 44 | namespace { | ||
| 45 | |||
| 46 | FileSys::StorageId GetStorageIdForFrontendSlot( | ||
| 47 | std::optional<FileSys::ContentProviderUnionSlot> slot) { | ||
| 48 | if (!slot.has_value()) { | ||
| 49 | return FileSys::StorageId::None; | ||
| 50 | } | ||
| 51 | |||
| 52 | switch (*slot) { | ||
| 53 | case FileSys::ContentProviderUnionSlot::UserNAND: | ||
| 54 | return FileSys::StorageId::NandUser; | ||
| 55 | case FileSys::ContentProviderUnionSlot::SysNAND: | ||
| 56 | return FileSys::StorageId::NandSystem; | ||
| 57 | case FileSys::ContentProviderUnionSlot::SDMC: | ||
| 58 | return FileSys::StorageId::SdCard; | ||
| 59 | case FileSys::ContentProviderUnionSlot::FrontendManual: | ||
| 60 | return FileSys::StorageId::Host; | ||
| 61 | default: | ||
| 62 | return FileSys::StorageId::None; | ||
| 63 | } | ||
| 64 | |||
| 65 | UNREACHABLE(); | ||
| 66 | } | ||
| 67 | |||
| 68 | } // Anonymous namespace | ||
| 69 | |||
| 42 | /*static*/ System System::s_instance; | 70 | /*static*/ System System::s_instance; |
| 43 | 71 | ||
| 44 | FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | 72 | FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, |
| @@ -110,6 +138,9 @@ struct System::Impl { | |||
| 110 | /// Create default implementations of applets if one is not provided. | 138 | /// Create default implementations of applets if one is not provided. |
| 111 | applet_manager.SetDefaultAppletsIfMissing(); | 139 | applet_manager.SetDefaultAppletsIfMissing(); |
| 112 | 140 | ||
| 141 | /// Reset all glue registrations | ||
| 142 | arp_manager.ResetAll(); | ||
| 143 | |||
| 113 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 144 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| 114 | service_manager = std::make_shared<Service::SM::ServiceManager>(); | 145 | service_manager = std::make_shared<Service::SM::ServiceManager>(); |
| 115 | 146 | ||
| @@ -161,6 +192,7 @@ struct System::Impl { | |||
| 161 | return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + | 192 | return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + |
| 162 | static_cast<u32>(load_result)); | 193 | static_cast<u32>(load_result)); |
| 163 | } | 194 | } |
| 195 | AddGlueRegistrationForProcess(*app_loader, *main_process); | ||
| 164 | kernel.MakeCurrentProcess(main_process.get()); | 196 | kernel.MakeCurrentProcess(main_process.get()); |
| 165 | 197 | ||
| 166 | // Main process has been loaded and been made current. | 198 | // Main process has been loaded and been made current. |
| @@ -219,6 +251,31 @@ struct System::Impl { | |||
| 219 | return app_loader->ReadTitle(out); | 251 | return app_loader->ReadTitle(out); |
| 220 | } | 252 | } |
| 221 | 253 | ||
| 254 | void AddGlueRegistrationForProcess(Loader::AppLoader& loader, Kernel::Process& process) { | ||
| 255 | std::vector<u8> nacp_data; | ||
| 256 | FileSys::NACP nacp; | ||
| 257 | if (loader.ReadControlData(nacp) == Loader::ResultStatus::Success) { | ||
| 258 | nacp_data = nacp.GetRawBytes(); | ||
| 259 | } else { | ||
| 260 | nacp_data.resize(sizeof(FileSys::RawNACP)); | ||
| 261 | } | ||
| 262 | |||
| 263 | Service::Glue::ApplicationLaunchProperty launch{}; | ||
| 264 | launch.title_id = process.GetTitleID(); | ||
| 265 | |||
| 266 | FileSys::PatchManager pm{launch.title_id}; | ||
| 267 | launch.version = pm.GetGameVersion().value_or(0); | ||
| 268 | |||
| 269 | // TODO(DarkLordZach): When FSController/Game Card Support is added, if | ||
| 270 | // current_process_game_card use correct StorageId | ||
| 271 | launch.base_game_storage_id = GetStorageIdForFrontendSlot(content_provider->GetSlotForEntry( | ||
| 272 | launch.title_id, FileSys::ContentRecordType::Program)); | ||
| 273 | launch.update_storage_id = GetStorageIdForFrontendSlot(content_provider->GetSlotForEntry( | ||
| 274 | FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); | ||
| 275 | |||
| 276 | arp_manager.Register(launch.title_id, launch, std::move(nacp_data)); | ||
| 277 | } | ||
| 278 | |||
| 222 | void SetStatus(ResultStatus new_status, const char* details = nullptr) { | 279 | void SetStatus(ResultStatus new_status, const char* details = nullptr) { |
| 223 | status = new_status; | 280 | status = new_status; |
| 224 | if (details) { | 281 | if (details) { |
| @@ -249,6 +306,9 @@ struct System::Impl { | |||
| 249 | /// Frontend applets | 306 | /// Frontend applets |
| 250 | Service::AM::Applets::AppletManager applet_manager; | 307 | Service::AM::Applets::AppletManager applet_manager; |
| 251 | 308 | ||
| 309 | /// Glue services | ||
| 310 | Service::Glue::ARPManager arp_manager; | ||
| 311 | |||
| 252 | /// Service manager | 312 | /// Service manager |
| 253 | std::shared_ptr<Service::SM::ServiceManager> service_manager; | 313 | std::shared_ptr<Service::SM::ServiceManager> service_manager; |
| 254 | 314 | ||
| @@ -500,6 +560,14 @@ const Reporter& System::GetReporter() const { | |||
| 500 | return impl->reporter; | 560 | return impl->reporter; |
| 501 | } | 561 | } |
| 502 | 562 | ||
| 563 | Service::Glue::ARPManager& System::GetARPManager() { | ||
| 564 | return impl->arp_manager; | ||
| 565 | } | ||
| 566 | |||
| 567 | const Service::Glue::ARPManager& System::GetARPManager() const { | ||
| 568 | return impl->arp_manager; | ||
| 569 | } | ||
| 570 | |||
| 503 | System::ResultStatus System::Init(Frontend::EmuWindow& emu_window) { | 571 | System::ResultStatus System::Init(Frontend::EmuWindow& emu_window) { |
| 504 | return impl->Init(*this, emu_window); | 572 | return impl->Init(*this, emu_window); |
| 505 | } | 573 | } |