diff options
| author | 2016-06-14 18:03:30 -0500 | |
|---|---|---|
| committer | 2016-11-30 23:02:05 -0500 | |
| commit | 073653e858abf377fd1ebbdb071809c8830ce99d (patch) | |
| tree | a29e1c1e50d53162ed89cd90e8c069525150392f /src/core/hle/service/fs | |
| parent | Merge pull request #2228 from freiro/winver_fix (diff) | |
| download | yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.gz yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.xz yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.zip | |
Kernel/IPC: Use Ports and Sessions as the fundamental building block of Inter Process Communication.
All handles obtained via srv::GetServiceHandle or svcConnectToPort are references to ClientSessions.
Service modules will wait on the counterpart of those ClientSessions (Called ServerSessions) using svcReplyAndReceive or svcWaitSynchronization[1|N], and will be awoken when a SyncRequest is performed.
HLE Interfaces are now ClientPorts which override the HandleSyncRequest virtual member function to perform command handling immediately.
Diffstat (limited to 'src/core/hle/service/fs')
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 12 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 9 |
3 files changed, 18 insertions, 15 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 4c29784e8..da009df91 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -92,7 +92,7 @@ File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& | |||
| 92 | 92 | ||
| 93 | File::~File() {} | 93 | File::~File() {} |
| 94 | 94 | ||
| 95 | ResultVal<bool> File::SyncRequest() { | 95 | ResultCode File::HandleSyncRequest() { |
| 96 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 96 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 97 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); | 97 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); |
| 98 | switch (cmd) { | 98 | switch (cmd) { |
| @@ -193,10 +193,10 @@ ResultVal<bool> File::SyncRequest() { | |||
| 193 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); | 193 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); |
| 194 | ResultCode error = UnimplementedFunction(ErrorModule::FS); | 194 | ResultCode error = UnimplementedFunction(ErrorModule::FS); |
| 195 | cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. | 195 | cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. |
| 196 | return error; | 196 | return ServerSession::HandleSyncRequest(); |
| 197 | } | 197 | } |
| 198 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 198 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 199 | return MakeResult<bool>(false); | 199 | return ServerSession::HandleSyncRequest(); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, | 202 | Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, |
| @@ -205,7 +205,7 @@ Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, | |||
| 205 | 205 | ||
| 206 | Directory::~Directory() {} | 206 | Directory::~Directory() {} |
| 207 | 207 | ||
| 208 | ResultVal<bool> Directory::SyncRequest() { | 208 | ResultCode Directory::HandleSyncRequest() { |
| 209 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 209 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 210 | DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); | 210 | DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); |
| 211 | switch (cmd) { | 211 | switch (cmd) { |
| @@ -236,10 +236,10 @@ ResultVal<bool> Directory::SyncRequest() { | |||
| 236 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); | 236 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); |
| 237 | ResultCode error = UnimplementedFunction(ErrorModule::FS); | 237 | ResultCode error = UnimplementedFunction(ErrorModule::FS); |
| 238 | cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. | 238 | cmd_buff[1] = error.raw; // TODO(Link Mauve): use the correct error code for that. |
| 239 | return MakeResult<bool>(false); | 239 | return ServerSession::HandleSyncRequest(); |
| 240 | } | 240 | } |
| 241 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 241 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 242 | return MakeResult<bool>(false); | 242 | return ServerSession::HandleSyncRequest(); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 245 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 21ed9717b..22e659c40 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/file_sys/archive_backend.h" | 10 | #include "core/file_sys/archive_backend.h" |
| 11 | #include "core/hle/kernel/session.h" | 11 | #include "core/hle/kernel/server_session.h" |
| 12 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 13 | 13 | ||
| 14 | namespace FileSys { | 14 | namespace FileSys { |
| @@ -41,7 +41,7 @@ enum class MediaType : u32 { NAND = 0, SDMC = 1 }; | |||
| 41 | 41 | ||
| 42 | typedef u64 ArchiveHandle; | 42 | typedef u64 ArchiveHandle; |
| 43 | 43 | ||
| 44 | class File : public Kernel::Session { | 44 | class File : public Kernel::ServerSession { |
| 45 | public: | 45 | public: |
| 46 | File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path); | 46 | File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path); |
| 47 | ~File(); | 47 | ~File(); |
| @@ -49,14 +49,15 @@ public: | |||
| 49 | std::string GetName() const override { | 49 | std::string GetName() const override { |
| 50 | return "Path: " + path.DebugStr(); | 50 | return "Path: " + path.DebugStr(); |
| 51 | } | 51 | } |
| 52 | ResultVal<bool> SyncRequest() override; | 52 | |
| 53 | ResultCode HandleSyncRequest() override; | ||
| 53 | 54 | ||
| 54 | FileSys::Path path; ///< Path of the file | 55 | FileSys::Path path; ///< Path of the file |
| 55 | u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means | 56 | u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means |
| 56 | std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface | 57 | std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface |
| 57 | }; | 58 | }; |
| 58 | 59 | ||
| 59 | class Directory : public Kernel::Session { | 60 | class Directory : public Kernel::ServerSession { |
| 60 | public: | 61 | public: |
| 61 | Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path); | 62 | Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path); |
| 62 | ~Directory(); | 63 | ~Directory(); |
| @@ -64,7 +65,8 @@ public: | |||
| 64 | std::string GetName() const override { | 65 | std::string GetName() const override { |
| 65 | return "Directory: " + path.DebugStr(); | 66 | return "Directory: " + path.DebugStr(); |
| 66 | } | 67 | } |
| 67 | ResultVal<bool> SyncRequest() override; | 68 | |
| 69 | ResultCode HandleSyncRequest() override; | ||
| 68 | 70 | ||
| 69 | FileSys::Path path; ///< Path of the directory | 71 | FileSys::Path path; ///< Path of the directory |
| 70 | std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface | 72 | std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 9ec17b395..bb78091f9 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "common/scope_exit.h" | 9 | #include "common/scope_exit.h" |
| 10 | #include "common/string_util.h" | 10 | #include "common/string_util.h" |
| 11 | #include "core/hle/kernel/client_session.h" | ||
| 11 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 12 | #include "core/hle/service/fs/archive.h" | 13 | #include "core/hle/service/fs/archive.h" |
| 13 | #include "core/hle/service/fs/fs_user.h" | 14 | #include "core/hle/service/fs/fs_user.h" |
| @@ -17,7 +18,7 @@ | |||
| 17 | // Namespace FS_User | 18 | // Namespace FS_User |
| 18 | 19 | ||
| 19 | using Kernel::SharedPtr; | 20 | using Kernel::SharedPtr; |
| 20 | using Kernel::Session; | 21 | using Kernel::ServerSession; |
| 21 | 22 | ||
| 22 | namespace Service { | 23 | namespace Service { |
| 23 | namespace FS { | 24 | namespace FS { |
| @@ -70,7 +71,7 @@ static void OpenFile(Service::Interface* self) { | |||
| 70 | ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode); | 71 | ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode); |
| 71 | cmd_buff[1] = file_res.Code().raw; | 72 | cmd_buff[1] = file_res.Code().raw; |
| 72 | if (file_res.Succeeded()) { | 73 | if (file_res.Succeeded()) { |
| 73 | cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); | 74 | cmd_buff[3] = Kernel::g_handle_table.Create((*file_res)->CreateClientSession()).MoveFrom(); |
| 74 | } else { | 75 | } else { |
| 75 | cmd_buff[3] = 0; | 76 | cmd_buff[3] = 0; |
| 76 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); | 77 | LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); |
| @@ -130,7 +131,7 @@ static void OpenFileDirectly(Service::Interface* self) { | |||
| 130 | ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(*archive_handle, file_path, mode); | 131 | ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(*archive_handle, file_path, mode); |
| 131 | cmd_buff[1] = file_res.Code().raw; | 132 | cmd_buff[1] = file_res.Code().raw; |
| 132 | if (file_res.Succeeded()) { | 133 | if (file_res.Succeeded()) { |
| 133 | cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); | 134 | cmd_buff[3] = Kernel::g_handle_table.Create((*file_res)->CreateClientSession()).MoveFrom(); |
| 134 | } else { | 135 | } else { |
| 135 | cmd_buff[3] = 0; | 136 | cmd_buff[3] = 0; |
| 136 | LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u", | 137 | LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u", |
| @@ -391,7 +392,7 @@ static void OpenDirectory(Service::Interface* self) { | |||
| 391 | ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path); | 392 | ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path); |
| 392 | cmd_buff[1] = dir_res.Code().raw; | 393 | cmd_buff[1] = dir_res.Code().raw; |
| 393 | if (dir_res.Succeeded()) { | 394 | if (dir_res.Succeeded()) { |
| 394 | cmd_buff[3] = Kernel::g_handle_table.Create(*dir_res).MoveFrom(); | 395 | cmd_buff[3] = Kernel::g_handle_table.Create((*dir_res)->CreateClientSession()).MoveFrom(); |
| 395 | } else { | 396 | } else { |
| 396 | LOG_ERROR(Service_FS, "failed to get a handle for directory type=%d size=%d data=%s", | 397 | LOG_ERROR(Service_FS, "failed to get a handle for directory type=%d size=%d data=%s", |
| 397 | dirname_type, dirname_size, dir_path.DebugStr().c_str()); | 398 | dirname_type, dirname_size, dir_path.DebugStr().c_str()); |