diff options
Diffstat (limited to 'src')
33 files changed, 99 insertions, 87 deletions
diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h index 6311e9ece..ffeed46cc 100644 --- a/src/core/device_memory_manager.h +++ b/src/core/device_memory_manager.h | |||
| @@ -28,6 +28,10 @@ class Memory; | |||
| 28 | template <typename DTraits> | 28 | template <typename DTraits> |
| 29 | struct DeviceMemoryManagerAllocator; | 29 | struct DeviceMemoryManagerAllocator; |
| 30 | 30 | ||
| 31 | struct Asid { | ||
| 32 | size_t id; | ||
| 33 | }; | ||
| 34 | |||
| 31 | template <typename Traits> | 35 | template <typename Traits> |
| 32 | class DeviceMemoryManager { | 36 | class DeviceMemoryManager { |
| 33 | using DeviceInterface = typename Traits::DeviceInterface; | 37 | using DeviceInterface = typename Traits::DeviceInterface; |
| @@ -43,15 +47,14 @@ public: | |||
| 43 | void AllocateFixed(DAddr start, size_t size); | 47 | void AllocateFixed(DAddr start, size_t size); |
| 44 | void Free(DAddr start, size_t size); | 48 | void Free(DAddr start, size_t size); |
| 45 | 49 | ||
| 46 | void Map(DAddr address, VAddr virtual_address, size_t size, size_t process_id, | 50 | void Map(DAddr address, VAddr virtual_address, size_t size, Asid asid, bool track = false); |
| 47 | bool track = false); | ||
| 48 | 51 | ||
| 49 | void Unmap(DAddr address, size_t size); | 52 | void Unmap(DAddr address, size_t size); |
| 50 | 53 | ||
| 51 | void TrackContinuityImpl(DAddr address, VAddr virtual_address, size_t size, size_t process_id); | 54 | void TrackContinuityImpl(DAddr address, VAddr virtual_address, size_t size, Asid asid); |
| 52 | void TrackContinuity(DAddr address, VAddr virtual_address, size_t size, size_t process_id) { | 55 | void TrackContinuity(DAddr address, VAddr virtual_address, size_t size, Asid asid) { |
| 53 | std::scoped_lock lk(mapping_guard); | 56 | std::scoped_lock lk(mapping_guard); |
| 54 | TrackContinuityImpl(address, virtual_address, size, process_id); | 57 | TrackContinuityImpl(address, virtual_address, size, asid); |
| 55 | } | 58 | } |
| 56 | 59 | ||
| 57 | // Write / Read | 60 | // Write / Read |
| @@ -105,8 +108,8 @@ public: | |||
| 105 | void WriteBlock(DAddr address, const void* src_pointer, size_t size); | 108 | void WriteBlock(DAddr address, const void* src_pointer, size_t size); |
| 106 | void WriteBlockUnsafe(DAddr address, const void* src_pointer, size_t size); | 109 | void WriteBlockUnsafe(DAddr address, const void* src_pointer, size_t size); |
| 107 | 110 | ||
| 108 | size_t RegisterProcess(Memory::Memory* memory); | 111 | Asid RegisterProcess(Memory::Memory* memory); |
| 109 | void UnregisterProcess(size_t id); | 112 | void UnregisterProcess(Asid id); |
| 110 | 113 | ||
| 111 | void UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta); | 114 | void UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta); |
| 112 | 115 | ||
| @@ -163,17 +166,17 @@ private: | |||
| 163 | static constexpr size_t guest_max_as_bits = 39; | 166 | static constexpr size_t guest_max_as_bits = 39; |
| 164 | static constexpr size_t guest_as_size = 1ULL << guest_max_as_bits; | 167 | static constexpr size_t guest_as_size = 1ULL << guest_max_as_bits; |
| 165 | static constexpr size_t guest_mask = guest_as_size - 1ULL; | 168 | static constexpr size_t guest_mask = guest_as_size - 1ULL; |
| 166 | static constexpr size_t process_id_start_bit = guest_max_as_bits; | 169 | static constexpr size_t asid_start_bit = guest_max_as_bits; |
| 167 | 170 | ||
| 168 | std::pair<size_t, VAddr> ExtractCPUBacking(size_t page_index) { | 171 | std::pair<Asid, VAddr> ExtractCPUBacking(size_t page_index) { |
| 169 | auto content = cpu_backing_address[page_index]; | 172 | auto content = cpu_backing_address[page_index]; |
| 170 | const VAddr address = content & guest_mask; | 173 | const VAddr address = content & guest_mask; |
| 171 | const size_t process_id = static_cast<size_t>(content >> process_id_start_bit); | 174 | const Asid asid{static_cast<size_t>(content >> asid_start_bit)}; |
| 172 | return std::make_pair(process_id, address); | 175 | return std::make_pair(asid, address); |
| 173 | } | 176 | } |
| 174 | 177 | ||
| 175 | void InsertCPUBacking(size_t page_index, VAddr address, size_t process_id) { | 178 | void InsertCPUBacking(size_t page_index, VAddr address, Asid asid) { |
| 176 | cpu_backing_address[page_index] = address | (process_id << process_id_start_bit); | 179 | cpu_backing_address[page_index] = address | (asid.id << asid_start_bit); |
| 177 | } | 180 | } |
| 178 | 181 | ||
| 179 | Common::VirtualBuffer<VAddr> cpu_backing_address; | 182 | Common::VirtualBuffer<VAddr> cpu_backing_address; |
| @@ -205,4 +208,4 @@ private: | |||
| 205 | std::mutex mapping_guard; | 208 | std::mutex mapping_guard; |
| 206 | }; | 209 | }; |
| 207 | 210 | ||
| 208 | } // namespace Core \ No newline at end of file | 211 | } // namespace Core |
diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index d7b4abacc..f6e4ad874 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc | |||
| @@ -215,8 +215,8 @@ void DeviceMemoryManager<Traits>::Free(DAddr start, size_t size) { | |||
| 215 | 215 | ||
| 216 | template <typename Traits> | 216 | template <typename Traits> |
| 217 | void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size_t size, | 217 | void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size_t size, |
| 218 | size_t process_id, bool track) { | 218 | Asid asid, bool track) { |
| 219 | Core::Memory::Memory* process_memory = registered_processes[process_id]; | 219 | Core::Memory::Memory* process_memory = registered_processes[asid.id]; |
| 220 | size_t start_page_d = address >> Memory::YUZU_PAGEBITS; | 220 | size_t start_page_d = address >> Memory::YUZU_PAGEBITS; |
| 221 | size_t num_pages = Common::AlignUp(size, Memory::YUZU_PAGESIZE) >> Memory::YUZU_PAGEBITS; | 221 | size_t num_pages = Common::AlignUp(size, Memory::YUZU_PAGESIZE) >> Memory::YUZU_PAGEBITS; |
| 222 | std::scoped_lock lk(mapping_guard); | 222 | std::scoped_lock lk(mapping_guard); |
| @@ -229,7 +229,7 @@ void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size | |||
| 229 | } | 229 | } |
| 230 | auto phys_addr = static_cast<u32>(GetRawPhysicalAddr(ptr) >> Memory::YUZU_PAGEBITS) + 1U; | 230 | auto phys_addr = static_cast<u32>(GetRawPhysicalAddr(ptr) >> Memory::YUZU_PAGEBITS) + 1U; |
| 231 | compressed_physical_ptr[start_page_d + i] = phys_addr; | 231 | compressed_physical_ptr[start_page_d + i] = phys_addr; |
| 232 | InsertCPUBacking(start_page_d + i, new_vaddress, process_id); | 232 | InsertCPUBacking(start_page_d + i, new_vaddress, asid); |
| 233 | const u32 base_dev = compressed_device_addr[phys_addr - 1U]; | 233 | const u32 base_dev = compressed_device_addr[phys_addr - 1U]; |
| 234 | const u32 new_dev = static_cast<u32>(start_page_d + i); | 234 | const u32 new_dev = static_cast<u32>(start_page_d + i); |
| 235 | if (base_dev == 0) [[likely]] { | 235 | if (base_dev == 0) [[likely]] { |
| @@ -244,7 +244,7 @@ void DeviceMemoryManager<Traits>::Map(DAddr address, VAddr virtual_address, size | |||
| 244 | impl->multi_dev_address.Register(new_dev, start_id); | 244 | impl->multi_dev_address.Register(new_dev, start_id); |
| 245 | } | 245 | } |
| 246 | if (track) { | 246 | if (track) { |
| 247 | TrackContinuityImpl(address, virtual_address, size, process_id); | 247 | TrackContinuityImpl(address, virtual_address, size, asid); |
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | 250 | ||
| @@ -277,8 +277,8 @@ void DeviceMemoryManager<Traits>::Unmap(DAddr address, size_t size) { | |||
| 277 | } | 277 | } |
| 278 | template <typename Traits> | 278 | template <typename Traits> |
| 279 | void DeviceMemoryManager<Traits>::TrackContinuityImpl(DAddr address, VAddr virtual_address, | 279 | void DeviceMemoryManager<Traits>::TrackContinuityImpl(DAddr address, VAddr virtual_address, |
| 280 | size_t size, size_t process_id) { | 280 | size_t size, Asid asid) { |
| 281 | Core::Memory::Memory* process_memory = registered_processes[process_id]; | 281 | Core::Memory::Memory* process_memory = registered_processes[asid.id]; |
| 282 | size_t start_page_d = address >> Memory::YUZU_PAGEBITS; | 282 | size_t start_page_d = address >> Memory::YUZU_PAGEBITS; |
| 283 | size_t num_pages = Common::AlignUp(size, Memory::YUZU_PAGESIZE) >> Memory::YUZU_PAGEBITS; | 283 | size_t num_pages = Common::AlignUp(size, Memory::YUZU_PAGESIZE) >> Memory::YUZU_PAGEBITS; |
| 284 | uintptr_t last_ptr = 0; | 284 | uintptr_t last_ptr = 0; |
| @@ -488,8 +488,8 @@ void DeviceMemoryManager<Traits>::WriteBlockUnsafe(DAddr address, const void* sr | |||
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | template <typename Traits> | 490 | template <typename Traits> |
| 491 | size_t DeviceMemoryManager<Traits>::RegisterProcess(Memory::Memory* memory_device_inter) { | 491 | Asid DeviceMemoryManager<Traits>::RegisterProcess(Memory::Memory* memory_device_inter) { |
| 492 | size_t new_id; | 492 | size_t new_id{}; |
| 493 | if (!id_pool.empty()) { | 493 | if (!id_pool.empty()) { |
| 494 | new_id = id_pool.front(); | 494 | new_id = id_pool.front(); |
| 495 | id_pool.pop_front(); | 495 | id_pool.pop_front(); |
| @@ -498,13 +498,13 @@ size_t DeviceMemoryManager<Traits>::RegisterProcess(Memory::Memory* memory_devic | |||
| 498 | registered_processes.emplace_back(memory_device_inter); | 498 | registered_processes.emplace_back(memory_device_inter); |
| 499 | new_id = registered_processes.size() - 1U; | 499 | new_id = registered_processes.size() - 1U; |
| 500 | } | 500 | } |
| 501 | return new_id; | 501 | return Asid{new_id}; |
| 502 | } | 502 | } |
| 503 | 503 | ||
| 504 | template <typename Traits> | 504 | template <typename Traits> |
| 505 | void DeviceMemoryManager<Traits>::UnregisterProcess(size_t id) { | 505 | void DeviceMemoryManager<Traits>::UnregisterProcess(Asid asid) { |
| 506 | registered_processes[id] = nullptr; | 506 | registered_processes[asid.id] = nullptr; |
| 507 | id_pool.push_front(id); | 507 | id_pool.push_front(asid.id); |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | template <typename Traits> | 510 | template <typename Traits> |
| @@ -530,9 +530,9 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size | |||
| 530 | std::atomic_thread_fence(std::memory_order_acquire); | 530 | std::atomic_thread_fence(std::memory_order_acquire); |
| 531 | const size_t page_end = Common::DivCeil(addr + size, Memory::YUZU_PAGESIZE); | 531 | const size_t page_end = Common::DivCeil(addr + size, Memory::YUZU_PAGESIZE); |
| 532 | size_t page = addr >> Memory::YUZU_PAGEBITS; | 532 | size_t page = addr >> Memory::YUZU_PAGEBITS; |
| 533 | auto [process_id, base_vaddress] = ExtractCPUBacking(page); | 533 | auto [asid, base_vaddress] = ExtractCPUBacking(page); |
| 534 | size_t vpage = base_vaddress >> Memory::YUZU_PAGEBITS; | 534 | size_t vpage = base_vaddress >> Memory::YUZU_PAGEBITS; |
| 535 | auto* memory_device_inter = registered_processes[process_id]; | 535 | auto* memory_device_inter = registered_processes[asid.id]; |
| 536 | for (; page != page_end; ++page) { | 536 | for (; page != page_end; ++page) { |
| 537 | std::atomic_uint8_t& count = cached_pages->at(page >> 3).Count(page); | 537 | std::atomic_uint8_t& count = cached_pages->at(page >> 3).Count(page); |
| 538 | 538 | ||
diff --git a/src/core/hle/service/nvdrv/core/container.cpp b/src/core/hle/service/nvdrv/core/container.cpp index d04b7f5ff..b5fd98a9d 100644 --- a/src/core/hle/service/nvdrv/core/container.cpp +++ b/src/core/hle/service/nvdrv/core/container.cpp | |||
| @@ -16,9 +16,8 @@ | |||
| 16 | 16 | ||
| 17 | namespace Service::Nvidia::NvCore { | 17 | namespace Service::Nvidia::NvCore { |
| 18 | 18 | ||
| 19 | Session::Session(size_t id_, Kernel::KProcess* process_, size_t smmu_id_) | 19 | Session::Session(SessionId id_, Kernel::KProcess* process_, Core::Asid asid_) |
| 20 | : id{id_}, process{process_}, smmu_id{smmu_id_}, | 20 | : id{id_}, process{process_}, asid{asid_}, has_preallocated_area{}, mapper{}, is_active{} {} |
| 21 | has_preallocated_area{}, mapper{}, is_active{} {} | ||
| 22 | 21 | ||
| 23 | Session::~Session() = default; | 22 | Session::~Session() = default; |
| 24 | 23 | ||
| @@ -41,7 +40,7 @@ Container::Container(Tegra::Host1x::Host1x& host1x_) { | |||
| 41 | 40 | ||
| 42 | Container::~Container() = default; | 41 | Container::~Container() = default; |
| 43 | 42 | ||
| 44 | size_t Container::OpenSession(Kernel::KProcess* process) { | 43 | SessionId Container::OpenSession(Kernel::KProcess* process) { |
| 45 | std::scoped_lock lk(impl->session_guard); | 44 | std::scoped_lock lk(impl->session_guard); |
| 46 | for (auto& session : impl->sessions) { | 45 | for (auto& session : impl->sessions) { |
| 47 | if (!session.is_active) { | 46 | if (!session.is_active) { |
| @@ -54,14 +53,14 @@ size_t Container::OpenSession(Kernel::KProcess* process) { | |||
| 54 | size_t new_id{}; | 53 | size_t new_id{}; |
| 55 | auto* memory_interface = &process->GetMemory(); | 54 | auto* memory_interface = &process->GetMemory(); |
| 56 | auto& smmu = impl->host1x.MemoryManager(); | 55 | auto& smmu = impl->host1x.MemoryManager(); |
| 57 | auto smmu_id = smmu.RegisterProcess(memory_interface); | 56 | auto asid = smmu.RegisterProcess(memory_interface); |
| 58 | if (!impl->id_pool.empty()) { | 57 | if (!impl->id_pool.empty()) { |
| 59 | new_id = impl->id_pool.front(); | 58 | new_id = impl->id_pool.front(); |
| 60 | impl->id_pool.pop_front(); | 59 | impl->id_pool.pop_front(); |
| 61 | impl->sessions[new_id] = Session{new_id, process, smmu_id}; | 60 | impl->sessions[new_id] = Session{SessionId{new_id}, process, asid}; |
| 62 | } else { | 61 | } else { |
| 63 | new_id = impl->new_ids++; | 62 | new_id = impl->new_ids++; |
| 64 | impl->sessions.emplace_back(new_id, process, smmu_id); | 63 | impl->sessions.emplace_back(SessionId{new_id}, process, asid); |
| 65 | } | 64 | } |
| 66 | auto& session = impl->sessions[new_id]; | 65 | auto& session = impl->sessions[new_id]; |
| 67 | session.is_active = true; | 66 | session.is_active = true; |
| @@ -100,18 +99,18 @@ size_t Container::OpenSession(Kernel::KProcess* process) { | |||
| 100 | auto start_region = (region_size >> 15) >= 1024 ? smmu.Allocate(region_size) : 0; | 99 | auto start_region = (region_size >> 15) >= 1024 ? smmu.Allocate(region_size) : 0; |
| 101 | if (start_region != 0) { | 100 | if (start_region != 0) { |
| 102 | session.mapper = std::make_unique<HeapMapper>(region_start, start_region, region_size, | 101 | session.mapper = std::make_unique<HeapMapper>(region_start, start_region, region_size, |
| 103 | smmu_id, impl->host1x); | 102 | asid, impl->host1x); |
| 104 | smmu.TrackContinuity(start_region, region_start, region_size, smmu_id); | 103 | smmu.TrackContinuity(start_region, region_start, region_size, asid); |
| 105 | session.has_preallocated_area = true; | 104 | session.has_preallocated_area = true; |
| 106 | LOG_CRITICAL(Debug, "Preallocation created!"); | 105 | LOG_CRITICAL(Debug, "Preallocation created!"); |
| 107 | } | 106 | } |
| 108 | } | 107 | } |
| 109 | return new_id; | 108 | return SessionId{new_id}; |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | void Container::CloseSession(size_t id) { | 111 | void Container::CloseSession(SessionId session_id) { |
| 113 | std::scoped_lock lk(impl->session_guard); | 112 | std::scoped_lock lk(impl->session_guard); |
| 114 | auto& session = impl->sessions[id]; | 113 | auto& session = impl->sessions[session_id.id]; |
| 115 | auto& smmu = impl->host1x.MemoryManager(); | 114 | auto& smmu = impl->host1x.MemoryManager(); |
| 116 | if (session.has_preallocated_area) { | 115 | if (session.has_preallocated_area) { |
| 117 | const DAddr region_start = session.mapper->GetRegionStart(); | 116 | const DAddr region_start = session.mapper->GetRegionStart(); |
| @@ -121,13 +120,13 @@ void Container::CloseSession(size_t id) { | |||
| 121 | session.has_preallocated_area = false; | 120 | session.has_preallocated_area = false; |
| 122 | } | 121 | } |
| 123 | session.is_active = false; | 122 | session.is_active = false; |
| 124 | smmu.UnregisterProcess(impl->sessions[id].smmu_id); | 123 | smmu.UnregisterProcess(impl->sessions[session_id.id].asid); |
| 125 | impl->id_pool.emplace_front(id); | 124 | impl->id_pool.emplace_front(session_id.id); |
| 126 | } | 125 | } |
| 127 | 126 | ||
| 128 | Session* Container::GetSession(size_t id) { | 127 | Session* Container::GetSession(SessionId session_id) { |
| 129 | std::atomic_thread_fence(std::memory_order_acquire); | 128 | std::atomic_thread_fence(std::memory_order_acquire); |
| 130 | return &impl->sessions[id]; | 129 | return &impl->sessions[session_id.id]; |
| 131 | } | 130 | } |
| 132 | 131 | ||
| 133 | NvMap& Container::GetNvMapFile() { | 132 | NvMap& Container::GetNvMapFile() { |
diff --git a/src/core/hle/service/nvdrv/core/container.h b/src/core/hle/service/nvdrv/core/container.h index 4b8452844..b4d3938a8 100644 --- a/src/core/hle/service/nvdrv/core/container.h +++ b/src/core/hle/service/nvdrv/core/container.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <unordered_map> | 9 | #include <unordered_map> |
| 10 | 10 | ||
| 11 | #include "core/device_memory_manager.h" | ||
| 11 | #include "core/hle/service/nvdrv/nvdata.h" | 12 | #include "core/hle/service/nvdrv/nvdata.h" |
| 12 | 13 | ||
| 13 | namespace Kernel { | 14 | namespace Kernel { |
| @@ -26,8 +27,12 @@ class SyncpointManager; | |||
| 26 | 27 | ||
| 27 | struct ContainerImpl; | 28 | struct ContainerImpl; |
| 28 | 29 | ||
| 30 | struct SessionId { | ||
| 31 | size_t id; | ||
| 32 | }; | ||
| 33 | |||
| 29 | struct Session { | 34 | struct Session { |
| 30 | Session(size_t id_, Kernel::KProcess* process_, size_t smmu_id_); | 35 | Session(SessionId id_, Kernel::KProcess* process_, Core::Asid asid_); |
| 31 | ~Session(); | 36 | ~Session(); |
| 32 | 37 | ||
| 33 | Session(const Session&) = delete; | 38 | Session(const Session&) = delete; |
| @@ -35,9 +40,9 @@ struct Session { | |||
| 35 | Session(Session&&) = default; | 40 | Session(Session&&) = default; |
| 36 | Session& operator=(Session&&) = default; | 41 | Session& operator=(Session&&) = default; |
| 37 | 42 | ||
| 38 | size_t id; | 43 | SessionId id; |
| 39 | Kernel::KProcess* process; | 44 | Kernel::KProcess* process; |
| 40 | size_t smmu_id; | 45 | Core::Asid asid; |
| 41 | bool has_preallocated_area{}; | 46 | bool has_preallocated_area{}; |
| 42 | std::unique_ptr<HeapMapper> mapper{}; | 47 | std::unique_ptr<HeapMapper> mapper{}; |
| 43 | bool is_active{}; | 48 | bool is_active{}; |
| @@ -48,10 +53,10 @@ public: | |||
| 48 | explicit Container(Tegra::Host1x::Host1x& host1x); | 53 | explicit Container(Tegra::Host1x::Host1x& host1x); |
| 49 | ~Container(); | 54 | ~Container(); |
| 50 | 55 | ||
| 51 | size_t OpenSession(Kernel::KProcess* process); | 56 | SessionId OpenSession(Kernel::KProcess* process); |
| 52 | void CloseSession(size_t id); | 57 | void CloseSession(SessionId id); |
| 53 | 58 | ||
| 54 | Session* GetSession(size_t id); | 59 | Session* GetSession(SessionId id); |
| 55 | 60 | ||
| 56 | NvMap& GetNvMapFile(); | 61 | NvMap& GetNvMapFile(); |
| 57 | 62 | ||
diff --git a/src/core/hle/service/nvdrv/core/heap_mapper.cpp b/src/core/hle/service/nvdrv/core/heap_mapper.cpp index c29191b92..096dc5deb 100644 --- a/src/core/hle/service/nvdrv/core/heap_mapper.cpp +++ b/src/core/hle/service/nvdrv/core/heap_mapper.cpp | |||
| @@ -109,9 +109,9 @@ struct HeapMapper::HeapMapperInternal { | |||
| 109 | std::mutex guard; | 109 | std::mutex guard; |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, size_t smmu_id, | 112 | HeapMapper::HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, Core::Asid asid, |
| 113 | Tegra::Host1x::Host1x& host1x) | 113 | Tegra::Host1x::Host1x& host1x) |
| 114 | : m_vaddress{start_vaddress}, m_daddress{start_daddress}, m_size{size}, m_smmu_id{smmu_id} { | 114 | : m_vaddress{start_vaddress}, m_daddress{start_daddress}, m_size{size}, m_asid{asid} { |
| 115 | m_internal = std::make_unique<HeapMapperInternal>(host1x); | 115 | m_internal = std::make_unique<HeapMapperInternal>(host1x); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| @@ -138,7 +138,7 @@ DAddr HeapMapper::Map(VAddr start, size_t size) { | |||
| 138 | const size_t offset = inter_addr - m_vaddress; | 138 | const size_t offset = inter_addr - m_vaddress; |
| 139 | const size_t sub_size = inter_addr_end - inter_addr; | 139 | const size_t sub_size = inter_addr_end - inter_addr; |
| 140 | m_internal->device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size, | 140 | m_internal->device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size, |
| 141 | m_smmu_id); | 141 | m_asid); |
| 142 | } | 142 | } |
| 143 | } | 143 | } |
| 144 | m_internal->mapping_overlaps += std::make_pair(interval, 1); | 144 | m_internal->mapping_overlaps += std::make_pair(interval, 1); |
| @@ -172,4 +172,4 @@ void HeapMapper::Unmap(VAddr start, size_t size) { | |||
| 172 | m_internal->base_set.clear(); | 172 | m_internal->base_set.clear(); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | } // namespace Service::Nvidia::NvCore \ No newline at end of file | 175 | } // namespace Service::Nvidia::NvCore |
diff --git a/src/core/hle/service/nvdrv/core/heap_mapper.h b/src/core/hle/service/nvdrv/core/heap_mapper.h index 8b23638b8..491a12e4f 100644 --- a/src/core/hle/service/nvdrv/core/heap_mapper.h +++ b/src/core/hle/service/nvdrv/core/heap_mapper.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | 7 | ||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/device_memory_manager.h" | ||
| 9 | 10 | ||
| 10 | namespace Tegra::Host1x { | 11 | namespace Tegra::Host1x { |
| 11 | class Host1x; | 12 | class Host1x; |
| @@ -15,7 +16,7 @@ namespace Service::Nvidia::NvCore { | |||
| 15 | 16 | ||
| 16 | class HeapMapper { | 17 | class HeapMapper { |
| 17 | public: | 18 | public: |
| 18 | HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, size_t smmu_id, | 19 | HeapMapper(VAddr start_vaddress, DAddr start_daddress, size_t size, Core::Asid asid, |
| 19 | Tegra::Host1x::Host1x& host1x); | 20 | Tegra::Host1x::Host1x& host1x); |
| 20 | ~HeapMapper(); | 21 | ~HeapMapper(); |
| 21 | 22 | ||
| @@ -41,8 +42,8 @@ private: | |||
| 41 | VAddr m_vaddress; | 42 | VAddr m_vaddress; |
| 42 | DAddr m_daddress; | 43 | DAddr m_daddress; |
| 43 | size_t m_size; | 44 | size_t m_size; |
| 44 | size_t m_smmu_id; | 45 | Core::Asid m_asid; |
| 45 | std::unique_ptr<HeapMapperInternal> m_internal; | 46 | std::unique_ptr<HeapMapperInternal> m_internal; |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| 48 | } // namespace Service::Nvidia::NvCore \ No newline at end of file | 49 | } // namespace Service::Nvidia::NvCore |
diff --git a/src/core/hle/service/nvdrv/core/nvmap.cpp b/src/core/hle/service/nvdrv/core/nvmap.cpp index 6e59d4fe1..1b59c6b15 100644 --- a/src/core/hle/service/nvdrv/core/nvmap.cpp +++ b/src/core/hle/service/nvdrv/core/nvmap.cpp | |||
| @@ -22,7 +22,8 @@ NvMap::Handle::Handle(u64 size_, Id id_) | |||
| 22 | flags.raw = 0; | 22 | flags.raw = 0; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress, size_t pSessionId) { | 25 | NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress, |
| 26 | NvCore::SessionId pSessionId) { | ||
| 26 | std::scoped_lock lock(mutex); | 27 | std::scoped_lock lock(mutex); |
| 27 | // Handles cannot be allocated twice | 28 | // Handles cannot be allocated twice |
| 28 | if (allocated) { | 29 | if (allocated) { |
| @@ -223,7 +224,7 @@ DAddr NvMap::PinHandle(NvMap::Handle::Id handle, bool low_area_pin) { | |||
| 223 | } | 224 | } |
| 224 | 225 | ||
| 225 | handle_description->d_address = address; | 226 | handle_description->d_address = address; |
| 226 | smmu.Map(address, vaddress, map_size, session->smmu_id, true); | 227 | smmu.Map(address, vaddress, map_size, session->asid, true); |
| 227 | handle_description->in_heap = false; | 228 | handle_description->in_heap = false; |
| 228 | } | 229 | } |
| 229 | } | 230 | } |
diff --git a/src/core/hle/service/nvdrv/core/nvmap.h b/src/core/hle/service/nvdrv/core/nvmap.h index aa5cd21ec..d7f695845 100644 --- a/src/core/hle/service/nvdrv/core/nvmap.h +++ b/src/core/hle/service/nvdrv/core/nvmap.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | #include "common/bit_field.h" | 15 | #include "common/bit_field.h" |
| 16 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "core/hle/service/nvdrv/core/container.h" | ||
| 17 | #include "core/hle/service/nvdrv/nvdata.h" | 18 | #include "core/hle/service/nvdrv/nvdata.h" |
| 18 | 19 | ||
| 19 | namespace Tegra { | 20 | namespace Tegra { |
| @@ -71,7 +72,7 @@ public: | |||
| 71 | u8 kind{}; //!< Used for memory compression | 72 | u8 kind{}; //!< Used for memory compression |
| 72 | bool allocated{}; //!< If the handle has been allocated with `Alloc` | 73 | bool allocated{}; //!< If the handle has been allocated with `Alloc` |
| 73 | bool in_heap{}; | 74 | bool in_heap{}; |
| 74 | size_t session_id{}; | 75 | NvCore::SessionId session_id{}; |
| 75 | 76 | ||
| 76 | DAddr d_address{}; //!< The memory location in the device's AS that this handle corresponds | 77 | DAddr d_address{}; //!< The memory location in the device's AS that this handle corresponds |
| 77 | //!< to, this can also be in the nvdrv tmem | 78 | //!< to, this can also be in the nvdrv tmem |
| @@ -83,7 +84,7 @@ public: | |||
| 83 | * if a 0 address is passed | 84 | * if a 0 address is passed |
| 84 | */ | 85 | */ |
| 85 | [[nodiscard]] NvResult Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress, | 86 | [[nodiscard]] NvResult Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress, |
| 86 | size_t pSessionId); | 87 | NvCore::SessionId pSessionId); |
| 87 | 88 | ||
| 88 | /** | 89 | /** |
| 89 | * @brief Increases the dupe counter of the handle for the given session | 90 | * @brief Increases the dupe counter of the handle for the given session |
diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index ff91aabcb..8adaddc60 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/service/nvdrv/core/container.h" | ||
| 10 | #include "core/hle/service/nvdrv/nvdata.h" | 11 | #include "core/hle/service/nvdrv/nvdata.h" |
| 11 | 12 | ||
| 12 | namespace Core { | 13 | namespace Core { |
| @@ -62,7 +63,7 @@ public: | |||
| 62 | * Called once a device is opened | 63 | * Called once a device is opened |
| 63 | * @param fd The device fd | 64 | * @param fd The device fd |
| 64 | */ | 65 | */ |
| 65 | virtual void OnOpen(size_t session_id, DeviceFD fd) = 0; | 66 | virtual void OnOpen(NvCore::SessionId session_id, DeviceFD fd) = 0; |
| 66 | 67 | ||
| 67 | /** | 68 | /** |
| 68 | * Called once a device is closed | 69 | * Called once a device is closed |
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index f1404b9da..c1ebbd62d 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | |||
| @@ -35,7 +35,7 @@ NvResult nvdisp_disp0::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 35 | return NvResult::NotImplemented; | 35 | return NvResult::NotImplemented; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void nvdisp_disp0::OnOpen(size_t session_id, DeviceFD fd) {} | 38 | void nvdisp_disp0::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} |
| 39 | void nvdisp_disp0::OnClose(DeviceFD fd) {} | 39 | void nvdisp_disp0::OnClose(DeviceFD fd) {} |
| 40 | 40 | ||
| 41 | void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width, | 41 | void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width, |
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h index 4e32ec191..5f13a50a2 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h | |||
| @@ -32,7 +32,7 @@ public: | |||
| 32 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 32 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 33 | std::span<u8> inline_output) override; | 33 | std::span<u8> inline_output) override; |
| 34 | 34 | ||
| 35 | void OnOpen(size_t session_id, DeviceFD fd) override; | 35 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 36 | void OnClose(DeviceFD fd) override; | 36 | void OnClose(DeviceFD fd) override; |
| 37 | 37 | ||
| 38 | /// Performs a screen flip, drawing the buffer pointed to by the handle. | 38 | /// Performs a screen flip, drawing the buffer pointed to by the handle. |
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 936b93bd9..e6646ba04 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | |||
| @@ -86,7 +86,7 @@ NvResult nvhost_as_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> i | |||
| 86 | return NvResult::NotImplemented; | 86 | return NvResult::NotImplemented; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | void nvhost_as_gpu::OnOpen(size_t session_id, DeviceFD fd) {} | 89 | void nvhost_as_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} |
| 90 | void nvhost_as_gpu::OnClose(DeviceFD fd) {} | 90 | void nvhost_as_gpu::OnClose(DeviceFD fd) {} |
| 91 | 91 | ||
| 92 | NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) { | 92 | NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) { |
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 7fd704bce..7d0a99988 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h | |||
| @@ -55,7 +55,7 @@ public: | |||
| 55 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 55 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 56 | std::span<u8> inline_output) override; | 56 | std::span<u8> inline_output) override; |
| 57 | 57 | ||
| 58 | void OnOpen(size_t session_id, DeviceFD fd) override; | 58 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 59 | void OnClose(DeviceFD fd) override; | 59 | void OnClose(DeviceFD fd) override; |
| 60 | 60 | ||
| 61 | Kernel::KEvent* QueryEvent(u32 event_id) override; | 61 | Kernel::KEvent* QueryEvent(u32 event_id) override; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index c4033cf1b..250d01de3 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -76,7 +76,7 @@ NvResult nvhost_ctrl::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inp | |||
| 76 | return NvResult::NotImplemented; | 76 | return NvResult::NotImplemented; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | void nvhost_ctrl::OnOpen(size_t session_id, DeviceFD fd) {} | 79 | void nvhost_ctrl::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} |
| 80 | 80 | ||
| 81 | void nvhost_ctrl::OnClose(DeviceFD fd) {} | 81 | void nvhost_ctrl::OnClose(DeviceFD fd) {} |
| 82 | 82 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index 84f419f16..403f1a746 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -32,7 +32,7 @@ public: | |||
| 32 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 32 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 33 | std::span<u8> inline_output) override; | 33 | std::span<u8> inline_output) override; |
| 34 | 34 | ||
| 35 | void OnOpen(size_t session_id, DeviceFD fd) override; | 35 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 36 | void OnClose(DeviceFD fd) override; | 36 | void OnClose(DeviceFD fd) override; |
| 37 | 37 | ||
| 38 | Kernel::KEvent* QueryEvent(u32 event_id) override; | 38 | Kernel::KEvent* QueryEvent(u32 event_id) override; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index 75276c37c..ddd85678b 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | |||
| @@ -82,7 +82,7 @@ NvResult nvhost_ctrl_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> | |||
| 82 | return NvResult::NotImplemented; | 82 | return NvResult::NotImplemented; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | void nvhost_ctrl_gpu::OnOpen(size_t session_id, DeviceFD fd) {} | 85 | void nvhost_ctrl_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} |
| 86 | void nvhost_ctrl_gpu::OnClose(DeviceFD fd) {} | 86 | void nvhost_ctrl_gpu::OnClose(DeviceFD fd) {} |
| 87 | 87 | ||
| 88 | NvResult nvhost_ctrl_gpu::GetCharacteristics1(IoctlCharacteristics& params) { | 88 | NvResult nvhost_ctrl_gpu::GetCharacteristics1(IoctlCharacteristics& params) { |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h index 6147e37cc..d2ab05b21 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h | |||
| @@ -28,7 +28,7 @@ public: | |||
| 28 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 28 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 29 | std::span<u8> inline_output) override; | 29 | std::span<u8> inline_output) override; |
| 30 | 30 | ||
| 31 | void OnOpen(size_t session_id, DeviceFD fd) override; | 31 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 32 | void OnClose(DeviceFD fd) override; | 32 | void OnClose(DeviceFD fd) override; |
| 33 | 33 | ||
| 34 | Kernel::KEvent* QueryEvent(u32 event_id) override; | 34 | Kernel::KEvent* QueryEvent(u32 event_id) override; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 0929c7128..bf12d69a5 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | |||
| @@ -120,7 +120,7 @@ NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu | |||
| 120 | return NvResult::NotImplemented; | 120 | return NvResult::NotImplemented; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | void nvhost_gpu::OnOpen(size_t session_id, DeviceFD fd) {} | 123 | void nvhost_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} |
| 124 | void nvhost_gpu::OnClose(DeviceFD fd) {} | 124 | void nvhost_gpu::OnClose(DeviceFD fd) {} |
| 125 | 125 | ||
| 126 | NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) { | 126 | NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) { |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index f5a396c40..e34a978db 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h | |||
| @@ -47,7 +47,7 @@ public: | |||
| 47 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 47 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 48 | std::span<u8> inline_output) override; | 48 | std::span<u8> inline_output) override; |
| 49 | 49 | ||
| 50 | void OnOpen(size_t session_id, DeviceFD fd) override; | 50 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 51 | void OnClose(DeviceFD fd) override; | 51 | void OnClose(DeviceFD fd) override; |
| 52 | 52 | ||
| 53 | Kernel::KEvent* QueryEvent(u32 event_id) override; | 53 | Kernel::KEvent* QueryEvent(u32 event_id) override; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 63228518e..2c0ac2a46 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | |||
| @@ -68,7 +68,7 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 68 | return NvResult::NotImplemented; | 68 | return NvResult::NotImplemented; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | void nvhost_nvdec::OnOpen(size_t session_id, DeviceFD fd) { | 71 | void nvhost_nvdec::OnOpen(NvCore::SessionId session_id, DeviceFD fd) { |
| 72 | LOG_INFO(Service_NVDRV, "NVDEC video stream started"); | 72 | LOG_INFO(Service_NVDRV, "NVDEC video stream started"); |
| 73 | system.SetNVDECActive(true); | 73 | system.SetNVDECActive(true); |
| 74 | sessions[fd] = session_id; | 74 | sessions[fd] = session_id; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h index 1fb27b814..627686757 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h | |||
| @@ -20,7 +20,7 @@ public: | |||
| 20 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 20 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 21 | std::span<u8> inline_output) override; | 21 | std::span<u8> inline_output) override; |
| 22 | 22 | ||
| 23 | void OnOpen(size_t session_id, DeviceFD fd) override; | 23 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 24 | void OnClose(DeviceFD fd) override; | 24 | void OnClose(DeviceFD fd) override; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index 718e0fecd..900db81d2 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h | |||
| @@ -127,7 +127,7 @@ protected: | |||
| 127 | NvCore::NvMap& nvmap; | 127 | NvCore::NvMap& nvmap; |
| 128 | NvCore::ChannelType channel_type; | 128 | NvCore::ChannelType channel_type; |
| 129 | std::array<u32, MaxSyncPoints> device_syncpoints{}; | 129 | std::array<u32, MaxSyncPoints> device_syncpoints{}; |
| 130 | std::unordered_map<DeviceFD, size_t> sessions; | 130 | std::unordered_map<DeviceFD, NvCore::SessionId> sessions; |
| 131 | }; | 131 | }; |
| 132 | }; // namespace Devices | 132 | }; // namespace Devices |
| 133 | } // namespace Service::Nvidia | 133 | } // namespace Service::Nvidia |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp index 1c88b39ab..f87d53f12 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp | |||
| @@ -44,7 +44,7 @@ NvResult nvhost_nvjpg::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 44 | return NvResult::NotImplemented; | 44 | return NvResult::NotImplemented; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void nvhost_nvjpg::OnOpen(size_t session_id, DeviceFD fd) {} | 47 | void nvhost_nvjpg::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} |
| 48 | void nvhost_nvjpg::OnClose(DeviceFD fd) {} | 48 | void nvhost_nvjpg::OnClose(DeviceFD fd) {} |
| 49 | 49 | ||
| 50 | NvResult nvhost_nvjpg::SetNVMAPfd(IoctlSetNvmapFD& params) { | 50 | NvResult nvhost_nvjpg::SetNVMAPfd(IoctlSetNvmapFD& params) { |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h index 3e33dffef..def9c254d 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h | |||
| @@ -22,7 +22,7 @@ public: | |||
| 22 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 22 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 23 | std::span<u8> inline_output) override; | 23 | std::span<u8> inline_output) override; |
| 24 | 24 | ||
| 25 | void OnOpen(size_t session_id, DeviceFD fd) override; | 25 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 26 | void OnClose(DeviceFD fd) override; | 26 | void OnClose(DeviceFD fd) override; |
| 27 | 27 | ||
| 28 | private: | 28 | private: |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp index a27bed29b..263061f1d 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp | |||
| @@ -68,7 +68,7 @@ NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu | |||
| 68 | return NvResult::NotImplemented; | 68 | return NvResult::NotImplemented; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | void nvhost_vic::OnOpen(size_t session_id, DeviceFD fd) { | 71 | void nvhost_vic::OnOpen(NvCore::SessionId session_id, DeviceFD fd) { |
| 72 | sessions[fd] = session_id; | 72 | sessions[fd] = session_id; |
| 73 | } | 73 | } |
| 74 | 74 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.h b/src/core/hle/service/nvdrv/devices/nvhost_vic.h index d70df0f20..0cc04354a 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.h | |||
| @@ -19,7 +19,7 @@ public: | |||
| 19 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 19 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 20 | std::span<u8> inline_output) override; | 20 | std::span<u8> inline_output) override; |
| 21 | 21 | ||
| 22 | void OnOpen(size_t session_id, DeviceFD fd) override; | 22 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 23 | void OnClose(DeviceFD fd) override; | 23 | void OnClose(DeviceFD fd) override; |
| 24 | }; | 24 | }; |
| 25 | } // namespace Service::Nvidia::Devices | 25 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index 08ee8ec24..da61a3bfe 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp | |||
| @@ -67,7 +67,7 @@ NvResult nvmap::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, st | |||
| 67 | return NvResult::NotImplemented; | 67 | return NvResult::NotImplemented; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | void nvmap::OnOpen(size_t session_id, DeviceFD fd) { | 70 | void nvmap::OnOpen(NvCore::SessionId session_id, DeviceFD fd) { |
| 71 | sessions[fd] = session_id; | 71 | sessions[fd] = session_id; |
| 72 | } | 72 | } |
| 73 | void nvmap::OnClose(DeviceFD fd) { | 73 | void nvmap::OnClose(DeviceFD fd) { |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h index ea5df2a9c..d07d85f88 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.h +++ b/src/core/hle/service/nvdrv/devices/nvmap.h | |||
| @@ -33,7 +33,7 @@ public: | |||
| 33 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, | 33 | NvResult Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output, |
| 34 | std::span<u8> inline_output) override; | 34 | std::span<u8> inline_output) override; |
| 35 | 35 | ||
| 36 | void OnOpen(size_t session_id, DeviceFD fd) override; | 36 | void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override; |
| 37 | void OnClose(DeviceFD fd) override; | 37 | void OnClose(DeviceFD fd) override; |
| 38 | 38 | ||
| 39 | enum class HandleParameterType : u32_le { | 39 | enum class HandleParameterType : u32_le { |
| @@ -115,7 +115,7 @@ private: | |||
| 115 | 115 | ||
| 116 | NvCore::Container& container; | 116 | NvCore::Container& container; |
| 117 | NvCore::NvMap& file; | 117 | NvCore::NvMap& file; |
| 118 | std::unordered_map<DeviceFD, size_t> sessions; | 118 | std::unordered_map<DeviceFD, NvCore::SessionId> sessions; |
| 119 | }; | 119 | }; |
| 120 | 120 | ||
| 121 | } // namespace Service::Nvidia::Devices | 121 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 5191341db..5f093c0d4 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -122,7 +122,7 @@ NvResult Module::VerifyFD(DeviceFD fd) const { | |||
| 122 | return NvResult::Success; | 122 | return NvResult::Success; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | DeviceFD Module::Open(const std::string& device_name, size_t session_id) { | 125 | DeviceFD Module::Open(const std::string& device_name, NvCore::SessionId session_id) { |
| 126 | auto it = builders.find(device_name); | 126 | auto it = builders.find(device_name); |
| 127 | if (it == builders.end()) { | 127 | if (it == builders.end()) { |
| 128 | LOG_ERROR(Service_NVDRV, "Trying to open unknown device {}", device_name); | 128 | LOG_ERROR(Service_NVDRV, "Trying to open unknown device {}", device_name); |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index d7648fb15..c594f0e5e 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -77,7 +77,7 @@ public: | |||
| 77 | NvResult VerifyFD(DeviceFD fd) const; | 77 | NvResult VerifyFD(DeviceFD fd) const; |
| 78 | 78 | ||
| 79 | /// Opens a device node and returns a file descriptor to it. | 79 | /// Opens a device node and returns a file descriptor to it. |
| 80 | DeviceFD Open(const std::string& device_name, size_t session_id); | 80 | DeviceFD Open(const std::string& device_name, NvCore::SessionId session_id); |
| 81 | 81 | ||
| 82 | /// Sends an ioctl command to the specified file descriptor. | 82 | /// Sends an ioctl command to the specified file descriptor. |
| 83 | NvResult Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output); | 83 | NvResult Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> input, std::span<u8> output); |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h index e7237c881..f2195ae1e 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.h +++ b/src/core/hle/service/nvdrv/nvdrv_interface.h | |||
| @@ -35,7 +35,7 @@ private: | |||
| 35 | 35 | ||
| 36 | u64 pid{}; | 36 | u64 pid{}; |
| 37 | bool is_initialized{}; | 37 | bool is_initialized{}; |
| 38 | size_t session_id{}; | 38 | NvCore::SessionId session_id{}; |
| 39 | Common::ScratchBuffer<u8> output_buffer; | 39 | Common::ScratchBuffer<u8> output_buffer; |
| 40 | Common::ScratchBuffer<u8> inline_output_buffer; | 40 | Common::ScratchBuffer<u8> inline_output_buffer; |
| 41 | }; | 41 | }; |
diff --git a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h index d2ec7a9b9..033bf4bbe 100644 --- a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h +++ b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/math_util.h" | 6 | #include "common/math_util.h" |
| 7 | #include "core/hle/service/nvdrv/core/container.h" | ||
| 7 | #include "core/hle/service/nvdrv/nvdata.h" | 8 | #include "core/hle/service/nvdrv/nvdata.h" |
| 8 | #include "core/hle/service/nvnflinger/nvnflinger.h" | 9 | #include "core/hle/service/nvnflinger/nvnflinger.h" |
| 9 | #include "core/hle/service/nvnflinger/ui/fence.h" | 10 | #include "core/hle/service/nvnflinger/ui/fence.h" |
| @@ -55,7 +56,7 @@ private: | |||
| 55 | u32 m_buffer_nvmap_handle = 0; | 56 | u32 m_buffer_nvmap_handle = 0; |
| 56 | SharedMemoryPoolLayout m_pool_layout = {}; | 57 | SharedMemoryPoolLayout m_pool_layout = {}; |
| 57 | Nvidia::DeviceFD m_nvmap_fd = {}; | 58 | Nvidia::DeviceFD m_nvmap_fd = {}; |
| 58 | size_t m_session_id = {}; | 59 | Nvidia::NvCore::SessionId m_session_id = {}; |
| 59 | std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group; | 60 | std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group; |
| 60 | 61 | ||
| 61 | std::mutex m_guard; | 62 | std::mutex m_guard; |
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index e4b38ae0b..423b9aef1 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp | |||
| @@ -126,7 +126,7 @@ void Nvnflinger::ShutdownLayers() { | |||
| 126 | 126 | ||
| 127 | void Nvnflinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { | 127 | void Nvnflinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { |
| 128 | nvdrv = std::move(instance); | 128 | nvdrv = std::move(instance); |
| 129 | disp_fd = nvdrv->Open("/dev/nvdisp_disp0", 0); | 129 | disp_fd = nvdrv->Open("/dev/nvdisp_disp0", {}); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | std::optional<u64> Nvnflinger::OpenDisplay(std::string_view name) { | 132 | std::optional<u64> Nvnflinger::OpenDisplay(std::string_view name) { |