aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/memory_manager.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-02-12 13:51:52 -0500
committerGitHub <noreply@github.com>2018-02-12 13:51:52 -0500
commitbe5ba4d95215217930e57976386adff6de79322f (patch)
tree299b1096450b0284a489900280a28819aa4fb349 /src/video_core/memory_manager.h
parent890e98a33e4afa3d7374c7951ee2bde7cc8849c5 (diff)
parent6cddf9d88e7fc49919fda92bcd4235797c56f07f (diff)
Merge pull request #178 from Subv/command_buffers
GPU: Added a command processor to decode the GPU pushbuffers and forward the commands to their respective engines
Diffstat (limited to 'src/video_core/memory_manager.h')
-rw-r--r--src/video_core/memory_manager.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
new file mode 100644
index 000000000..47da7acd6
--- /dev/null
+++ b/src/video_core/memory_manager.h
@@ -0,0 +1,49 @@
+// Copyright 2018 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <memory>
+#include "common/common_types.h"
+#include "core/memory.h"
+
+namespace Tegra {
+
+/// Virtual addresses in the GPU's memory map are 64 bit.
+using GPUVAddr = u64;
+
+class MemoryManager final {
+public:
+ MemoryManager() = default;
+
+ PAddr AllocateSpace(u64 size, u64 align);
+ PAddr AllocateSpace(PAddr paddr, u64 size, u64 align);
+ PAddr MapBufferEx(VAddr vaddr, u64 size);
+ PAddr MapBufferEx(VAddr vaddr, PAddr paddr, u64 size);
+ VAddr PhysicalToVirtualAddress(PAddr paddr);
+
+private:
+ boost::optional<PAddr> FindFreeBlock(u64 size, u64 align = 1);
+ bool IsPageMapped(PAddr paddr);
+ VAddr& PageSlot(PAddr paddr);
+
+ enum class PageStatus : u64 {
+ Unmapped = 0xFFFFFFFFFFFFFFFFULL,
+ Allocated = 0xFFFFFFFFFFFFFFFEULL,
+ };
+
+ static constexpr u64 MAX_ADDRESS{0x10000000000ULL};
+ static constexpr u64 PAGE_TABLE_BITS{14};
+ static constexpr u64 PAGE_TABLE_SIZE{1 << PAGE_TABLE_BITS};
+ static constexpr u64 PAGE_TABLE_MASK{PAGE_TABLE_SIZE - 1};
+ static constexpr u64 PAGE_BLOCK_BITS{14};
+ static constexpr u64 PAGE_BLOCK_SIZE{1 << PAGE_BLOCK_BITS};
+ static constexpr u64 PAGE_BLOCK_MASK{PAGE_BLOCK_SIZE - 1};
+
+ using PageBlock = std::array<VAddr, PAGE_BLOCK_SIZE>;
+ std::array<std::unique_ptr<PageBlock>, PAGE_TABLE_SIZE> page_table{};
+};
+
+} // namespace Tegra