diff options
| author | 2018-02-11 23:44:12 -0500 | |
|---|---|---|
| committer | 2018-02-11 23:44:12 -0500 | |
| commit | 6cddf9d88e7fc49919fda92bcd4235797c56f07f (patch) | |
| tree | 3f7da3795b5561b2d325325b72610996e2857742 /src/core | |
| parent | GPU: Added a command processor to decode the GPU pushbuffers and forward the ... (diff) | |
| download | yuzu-6cddf9d88e7fc49919fda92bcd4235797c56f07f.tar.gz yuzu-6cddf9d88e7fc49919fda92bcd4235797c56f07f.tar.xz yuzu-6cddf9d88e7fc49919fda92bcd4235797c56f07f.zip | |
Make a GPU class in VideoCore to contain the GPU state.
Also moved the GPU MemoryManager class to video_core since it makes more sense for it to be there.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/core/core.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/memory_manager.cpp | 112 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/memory_manager.h | 48 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 7 |
10 files changed, 24 insertions, 183 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a78d6d888..fc6cb67c7 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -139,8 +139,6 @@ add_library(core STATIC | |||
| 139 | hle/service/nvdrv/devices/nvmap.h | 139 | hle/service/nvdrv/devices/nvmap.h |
| 140 | hle/service/nvdrv/interface.cpp | 140 | hle/service/nvdrv/interface.cpp |
| 141 | hle/service/nvdrv/interface.h | 141 | hle/service/nvdrv/interface.h |
| 142 | hle/service/nvdrv/memory_manager.cpp | ||
| 143 | hle/service/nvdrv/memory_manager.h | ||
| 144 | hle/service/nvdrv/nvdrv.cpp | 142 | hle/service/nvdrv/nvdrv.cpp |
| 145 | hle/service/nvdrv/nvdrv.h | 143 | hle/service/nvdrv/nvdrv.h |
| 146 | hle/service/nvdrv/nvmemp.cpp | 144 | hle/service/nvdrv/nvmemp.cpp |
diff --git a/src/core/core.cpp b/src/core/core.cpp index dc21e4f04..613a98b4c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -154,6 +154,8 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { | |||
| 154 | break; | 154 | break; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | gpu_core = std::make_unique<Tegra::GPU>(); | ||
| 158 | |||
| 157 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 159 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| 158 | 160 | ||
| 159 | CoreTiming::Init(); | 161 | CoreTiming::Init(); |
diff --git a/src/core/core.h b/src/core/core.h index 06ab4c75f..f63cc47cc 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "core/memory.h" | 11 | #include "core/memory.h" |
| 12 | #include "core/perf_stats.h" | 12 | #include "core/perf_stats.h" |
| 13 | #include "core/telemetry_session.h" | 13 | #include "core/telemetry_session.h" |
| 14 | #include "video_core/gpu.h" | ||
| 14 | 15 | ||
| 15 | class EmuWindow; | 16 | class EmuWindow; |
| 16 | class ARM_Interface; | 17 | class ARM_Interface; |
| @@ -102,6 +103,10 @@ public: | |||
| 102 | return *cpu_core; | 103 | return *cpu_core; |
| 103 | } | 104 | } |
| 104 | 105 | ||
| 106 | Tegra::GPU& GPU() { | ||
| 107 | return *gpu_core; | ||
| 108 | } | ||
| 109 | |||
| 105 | PerfStats perf_stats; | 110 | PerfStats perf_stats; |
| 106 | FrameLimiter frame_limiter; | 111 | FrameLimiter frame_limiter; |
| 107 | 112 | ||
| @@ -138,6 +143,8 @@ private: | |||
| 138 | ///< ARM11 CPU core | 143 | ///< ARM11 CPU core |
| 139 | std::unique_ptr<ARM_Interface> cpu_core; | 144 | std::unique_ptr<ARM_Interface> cpu_core; |
| 140 | 145 | ||
| 146 | std::unique_ptr<Tegra::GPU> gpu_core; | ||
| 147 | |||
| 141 | /// When true, signals that a reschedule should happen | 148 | /// When true, signals that a reschedule should happen |
| 142 | bool reschedule_pending{}; | 149 | bool reschedule_pending{}; |
| 143 | 150 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index cf3601f02..9832e1899 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | ||
| 7 | #include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h" | 8 | #include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h" |
| 8 | #include "core/hle/service/nvdrv/devices/nvmap.h" | 9 | #include "core/hle/service/nvdrv/devices/nvmap.h" |
| 9 | 10 | ||
| @@ -44,11 +45,12 @@ u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>& | |||
| 44 | LOG_DEBUG(Service_NVDRV, "called, pages=%x, page_size=%x, flags=%x", params.pages, | 45 | LOG_DEBUG(Service_NVDRV, "called, pages=%x, page_size=%x, flags=%x", params.pages, |
| 45 | params.page_size, params.flags); | 46 | params.page_size, params.flags); |
| 46 | 47 | ||
| 48 | auto& gpu = Core::System::GetInstance().GPU(); | ||
| 47 | const u64 size{static_cast<u64>(params.pages) * static_cast<u64>(params.page_size)}; | 49 | const u64 size{static_cast<u64>(params.pages) * static_cast<u64>(params.page_size)}; |
| 48 | if (params.flags & 1) { | 50 | if (params.flags & 1) { |
| 49 | params.offset = memory_manager->AllocateSpace(params.offset, size, 1); | 51 | params.offset = gpu.memory_manager->AllocateSpace(params.offset, size, 1); |
| 50 | } else { | 52 | } else { |
| 51 | params.offset = memory_manager->AllocateSpace(size, params.align); | 53 | params.offset = gpu.memory_manager->AllocateSpace(size, params.align); |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | std::memcpy(output.data(), ¶ms, output.size()); | 56 | std::memcpy(output.data(), ¶ms, output.size()); |
| @@ -71,10 +73,12 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou | |||
| 71 | auto object = nvmap_dev->GetObject(params.nvmap_handle); | 73 | auto object = nvmap_dev->GetObject(params.nvmap_handle); |
| 72 | ASSERT(object); | 74 | ASSERT(object); |
| 73 | 75 | ||
| 76 | auto& gpu = Core::System::GetInstance().GPU(); | ||
| 77 | |||
| 74 | if (params.flags & 1) { | 78 | if (params.flags & 1) { |
| 75 | params.offset = memory_manager->MapBufferEx(object->addr, params.offset, object->size); | 79 | params.offset = gpu.memory_manager->MapBufferEx(object->addr, params.offset, object->size); |
| 76 | } else { | 80 | } else { |
| 77 | params.offset = memory_manager->MapBufferEx(object->addr, object->size); | 81 | params.offset = gpu.memory_manager->MapBufferEx(object->addr, object->size); |
| 78 | } | 82 | } |
| 79 | 83 | ||
| 80 | std::memcpy(output.data(), ¶ms, output.size()); | 84 | std::memcpy(output.data(), ¶ms, output.size()); |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index 301a8a79f..f8a60cce7 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/swap.h" | 11 | #include "common/swap.h" |
| 12 | #include "core/hle/service/nvdrv/devices/nvdevice.h" | 12 | #include "core/hle/service/nvdrv/devices/nvdevice.h" |
| 13 | #include "core/hle/service/nvdrv/memory_manager.h" | ||
| 14 | 13 | ||
| 15 | namespace Service { | 14 | namespace Service { |
| 16 | namespace Nvidia { | 15 | namespace Nvidia { |
| @@ -20,8 +19,7 @@ class nvmap; | |||
| 20 | 19 | ||
| 21 | class nvhost_as_gpu final : public nvdevice { | 20 | class nvhost_as_gpu final : public nvdevice { |
| 22 | public: | 21 | public: |
| 23 | nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev, std::shared_ptr<MemoryManager> memory_manager) | 22 | nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {} |
| 24 | : nvmap_dev(std::move(nvmap_dev)), memory_manager(std::move(memory_manager)) {} | ||
| 25 | ~nvhost_as_gpu() override = default; | 23 | ~nvhost_as_gpu() override = default; |
| 26 | 24 | ||
| 27 | u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; | 25 | u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; |
| @@ -100,7 +98,6 @@ private: | |||
| 100 | u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output); | 98 | u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output); |
| 101 | 99 | ||
| 102 | std::shared_ptr<nvmap> nvmap_dev; | 100 | std::shared_ptr<nvmap> nvmap_dev; |
| 103 | std::shared_ptr<MemoryManager> memory_manager; | ||
| 104 | }; | 101 | }; |
| 105 | 102 | ||
| 106 | } // namespace Devices | 103 | } // namespace Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 1c3079889..0b2ebd466 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | |||
| @@ -5,8 +5,8 @@ | |||
| 5 | #include <map> | 5 | #include <map> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/core.h" | ||
| 8 | #include "core/hle/service/nvdrv/devices/nvhost_gpu.h" | 9 | #include "core/hle/service/nvdrv/devices/nvhost_gpu.h" |
| 9 | #include "video_core/command_processor.h" | ||
| 10 | 10 | ||
| 11 | namespace Service { | 11 | namespace Service { |
| 12 | namespace Nvidia { | 12 | namespace Nvidia { |
| @@ -131,9 +131,8 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp | |||
| 131 | std::memcpy(&entries[0], &input.data()[sizeof(IoctlSubmitGpfifo)], | 131 | std::memcpy(&entries[0], &input.data()[sizeof(IoctlSubmitGpfifo)], |
| 132 | params.num_entries * sizeof(IoctlGpfifoEntry)); | 132 | params.num_entries * sizeof(IoctlGpfifoEntry)); |
| 133 | for (auto entry : entries) { | 133 | for (auto entry : entries) { |
| 134 | VAddr va_addr = memory_manager->PhysicalToVirtualAddress(entry.Address()); | 134 | VAddr va_addr = entry.Address(); |
| 135 | Tegra::CommandProcessor::ProcessCommandList(va_addr, entry.sz); | 135 | Core::System::GetInstance().GPU().ProcessCommandList(va_addr, entry.sz); |
| 136 | // TODO(ogniK): Process these | ||
| 137 | } | 136 | } |
| 138 | params.fence_out.id = 0; | 137 | params.fence_out.id = 0; |
| 139 | params.fence_out.value = 0; | 138 | params.fence_out.value = 0; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index 6f9b90b05..e7e9a0088 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/hle/service/nvdrv/devices/nvdevice.h" | 11 | #include "core/hle/service/nvdrv/devices/nvdevice.h" |
| 12 | #include "core/hle/service/nvdrv/memory_manager.h" | ||
| 13 | 12 | ||
| 14 | namespace Service { | 13 | namespace Service { |
| 15 | namespace Nvidia { | 14 | namespace Nvidia { |
| @@ -21,8 +20,7 @@ constexpr u32 NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO(0x8); | |||
| 21 | 20 | ||
| 22 | class nvhost_gpu final : public nvdevice { | 21 | class nvhost_gpu final : public nvdevice { |
| 23 | public: | 22 | public: |
| 24 | nvhost_gpu(std::shared_ptr<nvmap> nvmap_dev, std::shared_ptr<MemoryManager> memory_manager) | 23 | nvhost_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {} |
| 25 | : nvmap_dev(std::move(nvmap_dev)), memory_manager(std::move(memory_manager)) {} | ||
| 26 | ~nvhost_gpu() override = default; | 24 | ~nvhost_gpu() override = default; |
| 27 | 25 | ||
| 28 | u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; | 26 | u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; |
| @@ -139,7 +137,6 @@ private: | |||
| 139 | u32 SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& output); | 137 | u32 SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& output); |
| 140 | 138 | ||
| 141 | std::shared_ptr<nvmap> nvmap_dev; | 139 | std::shared_ptr<nvmap> nvmap_dev; |
| 142 | std::shared_ptr<MemoryManager> memory_manager; | ||
| 143 | }; | 140 | }; |
| 144 | 141 | ||
| 145 | } // namespace Devices | 142 | } // namespace Devices |
diff --git a/src/core/hle/service/nvdrv/memory_manager.cpp b/src/core/hle/service/nvdrv/memory_manager.cpp deleted file mode 100644 index 55a8675d5..000000000 --- a/src/core/hle/service/nvdrv/memory_manager.cpp +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/assert.h" | ||
| 6 | #include "core/hle/service/nvdrv/memory_manager.h" | ||
| 7 | |||
| 8 | namespace Service { | ||
| 9 | namespace Nvidia { | ||
| 10 | |||
| 11 | PAddr MemoryManager::AllocateSpace(u64 size, u64 align) { | ||
| 12 | boost::optional<PAddr> paddr = FindFreeBlock(size, align); | ||
| 13 | ASSERT(paddr); | ||
| 14 | |||
| 15 | for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { | ||
| 16 | PageSlot(*paddr + offset) = static_cast<u64>(PageStatus::Allocated); | ||
| 17 | } | ||
| 18 | |||
| 19 | return *paddr; | ||
| 20 | } | ||
| 21 | |||
| 22 | PAddr MemoryManager::AllocateSpace(PAddr paddr, u64 size, u64 align) { | ||
| 23 | for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { | ||
| 24 | if (IsPageMapped(paddr + offset)) { | ||
| 25 | return AllocateSpace(size, align); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { | ||
| 30 | PageSlot(paddr + offset) = static_cast<u64>(PageStatus::Allocated); | ||
| 31 | } | ||
| 32 | |||
| 33 | return paddr; | ||
| 34 | } | ||
| 35 | |||
| 36 | PAddr MemoryManager::MapBufferEx(VAddr vaddr, u64 size) { | ||
| 37 | vaddr &= ~Memory::PAGE_MASK; | ||
| 38 | |||
| 39 | boost::optional<PAddr> paddr = FindFreeBlock(size); | ||
| 40 | ASSERT(paddr); | ||
| 41 | |||
| 42 | for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { | ||
| 43 | PageSlot(*paddr + offset) = vaddr + offset; | ||
| 44 | } | ||
| 45 | |||
| 46 | return *paddr; | ||
| 47 | } | ||
| 48 | |||
| 49 | PAddr MemoryManager::MapBufferEx(VAddr vaddr, PAddr paddr, u64 size) { | ||
| 50 | vaddr &= ~Memory::PAGE_MASK; | ||
| 51 | paddr &= ~Memory::PAGE_MASK; | ||
| 52 | |||
| 53 | for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { | ||
| 54 | if (PageSlot(paddr + offset) != static_cast<u64>(PageStatus::Allocated)) { | ||
| 55 | return MapBufferEx(vaddr, size); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) { | ||
| 60 | PageSlot(paddr + offset) = vaddr + offset; | ||
| 61 | } | ||
| 62 | |||
| 63 | return paddr; | ||
| 64 | } | ||
| 65 | |||
| 66 | boost::optional<PAddr> MemoryManager::FindFreeBlock(u64 size, u64 align) { | ||
| 67 | PAddr paddr{}; | ||
| 68 | u64 free_space{}; | ||
| 69 | align = (align + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | ||
| 70 | |||
| 71 | while (paddr + free_space < MAX_ADDRESS) { | ||
| 72 | if (!IsPageMapped(paddr + free_space)) { | ||
| 73 | free_space += Memory::PAGE_SIZE; | ||
| 74 | if (free_space >= size) { | ||
| 75 | return paddr; | ||
| 76 | } | ||
| 77 | } else { | ||
| 78 | paddr += free_space + Memory::PAGE_SIZE; | ||
| 79 | free_space = 0; | ||
| 80 | const u64 remainder{paddr % align}; | ||
| 81 | if (!remainder) { | ||
| 82 | paddr = (paddr - remainder) + align; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | return {}; | ||
| 88 | } | ||
| 89 | |||
| 90 | VAddr MemoryManager::PhysicalToVirtualAddress(PAddr paddr) { | ||
| 91 | VAddr base_addr = PageSlot(paddr); | ||
| 92 | ASSERT(base_addr != static_cast<u64>(PageStatus::Unmapped)); | ||
| 93 | return base_addr + (paddr & Memory::PAGE_MASK); | ||
| 94 | } | ||
| 95 | |||
| 96 | bool MemoryManager::IsPageMapped(PAddr paddr) { | ||
| 97 | return PageSlot(paddr) != static_cast<u64>(PageStatus::Unmapped); | ||
| 98 | } | ||
| 99 | |||
| 100 | VAddr& MemoryManager::PageSlot(PAddr paddr) { | ||
| 101 | auto& block = page_table[(paddr >> (Memory::PAGE_BITS + PAGE_TABLE_BITS)) & PAGE_TABLE_MASK]; | ||
| 102 | if (!block) { | ||
| 103 | block = std::make_unique<PageBlock>(); | ||
| 104 | for (unsigned index = 0; index < PAGE_BLOCK_SIZE; index++) { | ||
| 105 | (*block)[index] = static_cast<u64>(PageStatus::Unmapped); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | return (*block)[(paddr >> Memory::PAGE_BITS) & PAGE_BLOCK_MASK]; | ||
| 109 | } | ||
| 110 | |||
| 111 | } // namespace Nvidia | ||
| 112 | } // namespace Service | ||
diff --git a/src/core/hle/service/nvdrv/memory_manager.h b/src/core/hle/service/nvdrv/memory_manager.h deleted file mode 100644 index 4ba1a3952..000000000 --- a/src/core/hle/service/nvdrv/memory_manager.h +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <memory> | ||
| 9 | #include "common/common_types.h" | ||
| 10 | #include "core/memory.h" | ||
| 11 | |||
| 12 | namespace Service { | ||
| 13 | namespace Nvidia { | ||
| 14 | |||
| 15 | class MemoryManager final { | ||
| 16 | public: | ||
| 17 | MemoryManager() = default; | ||
| 18 | |||
| 19 | PAddr AllocateSpace(u64 size, u64 align); | ||
| 20 | PAddr AllocateSpace(PAddr paddr, u64 size, u64 align); | ||
| 21 | PAddr MapBufferEx(VAddr vaddr, u64 size); | ||
| 22 | PAddr MapBufferEx(VAddr vaddr, PAddr paddr, u64 size); | ||
| 23 | VAddr PhysicalToVirtualAddress(PAddr paddr); | ||
| 24 | |||
| 25 | private: | ||
| 26 | boost::optional<PAddr> FindFreeBlock(u64 size, u64 align = 1); | ||
| 27 | bool IsPageMapped(PAddr paddr); | ||
| 28 | VAddr& PageSlot(PAddr paddr); | ||
| 29 | |||
| 30 | enum class PageStatus : u64 { | ||
| 31 | Unmapped = 0xFFFFFFFFFFFFFFFFULL, | ||
| 32 | Allocated = 0xFFFFFFFFFFFFFFFEULL, | ||
| 33 | }; | ||
| 34 | |||
| 35 | static constexpr u64 MAX_ADDRESS{0x10000000000ULL}; | ||
| 36 | static constexpr u64 PAGE_TABLE_BITS{14}; | ||
| 37 | static constexpr u64 PAGE_TABLE_SIZE{1 << PAGE_TABLE_BITS}; | ||
| 38 | static constexpr u64 PAGE_TABLE_MASK{PAGE_TABLE_SIZE - 1}; | ||
| 39 | static constexpr u64 PAGE_BLOCK_BITS{14}; | ||
| 40 | static constexpr u64 PAGE_BLOCK_SIZE{1 << PAGE_BLOCK_BITS}; | ||
| 41 | static constexpr u64 PAGE_BLOCK_MASK{PAGE_BLOCK_SIZE - 1}; | ||
| 42 | |||
| 43 | using PageBlock = std::array<VAddr, PAGE_BLOCK_SIZE>; | ||
| 44 | std::array<std::unique_ptr<PageBlock>, PAGE_TABLE_SIZE> page_table{}; | ||
| 45 | }; | ||
| 46 | |||
| 47 | } // namespace Nvidia | ||
| 48 | } // namespace Service | ||
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 469d6d33a..ea00240e6 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include "core/hle/service/nvdrv/devices/nvhost_gpu.h" | 11 | #include "core/hle/service/nvdrv/devices/nvhost_gpu.h" |
| 12 | #include "core/hle/service/nvdrv/devices/nvmap.h" | 12 | #include "core/hle/service/nvdrv/devices/nvmap.h" |
| 13 | #include "core/hle/service/nvdrv/interface.h" | 13 | #include "core/hle/service/nvdrv/interface.h" |
| 14 | #include "core/hle/service/nvdrv/memory_manager.h" | ||
| 15 | #include "core/hle/service/nvdrv/nvdrv.h" | 14 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 16 | #include "core/hle/service/nvdrv/nvmemp.h" | 15 | #include "core/hle/service/nvdrv/nvmemp.h" |
| 17 | 16 | ||
| @@ -32,10 +31,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { | |||
| 32 | 31 | ||
| 33 | Module::Module() { | 32 | Module::Module() { |
| 34 | auto nvmap_dev = std::make_shared<Devices::nvmap>(); | 33 | auto nvmap_dev = std::make_shared<Devices::nvmap>(); |
| 35 | auto memory_manager = std::make_shared<MemoryManager>(); | 34 | devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>(nvmap_dev); |
| 36 | devices["/dev/nvhost-as-gpu"] = | 35 | devices["/dev/nvhost-gpu"] = std::make_shared<Devices::nvhost_gpu>(nvmap_dev); |
| 37 | std::make_shared<Devices::nvhost_as_gpu>(nvmap_dev, memory_manager); | ||
| 38 | devices["/dev/nvhost-gpu"] = std::make_shared<Devices::nvhost_gpu>(nvmap_dev, memory_manager); | ||
| 39 | devices["/dev/nvhost-ctrl-gpu"] = std::make_shared<Devices::nvhost_ctrl_gpu>(); | 36 | devices["/dev/nvhost-ctrl-gpu"] = std::make_shared<Devices::nvhost_ctrl_gpu>(); |
| 40 | devices["/dev/nvmap"] = nvmap_dev; | 37 | devices["/dev/nvmap"] = nvmap_dev; |
| 41 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(nvmap_dev); | 38 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(nvmap_dev); |