From 67c43e92005c34da08005cf9f9b542874c5c4005 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 17:30:58 -0500 Subject: IPC: Don't create an unnecessary port when using PushIpcInterface outside of a domain. --- src/core/hle/ipc_helpers.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index a27cfbc2d..ab479b49b 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -118,10 +118,11 @@ public: if (context->IsDomain()) { context->AddDomainObject(std::move(iface)); } else { - auto port = iface->CreatePort(); - auto session = port->Connect(); - ASSERT(session.Succeeded()); - context->AddMoveObject(std::move(session).Unwrap()); + auto sessions = Kernel::ServerSession::CreateSessionPair(iface->GetServiceName()); + auto server = std::get>(sessions); + auto client = std::get>(sessions); + iface->ClientConnected(server); + context->AddMoveObject(std::move(client)); } } -- cgit v1.2.3 From 1a9c96e4de6699722ad0fbe511c9868e89d29eee Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 17:35:40 -0500 Subject: LM: Don't create an unnecessary port in Initialize. --- src/core/hle/service/lm/lm.cpp | 22 ++++++++++------------ src/core/hle/service/lm/lm.h | 3 --- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 13c9ee3d3..dd0f75ce1 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -146,18 +146,16 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { * 0: ResultCode */ void LM::Initialize(Kernel::HLERequestContext& ctx) { - auto client_port = std::make_shared()->CreatePort(); - auto session = client_port->Connect(); - if (session.Succeeded()) { - LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", - (*session)->GetObjectId()); - IPC::RequestBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(std::move(session).Unwrap()); - registered_loggers.emplace_back(std::move(client_port)); - } else { - UNIMPLEMENTED(); - } + auto logger = std::make_shared(); + auto sessions = Kernel::ServerSession::CreateSessionPair(logger->GetServiceName()); + auto server = std::get>(sessions); + auto client = std::get>(sessions); + logger->ClientConnected(server); + + LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", client->GetObjectId()); + IPC::RequestBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushMoveObjects(std::move(client)); LOG_INFO(Service_SM, "called"); } diff --git a/src/core/hle/service/lm/lm.h b/src/core/hle/service/lm/lm.h index 4b954bdb2..371135057 100644 --- a/src/core/hle/service/lm/lm.h +++ b/src/core/hle/service/lm/lm.h @@ -5,7 +5,6 @@ #pragma once #include -#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/service.h" @@ -19,8 +18,6 @@ public: private: void Initialize(Kernel::HLERequestContext& ctx); - - std::vector> registered_loggers; }; /// Registers all LM services with the specified service manager. -- cgit v1.2.3 From 1003996e80791baf1187b8a122f521d3cf02cc96 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 17:41:31 -0500 Subject: HID: Don't create an unnecessary port in CreateAppletResource. --- src/core/hle/service/hid/hid.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index d99e9c505..9b1e680f1 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -162,23 +162,23 @@ public: ~Hid() = default; private: - Kernel::SharedPtr client_port; + std::shared_ptr applet_resource; void CreateAppletResource(Kernel::HLERequestContext& ctx) { - if (client_port == nullptr) { - client_port = std::make_shared()->CreatePort(); + if (applet_resource == nullptr) { + applet_resource = std::make_shared(); } - auto session = client_port->Connect(); - if (session.Succeeded()) { - LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u", - (*session)->GetObjectId()); - IPC::RequestBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(std::move(session).Unwrap()); - } else { - UNIMPLEMENTED(); - } + auto sessions = Kernel::ServerSession::CreateSessionPair(applet_resource->GetServiceName()); + auto server = std::get>(sessions); + auto client = std::get>(sessions); + applet_resource->ClientConnected(server); + + LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u", + client->GetObjectId()); + IPC::RequestBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushMoveObjects(std::move(client)); } }; -- cgit v1.2.3 From 7efa6e8801866da8ed4dca97fa25d2451dcb042e Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 17:42:11 -0500 Subject: Time: Don't create unnecessary ports when retrieving the clock service sessions. --- src/core/hle/service/time/time.cpp | 60 +++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 9fed89246..9039a4cec 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -83,45 +83,39 @@ private: }; void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { - auto client_port = std::make_shared()->CreatePort(); - auto session = client_port->Connect(); - if (session.Succeeded()) { - LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", - (*session)->GetObjectId()); - IPC::RequestBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(std::move(session).Unwrap()); - } else { - UNIMPLEMENTED(); - } + auto system_clock = std::make_shared(); + auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName()); + auto server = std::get>(sessions); + auto client = std::get>(sessions); + system_clock->ClientConnected(server); + LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId()); + IPC::RequestBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushMoveObjects(std::move(client)); } void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { - auto client_port = std::make_shared()->CreatePort(); - auto session = client_port->Connect(); - if (session.Succeeded()) { - LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", - (*session)->GetObjectId()); - IPC::RequestBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(std::move(session).Unwrap()); - } else { - UNIMPLEMENTED(); - } + auto system_clock = std::make_shared(); + auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName()); + auto server = std::get>(sessions); + auto client = std::get>(sessions); + system_clock->ClientConnected(server); + LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId()); + IPC::RequestBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushMoveObjects(std::move(client)); } void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { - auto client_port = std::make_shared()->CreatePort(); - auto session = client_port->Connect(); - if (session.Succeeded()) { - LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", - (*session)->GetObjectId()); - IPC::RequestBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(std::move(session).Unwrap()); - } else { - UNIMPLEMENTED(); - } + auto steady_clock = std::make_shared(); + auto sessions = Kernel::ServerSession::CreateSessionPair(steady_clock->GetServiceName()); + auto server = std::get>(sessions); + auto client = std::get>(sessions); + steady_clock->ClientConnected(server); + LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", client->GetObjectId()); + IPC::RequestBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushMoveObjects(std::move(client)); } void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { -- cgit v1.2.3 From b0489c9a64588d2140d9a98b69c5a0adc541a436 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 22 Jan 2018 17:59:24 -0500 Subject: Services: Added a todo about returning interfaces as domain objects in lm, hid and time. --- src/core/hle/service/hid/hid.cpp | 3 +++ src/core/hle/service/lm/lm.cpp | 3 +++ src/core/hle/service/time/time.cpp | 6 ++++++ 3 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 9b1e680f1..ae60cc7b4 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -169,6 +169,9 @@ private: applet_resource = std::make_shared(); } + // TODO(Subv): Verify if this should return the interface as a domain object when called + // from within a domain. + auto sessions = Kernel::ServerSession::CreateSessionPair(applet_resource->GetServiceName()); auto server = std::get>(sessions); auto client = std::get>(sessions); diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index dd0f75ce1..b505cdcaf 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -146,6 +146,9 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { * 0: ResultCode */ void LM::Initialize(Kernel::HLERequestContext& ctx) { + // TODO(Subv): Verify if this should return the interface as a domain object when called from + // within a domain. + auto logger = std::make_shared(); auto sessions = Kernel::ServerSession::CreateSessionPair(logger->GetServiceName()); auto server = std::get>(sessions); diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 9039a4cec..8abb2ce7a 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -83,6 +83,8 @@ private: }; void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { + // TODO(Subv): Verify if this should return the interface as a domain object when called from + // within a domain. auto system_clock = std::make_shared(); auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName()); auto server = std::get>(sessions); @@ -95,6 +97,8 @@ void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ct } void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { + // TODO(Subv): Verify if this should return the interface as a domain object when called from + // within a domain. auto system_clock = std::make_shared(); auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName()); auto server = std::get>(sessions); @@ -107,6 +111,8 @@ void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& } void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { + // TODO(Subv): Verify if this should return the interface as a domain object when called from + // within a domain. auto steady_clock = std::make_shared(); auto sessions = Kernel::ServerSession::CreateSessionPair(steady_clock->GetServiceName()); auto server = std::get>(sessions); -- cgit v1.2.3