diff options
Diffstat (limited to 'src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp')
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 48 |
1 files changed, 27 insertions, 21 deletions
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 f2529a12e..3a5bebff3 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -155,7 +155,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou const auto object{nvmap_dev->GetObject(params.nvmap_handle)}; if (!object) { - LOG_CRITICAL(Service_NVDRV, "invalid nvmap_handle={:X}", params.nvmap_handle); + LOG_ERROR(Service_NVDRV, "invalid nvmap_handle={:X}", params.nvmap_handle); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; } @@ -167,21 +167,24 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou auto& gpu = system.GPU(); u64 page_size{params.page_size}; - if (!page_size) { + if (page_size == 0) { page_size = object->align; } if ((params.flags & AddressSpaceFlags::Remap) != AddressSpaceFlags::None) { - if (const auto buffer_map{FindBufferMap(params.offset)}; buffer_map) { - const auto cpu_addr{static_cast<VAddr>(buffer_map->CpuAddr() + params.buffer_offset)}; + const auto buffer_map = FindBufferMap(static_cast<GPUVAddr>(params.offset)); + + if (buffer_map) { + const auto cpu_addr{ + static_cast<VAddr>(buffer_map->CpuAddr() + static_cast<u64>(params.buffer_offset))}; const auto gpu_addr{static_cast<GPUVAddr>(params.offset + params.buffer_offset)}; if (!gpu.MemoryManager().Map(cpu_addr, gpu_addr, params.mapping_size)) { - LOG_CRITICAL(Service_NVDRV, - "remap failed, flags={:X}, nvmap_handle={:X}, buffer_offset={}, " - "mapping_size = {}, offset={}", - params.flags, params.nvmap_handle, params.buffer_offset, - params.mapping_size, params.offset); + LOG_ERROR(Service_NVDRV, + "Remap failed, flags={:X}, nvmap_handle={:X}, buffer_offset={}, " + "mapping_size = {}, offset={}", + params.flags, params.nvmap_handle, params.buffer_offset, + params.mapping_size, params.offset); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; @@ -190,7 +193,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::Success; } else { - LOG_CRITICAL(Service_NVDRV, "address not mapped offset={}", params.offset); + LOG_ERROR(Service_NVDRV, "Address not mapped. offset={}", params.offset); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; @@ -200,25 +203,27 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou // We can only map objects that have already been assigned a CPU address. ASSERT(object->status == nvmap::Object::Status::Allocated); - const auto physical_address{object->addr + params.buffer_offset}; + const auto physical_address{object->addr + static_cast<VAddr>(params.buffer_offset)}; u64 size{params.mapping_size}; - if (!size) { + if (size == 0) { size = object->size; } const bool is_alloc{(params.flags & AddressSpaceFlags::FixedOffset) == AddressSpaceFlags::None}; if (is_alloc) { - params.offset = gpu.MemoryManager().MapAllocate(physical_address, size, page_size); + params.offset = + static_cast<s64>(gpu.MemoryManager().MapAllocate(physical_address, size, page_size)); } else { - params.offset = gpu.MemoryManager().Map(physical_address, params.offset, size); + params.offset = static_cast<s64>( + gpu.MemoryManager().Map(physical_address, static_cast<GPUVAddr>(params.offset), size)); } auto result{NvErrCodes::Success}; - if (!params.offset) { - LOG_CRITICAL(Service_NVDRV, "failed to map size={}", size); + if (params.offset == 0) { + LOG_ERROR(Service_NVDRV, "Failed to map size={}", size); result = NvErrCodes::InvalidInput; } else { - AddBufferMap(params.offset, size, physical_address, is_alloc); + AddBufferMap(static_cast<GPUVAddr>(params.offset), size, physical_address, is_alloc); } std::memcpy(output.data(), ¶ms, output.size()); @@ -229,12 +234,13 @@ u32 nvhost_as_gpu::UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& ou IoctlUnmapBuffer params{}; std::memcpy(¶ms, input.data(), input.size()); - LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", params.offset); + const auto offset = static_cast<GPUVAddr>(params.offset); + LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", offset); - if (const auto size{RemoveBufferMap(params.offset)}; size) { - system.GPU().MemoryManager().Unmap(params.offset, *size); + if (const auto size{RemoveBufferMap(offset)}; size) { + system.GPU().MemoryManager().Unmap(offset, *size); } else { - LOG_ERROR(Service_NVDRV, "invalid offset=0x{:X}", params.offset); + LOG_ERROR(Service_NVDRV, "invalid offset=0x{:X}", offset); } std::memcpy(output.data(), ¶ms, output.size()); |