summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-06 07:39:26 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-06 11:56:32 +0200
commit6354d083594249fa1995be7b024943c258f63880 (patch)
treebe459930c35e50f698ef7747730092116eea6a74 /src/core/hle/service
parentResultVal: Add more convenience utils for creating and cascading results (diff)
downloadyuzu-6354d083594249fa1995be7b024943c258f63880.tar
yuzu-6354d083594249fa1995be7b024943c258f63880.tar.gz
yuzu-6354d083594249fa1995be7b024943c258f63880.tar.bz2
yuzu-6354d083594249fa1995be7b024943c258f63880.tar.lz
yuzu-6354d083594249fa1995be7b024943c258f63880.tar.xz
yuzu-6354d083594249fa1995be7b024943c258f63880.tar.zst
yuzu-6354d083594249fa1995be7b024943c258f63880.zip
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/fs/archive.cpp11
-rw-r--r--src/core/hle/service/fs/archive.h2
-rw-r--r--src/core/hle/service/fs/fs_user.cpp33
-rw-r--r--src/core/hle/service/service.cpp20
4 files changed, 37 insertions, 29 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index d6128d6a7..bbc5f8067 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -84,6 +84,10 @@ File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path&
File::~File() {}
void File::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
+ using Kernel::ClientSession;
+ using Kernel::ServerSession;
+ using Kernel::SharedPtr;
+
u32* cmd_buff = Kernel::GetCommandBuffer();
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
switch (cmd) {
@@ -162,10 +166,9 @@ void File::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_ses
case FileCommand::OpenLinkFile: {
LOG_WARNING(Service_FS, "(STUBBED) File command OpenLinkFile %s", GetName().c_str());
- auto sessions = Kernel::ServerSession::CreateSessionPair(GetName(), shared_from_this());
- ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
- cmd_buff[3] = Kernel::g_handle_table
- .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
+ auto sessions = ServerSession::CreateSessionPair(GetName());
+ ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));
+ cmd_buff[3] = Kernel::g_handle_table.Create(std::get<SharedPtr<ClientSession>>(sessions))
.ValueOr(INVALID_HANDLE);
break;
}
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index 28e33caaa..3a3371c88 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -43,7 +43,7 @@ enum class MediaType : u32 { NAND = 0, SDMC = 1, GameCard = 2 };
typedef u64 ArchiveHandle;
-class File final : public Kernel::SessionRequestHandler, public std::enable_shared_from_this<File> {
+class File final : public Kernel::SessionRequestHandler {
public:
File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path);
~File();
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index fafdd3cc8..fe50403b9 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -20,8 +20,9 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace FS_User
-using Kernel::SharedPtr;
+using Kernel::ClientSession;
using Kernel::ServerSession;
+using Kernel::SharedPtr;
namespace Service {
namespace FS {
@@ -79,11 +80,11 @@ static void OpenFile(Service::Interface* self) {
rb.Push(file_res.Code());
if (file_res.Succeeded()) {
std::shared_ptr<File> file = *file_res;
- auto sessions = ServerSession::CreateSessionPair(file->GetName(), file);
- file->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
- rb.PushMoveHandles(Kernel::g_handle_table
- .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
- .MoveFrom());
+ auto sessions = ServerSession::CreateSessionPair(file->GetName());
+ file->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));
+
+ rb.PushMoveHandles(
+ Kernel::g_handle_table.Create(std::get<SharedPtr<ClientSession>>(sessions)).MoveFrom());
} else {
rb.PushMoveHandles(0);
LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str());
@@ -145,11 +146,11 @@ static void OpenFileDirectly(Service::Interface* self) {
cmd_buff[1] = file_res.Code().raw;
if (file_res.Succeeded()) {
std::shared_ptr<File> file = *file_res;
- auto sessions = ServerSession::CreateSessionPair(file->GetName(), file);
- file->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
- cmd_buff[3] = Kernel::g_handle_table
- .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
- .MoveFrom();
+ auto sessions = ServerSession::CreateSessionPair(file->GetName());
+ file->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));
+
+ cmd_buff[3] =
+ Kernel::g_handle_table.Create(std::get<SharedPtr<ClientSession>>(sessions)).MoveFrom();
} else {
cmd_buff[3] = 0;
LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u",
@@ -412,11 +413,11 @@ static void OpenDirectory(Service::Interface* self) {
cmd_buff[1] = dir_res.Code().raw;
if (dir_res.Succeeded()) {
std::shared_ptr<Directory> directory = *dir_res;
- auto sessions = ServerSession::CreateSessionPair(directory->GetName(), directory);
- directory->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
- cmd_buff[3] = Kernel::g_handle_table
- .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
- .MoveFrom();
+ auto sessions = ServerSession::CreateSessionPair(directory->GetName());
+ directory->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));
+
+ cmd_buff[3] =
+ Kernel::g_handle_table.Create(std::get<SharedPtr<ClientSession>>(sessions)).MoveFrom();
} else {
LOG_ERROR(Service_FS, "failed to get a handle for directory type=%d size=%d data=%s",
dirname_type, dirname_size, dir_path.DebugStr().c_str());
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index bb22e25be..8f7c97d54 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -105,18 +105,22 @@ void Interface::Register(const FunctionInfo* functions, size_t n) {
// Module interface
static void AddNamedPort(Interface* interface_) {
- auto ports =
- Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName(),
- std::shared_ptr<Interface>(interface_));
- auto client_port = std::get<Kernel::SharedPtr<Kernel::ClientPort>>(ports);
+ Kernel::SharedPtr<Kernel::ServerPort> server_port;
+ Kernel::SharedPtr<Kernel::ClientPort> client_port;
+ std::tie(server_port, client_port) =
+ Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName());
+
+ server_port->SetHleHandler(std::shared_ptr<Interface>(interface_));
g_kernel_named_ports.emplace(interface_->GetPortName(), std::move(client_port));
}
void AddService(Interface* interface_) {
- auto ports =
- Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName(),
- std::shared_ptr<Interface>(interface_));
- auto client_port = std::get<Kernel::SharedPtr<Kernel::ClientPort>>(ports);
+ Kernel::SharedPtr<Kernel::ServerPort> server_port;
+ Kernel::SharedPtr<Kernel::ClientPort> client_port;
+ std::tie(server_port, client_port) =
+ Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName());
+
+ server_port->SetHleHandler(std::shared_ptr<Interface>(interface_));
g_srv_services.emplace(interface_->GetPortName(), std::move(client_port));
}