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()) {
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<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
iface->ClientConnected(server);
context->AddMoveObject(std::move(client));
}
}

View File

@ -162,23 +162,26 @@ public:
~Hid() = default;
private:
Kernel::SharedPtr<Kernel::ClientPort> client_port;
std::shared_ptr<IAppletResource> applet_resource;
void CreateAppletResource(Kernel::HLERequestContext& ctx) {
if (client_port == nullptr) {
client_port = std::make_shared<IAppletResource>()->CreatePort();
if (applet_resource == nullptr) {
applet_resource = std::make_shared<IAppletResource>();
}
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();
}
// 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<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",
client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
}
};

View File

@ -146,18 +146,19 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {
* 0: ResultCode
*/
void LM::Initialize(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<Logger>()->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();
}
// TODO(Subv): Verify if this should return the interface as a domain object when called from
// within a domain.
auto logger = std::make_shared<Logger>();
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};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
LOG_INFO(Service_SM, "called");
}

View File

@ -5,7 +5,6 @@
#pragma once
#include <vector>
#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<Kernel::SharedPtr<Kernel::ClientPort>> registered_loggers;
};
/// Registers all LM services with the specified service manager.

View File

@ -83,45 +83,45 @@ private:
};
void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->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();
}
// 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<ISystemClock>();
auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
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};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
}
void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->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();
}
// 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<ISystemClock>();
auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
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};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
}
void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISteadyClock>()->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();
}
// 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<ISteadyClock>();
auto sessions = Kernel::ServerSession::CreateSessionPair(steady_clock->GetServiceName());
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};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
}
void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {