diff options
| author | 2021-04-23 17:00:15 -0700 | |
|---|---|---|
| committer | 2021-05-05 16:40:52 -0700 | |
| commit | 626f746971d1d3216a38b20680959df3a1f5f256 (patch) | |
| tree | d9b9448732e264e84557e12d7a14a40f00cb006f /src/core/hle/kernel/svc.cpp | |
| parent | hle: kernel: Migrate KServerPort to KAutoObject. (diff) | |
| download | yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.gz yuzu-626f746971d1d3216a38b20680959df3a1f5f256.tar.xz yuzu-626f746971d1d3216a38b20680959df3a1f5f256.zip | |
hle: kernel: Migrate KPort, KClientPort, and KServerPort to KAutoObject.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 22 |
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 | |||
| 293 | /// Connect to an OS service given the port name, returns the handle to the port to out | 293 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 294 | static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, | 294 | static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, |
| 295 | VAddr port_name_address) { | 295 | VAddr port_name_address) { |
| 296 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 297 | auto& memory = system.Memory(); | 296 | auto& memory = system.Memory(); |
| 298 | |||
| 299 | if (!memory.IsValidVirtualAddress(port_name_address)) { | 297 | if (!memory.IsValidVirtualAddress(port_name_address)) { |
| 300 | LOG_ERROR(Kernel_SVC, | 298 | LOG_ERROR(Kernel_SVC, |
| 301 | "Port Name Address is not a valid virtual address, port_name_address=0x{:016X}", | 299 | "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, | |||
| 314 | 312 | ||
| 315 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); | 313 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); |
| 316 | 314 | ||
| 315 | // Get the current handle table. | ||
| 317 | auto& kernel = system.Kernel(); | 316 | auto& kernel = system.Kernel(); |
| 317 | auto& handle_table = kernel.CurrentProcess()->GetHandleTable(); | ||
| 318 | |||
| 319 | // Find the client port. | ||
| 318 | const auto it = kernel.FindNamedPort(port_name); | 320 | const auto it = kernel.FindNamedPort(port_name); |
| 319 | if (!kernel.IsValidNamedPort(it)) { | 321 | if (!kernel.IsValidNamedPort(it)) { |
| 320 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); | 322 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); |
| 321 | return ResultNotFound; | 323 | return ResultNotFound; |
| 322 | } | 324 | } |
| 325 | auto port = it->second; | ||
| 323 | 326 | ||
| 324 | auto client_port = it->second; | 327 | // Create a session. |
| 328 | KClientSession* session{}; | ||
| 329 | R_TRY(port->CreateSession(std::addressof(session))); | ||
| 325 | 330 | ||
| 326 | KClientSession* client_session{}; | 331 | // Register the session in the table, close the extra reference. |
| 327 | CASCADE_RESULT(client_session, client_port->Connect()); | 332 | handle_table.Add(out_handle, session); |
| 333 | session->Close(); | ||
| 328 | 334 | ||
| 329 | // Return the client session | 335 | // We succeeded. |
| 330 | auto& handle_table = kernel.CurrentProcess()->GetHandleTable(); | ||
| 331 | handle_table.Add(out_handle, client_session); | ||
| 332 | return RESULT_SUCCESS; | 336 | return RESULT_SUCCESS; |
| 333 | } | 337 | } |
| 334 | 338 | ||
| @@ -340,13 +344,13 @@ static ResultCode ConnectToNamedPort32(Core::System& system, Handle* out_handle, | |||
| 340 | 344 | ||
| 341 | /// Makes a blocking IPC call to an OS service. | 345 | /// Makes a blocking IPC call to an OS service. |
| 342 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | 346 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { |
| 343 | LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); | ||
| 344 | 347 | ||
| 345 | auto& kernel = system.Kernel(); | 348 | auto& kernel = system.Kernel(); |
| 346 | 349 | ||
| 347 | KScopedAutoObject session = | 350 | KScopedAutoObject session = |
| 348 | kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle); | 351 | kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle); |
| 349 | R_UNLESS(session.IsNotNull(), ResultInvalidHandle); | 352 | R_UNLESS(session.IsNotNull(), ResultInvalidHandle); |
| 353 | LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); | ||
| 350 | 354 | ||
| 351 | auto thread = kernel.CurrentScheduler()->GetCurrentThread(); | 355 | auto thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 352 | { | 356 | { |