summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc.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/kernel/svc.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 '')
-rw-r--r--src/core/hle/kernel/svc.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 8d8d3dd5a..ef8fa98a9 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -293,9 +293,7 @@ static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr
/// Connect to an OS service given the port name, returns the handle to the port to out
static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
VAddr port_name_address) {
- std::lock_guard lock{HLE::g_hle_lock};
auto& memory = system.Memory();
-
if (!memory.IsValidVirtualAddress(port_name_address)) {
LOG_ERROR(Kernel_SVC,
"Port Name Address is not a valid virtual address, port_name_address=0x{:016X}",
@@ -314,21 +312,27 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
LOG_TRACE(Kernel_SVC, "called port_name={}", port_name);
+ // Get the current handle table.
auto& kernel = system.Kernel();
+ auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
+
+ // Find the client port.
const auto it = kernel.FindNamedPort(port_name);
if (!kernel.IsValidNamedPort(it)) {
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name);
return ResultNotFound;
}
+ auto port = it->second;
- auto client_port = it->second;
+ // Create a session.
+ KClientSession* session{};
+ R_TRY(port->CreateSession(std::addressof(session)));
- KClientSession* client_session{};
- CASCADE_RESULT(client_session, client_port->Connect());
+ // Register the session in the table, close the extra reference.
+ handle_table.Add(out_handle, session);
+ session->Close();
- // Return the client session
- auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
- handle_table.Add(out_handle, client_session);
+ // We succeeded.
return RESULT_SUCCESS;
}
@@ -340,13 +344,13 @@ static ResultCode ConnectToNamedPort32(Core::System& system, Handle* out_handle,
/// Makes a blocking IPC call to an OS service.
static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
- LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
auto& kernel = system.Kernel();
KScopedAutoObject session =
kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle);
R_UNLESS(session.IsNotNull(), ResultInvalidHandle);
+ LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
auto thread = kernel.CurrentScheduler()->GetCurrentThread();
{