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