summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/srv.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/srv.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index b25be413a..3bd787147 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -2,14 +2,16 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <tuple>
+
#include "common/common_types.h"
#include "common/logging/log.h"
+#include "core/hle/kernel/client_session.h"
#include "core/hle/kernel/event.h"
+#include "core/hle/kernel/server_session.h"
#include "core/hle/service/srv.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Namespace SRV
-
+namespace Service {
namespace SRV {
static Kernel::SharedPtr<Kernel::Event> event_handle;
@@ -23,7 +25,7 @@ static Kernel::SharedPtr<Kernel::Event> event_handle;
* 0: 0x00010040
* 1: ResultCode
*/
-static void RegisterClient(Service::Interface* self) {
+static void RegisterClient(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
if (cmd_buff[1] != IPC::CallingPidDesc()) {
@@ -48,7 +50,7 @@ static void RegisterClient(Service::Interface* self) {
* 2: Translation descriptor: 0x20
* 3: Handle to semaphore signaled on process notification
*/
-static void EnableNotification(Service::Interface* self) {
+static void EnableNotification(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
// TODO(bunnei): Change to a semaphore once these have been implemented
@@ -73,7 +75,7 @@ static void EnableNotification(Service::Interface* self) {
* 1: ResultCode
* 3: Service handle
*/
-static void GetServiceHandle(Service::Interface* self) {
+static void GetServiceHandle(Interface* self) {
ResultCode res = RESULT_SUCCESS;
u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -81,7 +83,15 @@ static void GetServiceHandle(Service::Interface* self) {
auto it = Service::g_srv_services.find(port_name);
if (it != Service::g_srv_services.end()) {
- cmd_buff[3] = Kernel::g_handle_table.Create(it->second).MoveFrom();
+ auto client_port = it->second;
+
+ auto client_session = client_port->Connect();
+ res = client_session.Code();
+
+ if (client_session.Succeeded()) {
+ // Return the client session
+ cmd_buff[3] = Kernel::g_handle_table.Create(*client_session).MoveFrom();
+ }
LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]);
} else {
LOG_ERROR(Service_SRV, "(UNIMPLEMENTED) called port=%s", port_name.c_str());
@@ -99,7 +109,7 @@ static void GetServiceHandle(Service::Interface* self) {
* 0: 0x00090040
* 1: ResultCode
*/
-static void Subscribe(Service::Interface* self) {
+static void Subscribe(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 notification_id = cmd_buff[1];
@@ -118,7 +128,7 @@ static void Subscribe(Service::Interface* self) {
* 0: 0x000A0040
* 1: ResultCode
*/
-static void Unsubscribe(Service::Interface* self) {
+static void Unsubscribe(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 notification_id = cmd_buff[1];
@@ -138,7 +148,7 @@ static void Unsubscribe(Service::Interface* self) {
* 0: 0x000C0040
* 1: ResultCode
*/
-static void PublishToSubscriber(Service::Interface* self) {
+static void PublishToSubscriber(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 notification_id = cmd_buff[1];
@@ -167,16 +177,14 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x000E00C0, nullptr, "IsServiceRegistered"},
};
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Interface class
-
-Interface::Interface() {
+SRV::SRV() {
Register(FunctionTable);
event_handle = nullptr;
}
-Interface::~Interface() {
+SRV::~SRV() {
event_handle = nullptr;
}
} // namespace SRV
+} // namespace Service