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