summaryrefslogtreecommitdiffstats
path: root/src/core/device_memory_manager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/device_memory_manager.h')
-rw-r--r--src/core/device_memory_manager.h43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h
index 71b95016c..1a63cbd09 100644
--- a/src/core/device_memory_manager.h
+++ b/src/core/device_memory_manager.h
@@ -3,10 +3,11 @@
#pragma once
-#include <deque>
-#include <memory>
#include <array>
#include <atomic>
+#include <deque>
+#include <memory>
+#include <mutex>
#include "common/common_types.h"
#include "common/virtual_buffer.h"
@@ -48,26 +49,54 @@ public:
template <typename T>
const T* GetPointer(DAddr address) const;
+ DAddr GetAddressFromPAddr(PAddr address) const {
+ DAddr subbits = static_cast<DAddr>(address & page_mask);
+ return (static_cast<DAddr>(compressed_device_addr[(address >> page_bits)]) << page_bits) + subbits;
+ }
+
+ PAddr GetPhysicalRawAddressFromDAddr(DAddr address) const {
+ PAddr subbits = static_cast<PAddr>(address & page_mask);
+ auto paddr = compressed_physical_ptr[(address >> page_bits)];
+ if (paddr == 0) {
+ return 0;
+ }
+ return (static_cast<PAddr>(paddr - 1) << page_bits) + subbits;
+ }
+
template <typename T>
void Write(DAddr address, T value);
template <typename T>
T Read(DAddr address) const;
+ const u8* GetSpan(const DAddr src_addr, const std::size_t size) const {
+ return nullptr;
+ }
+
+ u8* GetSpan(const DAddr src_addr, const std::size_t size) {
+ return nullptr;
+ }
+
void ReadBlock(DAddr address, void* dest_pointer, size_t size);
- void WriteBlock(DAddr address, void* src_pointer, size_t size);
+ void ReadBlockUnsafe(DAddr address, void* dest_pointer, size_t size);
+ void WriteBlock(DAddr address, const void* src_pointer, size_t size);
+ void WriteBlockUnsafe(DAddr address, const void* src_pointer, size_t size);
size_t RegisterProcess(Memory::Memory* memory);
void UnregisterProcess(size_t id);
void UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta);
+ static constexpr size_t AS_BITS = Traits::device_virtual_bits;
+
private:
static constexpr bool supports_pinning = Traits::supports_pinning;
static constexpr size_t device_virtual_bits = Traits::device_virtual_bits;
static constexpr size_t device_as_size = 1ULL << device_virtual_bits;
static constexpr size_t physical_max_bits = 33;
static constexpr size_t page_bits = 12;
+ static constexpr size_t page_size = 1ULL << page_bits;
+ static constexpr size_t page_mask = page_size - 1ULL;
static constexpr u32 physical_address_base = 1U << page_bits;
template <typename T>
@@ -136,11 +165,15 @@ private:
private:
std::array<std::atomic_uint16_t, subentries> values{};
};
- static_assert(sizeof(CounterEntry) == subentries * sizeof(u16), "CounterEntry should be 8 bytes!");
+ static_assert(sizeof(CounterEntry) == subentries * sizeof(u16),
+ "CounterEntry should be 8 bytes!");
- static constexpr size_t num_counter_entries = (1ULL << (device_virtual_bits - page_bits)) / subentries;
+ static constexpr size_t num_counter_entries =
+ (1ULL << (device_virtual_bits - page_bits)) / subentries;
using CachedPages = std::array<CounterEntry, num_counter_entries>;
std::unique_ptr<CachedPages> cached_pages;
+ std::mutex counter_guard;
+ std::mutex mapping_guard;
};
} // namespace Core \ No newline at end of file