mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-30 13:24:16 +01:00
ServiceManager: pass down core reference
This commit is contained in:
parent
d940293d32
commit
181646679c
@ -197,7 +197,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
|
|||||||
|
|
||||||
HW::Init();
|
HW::Init();
|
||||||
kernel = std::make_unique<Kernel::KernelSystem>(system_mode);
|
kernel = std::make_unique<Kernel::KernelSystem>(system_mode);
|
||||||
Service::Init(*this, service_manager);
|
Service::Init(*this);
|
||||||
GDBStub::Init();
|
GDBStub::Init();
|
||||||
|
|
||||||
ResultStatus result = VideoCore::Init(emu_window);
|
ResultStatus result = VideoCore::Init(emu_window);
|
||||||
|
@ -235,8 +235,8 @@ static bool AttemptLLE(const ServiceModuleInfo& service_module) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init(Core::System& core, std::shared_ptr<SM::ServiceManager>& sm) {
|
void Init(Core::System& core) {
|
||||||
SM::ServiceManager::InstallInterfaces(sm);
|
SM::ServiceManager::InstallInterfaces(core);
|
||||||
|
|
||||||
for (const auto& service_module : service_module_map) {
|
for (const auto& service_module : service_module_map) {
|
||||||
if (!AttemptLLE(service_module) && service_module.init_function != nullptr)
|
if (!AttemptLLE(service_module) && service_module.init_function != nullptr)
|
||||||
|
@ -184,7 +184,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init(Core::System& system, std::shared_ptr<SM::ServiceManager>& sm);
|
void Init(Core::System& system);
|
||||||
|
|
||||||
/// Shutdown ServiceManager
|
/// Shutdown ServiceManager
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
@ -21,12 +22,12 @@ static ResultCode ValidateServiceName(const std::string& name) {
|
|||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self) {
|
void ServiceManager::InstallInterfaces(Core::System& system) {
|
||||||
ASSERT(self->srv_interface.expired());
|
ASSERT(system.ServiceManager().srv_interface.expired());
|
||||||
|
|
||||||
auto srv = std::make_shared<SRV>(self);
|
auto srv = std::make_shared<SRV>(system);
|
||||||
srv->InstallAsNamedPort();
|
srv->InstallAsNamedPort();
|
||||||
self->srv_interface = srv;
|
system.ServiceManager().srv_interface = srv;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> ServiceManager::RegisterService(
|
ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> ServiceManager::RegisterService(
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
class ClientSession;
|
class ClientSession;
|
||||||
class SessionRequestHandler;
|
class SessionRequestHandler;
|
||||||
@ -39,7 +43,7 @@ constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorDescription::AlreadyExists, Err
|
|||||||
|
|
||||||
class ServiceManager {
|
class ServiceManager {
|
||||||
public:
|
public:
|
||||||
static void InstallInterfaces(std::shared_ptr<ServiceManager> self);
|
static void InstallInterfaces(Core::System& system);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/core.h"
|
||||||
#include "core/hle/ipc.h"
|
#include "core/hle/ipc.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/kernel/client_port.h"
|
#include "core/hle/kernel/client_port.h"
|
||||||
@ -103,7 +104,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) {
|
|||||||
Kernel::HLERequestContext& ctx,
|
Kernel::HLERequestContext& ctx,
|
||||||
Kernel::ThreadWakeupReason reason) {
|
Kernel::ThreadWakeupReason reason) {
|
||||||
LOG_ERROR(Service_SRV, "called service={} wakeup", name);
|
LOG_ERROR(Service_SRV, "called service={} wakeup", name);
|
||||||
auto client_port = service_manager->GetServicePort(name);
|
auto client_port = system.ServiceManager().GetServicePort(name);
|
||||||
|
|
||||||
auto session = client_port.Unwrap()->Connect();
|
auto session = client_port.Unwrap()->Connect();
|
||||||
if (session.Succeeded()) {
|
if (session.Succeeded()) {
|
||||||
@ -122,7 +123,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto client_port = service_manager->GetServicePort(name);
|
auto client_port = system.ServiceManager().GetServicePort(name);
|
||||||
if (client_port.Failed()) {
|
if (client_port.Failed()) {
|
||||||
if (wait_until_available && client_port.Code() == ERR_SERVICE_NOT_REGISTERED) {
|
if (wait_until_available && client_port.Code() == ERR_SERVICE_NOT_REGISTERED) {
|
||||||
LOG_INFO(Service_SRV, "called service={} delayed", name);
|
LOG_INFO(Service_SRV, "called service={} delayed", name);
|
||||||
@ -223,7 +224,7 @@ void SRV::RegisterService(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
std::string name(name_buf.data(), std::min(name_len, name_buf.size()));
|
std::string name(name_buf.data(), std::min(name_len, name_buf.size()));
|
||||||
|
|
||||||
auto port = service_manager->RegisterService(name, max_sessions);
|
auto port = system.ServiceManager().RegisterService(name, max_sessions);
|
||||||
|
|
||||||
if (port.Failed()) {
|
if (port.Failed()) {
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||||
@ -243,8 +244,7 @@ void SRV::RegisterService(Kernel::HLERequestContext& ctx) {
|
|||||||
rb.PushMoveObjects(port.Unwrap());
|
rb.PushMoveObjects(port.Unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
SRV::SRV(std::shared_ptr<ServiceManager> service_manager)
|
SRV::SRV(Core::System& system) : ServiceFramework("srv:", 4), system(system) {
|
||||||
: ServiceFramework("srv:", 4), service_manager(std::move(service_manager)) {
|
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0x00010002, &SRV::RegisterClient, "RegisterClient"},
|
{0x00010002, &SRV::RegisterClient, "RegisterClient"},
|
||||||
{0x00020000, &SRV::EnableNotification, "EnableNotification"},
|
{0x00020000, &SRV::EnableNotification, "EnableNotification"},
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
class HLERequestContext;
|
class HLERequestContext;
|
||||||
class Semaphore;
|
class Semaphore;
|
||||||
@ -18,7 +22,7 @@ namespace Service::SM {
|
|||||||
/// Interface to "srv:" service
|
/// Interface to "srv:" service
|
||||||
class SRV final : public ServiceFramework<SRV> {
|
class SRV final : public ServiceFramework<SRV> {
|
||||||
public:
|
public:
|
||||||
explicit SRV(std::shared_ptr<ServiceManager> service_manager);
|
explicit SRV(Core::System& system);
|
||||||
~SRV();
|
~SRV();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -30,7 +34,7 @@ private:
|
|||||||
void PublishToSubscriber(Kernel::HLERequestContext& ctx);
|
void PublishToSubscriber(Kernel::HLERequestContext& ctx);
|
||||||
void RegisterService(Kernel::HLERequestContext& ctx);
|
void RegisterService(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
std::shared_ptr<ServiceManager> service_manager;
|
Core::System& system;
|
||||||
Kernel::SharedPtr<Kernel::Semaphore> notification_semaphore;
|
Kernel::SharedPtr<Kernel::Semaphore> notification_semaphore;
|
||||||
std::unordered_map<std::string, Kernel::SharedPtr<Kernel::Event>>
|
std::unordered_map<std::string, Kernel::SharedPtr<Kernel::Event>>
|
||||||
get_service_handle_delayed_map;
|
get_service_handle_delayed_map;
|
||||||
|
Loading…
Reference in New Issue
Block a user