2019-03-13 08:09:27 +01:00
|
|
|
// Copyright 2019 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-03 22:31:26 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2020-04-09 01:05:31 +02:00
|
|
|
#include "core/hle/kernel/memory/memory_block.h"
|
2019-03-13 08:09:27 +01:00
|
|
|
#include "core/hle/kernel/object.h"
|
2019-07-19 00:15:53 +02:00
|
|
|
#include "core/hle/kernel/physical_memory.h"
|
2019-03-13 08:09:27 +01:00
|
|
|
|
|
|
|
union ResultCode;
|
|
|
|
|
2020-03-31 21:10:44 +02:00
|
|
|
namespace Core::Memory {
|
2020-01-31 04:39:07 +01:00
|
|
|
class Memory;
|
|
|
|
}
|
|
|
|
|
2019-03-13 08:09:27 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class KernelCore;
|
|
|
|
class Process;
|
|
|
|
|
|
|
|
/// 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:
|
2020-03-31 21:10:44 +02:00
|
|
|
explicit TransferMemory(KernelCore& kernel, Core::Memory::Memory& memory);
|
2019-11-25 02:15:51 +01:00
|
|
|
~TransferMemory() override;
|
|
|
|
|
2019-03-13 08:09:27 +01:00
|
|
|
static constexpr HandleType HANDLE_TYPE = HandleType::TransferMemory;
|
|
|
|
|
2020-03-31 21:10:44 +02:00
|
|
|
static std::shared_ptr<TransferMemory> Create(KernelCore& kernel, Core::Memory::Memory& memory,
|
2020-04-09 01:05:31 +02:00
|
|
|
VAddr base_address, std::size_t size,
|
|
|
|
Memory::MemoryPermission permissions);
|
2019-03-13 08:09:27 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-04-03 22:31:26 +02:00
|
|
|
/// Gets a pointer to the backing block of this instance.
|
|
|
|
const u8* GetPointer() const;
|
|
|
|
|
|
|
|
/// Gets the size of the memory backing this instance in bytes.
|
2020-04-09 01:05:31 +02:00
|
|
|
constexpr std::size_t GetSize() const {
|
|
|
|
return size;
|
|
|
|
}
|
2019-03-13 08:09:27 +01:00
|
|
|
|
2020-01-31 04:39:07 +01:00
|
|
|
/// Reserves the region to be used for the transfer memory, called after the transfer memory is
|
|
|
|
/// created.
|
|
|
|
ResultCode Reserve();
|
|
|
|
|
|
|
|
/// Resets the region previously used for the transfer memory, called after the transfer memory
|
|
|
|
/// is closed.
|
|
|
|
ResultCode Reset();
|
|
|
|
|
2019-03-13 08:09:27 +01:00
|
|
|
private:
|
|
|
|
/// The base address for the memory managed by this instance.
|
2020-04-09 01:05:31 +02:00
|
|
|
VAddr base_address{};
|
2019-03-13 08:09:27 +01:00
|
|
|
|
|
|
|
/// Size of the memory, in bytes, that this instance manages.
|
2020-04-09 01:05:31 +02:00
|
|
|
std::size_t size{};
|
2019-03-13 08:09:27 +01:00
|
|
|
|
|
|
|
/// The memory permissions that are applied to this instance.
|
2020-04-09 01:05:31 +02:00
|
|
|
Memory::MemoryPermission owner_permissions{};
|
2019-03-13 08:09:27 +01:00
|
|
|
|
|
|
|
/// The process that this transfer memory instance was created under.
|
2020-04-09 01:05:31 +02:00
|
|
|
Process* owner_process{};
|
2020-01-31 04:39:07 +01:00
|
|
|
|
2020-03-31 21:10:44 +02:00
|
|
|
Core::Memory::Memory& memory;
|
2019-03-13 08:09:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Kernel
|