core: Make use of fastmem

This commit is contained in:
Markus Wick
2020-01-19 01:49:30 +01:00
parent 740edacc8d
commit 621f3f5f47
7 changed files with 31 additions and 9 deletions

View File

@ -5,7 +5,7 @@
#pragma once
#include "common/common_types.h"
#include "common/virtual_buffer.h"
#include "common/host_memory.h"
namespace Core {
@ -21,27 +21,30 @@ enum : u64 {
};
}; // namespace DramMemoryMap
class DeviceMemory : NonCopyable {
class DeviceMemory {
public:
explicit DeviceMemory();
~DeviceMemory();
DeviceMemory& operator=(const DeviceMemory&) = delete;
DeviceMemory(const DeviceMemory&) = delete;
template <typename T>
PAddr GetPhysicalAddr(const T* ptr) const {
return (reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(buffer.data())) +
return (reinterpret_cast<uintptr_t>(ptr) -
reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) +
DramMemoryMap::Base;
}
u8* GetPointer(PAddr addr) {
return buffer.data() + (addr - DramMemoryMap::Base);
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
}
const u8* GetPointer(PAddr addr) const {
return buffer.data() + (addr - DramMemoryMap::Base);
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
}
private:
Common::VirtualBuffer<u8> buffer;
Common::HostMemory buffer;
};
} // namespace Core