2020-04-03 02:00:41 +00: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 03:36:08 +00:00
|
|
|
#include "common/common_types.h"
|
2020-01-19 00:49:30 +00:00
|
|
|
#include "common/host_memory.h"
|
2020-04-03 02:00:41 +00:00
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
namespace DramMemoryMap {
|
2020-04-17 04:59:08 +00:00
|
|
|
enum : u64 {
|
|
|
|
Base = 0x80000000ULL,
|
|
|
|
KernelReserveBase = Base + 0x60000,
|
|
|
|
SlabHeapBase = KernelReserveBase + 0x85000,
|
|
|
|
};
|
2020-04-03 02:00:41 +00:00
|
|
|
}; // namespace DramMemoryMap
|
|
|
|
|
2020-01-19 00:49:30 +00:00
|
|
|
class DeviceMemory {
|
2020-04-03 02:00:41 +00:00
|
|
|
public:
|
2020-07-28 03:36:08 +00:00
|
|
|
explicit DeviceMemory();
|
2020-04-03 02:00:41 +00:00
|
|
|
~DeviceMemory();
|
|
|
|
|
2020-01-19 00:49:30 +00:00
|
|
|
DeviceMemory& operator=(const DeviceMemory&) = delete;
|
|
|
|
DeviceMemory(const DeviceMemory&) = delete;
|
|
|
|
|
2020-04-03 02:00:41 +00:00
|
|
|
template <typename T>
|
2020-04-16 03:06:29 +00: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 03:37:24 +00:00
|
|
|
DramMemoryMap::Base;
|
2020-04-03 02:00:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 03:06:29 +00:00
|
|
|
u8* GetPointer(PAddr addr) {
|
2020-01-19 00:49:30 +00:00
|
|
|
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
|
2020-04-16 03:06:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const u8* GetPointer(PAddr addr) const {
|
2020-01-19 00:49:30 +00:00
|
|
|
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
|
2020-04-08 21:39:58 +00:00
|
|
|
}
|
2020-04-03 02:00:41 +00:00
|
|
|
|
2020-01-19 00:49:30 +00:00
|
|
|
Common::HostMemory buffer;
|
2020-04-03 02:00:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Core
|