device_memory.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "common/host_memory.h"
  7. namespace Core {
  8. namespace DramMemoryMap {
  9. enum : u64 {
  10. Base = 0x80000000ULL,
  11. Size = 0x100000000ULL,
  12. End = Base + Size,
  13. KernelReserveBase = Base + 0x60000,
  14. SlabHeapBase = KernelReserveBase + 0x85000,
  15. SlapHeapSize = 0xa21000,
  16. SlabHeapEnd = SlabHeapBase + SlapHeapSize,
  17. };
  18. }; // namespace DramMemoryMap
  19. class DeviceMemory {
  20. public:
  21. explicit DeviceMemory();
  22. ~DeviceMemory();
  23. DeviceMemory& operator=(const DeviceMemory&) = delete;
  24. DeviceMemory(const DeviceMemory&) = delete;
  25. template <typename T>
  26. PAddr GetPhysicalAddr(const T* ptr) const {
  27. return (reinterpret_cast<uintptr_t>(ptr) -
  28. reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) +
  29. DramMemoryMap::Base;
  30. }
  31. u8* GetPointer(PAddr addr) {
  32. return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
  33. }
  34. const u8* GetPointer(PAddr addr) const {
  35. return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
  36. }
  37. Common::HostMemory buffer;
  38. };
  39. } // namespace Core