From 6c8faaf2c261ed14f381d4ee2868d4e810c27c02 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 28 Nov 2018 23:20:51 -0700 Subject: [PATCH] HLE: Remove BaseInterface and add ns.cpp back --- src/core/CMakeLists.txt | 2 ++ src/core/hle/service/apt/applet_manager.cpp | 2 +- src/core/hle/service/apt/apt.cpp | 28 ++--------------- src/core/hle/service/apt/apt.h | 21 ++++--------- src/core/hle/service/apt/ns.cpp | 33 +++++++++++++++++++++ src/core/hle/service/apt/ns.h | 20 +++++++++++++ 6 files changed, 64 insertions(+), 42 deletions(-) create mode 100644 src/core/hle/service/apt/ns.cpp create mode 100644 src/core/hle/service/apt/ns.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 375cdc15a..0c7bbbecf 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -205,6 +205,8 @@ add_library(core STATIC hle/service/apt/apt_s.h hle/service/apt/apt_u.cpp hle/service/apt/apt_u.h + hle/service/apt/ns.cpp + hle/service/apt/ns.h hle/service/apt/ns_s.cpp hle/service/apt/ns_s.h hle/service/apt/bcfnt/bcfnt.cpp diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index 307a9f0a7..a613eb339 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -7,8 +7,8 @@ #include "core/hle/applets/applet.h" #include "core/hle/service/apt/applet_manager.h" #include "core/hle/service/apt/errors.h" +#include "core/hle/service/apt/ns.h" #include "core/hle/service/cfg/cfg.h" -#include "core/hle/service/ns/ns.h" namespace Service::APT { diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index bcaf5247e..f2de090b2 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -30,7 +30,7 @@ namespace Service::APT { Module::NSInterface::NSInterface(std::shared_ptr apt, const char* name, u32 max_session) - : ServiceFramework(name, max_session), BaseInterface(std::move(apt)) {} + : ServiceFramework(name, max_session), apt(std::move(apt)) {} Module::NSInterface::~NSInterface() = default; @@ -860,7 +860,7 @@ void Module::APTInterface::CheckNew3DS(Kernel::HLERequestContext& ctx) { } Module::APTInterface::APTInterface(std::shared_ptr apt, const char* name, u32 max_session) - : ServiceFramework(name, max_session), BaseInterface(std::move(apt)) {} + : ServiceFramework(name, max_session), apt(std::move(apt)) {} Module::APTInterface::~APTInterface() = default; @@ -889,27 +889,3 @@ void InstallInterfaces(Core::System& system) { } } // namespace Service::APT - -namespace Service::NS { - -Kernel::SharedPtr LaunchTitle(FS::MediaType media_type, u64 title_id) { - std::string path = AM::GetTitleContentPath(media_type, title_id); - auto loader = Loader::GetLoader(path); - - if (!loader) { - LOG_WARNING(Service_NS, "Could not find .app for title 0x{:016x}", title_id); - return nullptr; - } - - Kernel::SharedPtr process; - Loader::ResultStatus result = loader->Load(process); - - if (result != Loader::ResultStatus::Success) { - LOG_WARNING(Service_NS, "Error loading .app for title 0x{:016x}", title_id); - return nullptr; - } - - return process; -} - -} // namespace Service::NS diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index 858757bd5..2e2c219cd 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -60,21 +60,16 @@ public: explicit Module(Core::System& system); ~Module(); - class BaseInterface { - public: - explicit BaseInterface(std::shared_ptr apt) : apt(apt) {} - - protected: - std::shared_ptr apt; - }; - - class NSInterface : public ServiceFramework, public BaseInterface { + class NSInterface : public ServiceFramework { public: NSInterface(std::shared_ptr apt, const char* name, u32 max_session); ~NSInterface(); + + private: + std::shared_ptr apt; }; - class APTInterface : public ServiceFramework, public BaseInterface { + class APTInterface : public ServiceFramework { public: APTInterface(std::shared_ptr apt, const char* name, u32 max_session); ~APTInterface(); @@ -608,6 +603,7 @@ public: private: bool application_reset_prepared{}; + std::shared_ptr apt; }; private: @@ -639,8 +635,3 @@ private: void InstallInterfaces(Core::System& system); } // namespace Service::APT - -namespace Service::NS { -/// Loads and launches the title identified by title_id in the specified media type. -Kernel::SharedPtr LaunchTitle(FS::MediaType media_type, u64 title_id); -} // namespace Service::NS diff --git a/src/core/hle/service/apt/ns.cpp b/src/core/hle/service/apt/ns.cpp new file mode 100644 index 000000000..1347be752 --- /dev/null +++ b/src/core/hle/service/apt/ns.cpp @@ -0,0 +1,33 @@ +// Copyright 2017 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include "core/core.h" +#include "core/hle/service/am/am.h" +#include "core/hle/service/apt/ns.h" +#include "core/loader/loader.h" + +namespace Service::NS { + +Kernel::SharedPtr LaunchTitle(FS::MediaType media_type, u64 title_id) { + std::string path = AM::GetTitleContentPath(media_type, title_id); + auto loader = Loader::GetLoader(path); + + if (!loader) { + LOG_WARNING(Service_NS, "Could not find .app for title 0x{:016x}", title_id); + return nullptr; + } + + Kernel::SharedPtr process; + Loader::ResultStatus result = loader->Load(process); + + if (result != Loader::ResultStatus::Success) { + LOG_WARNING(Service_NS, "Error loading .app for title 0x{:016x}", title_id); + return nullptr; + } + + return process; +} + +} // namespace Service::NS diff --git a/src/core/hle/service/apt/ns.h b/src/core/hle/service/apt/ns.h new file mode 100644 index 000000000..e1515ad8f --- /dev/null +++ b/src/core/hle/service/apt/ns.h @@ -0,0 +1,20 @@ +// Copyright 2017 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/kernel/process.h" +#include "core/hle/service/fs/archive.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::NS { + +/// Loads and launches the title identified by title_id in the specified media type. +Kernel::SharedPtr LaunchTitle(FS::MediaType media_type, u64 title_id); + +} // namespace Service::NS \ No newline at end of file