summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/sm
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2022-10-16 07:53:56 +0200
committerLiam <byteslice@airmail.cc>2022-10-31 22:44:06 +0100
commit983f2b70741f17f30fe2321451f10cabecc013d2 (patch)
treec1ac3c1033fdeefaabe76590ca204c4c1b2a98cd /src/core/hle/service/sm
parentMerge pull request #9159 from liamwhite/kbork (diff)
downloadyuzu-983f2b70741f17f30fe2321451f10cabecc013d2.tar
yuzu-983f2b70741f17f30fe2321451f10cabecc013d2.tar.gz
yuzu-983f2b70741f17f30fe2321451f10cabecc013d2.tar.bz2
yuzu-983f2b70741f17f30fe2321451f10cabecc013d2.tar.lz
yuzu-983f2b70741f17f30fe2321451f10cabecc013d2.tar.xz
yuzu-983f2b70741f17f30fe2321451f10cabecc013d2.tar.zst
yuzu-983f2b70741f17f30fe2321451f10cabecc013d2.zip
Diffstat (limited to 'src/core/hle/service/sm')
-rw-r--r--src/core/hle/service/sm/sm.cpp13
-rw-r--r--src/core/hle/service/sm/sm.h1
-rw-r--r--src/core/hle/service/sm/sm_controller.cpp21
3 files changed, 20 insertions, 15 deletions
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index cb6c0e96f..c1f535d71 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -43,6 +43,10 @@ Kernel::KClientPort& ServiceManager::InterfaceFactory(ServiceManager& self, Core
return self.sm_interface->CreatePort();
}
+void ServiceManager::SessionHandler(ServiceManager& self, Kernel::KServerPort* server_port) {
+ self.sm_interface->AcceptSession(server_port);
+}
+
Result ServiceManager::RegisterService(std::string name, u32 max_sessions,
Kernel::SessionRequestHandlerPtr handler) {
@@ -83,7 +87,6 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name
port->Initialize(ServerSessionCountMax, false, name);
auto handler = it->second;
- port->GetServerPort().SetSessionHandler(std::move(handler));
return port;
}
@@ -144,7 +147,8 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext&
// Find the named port.
auto port_result = service_manager.GetServicePort(name);
- if (port_result.Failed()) {
+ auto service = service_manager.GetService<Kernel::SessionRequestHandler>(name);
+ if (port_result.Failed() || !service) {
LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, port_result.Code().raw);
return port_result.Code();
}
@@ -156,12 +160,11 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext&
// Create a new session.
Kernel::KClientSession* session{};
- if (const auto result = port->GetClientPort().CreateSession(
- std::addressof(session), std::make_shared<Kernel::SessionRequestManager>(kernel));
- result.IsError()) {
+ if (const auto result = port->GetClientPort().CreateSession(&session); result.IsError()) {
LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.raw);
return result;
}
+ service->AcceptSession(&port->GetServerPort());
LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 878decc6f..cfe370652 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -51,6 +51,7 @@ private:
class ServiceManager {
public:
static Kernel::KClientPort& InterfaceFactory(ServiceManager& self, Core::System& system);
+ static void SessionHandler(ServiceManager& self, Kernel::KServerPort* server_port);
explicit ServiceManager(Kernel::KernelCore& kernel_);
~ServiceManager();
diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp
index 46a8439d8..940c33478 100644
--- a/src/core/hle/service/sm/sm_controller.cpp
+++ b/src/core/hle/service/sm/sm_controller.cpp
@@ -15,10 +15,9 @@
namespace Service::SM {
void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) {
- ASSERT_MSG(!ctx.Session()->GetSessionRequestManager()->IsDomain(),
- "Session is already a domain");
+ ASSERT_MSG(!ctx.GetManager()->IsDomain(), "Session is already a domain");
LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId());
- ctx.Session()->GetSessionRequestManager()->ConvertToDomainOnRequestEnd();
+ ctx.GetManager()->ConvertToDomainOnRequestEnd();
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
@@ -29,30 +28,32 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service, "called");
auto& process = *ctx.GetThread().GetOwnerProcess();
- auto& parent_session = *ctx.Session()->GetParent();
- auto& session_manager = parent_session.GetServerSession().GetSessionRequestManager();
- auto& session_handler = session_manager->SessionHandler();
+ auto session_manager = ctx.GetManager();
// FIXME: this is duplicated from the SVC, it should just call it instead
// once this is a proper process
+ // Declare the session we're going to allocate.
+ Kernel::KSession* session;
+
// Reserve a new session from the process resource limit.
Kernel::KScopedResourceReservation session_reservation(&process,
Kernel::LimitableResource::Sessions);
ASSERT(session_reservation.Succeeded());
// Create the session.
- Kernel::KSession* session = Kernel::KSession::Create(system.Kernel());
+ session = Kernel::KSession::Create(system.Kernel());
ASSERT(session != nullptr);
// Initialize the session.
- session->Initialize(nullptr, parent_session.GetName(), session_manager);
+ session->Initialize(nullptr, "");
// Commit the session reservation.
session_reservation.Commit();
- // Register the session.
- session_handler.ClientConnected(&session->GetServerSession());
+ // Register with manager.
+ session_manager->SessionHandler().RegisterSession(&session->GetServerSession(),
+ session_manager);
// We succeeded.
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};