citra-emu
/
citra
Archived
1
0
Fork 0

Merge pull request #3656 from lioncash/relocate

sm: Relocate the service manager to the System class
This commit is contained in:
Merry 2018-04-15 10:34:14 +01:00 committed by GitHub
commit d5b1c33587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 41 deletions

View File

@ -15,10 +15,12 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/gdbstub/gdbstub.h" #include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"
#include "core/hw/hw.h" #include "core/hw/hw.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/memory_setup.h" #include "core/memory_setup.h"
@ -168,10 +170,11 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
dsp_core->EnableStretching(Settings::values.enable_audio_stretching); dsp_core->EnableStretching(Settings::values.enable_audio_stretching);
telemetry_session = std::make_unique<Core::TelemetrySession>(); telemetry_session = std::make_unique<Core::TelemetrySession>();
service_manager = std::make_shared<Service::SM::ServiceManager>();
HW::Init(); HW::Init();
Kernel::Init(system_mode); Kernel::Init(system_mode);
Service::Init(); Service::Init(service_manager);
GDBStub::Init(); GDBStub::Init();
Movie::GetInstance().Init(); Movie::GetInstance().Init();
@ -188,6 +191,14 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
return ResultStatus::Success; return ResultStatus::Success;
} }
Service::SM::ServiceManager& System::ServiceManager() {
return *service_manager;
}
const Service::SM::ServiceManager& System::ServiceManager() const {
return *service_manager;
}
void System::Shutdown() { void System::Shutdown() {
// Log last frame performance stats // Log last frame performance stats
auto perf_results = GetAndResetPerfStats(); auto perf_results = GetAndResetPerfStats();
@ -205,11 +216,12 @@ void System::Shutdown() {
Service::Shutdown(); Service::Shutdown();
Kernel::Shutdown(); Kernel::Shutdown();
HW::Shutdown(); HW::Shutdown();
telemetry_session = nullptr; telemetry_session.reset();
dsp_core = nullptr; service_manager.reset();
cpu_core = nullptr; dsp_core.reset();
cpu_core.reset();
CoreTiming::Shutdown(); CoreTiming::Shutdown();
app_loader = nullptr; app_loader.reset();
if (auto room_member = Network::GetRoomMember().lock()) { if (auto room_member = Network::GetRoomMember().lock()) {
Network::GameInfo game_info{}; Network::GameInfo game_info{};

View File

@ -19,6 +19,12 @@ namespace AudioCore {
class DspInterface; class DspInterface;
} }
namespace Service {
namespace SM {
class ServiceManager;
}
} // namespace Service
namespace Core { namespace Core {
class System { class System {
@ -114,6 +120,18 @@ public:
return *dsp_core; return *dsp_core;
} }
/**
* Gets a reference to the service manager.
* @returns A reference to the service manager.
*/
Service::SM::ServiceManager& ServiceManager();
/**
* Gets a const reference to the service manager.
* @returns A const reference to the service manager.
*/
const Service::SM::ServiceManager& ServiceManager() const;
PerfStats perf_stats; PerfStats perf_stats;
FrameLimiter frame_limiter; FrameLimiter frame_limiter;
@ -147,10 +165,10 @@ private:
/// AppLoader used to load the current executing application /// AppLoader used to load the current executing application
std::unique_ptr<Loader::AppLoader> app_loader; std::unique_ptr<Loader::AppLoader> app_loader;
///< ARM11 CPU core /// ARM11 CPU core
std::unique_ptr<ARM_Interface> cpu_core; std::unique_ptr<ARM_Interface> cpu_core;
///< DSP core /// DSP core
std::unique_ptr<AudioCore::DspInterface> dsp_core; std::unique_ptr<AudioCore::DspInterface> dsp_core;
/// When true, signals that a reschedule should happen /// When true, signals that a reschedule should happen
@ -159,6 +177,9 @@ private:
/// Telemetry session for this emulation session /// Telemetry session for this emulation session
std::unique_ptr<Core::TelemetrySession> telemetry_session; std::unique_ptr<Core::TelemetrySession> telemetry_session;
/// Service manager
std::shared_ptr<Service::SM::ServiceManager> service_manager;
static System s_instance; static System s_instance;
ResultStatus status = ResultStatus::Success; ResultStatus status = ResultStatus::Success;

View File

@ -7,6 +7,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/core.h"
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
@ -214,48 +215,47 @@ static void AddNamedPort(Interface* interface_) {
} }
void AddService(Interface* interface_) { void AddService(Interface* interface_) {
auto server_port = auto server_port = Core::System::GetInstance()
SM::g_service_manager .ServiceManager()
->RegisterService(interface_->GetPortName(), interface_->GetMaxSessions()) .RegisterService(interface_->GetPortName(), interface_->GetMaxSessions())
.Unwrap(); .Unwrap();
server_port->SetHleHandler(std::shared_ptr<Interface>(interface_)); server_port->SetHleHandler(std::shared_ptr<Interface>(interface_));
} }
/// Initialize ServiceManager /// Initialize ServiceManager
void Init() { void Init(std::shared_ptr<SM::ServiceManager>& sm) {
SM::g_service_manager = std::make_shared<SM::ServiceManager>(); SM::ServiceManager::InstallInterfaces(sm);
SM::ServiceManager::InstallInterfaces(SM::g_service_manager);
ERR::InstallInterfaces(); ERR::InstallInterfaces();
PXI::InstallInterfaces(*SM::g_service_manager); PXI::InstallInterfaces(*sm);
NS::InstallInterfaces(*SM::g_service_manager); NS::InstallInterfaces(*sm);
AC::InstallInterfaces(*SM::g_service_manager); AC::InstallInterfaces(*sm);
LDR::InstallInterfaces(*SM::g_service_manager); LDR::InstallInterfaces(*sm);
MIC::InstallInterfaces(*SM::g_service_manager); MIC::InstallInterfaces(*sm);
NWM::InstallInterfaces(*SM::g_service_manager); NWM::InstallInterfaces(*sm);
FS::InstallInterfaces(*SM::g_service_manager); FS::InstallInterfaces(*sm);
FS::ArchiveInit(); FS::ArchiveInit();
ACT::InstallInterfaces(*SM::g_service_manager); ACT::InstallInterfaces(*sm);
AM::InstallInterfaces(*SM::g_service_manager); AM::InstallInterfaces(*sm);
APT::InstallInterfaces(*SM::g_service_manager); APT::InstallInterfaces(*sm);
BOSS::Init(); BOSS::Init();
CAM::InstallInterfaces(*SM::g_service_manager); CAM::InstallInterfaces(*sm);
CECD::Init(); CECD::Init();
CFG::InstallInterfaces(*SM::g_service_manager); CFG::InstallInterfaces(*sm);
DLP::Init(); DLP::Init();
FRD::InstallInterfaces(*SM::g_service_manager); FRD::InstallInterfaces(*sm);
GSP::InstallInterfaces(*SM::g_service_manager); GSP::InstallInterfaces(*sm);
HID::InstallInterfaces(*SM::g_service_manager); HID::InstallInterfaces(*sm);
IR::InstallInterfaces(*SM::g_service_manager); IR::InstallInterfaces(*sm);
MVD::Init(); MVD::Init();
NDM::Init(); NDM::Init();
NEWS::InstallInterfaces(*SM::g_service_manager); NEWS::InstallInterfaces(*sm);
NFC::InstallInterfaces(*SM::g_service_manager); NFC::InstallInterfaces(*sm);
NIM::InstallInterfaces(*SM::g_service_manager); NIM::InstallInterfaces(*sm);
NWM::Init(); NWM::Init();
PTM::InstallInterfaces(*SM::g_service_manager); PTM::InstallInterfaces(*sm);
QTM::Init(); QTM::Init();
AddService(new CSND::CSND_SND); AddService(new CSND::CSND_SND);
@ -265,7 +265,7 @@ void Init() {
AddService(new PM::PM_APP); AddService(new PM::PM_APP);
AddService(new SOC::SOC_U); AddService(new SOC::SOC_U);
AddService(new SSL::SSL_C); AddService(new SSL::SSL_C);
Y2R::InstallInterfaces(*SM::g_service_manager); Y2R::InstallInterfaces(*sm);
LOG_DEBUG(Service, "initialized OK"); LOG_DEBUG(Service, "initialized OK");
} }
@ -278,7 +278,6 @@ void Shutdown() {
BOSS::Shutdown(); BOSS::Shutdown();
FS::ArchiveShutdown(); FS::ArchiveShutdown();
SM::g_service_manager = nullptr;
g_kernel_named_ports.clear(); g_kernel_named_ports.clear();
LOG_DEBUG(Service, "shutdown OK"); LOG_DEBUG(Service, "shutdown OK");
} }

View File

@ -262,7 +262,7 @@ private:
}; };
/// Initialize ServiceManager /// Initialize ServiceManager
void Init(); void Init(std::shared_ptr<SM::ServiceManager>& sm);
/// Shutdown ServiceManager /// Shutdown ServiceManager
void Shutdown(); void Shutdown();

View File

@ -67,7 +67,5 @@ ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ServiceManager::ConnectToSer
return client_port->Connect(); return client_port->Connect();
} }
std::shared_ptr<ServiceManager> g_service_manager;
} // namespace SM } // namespace SM
} // namespace Service } // namespace Service

View File

@ -52,7 +52,5 @@ private:
std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> registered_services; std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> registered_services;
}; };
extern std::shared_ptr<ServiceManager> g_service_manager;
} // namespace SM } // namespace SM
} // namespace Service } // namespace Service