yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Merge pull request #135 from Subv/no_ports

IPC: Don't create unnecessary ports when returning sub interfaces.
This commit is contained in:
bunnei 2018-01-22 21:37:15 -05:00 committed by GitHub
commit d1b64cdc07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 65 deletions

View File

@ -118,10 +118,11 @@ public:
if (context->IsDomain()) { if (context->IsDomain()) {
context->AddDomainObject(std::move(iface)); context->AddDomainObject(std::move(iface));
} else { } else {
auto port = iface->CreatePort(); auto sessions = Kernel::ServerSession::CreateSessionPair(iface->GetServiceName());
auto session = port->Connect(); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
ASSERT(session.Succeeded()); auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
context->AddMoveObject(std::move(session).Unwrap()); iface->ClientConnected(server);
context->AddMoveObject(std::move(client));
} }
} }

View File

@ -162,23 +162,26 @@ public:
~Hid() = default; ~Hid() = default;
private: private:
Kernel::SharedPtr<Kernel::ClientPort> client_port; std::shared_ptr<IAppletResource> applet_resource;
void CreateAppletResource(Kernel::HLERequestContext& ctx) { void CreateAppletResource(Kernel::HLERequestContext& ctx) {
if (client_port == nullptr) { if (applet_resource == nullptr) {
client_port = std::make_shared<IAppletResource>()->CreatePort(); applet_resource = std::make_shared<IAppletResource>();
} }
auto session = client_port->Connect(); // TODO(Subv): Verify if this should return the interface as a domain object when called
if (session.Succeeded()) { // from within a domain.
auto sessions = Kernel::ServerSession::CreateSessionPair(applet_resource->GetServiceName());
auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
applet_resource->ClientConnected(server);
LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u", LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u",
(*session)->GetObjectId()); client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap()); rb.PushMoveObjects(std::move(client));
} else {
UNIMPLEMENTED();
}
} }
}; };

View File

@ -146,18 +146,19 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {
* 0: ResultCode * 0: ResultCode
*/ */
void LM::Initialize(Kernel::HLERequestContext& ctx) { void LM::Initialize(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<Logger>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) {
LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", auto logger = std::make_shared<Logger>();
(*session)->GetObjectId()); auto sessions = Kernel::ServerSession::CreateSessionPair(logger->GetServiceName());
auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
logger->ClientConnected(server);
LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap()); rb.PushMoveObjects(std::move(client));
registered_loggers.emplace_back(std::move(client_port));
} else {
UNIMPLEMENTED();
}
LOG_INFO(Service_SM, "called"); LOG_INFO(Service_SM, "called");
} }

View File

@ -5,7 +5,6 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
@ -19,8 +18,6 @@ public:
private: private:
void Initialize(Kernel::HLERequestContext& ctx); void Initialize(Kernel::HLERequestContext& ctx);
std::vector<Kernel::SharedPtr<Kernel::ClientPort>> registered_loggers;
}; };
/// Registers all LM services with the specified service manager. /// Registers all LM services with the specified service manager.

View File

@ -83,45 +83,45 @@ private:
}; };
void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) { auto system_clock = std::make_shared<ISystemClock>();
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
(*session)->GetObjectId()); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
system_clock->ClientConnected(server);
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap()); rb.PushMoveObjects(std::move(client));
} else {
UNIMPLEMENTED();
}
} }
void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) { auto system_clock = std::make_shared<ISystemClock>();
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
(*session)->GetObjectId()); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
system_clock->ClientConnected(server);
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap()); rb.PushMoveObjects(std::move(client));
} else {
UNIMPLEMENTED();
}
} }
void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISteadyClock>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) { auto steady_clock = std::make_shared<ISteadyClock>();
LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", auto sessions = Kernel::ServerSession::CreateSessionPair(steady_clock->GetServiceName());
(*session)->GetObjectId()); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
steady_clock->ClientConnected(server);
LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap()); rb.PushMoveObjects(std::move(client));
} else {
UNIMPLEMENTED();
}
} }
void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {