2014-07-05 06:55:39 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-11-19 09:49:13 +01:00
|
|
|
// Refer to the license.txt file included.
|
2014-07-05 06:55:39 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
#include "core/hle/kernel/kernel.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2014-07-05 16:22:03 +02:00
|
|
|
/// Permissions for mapped shared memory blocks
|
|
|
|
enum class MemoryPermission : u32 {
|
2014-11-08 03:53:18 +01:00
|
|
|
None = 0,
|
|
|
|
Read = (1u << 0),
|
|
|
|
Write = (1u << 1),
|
|
|
|
ReadWrite = (Read | Write),
|
|
|
|
Execute = (1u << 2),
|
|
|
|
ReadExecute = (Read | Execute),
|
|
|
|
WriteExecute = (Write | Execute),
|
|
|
|
ReadWriteExecute = (Read | Write | Execute),
|
|
|
|
DontCare = (1u << 28)
|
2014-07-05 16:22:03 +02:00
|
|
|
};
|
|
|
|
|
2015-01-27 05:40:21 +01:00
|
|
|
class SharedMemory final : public Object {
|
2015-01-11 06:43:29 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a shared memory object
|
|
|
|
* @param name Optional object name, used only for debugging purposes.
|
|
|
|
*/
|
|
|
|
static ResultVal<SharedPtr<SharedMemory>> Create(std::string name = "Unknown");
|
|
|
|
|
|
|
|
std::string GetTypeName() const override { return "SharedMemory"; }
|
|
|
|
|
|
|
|
static const HandleType HANDLE_TYPE = HandleType::SharedMemory;
|
|
|
|
HandleType GetHandleType() const override { return HANDLE_TYPE; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a shared memory block to an address in system memory
|
|
|
|
* @param address Address in system memory to map shared memory block to
|
|
|
|
* @param permissions Memory block map permissions (specified by SVC field)
|
|
|
|
* @param other_permissions Memory block map other permissions (specified by SVC field)
|
|
|
|
*/
|
|
|
|
ResultCode Map(VAddr address, MemoryPermission permissions, MemoryPermission other_permissions);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a pointer to the shared memory block
|
|
|
|
* @param offset Offset from the start of the shared memory block to get pointer
|
|
|
|
* @return Pointer to the shared memory block from the specified offset
|
|
|
|
*/
|
|
|
|
ResultVal<u8*> GetPointer(u32 offset = 0);
|
|
|
|
|
2015-01-30 17:37:53 +01:00
|
|
|
VAddr base_address; ///< Address of shared memory block in RAM
|
2015-01-11 06:43:29 +01:00
|
|
|
MemoryPermission permissions; ///< Permissions of shared memory block (SVC field)
|
|
|
|
MemoryPermission other_permissions; ///< Other permissions of shared memory block (SVC field)
|
|
|
|
std::string name; ///< Name of shared memory object (optional)
|
|
|
|
|
|
|
|
private:
|
2015-02-01 01:56:59 +01:00
|
|
|
SharedMemory();
|
|
|
|
~SharedMemory() override;
|
2015-01-11 06:43:29 +01:00
|
|
|
};
|
2014-07-05 06:55:39 +02:00
|
|
|
|
|
|
|
} // namespace
|