summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-24 02:00:15 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:52 +0200
commit626f746971d1d3216a38b20680959df3a1f5f256 (patch)
treed9b9448732e264e84557e12d7a14a40f00cb006f /src/core/hle/service
parenthle: kernel: Migrate KServerPort to KAutoObject. (diff)
downloadyuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar
yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.gz
yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.bz2
yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.lz
yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.xz
yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.zst
yuzu-626f746971d1d3216a38b20680959df3a1f5f256.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/service.cpp9
-rw-r--r--src/core/hle/service/sm/sm.cpp31
-rw-r--r--src/core/hle/service/sm/sm.h13
3 files changed, 27 insertions, 26 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index a882b3b4e..42e464024 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -116,10 +116,11 @@ void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) {
ASSERT(!port_installed);
- auto [server_port, client_port] =
- Kernel::KServerPort::CreatePortPair(kernel, max_sessions, service_name);
- server_port->SetHleHandler(shared_from_this());
- kernel.AddNamedPort(service_name, client_port);
+ auto* port = Kernel::KPort::Create(kernel);
+ port->Initialize(max_sessions, false, service_name);
+ port->GetServerPort().SetHleHandler(shared_from_this());
+ kernel.AddNamedPort(service_name, &port->GetClientPort());
+
port_installed = true;
}
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 51274bfb1..71ab4b6f5 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -8,6 +8,7 @@
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/k_client_port.h"
#include "core/hle/kernel/k_client_session.h"
+#include "core/hle/kernel/k_port.h"
#include "core/hle/kernel/k_server_port.h"
#include "core/hle/kernel/k_server_session.h"
#include "core/hle/kernel/k_session.h"
@@ -59,13 +60,12 @@ ResultVal<Kernel::KServerPort*> ServiceManager::RegisterService(std::string name
return ERR_ALREADY_REGISTERED;
}
- auto [server_port, client_port] =
- Kernel::KServerPort::CreatePortPair(kernel, max_sessions, name);
+ auto* port = Kernel::KPort::Create(kernel);
+ port->Initialize(max_sessions, false, name);
- client_port->Open();
+ registered_services.emplace(std::move(name), port);
- registered_services.emplace(std::move(name), client_port);
- return MakeResult(server_port);
+ return MakeResult(&port->GetServerPort());
}
ResultCode ServiceManager::UnregisterService(const std::string& name) {
@@ -83,7 +83,7 @@ ResultCode ServiceManager::UnregisterService(const std::string& name) {
return RESULT_SUCCESS;
}
-ResultVal<Kernel::KClientPort*> ServiceManager::GetServicePort(const std::string& name) {
+ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name) {
CASCADE_CODE(ValidateServiceName(name));
auto it = registered_services.find(name);
@@ -118,25 +118,26 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
std::string name(name_buf.begin(), end);
- auto client_port = service_manager->GetServicePort(name);
- if (client_port.Failed()) {
+ auto result = service_manager->GetServicePort(name);
+ if (result.Failed()) {
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(client_port.Code());
- LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, client_port.Code().raw);
+ rb.Push(result.Code());
+ LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw);
if (name.length() == 0)
return; // LibNX Fix
UNIMPLEMENTED();
return;
}
+ auto* port = result.Unwrap();
+
auto* session = Kernel::KSession::Create(kernel);
- session->Initialize(std::move(name));
+ session->Initialize(&port->GetClientPort(), std::move(name));
- const auto& server_port = client_port.Unwrap()->GetServerPort();
- if (server_port->GetHLEHandler()) {
- server_port->GetHLEHandler()->ClientConnected(session);
+ if (port->GetServerPort().GetHLEHandler()) {
+ port->GetServerPort().GetHLEHandler()->ClientConnected(&session->GetServerSession());
} else {
- server_port->AppendPendingSession(&session->GetServerSession());
+ port->EnqueueSession(&session->GetServerSession());
}
LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetObjectId());
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index b0204c4bb..af5010c3b 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -10,9 +10,7 @@
#include <unordered_map>
#include "common/concepts.h"
-#include "core/hle/kernel/k_client_port.h"
-#include "core/hle/kernel/k_server_port.h"
-#include "core/hle/kernel/object.h"
+#include "core/hle/kernel/k_port.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@@ -24,6 +22,7 @@ namespace Kernel {
class KClientPort;
class KClientSession;
class KernelCore;
+class KPort;
class KServerPort;
class SessionRequestHandler;
} // namespace Kernel
@@ -57,7 +56,7 @@ public:
ResultVal<Kernel::KServerPort*> RegisterService(std::string name, u32 max_sessions);
ResultCode UnregisterService(const std::string& name);
- ResultVal<Kernel::KClientPort*> GetServicePort(const std::string& name);
+ ResultVal<Kernel::KPort*> GetServicePort(const std::string& name);
template <Common::DerivedFrom<Kernel::SessionRequestHandler> T>
std::shared_ptr<T> GetService(const std::string& service_name) const {
@@ -66,11 +65,11 @@ public:
LOG_DEBUG(Service, "Can't find service: {}", service_name);
return nullptr;
}
- auto port = service->second->GetServerPort();
+ auto* port = service->second;
if (port == nullptr) {
return nullptr;
}
- return std::static_pointer_cast<T>(port->GetHLEHandler());
+ return std::static_pointer_cast<T>(port->GetServerPort().GetHLEHandler());
}
void InvokeControlRequest(Kernel::HLERequestContext& context);
@@ -80,7 +79,7 @@ private:
std::unique_ptr<Controller> controller_interface;
/// Map of registered services, retrieved using GetServicePort.
- std::unordered_map<std::string, Kernel::KClientPort*> registered_services;
+ std::unordered_map<std::string, Kernel::KPort*> registered_services;
/// Kernel context
Kernel::KernelCore& kernel;