summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/transfer_memory.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-03-13 08:09:27 +0100
committerLioncash <mathew1800@gmail.com>2019-03-13 11:04:44 +0100
commitcb198d7985a4af00d9fdb656e9aeb16c158ce335 (patch)
tree301b07d551e6f0c2a18ec68a99a79d52a1c64500 /src/core/hle/kernel/transfer_memory.h
parentMerge pull request #2211 from lioncash/arbiter (diff)
downloadyuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.gz
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.bz2
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.lz
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.xz
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.tar.zst
yuzu-cb198d7985a4af00d9fdb656e9aeb16c158ce335.zip
Diffstat (limited to 'src/core/hle/kernel/transfer_memory.h')
-rw-r--r--src/core/hle/kernel/transfer_memory.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/core/hle/kernel/transfer_memory.h b/src/core/hle/kernel/transfer_memory.h
new file mode 100644
index 000000000..ec294951e
--- /dev/null
+++ b/src/core/hle/kernel/transfer_memory.h
@@ -0,0 +1,91 @@
+// Copyright 2019 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include "core/hle/kernel/object.h"
+
+union ResultCode;
+
+namespace Kernel {
+
+class KernelCore;
+class Process;
+
+enum class MemoryPermission : u32;
+
+/// Defines the interface for transfer memory objects.
+///
+/// Transfer memory is typically used for the purpose of
+/// transferring memory between separate process instances,
+/// thus the name.
+///
+class TransferMemory final : public Object {
+public:
+ static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory;
+
+ static SharedPtr<TransferMemory> Create(KernelCore& kernel, VAddr base_address, size_t size,
+ MemoryPermission permissions);
+
+ TransferMemory(const TransferMemory&) = delete;
+ TransferMemory& operator=(const TransferMemory&) = delete;
+
+ TransferMemory(TransferMemory&&) = delete;
+ TransferMemory& operator=(TransferMemory&&) = delete;
+
+ std::string GetTypeName() const override {
+ return "TransferMemory";
+ }
+
+ std::string GetName() const override {
+ return GetTypeName();
+ }
+
+ HandleType GetHandleType() const override {
+ return HANDLE_TYPE;
+ }
+
+ /// Attempts to map transfer memory with the given range and memory permissions.
+ ///
+ /// @param address The base address to being mapping memory at.
+ /// @param size The size of the memory to map, in bytes.
+ /// @param permissions The memory permissions to check against when mapping memory.
+ ///
+ /// @pre The given address, size, and memory permissions must all match
+ /// the same values that were given when creating the transfer memory
+ /// instance.
+ ///
+ ResultCode MapMemory(VAddr address, size_t size, MemoryPermission permissions);
+
+ /// Unmaps the transfer memory with the given range
+ ///
+ /// @param address The base address to begin unmapping memory at.
+ /// @param size The size of the memory to unmap, in bytes.
+ ///
+ /// @pre The given address and size must be the same as the ones used
+ /// to create the transfer memory instance.
+ ///
+ ResultCode UnmapMemory(VAddr address, size_t size);
+
+private:
+ explicit TransferMemory(KernelCore& kernel);
+ ~TransferMemory() override;
+
+ /// The base address for the memory managed by this instance.
+ VAddr base_address = 0;
+
+ /// Size of the memory, in bytes, that this instance manages.
+ size_t memory_size = 0;
+
+ /// The memory permissions that are applied to this instance.
+ MemoryPermission owner_permissions{};
+
+ /// The process that this transfer memory instance was created under.
+ Process* owner_process = nullptr;
+
+ /// Whether or not this transfer memory instance has mapped memory.
+ bool is_mapped = false;
+};
+
+} // namespace Kernel