summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-10-29 22:38:45 +0200
committerbunnei <bunneidev@gmail.com>2022-11-04 05:17:06 +0100
commit0897f4f96c2d463976e7a28ac0b69c449bcd9624 (patch)
treed461ac2c010490d10c1ccca037c450ed57c4aaeb /src/core/hle
parentcore: hle: kernel: Add KPageTableSlabHeap. (diff)
downloadyuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.tar
yuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.tar.gz
yuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.tar.bz2
yuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.tar.lz
yuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.tar.xz
yuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.tar.zst
yuzu-0897f4f96c2d463976e7a28ac0b69c449bcd9624.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_page_table_manager.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_page_table_manager.h b/src/core/hle/kernel/k_page_table_manager.h
new file mode 100644
index 000000000..91a45cde3
--- /dev/null
+++ b/src/core/hle/kernel/k_page_table_manager.h
@@ -0,0 +1,55 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <atomic>
+
+#include "common/common_types.h"
+#include "core/hle/kernel/k_dynamic_resource_manager.h"
+#include "core/hle/kernel/k_page_table_slab_heap.h"
+
+namespace Kernel {
+
+class KPageTableManager : public KDynamicResourceManager<impl::PageTablePage, true> {
+public:
+ using RefCount = KPageTableSlabHeap::RefCount;
+ static constexpr size_t PageTableSize = KPageTableSlabHeap::PageTableSize;
+
+public:
+ KPageTableManager() = default;
+
+ void Initialize(KDynamicPageManager* page_allocator, KPageTableSlabHeap* pt_heap) {
+ m_pt_heap = pt_heap;
+
+ static_assert(std::derived_from<KPageTableSlabHeap, DynamicSlabType>);
+ BaseHeap::Initialize(page_allocator, pt_heap);
+ }
+
+ VAddr Allocate() {
+ return VAddr(BaseHeap::Allocate());
+ }
+
+ RefCount GetRefCount(VAddr addr) const {
+ return m_pt_heap->GetRefCount(addr);
+ }
+
+ void Open(VAddr addr, int count) {
+ return m_pt_heap->Open(addr, count);
+ }
+
+ bool Close(VAddr addr, int count) {
+ return m_pt_heap->Close(addr, count);
+ }
+
+ bool IsInPageTableHeap(VAddr addr) const {
+ return m_pt_heap->IsInRange(addr);
+ }
+
+private:
+ using BaseHeap = KDynamicResourceManager<impl::PageTablePage, true>;
+
+ KPageTableSlabHeap* m_pt_heap{};
+};
+
+} // namespace Kernel