summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvdrv
diff options
context:
space:
mode:
authorLC <mathew1800@gmail.com>2020-10-21 01:19:12 +0200
committerGitHub <noreply@github.com>2020-10-21 01:19:12 +0200
commit88d5140cf2f80d51dc297af3a128a4212215149f (patch)
treecd524e8ab111fba79f75a48cc672cb875251a32f /src/core/hle/service/nvdrv
parentMerge pull request #4390 from ogniK5377/get-applet-inf-stub (diff)
parentcore: Fix clang build (diff)
downloadyuzu-88d5140cf2f80d51dc297af3a128a4212215149f.tar
yuzu-88d5140cf2f80d51dc297af3a128a4212215149f.tar.gz
yuzu-88d5140cf2f80d51dc297af3a128a4212215149f.tar.bz2
yuzu-88d5140cf2f80d51dc297af3a128a4212215149f.tar.lz
yuzu-88d5140cf2f80d51dc297af3a128a4212215149f.tar.xz
yuzu-88d5140cf2f80d51dc297af3a128a4212215149f.tar.zst
yuzu-88d5140cf2f80d51dc297af3a128a4212215149f.zip
Diffstat (limited to 'src/core/hle/service/nvdrv')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp48
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp8
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp8
4 files changed, 42 insertions, 34 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(), &params, 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(), &params, 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(), &params, 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(), &params, 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(), &params, output.size());
@@ -229,12 +234,13 @@ u32 nvhost_as_gpu::UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& ou
IoctlUnmapBuffer params{};
std::memcpy(&params, 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(), &params, output.size());
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index b27ee0502..07d851d0e 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -63,8 +63,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
return NvResult::BadParameter;
}
- u32 event_id = params.value & 0x00FF;
-
+ const u32 event_id = params.value & 0x00FF;
if (event_id >= MaxNvEvents) {
std::memcpy(output.data(), &params, sizeof(params));
return NvResult::BadParameter;
@@ -78,16 +77,17 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
event.writable->Signal();
return NvResult::Success;
}
+
auto lock = gpu.LockSync();
const u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id);
- const s32 diff = current_syncpoint_value - params.threshold;
+ const s32 diff = static_cast<s32>(current_syncpoint_value - params.threshold);
if (diff >= 0) {
event.writable->Signal();
params.value = current_syncpoint_value;
std::memcpy(output.data(), &params, sizeof(params));
return NvResult::Success;
}
- const u32 target_value = current_syncpoint_value - diff;
+ const u32 target_value = current_syncpoint_value - static_cast<u32>(diff);
if (!is_async) {
params.value = 0;
@@ -98,7 +98,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
return NvResult::Timeout;
}
- EventState status = events_interface.status[event_id];
+ const EventState status = events_interface.status[event_id];
if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) {
events_interface.SetEventStatus(event_id, EventState::Waiting);
events_interface.assigned_syncpt[event_id] = params.syncpt_id;
@@ -114,7 +114,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
if (!is_async && ctrl.fresh_call) {
ctrl.must_delay = true;
ctrl.timeout = params.timeout;
- ctrl.event_id = event_id;
+ ctrl.event_id = static_cast<s32>(event_id);
return NvResult::Timeout;
}
std::memcpy(output.data(), &params, sizeof(params));
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index f1966ac0e..5e51b37be 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -127,7 +127,7 @@ u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& ou
params.unk3);
auto& gpu = system.GPU();
- params.fence_out.id = assigned_syncpoints;
+ params.fence_out.id = static_cast<s32>(assigned_syncpoints);
params.fence_out.value = gpu.GetSyncpointValue(assigned_syncpoints);
assigned_syncpoints++;
std::memcpy(output.data(), &params, output.size());
@@ -166,7 +166,8 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp
UNIMPLEMENTED_IF(params.flags.add_increment.Value() != 0);
auto& gpu = system.GPU();
- u32 current_syncpoint_value = gpu.GetSyncpointValue(params.fence_out.id);
+ const u32 current_syncpoint_value =
+ gpu.GetSyncpointValue(static_cast<u32>(params.fence_out.id));
if (params.flags.increment.Value()) {
params.fence_out.value += current_syncpoint_value;
} else {
@@ -200,7 +201,8 @@ u32 nvhost_gpu::KickoffPB(const std::vector<u8>& input, std::vector<u8>& output,
UNIMPLEMENTED_IF(params.flags.add_increment.Value() != 0);
auto& gpu = system.GPU();
- u32 current_syncpoint_value = gpu.GetSyncpointValue(params.fence_out.id);
+ const u32 current_syncpoint_value =
+ gpu.GetSyncpointValue(static_cast<u32>(params.fence_out.id));
if (params.flags.increment.Value()) {
params.fence_out.value += current_syncpoint_value;
} else {
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index 88fbfa9b0..2f4f73487 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -61,9 +61,9 @@ void NVDRV::IoctlBase(Kernel::HLERequestContext& ctx, IoctlVersion version) {
if (ctrl.must_delay) {
ctrl.fresh_call = false;
ctx.SleepClientThread(
- "NVServices::DelayedResponse", ctrl.timeout,
- [=, this](std::shared_ptr<Kernel::Thread> thread, Kernel::HLERequestContext& ctx_,
- Kernel::ThreadWakeupReason reason) {
+ "NVServices::DelayedResponse", static_cast<u64>(ctrl.timeout),
+ [=, this](std::shared_ptr<Kernel::Thread>, Kernel::HLERequestContext& ctx_,
+ Kernel::ThreadWakeupReason) {
IoctlCtrl ctrl2{ctrl};
std::vector<u8> tmp_output = output;
std::vector<u8> tmp_output2 = output2;
@@ -77,7 +77,7 @@ void NVDRV::IoctlBase(Kernel::HLERequestContext& ctx, IoctlVersion version) {
rb.Push(RESULT_SUCCESS);
rb.Push(ioctl_result);
},
- nvdrv->GetEventWriteable(ctrl.event_id));
+ nvdrv->GetEventWriteable(static_cast<u32>(ctrl.event_id)));
} else {
ctx.WriteBuffer(output);
if (version == IoctlVersion::Version3) {