summaryrefslogtreecommitdiff
path: root/src/core/device_memory.h
diff options
context:
space:
mode:
authorGravatar bunnei2020-04-02 22:00:41 -0400
committerGravatar bunnei2020-04-17 00:59:29 -0400
commitdc25c86556c36dd23224d88234afc9ecbf780719 (patch)
tree5dbe45bcc17ecad8675e7a4cb03dd34361f01e03 /src/core/device_memory.h
parentdynarmic: Enable strict alignment checks. (diff)
downloadyuzu-dc25c86556c36dd23224d88234afc9ecbf780719.tar.gz
yuzu-dc25c86556c36dd23224d88234afc9ecbf780719.tar.xz
yuzu-dc25c86556c36dd23224d88234afc9ecbf780719.zip
core: device_manager: Add a simple class to manage device RAM.
Diffstat (limited to 'src/core/device_memory.h')
-rw-r--r--src/core/device_memory.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/core/device_memory.h b/src/core/device_memory.h
new file mode 100644
index 000000000..a60a7238a
--- /dev/null
+++ b/src/core/device_memory.h
@@ -0,0 +1,48 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/assert.h"
8#include "common/common_funcs.h"
9#include "core/hle/kernel/physical_memory.h"
10
11namespace Core {
12
13class System;
14
15namespace DramMemoryMap {
16constexpr u64 Base = 0x80000000ULL;
17constexpr u64 Size = 0x100000000ULL;
18constexpr u64 End = Base + Size;
19constexpr u64 KernelReserveBase = Base + 0x60000;
20constexpr u64 SlabHeapBase = KernelReserveBase + 0x85000;
21constexpr u64 SlapHeapSize = 0xa21000;
22constexpr u64 SlabHeapEnd = SlabHeapBase + SlapHeapSize;
23}; // namespace DramMemoryMap
24
25class DeviceMemory : NonCopyable {
26public:
27 DeviceMemory(Core::System& system);
28 ~DeviceMemory();
29
30 template <typename T>
31 PAddr GetPhysicalAddr(T* ptr) {
32 const auto ptr_addr{reinterpret_cast<uintptr_t>(ptr)};
33 const auto base_addr{reinterpret_cast<uintptr_t>(base)};
34 ASSERT(ptr_addr >= base_addr);
35 return ptr_addr - base_addr + DramMemoryMap::Base;
36 }
37
38 PAddr GetPhysicalAddr(VAddr addr);
39
40 u8* GetPointer(PAddr addr);
41
42private:
43 u8* base{};
44 Kernel::PhysicalMemory physical_memory;
45 Core::System& system;
46};
47
48} // namespace Core