summaryrefslogtreecommitdiffstats
path: root/src/core/device_memory_manager.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-01-16 03:47:59 +0100
committerLiam <byteslice@airmail.cc>2024-01-19 03:12:30 +0100
commitbeb438bb0bede8b8906a41f7a1ad7b010ec3ec60 (patch)
tree5a52c54369a0b1b553800ec915fb4c34b0c1f472 /src/core/device_memory_manager.h
parentCore: Invert guest memory depandancy (diff)
downloadyuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.tar
yuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.tar.gz
yuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.tar.bz2
yuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.tar.lz
yuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.tar.xz
yuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.tar.zst
yuzu-beb438bb0bede8b8906a41f7a1ad7b010ec3ec60.zip
Diffstat (limited to 'src/core/device_memory_manager.h')
-rw-r--r--src/core/device_memory_manager.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h
index 6311e9ece..ffeed46cc 100644
--- a/src/core/device_memory_manager.h
+++ b/src/core/device_memory_manager.h
@@ -28,6 +28,10 @@ class Memory;
template <typename DTraits>
struct DeviceMemoryManagerAllocator;
+struct Asid {
+ size_t id;
+};
+
template <typename Traits>
class DeviceMemoryManager {
using DeviceInterface = typename Traits::DeviceInterface;
@@ -43,15 +47,14 @@ public:
void AllocateFixed(DAddr start, size_t size);
void Free(DAddr start, size_t size);
- void Map(DAddr address, VAddr virtual_address, size_t size, size_t process_id,
- bool track = false);
+ void Map(DAddr address, VAddr virtual_address, size_t size, Asid asid, bool track = false);
void Unmap(DAddr address, size_t size);
- void TrackContinuityImpl(DAddr address, VAddr virtual_address, size_t size, size_t process_id);
- void TrackContinuity(DAddr address, VAddr virtual_address, size_t size, size_t process_id) {
+ void TrackContinuityImpl(DAddr address, VAddr virtual_address, size_t size, Asid asid);
+ void TrackContinuity(DAddr address, VAddr virtual_address, size_t size, Asid asid) {
std::scoped_lock lk(mapping_guard);
- TrackContinuityImpl(address, virtual_address, size, process_id);
+ TrackContinuityImpl(address, virtual_address, size, asid);
}
// Write / Read
@@ -105,8 +108,8 @@ public:
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);
+ Asid RegisterProcess(Memory::Memory* memory);
+ void UnregisterProcess(Asid id);
void UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta);
@@ -163,17 +166,17 @@ private:
static constexpr size_t guest_max_as_bits = 39;
static constexpr size_t guest_as_size = 1ULL << guest_max_as_bits;
static constexpr size_t guest_mask = guest_as_size - 1ULL;
- static constexpr size_t process_id_start_bit = guest_max_as_bits;
+ static constexpr size_t asid_start_bit = guest_max_as_bits;
- std::pair<size_t, VAddr> ExtractCPUBacking(size_t page_index) {
+ std::pair<Asid, VAddr> ExtractCPUBacking(size_t page_index) {
auto content = cpu_backing_address[page_index];
const VAddr address = content & guest_mask;
- const size_t process_id = static_cast<size_t>(content >> process_id_start_bit);
- return std::make_pair(process_id, address);
+ const Asid asid{static_cast<size_t>(content >> asid_start_bit)};
+ return std::make_pair(asid, address);
}
- void InsertCPUBacking(size_t page_index, VAddr address, size_t process_id) {
- cpu_backing_address[page_index] = address | (process_id << process_id_start_bit);
+ void InsertCPUBacking(size_t page_index, VAddr address, Asid asid) {
+ cpu_backing_address[page_index] = address | (asid.id << asid_start_bit);
}
Common::VirtualBuffer<VAddr> cpu_backing_address;
@@ -205,4 +208,4 @@ private:
std::mutex mapping_guard;
};
-} // namespace Core \ No newline at end of file
+} // namespace Core