summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/sm/sm.cpp
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/sm/sm.cpp
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 'src/core/hle/service/sm/sm.cpp')
-rw-r--r--src/core/hle/service/sm/sm.cpp31
1 files changed, 16 insertions, 15 deletions
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());