core.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <array>
  5. #include <memory>
  6. #include <utility>
  7. #include "common/file_util.h"
  8. #include "common/logging/log.h"
  9. #include "common/string_util.h"
  10. #include "core/arm/exclusive_monitor.h"
  11. #include "core/core.h"
  12. #include "core/core_cpu.h"
  13. #include "core/core_timing.h"
  14. #include "core/cpu_core_manager.h"
  15. #include "core/file_sys/bis_factory.h"
  16. #include "core/file_sys/card_image.h"
  17. #include "core/file_sys/mode.h"
  18. #include "core/file_sys/patch_manager.h"
  19. #include "core/file_sys/registered_cache.h"
  20. #include "core/file_sys/romfs_factory.h"
  21. #include "core/file_sys/savedata_factory.h"
  22. #include "core/file_sys/sdmc_factory.h"
  23. #include "core/file_sys/vfs_concat.h"
  24. #include "core/file_sys/vfs_real.h"
  25. #include "core/gdbstub/gdbstub.h"
  26. #include "core/hardware_interrupt_manager.h"
  27. #include "core/hle/kernel/client_port.h"
  28. #include "core/hle/kernel/kernel.h"
  29. #include "core/hle/kernel/process.h"
  30. #include "core/hle/kernel/scheduler.h"
  31. #include "core/hle/kernel/thread.h"
  32. #include "core/hle/service/am/applets/applets.h"
  33. #include "core/hle/service/apm/controller.h"
  34. #include "core/hle/service/filesystem/filesystem.h"
  35. #include "core/hle/service/glue/manager.h"
  36. #include "core/hle/service/lm/manager.h"
  37. #include "core/hle/service/service.h"
  38. #include "core/hle/service/sm/sm.h"
  39. #include "core/loader/loader.h"
  40. #include "core/memory/cheat_engine.h"
  41. #include "core/perf_stats.h"
  42. #include "core/reporter.h"
  43. #include "core/settings.h"
  44. #include "core/telemetry_session.h"
  45. #include "core/tools/freezer.h"
  46. #include "video_core/debug_utils/debug_utils.h"
  47. #include "video_core/renderer_base.h"
  48. #include "video_core/video_core.h"
  49. namespace Core {
  50. namespace {
  51. FileSys::StorageId GetStorageIdForFrontendSlot(
  52. std::optional<FileSys::ContentProviderUnionSlot> slot) {
  53. if (!slot.has_value()) {
  54. return FileSys::StorageId::None;
  55. }
  56. switch (*slot) {
  57. case FileSys::ContentProviderUnionSlot::UserNAND:
  58. return FileSys::StorageId::NandUser;
  59. case FileSys::ContentProviderUnionSlot::SysNAND:
  60. return FileSys::StorageId::NandSystem;
  61. case FileSys::ContentProviderUnionSlot::SDMC:
  62. return FileSys::StorageId::SdCard;
  63. case FileSys::ContentProviderUnionSlot::FrontendManual:
  64. return FileSys::StorageId::Host;
  65. default:
  66. return FileSys::StorageId::None;
  67. }
  68. }
  69. } // Anonymous namespace
  70. /*static*/ System System::s_instance;
  71. FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
  72. const std::string& path) {
  73. // To account for split 00+01+etc files.
  74. std::string dir_name;
  75. std::string filename;
  76. Common::SplitPath(path, &dir_name, &filename, nullptr);
  77. if (filename == "00") {
  78. const auto dir = vfs->OpenDirectory(dir_name, FileSys::Mode::Read);
  79. std::vector<FileSys::VirtualFile> concat;
  80. for (u8 i = 0; i < 0x10; ++i) {
  81. auto next = dir->GetFile(fmt::format("{:02X}", i));
  82. if (next != nullptr)
  83. concat.push_back(std::move(next));
  84. else {
  85. next = dir->GetFile(fmt::format("{:02x}", i));
  86. if (next != nullptr)
  87. concat.push_back(std::move(next));
  88. else
  89. break;
  90. }
  91. }
  92. if (concat.empty())
  93. return nullptr;
  94. return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(concat, dir->GetName());
  95. }
  96. if (FileUtil::IsDirectory(path))
  97. return vfs->OpenFile(path + "/" + "main", FileSys::Mode::Read);
  98. return vfs->OpenFile(path, FileSys::Mode::Read);
  99. }
  100. struct System::Impl {
  101. explicit Impl(System& system)
  102. : kernel{system}, fs_controller{system}, cpu_core_manager{system},
  103. applet_manager{system}, reporter{system} {}
  104. Cpu& CurrentCpuCore() {
  105. return cpu_core_manager.GetCurrentCore();
  106. }
  107. ResultStatus RunLoop(bool tight_loop) {
  108. status = ResultStatus::Success;
  109. cpu_core_manager.RunLoop(tight_loop);
  110. return status;
  111. }
  112. ResultStatus Init(System& system, Frontend::EmuWindow& emu_window) {
  113. LOG_DEBUG(HW_Memory, "initialized OK");
  114. core_timing.Initialize();
  115. cpu_core_manager.Initialize();
  116. kernel.Initialize();
  117. const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
  118. std::chrono::system_clock::now().time_since_epoch());
  119. Settings::values.custom_rtc_differential =
  120. Settings::values.custom_rtc.value_or(current_time) - current_time;
  121. // Create a default fs if one doesn't already exist.
  122. if (virtual_filesystem == nullptr)
  123. virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>();
  124. if (content_provider == nullptr)
  125. content_provider = std::make_unique<FileSys::ContentProviderUnion>();
  126. /// Create default implementations of applets if one is not provided.
  127. applet_manager.SetDefaultAppletsIfMissing();
  128. /// Reset all glue registrations
  129. arp_manager.ResetAll();
  130. telemetry_session = std::make_unique<Core::TelemetrySession>();
  131. service_manager = std::make_shared<Service::SM::ServiceManager>();
  132. Service::Init(service_manager, system);
  133. GDBStub::Init();
  134. renderer = VideoCore::CreateRenderer(emu_window, system);
  135. if (!renderer->Init()) {
  136. return ResultStatus::ErrorVideoCore;
  137. }
  138. interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system);
  139. gpu_core = VideoCore::CreateGPU(system);
  140. is_powered_on = true;
  141. exit_lock = false;
  142. LOG_DEBUG(Core, "Initialized OK");
  143. return ResultStatus::Success;
  144. }
  145. ResultStatus Load(System& system, Frontend::EmuWindow& emu_window,
  146. const std::string& filepath) {
  147. app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath));
  148. if (!app_loader) {
  149. LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);
  150. return ResultStatus::ErrorGetLoader;
  151. }
  152. ResultStatus init_result{Init(system, emu_window)};
  153. if (init_result != ResultStatus::Success) {
  154. LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
  155. static_cast<int>(init_result));
  156. Shutdown();
  157. return init_result;
  158. }
  159. telemetry_session->AddInitialInfo(*app_loader);
  160. auto main_process =
  161. Kernel::Process::Create(system, "main", Kernel::Process::ProcessType::Userland);
  162. const auto [load_result, load_parameters] = app_loader->Load(*main_process);
  163. if (load_result != Loader::ResultStatus::Success) {
  164. LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result));
  165. Shutdown();
  166. return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) +
  167. static_cast<u32>(load_result));
  168. }
  169. AddGlueRegistrationForProcess(*app_loader, *main_process);
  170. kernel.MakeCurrentProcess(main_process.get());
  171. // Main process has been loaded and been made current.
  172. // Begin GPU and CPU execution.
  173. gpu_core->Start();
  174. cpu_core_manager.StartThreads();
  175. // Initialize cheat engine
  176. if (cheat_engine) {
  177. cheat_engine->Initialize();
  178. }
  179. // All threads are started, begin main process execution, now that we're in the clear.
  180. main_process->Run(load_parameters->main_thread_priority,
  181. load_parameters->main_thread_stack_size);
  182. if (Settings::values.gamecard_inserted) {
  183. if (Settings::values.gamecard_current_game) {
  184. fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath));
  185. } else if (!Settings::values.gamecard_path.empty()) {
  186. fs_controller.SetGameCard(
  187. GetGameFileFromPath(virtual_filesystem, Settings::values.gamecard_path));
  188. }
  189. }
  190. u64 title_id{0};
  191. if (app_loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) {
  192. LOG_ERROR(Core, "Failed to find title id for ROM (Error {})",
  193. static_cast<u32>(load_result));
  194. }
  195. perf_stats = std::make_unique<PerfStats>(title_id);
  196. // Reset counters and set time origin to current frame
  197. GetAndResetPerfStats();
  198. perf_stats->BeginSystemFrame();
  199. status = ResultStatus::Success;
  200. return status;
  201. }
  202. void Shutdown() {
  203. // Log last frame performance stats
  204. const auto perf_results = GetAndResetPerfStats();
  205. telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed",
  206. perf_results.emulation_speed * 100.0);
  207. telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate",
  208. perf_results.game_fps);
  209. telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime",
  210. perf_results.frametime * 1000.0);
  211. telemetry_session->AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS",
  212. perf_stats->GetMeanFrametime());
  213. lm_manager.Flush();
  214. is_powered_on = false;
  215. exit_lock = false;
  216. gpu_core->WaitIdle();
  217. // Shutdown emulation session
  218. renderer.reset();
  219. GDBStub::Shutdown();
  220. Service::Shutdown();
  221. service_manager.reset();
  222. cheat_engine.reset();
  223. telemetry_session.reset();
  224. perf_stats.reset();
  225. gpu_core.reset();
  226. // Close all CPU/threading state
  227. cpu_core_manager.Shutdown();
  228. // Shutdown kernel and core timing
  229. kernel.Shutdown();
  230. core_timing.Shutdown();
  231. // Close app loader
  232. app_loader.reset();
  233. // Clear all applets
  234. applet_manager.ClearAll();
  235. LOG_DEBUG(Core, "Shutdown OK");
  236. }
  237. Loader::ResultStatus GetGameName(std::string& out) const {
  238. if (app_loader == nullptr)
  239. return Loader::ResultStatus::ErrorNotInitialized;
  240. return app_loader->ReadTitle(out);
  241. }
  242. void AddGlueRegistrationForProcess(Loader::AppLoader& loader, Kernel::Process& process) {
  243. std::vector<u8> nacp_data;
  244. FileSys::NACP nacp;
  245. if (loader.ReadControlData(nacp) == Loader::ResultStatus::Success) {
  246. nacp_data = nacp.GetRawBytes();
  247. } else {
  248. nacp_data.resize(sizeof(FileSys::RawNACP));
  249. }
  250. Service::Glue::ApplicationLaunchProperty launch{};
  251. launch.title_id = process.GetTitleID();
  252. FileSys::PatchManager pm{launch.title_id};
  253. launch.version = pm.GetGameVersion().value_or(0);
  254. // TODO(DarkLordZach): When FSController/Game Card Support is added, if
  255. // current_process_game_card use correct StorageId
  256. launch.base_game_storage_id = GetStorageIdForFrontendSlot(content_provider->GetSlotForEntry(
  257. launch.title_id, FileSys::ContentRecordType::Program));
  258. launch.update_storage_id = GetStorageIdForFrontendSlot(content_provider->GetSlotForEntry(
  259. FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program));
  260. arp_manager.Register(launch.title_id, launch, std::move(nacp_data));
  261. }
  262. void SetStatus(ResultStatus new_status, const char* details = nullptr) {
  263. status = new_status;
  264. if (details) {
  265. status_details = details;
  266. }
  267. }
  268. PerfStatsResults GetAndResetPerfStats() {
  269. return perf_stats->GetAndResetStats(core_timing.GetGlobalTimeUs());
  270. }
  271. Timing::CoreTiming core_timing;
  272. Kernel::KernelCore kernel;
  273. /// RealVfsFilesystem instance
  274. FileSys::VirtualFilesystem virtual_filesystem;
  275. /// ContentProviderUnion instance
  276. std::unique_ptr<FileSys::ContentProviderUnion> content_provider;
  277. Service::FileSystem::FileSystemController fs_controller;
  278. /// AppLoader used to load the current executing application
  279. std::unique_ptr<Loader::AppLoader> app_loader;
  280. std::unique_ptr<VideoCore::RendererBase> renderer;
  281. std::unique_ptr<Tegra::GPU> gpu_core;
  282. std::shared_ptr<Tegra::DebugContext> debug_context;
  283. std::unique_ptr<Core::Hardware::InterruptManager> interrupt_manager;
  284. CpuCoreManager cpu_core_manager;
  285. bool is_powered_on = false;
  286. bool exit_lock = false;
  287. Reporter reporter;
  288. std::unique_ptr<Memory::CheatEngine> cheat_engine;
  289. std::unique_ptr<Tools::Freezer> memory_freezer;
  290. std::array<u8, 0x20> build_id{};
  291. /// Frontend applets
  292. Service::AM::Applets::AppletManager applet_manager;
  293. /// APM (Performance) services
  294. Service::APM::Controller apm_controller{core_timing};
  295. /// Service State
  296. Service::Glue::ARPManager arp_manager;
  297. Service::LM::Manager lm_manager{reporter};
  298. /// Service manager
  299. std::shared_ptr<Service::SM::ServiceManager> service_manager;
  300. /// Telemetry session for this emulation session
  301. std::unique_ptr<Core::TelemetrySession> telemetry_session;
  302. ResultStatus status = ResultStatus::Success;
  303. std::string status_details = "";
  304. std::unique_ptr<Core::PerfStats> perf_stats;
  305. Core::FrameLimiter frame_limiter;
  306. };
  307. System::System() : impl{std::make_unique<Impl>(*this)} {}
  308. System::~System() = default;
  309. Cpu& System::CurrentCpuCore() {
  310. return impl->CurrentCpuCore();
  311. }
  312. const Cpu& System::CurrentCpuCore() const {
  313. return impl->CurrentCpuCore();
  314. }
  315. System::ResultStatus System::RunLoop(bool tight_loop) {
  316. return impl->RunLoop(tight_loop);
  317. }
  318. System::ResultStatus System::SingleStep() {
  319. return RunLoop(false);
  320. }
  321. void System::InvalidateCpuInstructionCaches() {
  322. impl->cpu_core_manager.InvalidateAllInstructionCaches();
  323. }
  324. System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) {
  325. return impl->Load(*this, emu_window, filepath);
  326. }
  327. bool System::IsPoweredOn() const {
  328. return impl->is_powered_on;
  329. }
  330. void System::PrepareReschedule() {
  331. CurrentCpuCore().PrepareReschedule();
  332. }
  333. PerfStatsResults System::GetAndResetPerfStats() {
  334. return impl->GetAndResetPerfStats();
  335. }
  336. TelemetrySession& System::TelemetrySession() {
  337. return *impl->telemetry_session;
  338. }
  339. const TelemetrySession& System::TelemetrySession() const {
  340. return *impl->telemetry_session;
  341. }
  342. ARM_Interface& System::CurrentArmInterface() {
  343. return CurrentCpuCore().ArmInterface();
  344. }
  345. const ARM_Interface& System::CurrentArmInterface() const {
  346. return CurrentCpuCore().ArmInterface();
  347. }
  348. std::size_t System::CurrentCoreIndex() const {
  349. return CurrentCpuCore().CoreIndex();
  350. }
  351. Kernel::Scheduler& System::CurrentScheduler() {
  352. return CurrentCpuCore().Scheduler();
  353. }
  354. const Kernel::Scheduler& System::CurrentScheduler() const {
  355. return CurrentCpuCore().Scheduler();
  356. }
  357. Kernel::Scheduler& System::Scheduler(std::size_t core_index) {
  358. return CpuCore(core_index).Scheduler();
  359. }
  360. const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const {
  361. return CpuCore(core_index).Scheduler();
  362. }
  363. Kernel::Process* System::CurrentProcess() {
  364. return impl->kernel.CurrentProcess();
  365. }
  366. const Kernel::Process* System::CurrentProcess() const {
  367. return impl->kernel.CurrentProcess();
  368. }
  369. ARM_Interface& System::ArmInterface(std::size_t core_index) {
  370. return CpuCore(core_index).ArmInterface();
  371. }
  372. const ARM_Interface& System::ArmInterface(std::size_t core_index) const {
  373. return CpuCore(core_index).ArmInterface();
  374. }
  375. Cpu& System::CpuCore(std::size_t core_index) {
  376. return impl->cpu_core_manager.GetCore(core_index);
  377. }
  378. const Cpu& System::CpuCore(std::size_t core_index) const {
  379. ASSERT(core_index < NUM_CPU_CORES);
  380. return impl->cpu_core_manager.GetCore(core_index);
  381. }
  382. ExclusiveMonitor& System::Monitor() {
  383. return impl->cpu_core_manager.GetExclusiveMonitor();
  384. }
  385. const ExclusiveMonitor& System::Monitor() const {
  386. return impl->cpu_core_manager.GetExclusiveMonitor();
  387. }
  388. Tegra::GPU& System::GPU() {
  389. return *impl->gpu_core;
  390. }
  391. const Tegra::GPU& System::GPU() const {
  392. return *impl->gpu_core;
  393. }
  394. Core::Hardware::InterruptManager& System::InterruptManager() {
  395. return *impl->interrupt_manager;
  396. }
  397. const Core::Hardware::InterruptManager& System::InterruptManager() const {
  398. return *impl->interrupt_manager;
  399. }
  400. VideoCore::RendererBase& System::Renderer() {
  401. return *impl->renderer;
  402. }
  403. const VideoCore::RendererBase& System::Renderer() const {
  404. return *impl->renderer;
  405. }
  406. Kernel::KernelCore& System::Kernel() {
  407. return impl->kernel;
  408. }
  409. const Kernel::KernelCore& System::Kernel() const {
  410. return impl->kernel;
  411. }
  412. Timing::CoreTiming& System::CoreTiming() {
  413. return impl->core_timing;
  414. }
  415. const Timing::CoreTiming& System::CoreTiming() const {
  416. return impl->core_timing;
  417. }
  418. Core::PerfStats& System::GetPerfStats() {
  419. return *impl->perf_stats;
  420. }
  421. const Core::PerfStats& System::GetPerfStats() const {
  422. return *impl->perf_stats;
  423. }
  424. Core::FrameLimiter& System::FrameLimiter() {
  425. return impl->frame_limiter;
  426. }
  427. const Core::FrameLimiter& System::FrameLimiter() const {
  428. return impl->frame_limiter;
  429. }
  430. Loader::ResultStatus System::GetGameName(std::string& out) const {
  431. return impl->GetGameName(out);
  432. }
  433. void System::SetStatus(ResultStatus new_status, const char* details) {
  434. impl->SetStatus(new_status, details);
  435. }
  436. const std::string& System::GetStatusDetails() const {
  437. return impl->status_details;
  438. }
  439. Loader::AppLoader& System::GetAppLoader() const {
  440. return *impl->app_loader;
  441. }
  442. void System::SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context) {
  443. impl->debug_context = std::move(context);
  444. }
  445. Tegra::DebugContext* System::GetGPUDebugContext() const {
  446. return impl->debug_context.get();
  447. }
  448. void System::SetFilesystem(std::shared_ptr<FileSys::VfsFilesystem> vfs) {
  449. impl->virtual_filesystem = std::move(vfs);
  450. }
  451. std::shared_ptr<FileSys::VfsFilesystem> System::GetFilesystem() const {
  452. return impl->virtual_filesystem;
  453. }
  454. void System::RegisterCheatList(const std::vector<Memory::CheatEntry>& list,
  455. const std::array<u8, 32>& build_id, VAddr main_region_begin,
  456. u64 main_region_size) {
  457. impl->cheat_engine = std::make_unique<Memory::CheatEngine>(*this, list, build_id);
  458. impl->cheat_engine->SetMainMemoryParameters(main_region_begin, main_region_size);
  459. }
  460. void System::SetAppletFrontendSet(Service::AM::Applets::AppletFrontendSet&& set) {
  461. impl->applet_manager.SetAppletFrontendSet(std::move(set));
  462. }
  463. void System::SetDefaultAppletFrontendSet() {
  464. impl->applet_manager.SetDefaultAppletFrontendSet();
  465. }
  466. Service::AM::Applets::AppletManager& System::GetAppletManager() {
  467. return impl->applet_manager;
  468. }
  469. const Service::AM::Applets::AppletManager& System::GetAppletManager() const {
  470. return impl->applet_manager;
  471. }
  472. void System::SetContentProvider(std::unique_ptr<FileSys::ContentProviderUnion> provider) {
  473. impl->content_provider = std::move(provider);
  474. }
  475. FileSys::ContentProvider& System::GetContentProvider() {
  476. return *impl->content_provider;
  477. }
  478. const FileSys::ContentProvider& System::GetContentProvider() const {
  479. return *impl->content_provider;
  480. }
  481. Service::FileSystem::FileSystemController& System::GetFileSystemController() {
  482. return impl->fs_controller;
  483. }
  484. const Service::FileSystem::FileSystemController& System::GetFileSystemController() const {
  485. return impl->fs_controller;
  486. }
  487. void System::RegisterContentProvider(FileSys::ContentProviderUnionSlot slot,
  488. FileSys::ContentProvider* provider) {
  489. impl->content_provider->SetSlot(slot, provider);
  490. }
  491. void System::ClearContentProvider(FileSys::ContentProviderUnionSlot slot) {
  492. impl->content_provider->ClearSlot(slot);
  493. }
  494. const Reporter& System::GetReporter() const {
  495. return impl->reporter;
  496. }
  497. Service::Glue::ARPManager& System::GetARPManager() {
  498. return impl->arp_manager;
  499. }
  500. const Service::Glue::ARPManager& System::GetARPManager() const {
  501. return impl->arp_manager;
  502. }
  503. Service::APM::Controller& System::GetAPMController() {
  504. return impl->apm_controller;
  505. }
  506. const Service::APM::Controller& System::GetAPMController() const {
  507. return impl->apm_controller;
  508. }
  509. Service::LM::Manager& System::GetLogManager() {
  510. return impl->lm_manager;
  511. }
  512. const Service::LM::Manager& System::GetLogManager() const {
  513. return impl->lm_manager;
  514. }
  515. void System::SetExitLock(bool locked) {
  516. impl->exit_lock = locked;
  517. }
  518. bool System::GetExitLock() const {
  519. return impl->exit_lock;
  520. }
  521. void System::SetCurrentProcessBuildID(const CurrentBuildProcessID& id) {
  522. impl->build_id = id;
  523. }
  524. const System::CurrentBuildProcessID& System::GetCurrentProcessBuildID() const {
  525. return impl->build_id;
  526. }
  527. System::ResultStatus System::Init(Frontend::EmuWindow& emu_window) {
  528. return impl->Init(*this, emu_window);
  529. }
  530. void System::Shutdown() {
  531. impl->Shutdown();
  532. }
  533. Service::SM::ServiceManager& System::ServiceManager() {
  534. return *impl->service_manager;
  535. }
  536. const Service::SM::ServiceManager& System::ServiceManager() const {
  537. return *impl->service_manager;
  538. }
  539. } // namespace Core