mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 12:42:52 +00:00
Merge pull request #371 from lioncash/global
core: Relocate g_service_manager to the System class
This commit is contained in:
commit
2e7ce96b1d
|
@ -12,10 +12,13 @@
|
||||||
#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/controller.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"
|
||||||
|
@ -26,6 +29,8 @@ namespace Core {
|
||||||
|
|
||||||
/*static*/ System System::s_instance;
|
/*static*/ System System::s_instance;
|
||||||
|
|
||||||
|
System::~System() = default;
|
||||||
|
|
||||||
System::ResultStatus System::RunLoop(bool tight_loop) {
|
System::ResultStatus System::RunLoop(bool tight_loop) {
|
||||||
status = ResultStatus::Success;
|
status = ResultStatus::Success;
|
||||||
if (!cpu_core) {
|
if (!cpu_core) {
|
||||||
|
@ -167,10 +172,12 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
|
||||||
|
|
||||||
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);
|
||||||
scheduler = std::make_unique<Kernel::Scheduler>(cpu_core.get());
|
scheduler = std::make_unique<Kernel::Scheduler>(cpu_core.get());
|
||||||
Service::Init();
|
Service::Init(service_manager);
|
||||||
GDBStub::Init();
|
GDBStub::Init();
|
||||||
|
|
||||||
if (!VideoCore::Init(emu_window)) {
|
if (!VideoCore::Init(emu_window)) {
|
||||||
|
@ -200,17 +207,26 @@ void System::Shutdown() {
|
||||||
VideoCore::Shutdown();
|
VideoCore::Shutdown();
|
||||||
GDBStub::Shutdown();
|
GDBStub::Shutdown();
|
||||||
Service::Shutdown();
|
Service::Shutdown();
|
||||||
scheduler = nullptr;
|
scheduler.reset();
|
||||||
Kernel::Shutdown();
|
Kernel::Shutdown();
|
||||||
HW::Shutdown();
|
HW::Shutdown();
|
||||||
telemetry_session = nullptr;
|
service_manager.reset();
|
||||||
gpu_core = nullptr;
|
telemetry_session.reset();
|
||||||
cpu_core = nullptr;
|
gpu_core.reset();
|
||||||
|
cpu_core.reset();
|
||||||
CoreTiming::Shutdown();
|
CoreTiming::Shutdown();
|
||||||
|
|
||||||
app_loader = nullptr;
|
app_loader.reset();
|
||||||
|
|
||||||
LOG_DEBUG(Core, "Shutdown OK");
|
LOG_DEBUG(Core, "Shutdown OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Service::SM::ServiceManager& System::ServiceManager() {
|
||||||
|
return *service_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Service::SM::ServiceManager& System::ServiceManager() const {
|
||||||
|
return *service_manager;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
|
@ -19,10 +19,16 @@
|
||||||
class EmuWindow;
|
class EmuWindow;
|
||||||
class ARM_Interface;
|
class ARM_Interface;
|
||||||
|
|
||||||
|
namespace Service::SM {
|
||||||
|
class ServiceManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class System {
|
class System {
|
||||||
public:
|
public:
|
||||||
|
~System();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the instance of the System singleton class.
|
* Gets the instance of the System singleton class.
|
||||||
* @returns Reference to the instance of the System singleton class.
|
* @returns Reference to the instance of the System singleton class.
|
||||||
|
@ -137,6 +143,9 @@ public:
|
||||||
return *app_loader;
|
return *app_loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Service::SM::ServiceManager& ServiceManager();
|
||||||
|
const Service::SM::ServiceManager& ServiceManager() const;
|
||||||
|
|
||||||
void SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context) {
|
void SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context) {
|
||||||
debug_context = std::move(context);
|
debug_context = std::move(context);
|
||||||
}
|
}
|
||||||
|
@ -171,6 +180,9 @@ private:
|
||||||
/// When true, signals that a reschedule should happen
|
/// When true, signals that a reschedule should happen
|
||||||
bool reschedule_pending{};
|
bool reschedule_pending{};
|
||||||
|
|
||||||
|
/// Service manager
|
||||||
|
std::shared_ptr<Service::SM::ServiceManager> service_manager;
|
||||||
|
|
||||||
/// 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;
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co
|
||||||
return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead);
|
return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead);
|
||||||
}
|
}
|
||||||
case IPC::CommandType::Control: {
|
case IPC::CommandType::Control: {
|
||||||
SM::g_service_manager->InvokeControlRequest(context);
|
Core::System::GetInstance().ServiceManager().InvokeControlRequest(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPC::CommandType::Request: {
|
case IPC::CommandType::Request: {
|
||||||
|
@ -170,42 +170,40 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init() {
|
void Init(std::shared_ptr<SM::ServiceManager>& sm) {
|
||||||
// NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
|
// NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
|
||||||
// here and pass it into the respective InstallInterfaces functions.
|
// here and pass it into the respective InstallInterfaces functions.
|
||||||
auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
|
auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
|
||||||
|
|
||||||
SM::g_service_manager = std::make_shared<SM::ServiceManager>();
|
SM::ServiceManager::InstallInterfaces(sm);
|
||||||
SM::ServiceManager::InstallInterfaces(SM::g_service_manager);
|
|
||||||
|
|
||||||
Account::InstallInterfaces(*SM::g_service_manager);
|
Account::InstallInterfaces(*sm);
|
||||||
AM::InstallInterfaces(*SM::g_service_manager, nv_flinger);
|
AM::InstallInterfaces(*sm, nv_flinger);
|
||||||
AOC::InstallInterfaces(*SM::g_service_manager);
|
AOC::InstallInterfaces(*sm);
|
||||||
APM::InstallInterfaces(*SM::g_service_manager);
|
APM::InstallInterfaces(*sm);
|
||||||
Audio::InstallInterfaces(*SM::g_service_manager);
|
Audio::InstallInterfaces(*sm);
|
||||||
Fatal::InstallInterfaces(*SM::g_service_manager);
|
Fatal::InstallInterfaces(*sm);
|
||||||
FileSystem::InstallInterfaces(*SM::g_service_manager);
|
FileSystem::InstallInterfaces(*sm);
|
||||||
Friend::InstallInterfaces(*SM::g_service_manager);
|
Friend::InstallInterfaces(*sm);
|
||||||
HID::InstallInterfaces(*SM::g_service_manager);
|
HID::InstallInterfaces(*sm);
|
||||||
LM::InstallInterfaces(*SM::g_service_manager);
|
LM::InstallInterfaces(*sm);
|
||||||
NFP::InstallInterfaces(*SM::g_service_manager);
|
NFP::InstallInterfaces(*sm);
|
||||||
NIFM::InstallInterfaces(*SM::g_service_manager);
|
NIFM::InstallInterfaces(*sm);
|
||||||
NS::InstallInterfaces(*SM::g_service_manager);
|
NS::InstallInterfaces(*sm);
|
||||||
Nvidia::InstallInterfaces(*SM::g_service_manager);
|
Nvidia::InstallInterfaces(*sm);
|
||||||
PCTL::InstallInterfaces(*SM::g_service_manager);
|
PCTL::InstallInterfaces(*sm);
|
||||||
Sockets::InstallInterfaces(*SM::g_service_manager);
|
Sockets::InstallInterfaces(*sm);
|
||||||
SPL::InstallInterfaces(*SM::g_service_manager);
|
SPL::InstallInterfaces(*sm);
|
||||||
SSL::InstallInterfaces(*SM::g_service_manager);
|
SSL::InstallInterfaces(*sm);
|
||||||
Time::InstallInterfaces(*SM::g_service_manager);
|
Time::InstallInterfaces(*sm);
|
||||||
VI::InstallInterfaces(*SM::g_service_manager, nv_flinger);
|
VI::InstallInterfaces(*sm, nv_flinger);
|
||||||
Set::InstallInterfaces(*SM::g_service_manager);
|
Set::InstallInterfaces(*sm);
|
||||||
|
|
||||||
LOG_DEBUG(Service, "initialized OK");
|
LOG_DEBUG(Service, "initialized OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shutdown ServiceManager
|
/// Shutdown ServiceManager
|
||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init();
|
void Init(std::shared_ptr<SM::ServiceManager>& sm);
|
||||||
|
|
||||||
/// Shutdown ServiceManager
|
/// Shutdown ServiceManager
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
namespace Service::SM {
|
namespace Service::SM {
|
||||||
|
|
||||||
|
ServiceManager::~ServiceManager() = default;
|
||||||
|
|
||||||
void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) {
|
void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) {
|
||||||
controller_interface->InvokeRequest(context);
|
controller_interface->InvokeRequest(context);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +74,7 @@ ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ServiceManager::ConnectToSer
|
||||||
return client_port->Connect();
|
return client_port->Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ServiceManager> g_service_manager;
|
SM::~SM() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SM::Initialize service function
|
* SM::Initialize service function
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Service::SM {
|
||||||
class SM final : public ServiceFramework<SM> {
|
class SM final : public ServiceFramework<SM> {
|
||||||
public:
|
public:
|
||||||
SM(std::shared_ptr<ServiceManager> service_manager);
|
SM(std::shared_ptr<ServiceManager> service_manager);
|
||||||
~SM() = default;
|
~SM() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize(Kernel::HLERequestContext& ctx);
|
void Initialize(Kernel::HLERequestContext& ctx);
|
||||||
|
@ -44,6 +44,8 @@ class ServiceManager {
|
||||||
public:
|
public:
|
||||||
static void InstallInterfaces(std::shared_ptr<ServiceManager> self);
|
static void InstallInterfaces(std::shared_ptr<ServiceManager> self);
|
||||||
|
|
||||||
|
~ServiceManager();
|
||||||
|
|
||||||
ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> RegisterService(std::string name,
|
ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> RegisterService(std::string name,
|
||||||
unsigned int max_sessions);
|
unsigned int max_sessions);
|
||||||
ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name);
|
ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name);
|
||||||
|
@ -59,6 +61,4 @@ 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 Service::SM
|
} // namespace Service::SM
|
||||||
|
|
Loading…
Reference in a new issue