2020-04-03 03:00:41 +01:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-07-28 04:36:08 +01:00
|
|
|
#include "common/common_types.h"
|
2020-01-19 00:49:30 +00:00
|
|
|
#include "common/host_memory.h"
|
2020-04-03 03:00:41 +01:00
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
namespace DramMemoryMap {
|
2020-04-17 05:59:08 +01:00
|
|
|
enum : u64 {
|
|
|
|
Base = 0x80000000ULL,
|
|
|
|
KernelReserveBase = Base + 0x60000,
|
|
|
|
SlabHeapBase = KernelReserveBase + 0x85000,
|
|
|
|
};
|
2020-04-03 03:00:41 +01:00
|
|
|
}; // namespace DramMemoryMap
|
|
|
|
|
2020-01-19 00:49:30 +00:00
|
|
|
class DeviceMemory {
|
2020-04-03 03:00:41 +01:00
|
|
|
public:
|
2020-07-28 04:36:08 +01:00
|
|
|
explicit DeviceMemory();
|
2020-04-03 03:00:41 +01:00
|
|
|
~DeviceMemory();
|
|
|
|
|
2020-01-19 00:49:30 +00:00
|
|
|
DeviceMemory& operator=(const DeviceMemory&) = delete;
|
|
|
|
DeviceMemory(const DeviceMemory&) = delete;
|
|
|
|
|
2020-04-03 03:00:41 +01:00
|
|
|
template <typename T>
|
2020-04-16 04:06:29 +01:00
|
|
|
PAddr GetPhysicalAddr(const T* ptr) const {
|
2020-01-19 00:49:30 +00:00
|
|
|
return (reinterpret_cast<uintptr_t>(ptr) -
|
|
|
|
reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) +
|
2020-04-09 04:37:24 +01:00
|
|
|
DramMemoryMap::Base;
|
2020-04-03 03:00:41 +01:00
|
|
|
}
|
|
|
|
|
2020-04-16 04:06:29 +01:00
|
|
|
u8* GetPointer(PAddr addr) {
|
2020-01-19 00:49:30 +00:00
|
|
|
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
|
2020-04-16 04:06:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const u8* GetPointer(PAddr addr) const {
|
2020-01-19 00:49:30 +00:00
|
|
|
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
|
2020-04-08 22:39:58 +01:00
|
|
|
}
|
2020-04-03 03:00:41 +01:00
|
|
|
|
2020-01-19 00:49:30 +00:00
|
|
|
Common::HostMemory buffer;
|
2020-04-03 03:00:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Core
|