summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/jit/jit_code_memory.h
blob: 6376d4c4eb883325ad0a7e40e46302ff8445f2f8 (plain) (blame)
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
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <random>

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

namespace Service::JIT {

class CodeMemory {
public:
    YUZU_NON_COPYABLE(CodeMemory);

    explicit CodeMemory() = default;

    CodeMemory(CodeMemory&& rhs) {
        std::swap(m_code_memory, rhs.m_code_memory);
        std::swap(m_size, rhs.m_size);
        std::swap(m_address, rhs.m_address);
        std::swap(m_perm, rhs.m_perm);
    }

    ~CodeMemory() {
        this->Finalize();
    }

public:
    Result Initialize(Kernel::KProcess& process, Kernel::KCodeMemory& code_memory, size_t size,
                      Kernel::Svc::MemoryPermission perm, std::mt19937_64& generate_random);
    void Finalize();

    size_t GetSize() const {
        return m_size;
    }

    u64 GetAddress() const {
        return m_address;
    }

private:
    Kernel::KCodeMemory* m_code_memory{};
    size_t m_size{};
    u64 m_address{};
    Kernel::Svc::MemoryPermission m_perm{};
};

} // namespace Service::JIT