From b62ca12e887678070041eda795e273e5eff5f8b2 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 28 Nov 2018 00:27:21 -0700 Subject: [PATCH] HLE: Move NS:S into APT and remove NS --- src/core/CMakeLists.txt | 6 ++-- src/core/hle/service/apt/apt.cpp | 27 ++++++++++++++++ src/core/hle/service/apt/apt.h | 6 ++++ src/core/hle/service/{ns => apt}/ns_s.cpp | 7 ++-- src/core/hle/service/{ns => apt}/ns_s.h | 7 ++-- src/core/hle/service/ns/ns.cpp | 39 ----------------------- src/core/hle/service/ns/ns.h | 24 -------------- src/core/hle/service/service.cpp | 7 +--- 8 files changed, 43 insertions(+), 80 deletions(-) rename src/core/hle/service/{ns => apt}/ns_s.cpp (84%) rename src/core/hle/service/{ns => apt}/ns_s.h (58%) delete mode 100644 src/core/hle/service/ns/ns.cpp delete mode 100644 src/core/hle/service/ns/ns.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 83056ec75..375cdc15a 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_s.cpp + hle/service/apt/ns_s.h hle/service/apt/bcfnt/bcfnt.cpp hle/service/apt/bcfnt/bcfnt.h hle/service/apt/errors.h @@ -326,10 +328,6 @@ add_library(core STATIC hle/service/nim/nim_s.h hle/service/nim/nim_u.cpp hle/service/nim/nim_u.h - hle/service/ns/ns.cpp - hle/service/ns/ns.h - hle/service/ns/ns_s.cpp - hle/service/ns/ns_s.h hle/service/nwm/nwm.cpp hle/service/nwm/nwm.h hle/service/nwm/nwm_cec.cpp diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 494624dc7..71c6d8b23 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -12,12 +12,14 @@ #include "core/hle/kernel/mutex.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/romfs.h" +#include "core/hle/service/am/am.h" #include "core/hle/service/apt/applet_manager.h" #include "core/hle/service/apt/apt.h" #include "core/hle/service/apt/apt_a.h" #include "core/hle/service/apt/apt_s.h" #include "core/hle/service/apt/apt_u.h" #include "core/hle/service/apt/bcfnt/bcfnt.h" +#include "core/hle/service/apt/ns_s.h" #include "core/hle/service/cfg/cfg.h" #include "core/hle/service/fs/archive.h" #include "core/hle/service/ptm/ptm.h" @@ -878,6 +880,31 @@ void InstallInterfaces(Core::System& system) { std::make_shared(apt)->InstallAsService(service_manager); std::make_shared(apt)->InstallAsService(service_manager); std::make_shared(apt)->InstallAsService(service_manager); + std::make_shared(apt)->InstallAsService(service_manager); } } // 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 3755be43f..9cf8af055 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -8,6 +8,7 @@ #include #include "common/common_funcs.h" #include "common/common_types.h" +#include "core/hle/service/fs/archive.h" #include "common/swap.h" #include "core/hle/service/service.h" @@ -625,3 +626,8 @@ 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/ns/ns_s.cpp b/src/core/hle/service/apt/ns_s.cpp similarity index 84% rename from src/core/hle/service/ns/ns_s.cpp rename to src/core/hle/service/apt/ns_s.cpp index 1709e8bd2..665530487 100644 --- a/src/core/hle/service/ns/ns_s.cpp +++ b/src/core/hle/service/apt/ns_s.cpp @@ -2,11 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/service/ns/ns_s.h" +#include "core/hle/service/apt/ns_s.h" namespace Service::NS { -NS_S::NS_S() : ServiceFramework("ns:s", 2) { +NS_S::NS_S(std::shared_ptr apt) + : Service::APT::Module::Interface(std::move(apt), "NS:S", Service::APT::MaxAPTSessions) { static const FunctionInfo functions[] = { {0x000100C0, nullptr, "LaunchFIRM"}, {0x000200C0, nullptr, "LaunchTitle"}, @@ -27,6 +28,4 @@ NS_S::NS_S() : ServiceFramework("ns:s", 2) { RegisterHandlers(functions); } -NS_S::~NS_S() = default; - } // namespace Service::NS diff --git a/src/core/hle/service/ns/ns_s.h b/src/core/hle/service/apt/ns_s.h similarity index 58% rename from src/core/hle/service/ns/ns_s.h rename to src/core/hle/service/apt/ns_s.h index d6c42b0fd..a302589b0 100644 --- a/src/core/hle/service/ns/ns_s.h +++ b/src/core/hle/service/apt/ns_s.h @@ -4,15 +4,16 @@ #pragma once +#include "core/hle/kernel/kernel.h" +#include "core/hle/service/apt/apt.h" #include "core/hle/service/service.h" namespace Service::NS { /// Interface to "ns:s" service -class NS_S final : public ServiceFramework { +class NS_S final : public Service::APT::Module::Interface { public: - NS_S(); - ~NS_S(); + explicit NS_S(std::shared_ptr apt); }; } // namespace Service::NS diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp deleted file mode 100644 index ba0fd793d..000000000 --- a/src/core/hle/service/ns/ns.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// 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/ns/ns.h" -#include "core/hle/service/ns/ns_s.h" -#include "core/loader/loader.h" - -namespace Service::NS { - -std::shared_ptr 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; - } - - std::shared_ptr 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; -} - -void InstallInterfaces(Core::System& system) { - auto& service_manager = system.ServiceManager(); - std::make_shared()->InstallAsService(service_manager); -} - -} // namespace Service::NS diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h deleted file mode 100644 index 25aec246e..000000000 --- a/src/core/hle/service/ns/ns.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#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. -std::shared_ptr LaunchTitle(FS::MediaType media_type, u64 title_id); - -/// Registers all NS services with the specified service manager. -void InstallInterfaces(Core::System& system); - -} // namespace Service::NS diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index e9aca4a2e..461d0930f 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -40,7 +40,6 @@ #include "core/hle/service/news/news.h" #include "core/hle/service/nfc/nfc.h" #include "core/hle/service/nim/nim.h" -#include "core/hle/service/ns/ns.h" #include "core/hle/service/nwm/nwm.h" #include "core/hle/service/pm/pm.h" #include "core/hle/service/ps/ps_ps.h" @@ -86,11 +85,7 @@ const std::array service_module_map{ {"NEWS", 0x00040130'00003502, NEWS::InstallInterfaces}, {"NFC", 0x00040130'00004002, NFC::InstallInterfaces}, {"NIM", 0x00040130'00002C02, NIM::InstallInterfaces}, - {"NS", 0x00040130'00008002, - [](Core::System& system) { - NS::InstallInterfaces(system); - APT::InstallInterfaces(system); - }}, + {"NS", 0x00040130'00008002, APT::InstallInterfaces}, {"NWM", 0x00040130'00002D02, NWM::InstallInterfaces}, {"PTM", 0x00040130'00002202, PTM::InstallInterfaces}, {"QTM", 0x00040130'00004202, QTM::InstallInterfaces},