summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/memory/address_space_info.h
blob: c479890be15922735a54c82d3ee1ce03bb1dca1b (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
50
51
52
53
// Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

// This file references various implementation details from Atmosphere, an open-source firmware for
// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.

#pragma once

#include "common/common_types.h"

namespace Kernel::Memory {

class AddressSpaceInfo final : NonCopyable {
public:
    enum class Type : u32 {
        Is32Bit = 0,
        Small64Bit = 1,
        Large64Bit = 2,
        Heap = 3,
        Stack = 4,
        Alias = 5,
        Count,
    };

private:
    std::size_t bit_width{};
    std::size_t addr{};
    std::size_t size{};
    Type type{};

public:
    static u64 GetAddressSpaceStart(std::size_t width, Type type);
    static std::size_t GetAddressSpaceSize(std::size_t width, Type type);

    constexpr AddressSpaceInfo(std::size_t bit_width, std::size_t addr, std::size_t size, Type type)
        : bit_width{bit_width}, addr{addr}, size{size}, type{type} {}

    constexpr std::size_t GetWidth() const {
        return bit_width;
    }
    constexpr std::size_t GetAddress() const {
        return addr;
    }
    constexpr std::size_t GetSize() const {
        return size;
    }
    constexpr Type GetType() const {
        return type;
    }
};

} // namespace Kernel::Memory