summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-03-13 03:09:27 -0400
committerGravatar Lioncash2019-03-13 06:04:44 -0400
commitcb198d7985a4af00d9fdb656e9aeb16c158ce335 (patch)
tree301b07d551e6f0c2a18ec68a99a79d52a1c64500 /src/core/hle/kernel/svc.cpp
parentMerge pull request #2211 from lioncash/arbiter (diff)
downloadyuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.gz
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.xz
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.zip
core/hle/kernel: Split transfer memory handling out into its own class
Within the kernel, shared memory and transfer memory facilities exist as completely different kernel objects. They also have different validity checking as well. Therefore, we shouldn't be treating the two as the same kind of memory. They also differ in terms of their behavioral aspect as well. Shared memory is intended for sharing memory between processes, while transfer memory is intended to be for transferring memory to other processes. This breaks out the handling for transfer memory into its own class and treats it as its own kernel object. This is also important when we consider resource limits as well. Particularly because transfer memory is limited by the resource limit value set for it. While we currently don't handle resource limit testing against objects yet (but we do allow setting them), this will make implementing that behavior much easier in the future, as we don't need to distinguish between shared memory and transfer memory allocations in the same place.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 77d0e3d96..c8b9e8aeb 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -32,6 +32,7 @@
32#include "core/hle/kernel/svc.h" 32#include "core/hle/kernel/svc.h"
33#include "core/hle/kernel/svc_wrap.h" 33#include "core/hle/kernel/svc_wrap.h"
34#include "core/hle/kernel/thread.h" 34#include "core/hle/kernel/thread.h"
35#include "core/hle/kernel/transfer_memory.h"
35#include "core/hle/kernel/writable_event.h" 36#include "core/hle/kernel/writable_event.h"
36#include "core/hle/lock.h" 37#include "core/hle/lock.h"
37#include "core/hle/result.h" 38#include "core/hle/result.h"
@@ -1577,11 +1578,15 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32
1577 } 1578 }
1578 1579
1579 auto& kernel = Core::System::GetInstance().Kernel(); 1580 auto& kernel = Core::System::GetInstance().Kernel();
1580 auto process = kernel.CurrentProcess(); 1581 auto transfer_mem_handle = TransferMemory::Create(kernel, addr, size, perms);
1581 auto& handle_table = process->GetHandleTable();
1582 const auto shared_mem_handle = SharedMemory::Create(kernel, process, size, perms, perms, addr);
1583 1582
1584 CASCADE_RESULT(*handle, handle_table.Create(shared_mem_handle)); 1583 auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
1584 const auto result = handle_table.Create(std::move(transfer_mem_handle));
1585 if (result.Failed()) {
1586 return result.Code();
1587 }
1588
1589 *handle = *result;
1585 return RESULT_SUCCESS; 1590 return RESULT_SUCCESS;
1586} 1591}
1587 1592