aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/kernel/shared_memory.h
blob: bb65c7ccd6fe4fcf7c1fd08ecbe6323fe6daea58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include "common/common_types.h"

#include "core/hle/kernel/kernel.h"

namespace Kernel {

/// Permissions for mapped shared memory blocks
enum class MemoryPermission : u32 {
    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)
};

/**
 * Creates a shared memory object
 * @param name Optional name of shared memory object
 * @return Handle of newly created shared memory object
 */
Handle CreateSharedMemory(const std::string& name="Unknown");

/**
 * Maps a shared memory block to an address in system memory
 * @param handle Shared memory block handle
 * @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 MapSharedMemory(Handle handle, u32 address, MemoryPermission permissions,
    MemoryPermission other_permissions);

/**
 * Gets a pointer to the shared memory block
 * @param handle Shared memory block handle
 * @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*> GetSharedMemoryPointer(Handle handle, u32 offset);

} // namespace