mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-27 11:52:31 -06:00
nvdrv: convert nvhost_gpu
This commit is contained in:
parent
789d9c8af9
commit
7a84a1a974
2 changed files with 49 additions and 76 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include "core/hle/service/nvdrv/core/container.h"
|
#include "core/hle/service/nvdrv/core/container.h"
|
||||||
#include "core/hle/service/nvdrv/core/nvmap.h"
|
#include "core/hle/service/nvdrv/core/nvmap.h"
|
||||||
#include "core/hle/service/nvdrv/core/syncpoint_manager.h"
|
#include "core/hle/service/nvdrv/core/syncpoint_manager.h"
|
||||||
|
#include "core/hle/service/nvdrv/devices/ioctl_serialization.h"
|
||||||
#include "core/hle/service/nvdrv/devices/nvhost_gpu.h"
|
#include "core/hle/service/nvdrv/devices/nvhost_gpu.h"
|
||||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
@ -52,7 +53,7 @@ NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||||
case 0x0:
|
case 0x0:
|
||||||
switch (command.cmd) {
|
switch (command.cmd) {
|
||||||
case 0x3:
|
case 0x3:
|
||||||
return GetWaitbase(input, output);
|
return Wrap1(&nvhost_gpu::GetWaitbase, input, output);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -60,25 +61,25 @@ NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||||
case 'H':
|
case 'H':
|
||||||
switch (command.cmd) {
|
switch (command.cmd) {
|
||||||
case 0x1:
|
case 0x1:
|
||||||
return SetNVMAPfd(input, output);
|
return Wrap1(&nvhost_gpu::SetNVMAPfd, input, output);
|
||||||
case 0x3:
|
case 0x3:
|
||||||
return ChannelSetTimeout(input, output);
|
return Wrap1(&nvhost_gpu::ChannelSetTimeout, input, output);
|
||||||
case 0x8:
|
case 0x8:
|
||||||
return SubmitGPFIFOBase(input, output, false);
|
return SubmitGPFIFOBase1(input, output, false);
|
||||||
case 0x9:
|
case 0x9:
|
||||||
return AllocateObjectContext(input, output);
|
return Wrap1(&nvhost_gpu::AllocateObjectContext, input, output);
|
||||||
case 0xb:
|
case 0xb:
|
||||||
return ZCullBind(input, output);
|
return Wrap1(&nvhost_gpu::ZCullBind, input, output);
|
||||||
case 0xc:
|
case 0xc:
|
||||||
return SetErrorNotifier(input, output);
|
return Wrap1(&nvhost_gpu::SetErrorNotifier, input, output);
|
||||||
case 0xd:
|
case 0xd:
|
||||||
return SetChannelPriority(input, output);
|
return Wrap1(&nvhost_gpu::SetChannelPriority, input, output);
|
||||||
case 0x1a:
|
case 0x1a:
|
||||||
return AllocGPFIFOEx2(input, output);
|
return Wrap1(&nvhost_gpu::AllocGPFIFOEx2, input, output);
|
||||||
case 0x1b:
|
case 0x1b:
|
||||||
return SubmitGPFIFOBase(input, output, true);
|
return SubmitGPFIFOBase1(input, output, true);
|
||||||
case 0x1d:
|
case 0x1d:
|
||||||
return ChannelSetTimeslice(input, output);
|
return Wrap1(&nvhost_gpu::ChannelSetTimeslice, input, output);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -86,9 +87,9 @@ NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||||
case 'G':
|
case 'G':
|
||||||
switch (command.cmd) {
|
switch (command.cmd) {
|
||||||
case 0x14:
|
case 0x14:
|
||||||
return SetClientData(input, output);
|
return Wrap1(&nvhost_gpu::SetClientData, input, output);
|
||||||
case 0x15:
|
case 0x15:
|
||||||
return GetClientData(input, output);
|
return Wrap1(&nvhost_gpu::GetClientData, input, output);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,7 @@ NvResult nvhost_gpu::Ioctl2(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||||
case 'H':
|
case 'H':
|
||||||
switch (command.cmd) {
|
switch (command.cmd) {
|
||||||
case 0x1b:
|
case 0x1b:
|
||||||
return SubmitGPFIFOBase(input, inline_input, output);
|
return SubmitGPFIFOBase2(input, inline_input, output);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -121,63 +122,45 @@ NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
|
||||||
void nvhost_gpu::OnOpen(DeviceFD fd) {}
|
void nvhost_gpu::OnOpen(DeviceFD fd) {}
|
||||||
void nvhost_gpu::OnClose(DeviceFD fd) {}
|
void nvhost_gpu::OnClose(DeviceFD fd) {}
|
||||||
|
|
||||||
NvResult nvhost_gpu::SetNVMAPfd(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) {
|
||||||
IoctlSetNvmapFD params{};
|
|
||||||
std::memcpy(¶ms, input.data(), input.size());
|
|
||||||
LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd);
|
LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd);
|
||||||
|
|
||||||
nvmap_fd = params.nvmap_fd;
|
nvmap_fd = params.nvmap_fd;
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::SetClientData(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::SetClientData(IoctlClientData& params) {
|
||||||
LOG_DEBUG(Service_NVDRV, "called");
|
LOG_DEBUG(Service_NVDRV, "called");
|
||||||
|
|
||||||
IoctlClientData params{};
|
|
||||||
std::memcpy(¶ms, input.data(), std::min(sizeof(IoctlClientData), input.size()));
|
|
||||||
user_data = params.data;
|
user_data = params.data;
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::GetClientData(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::GetClientData(IoctlClientData& params) {
|
||||||
LOG_DEBUG(Service_NVDRV, "called");
|
LOG_DEBUG(Service_NVDRV, "called");
|
||||||
|
|
||||||
IoctlClientData params{};
|
|
||||||
std::memcpy(¶ms, input.data(), std::min(sizeof(IoctlClientData), input.size()));
|
|
||||||
params.data = user_data;
|
params.data = user_data;
|
||||||
std::memcpy(output.data(), ¶ms, std::min(sizeof(IoctlClientData), output.size()));
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::ZCullBind(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::ZCullBind(IoctlZCullBind& params) {
|
||||||
std::memcpy(&zcull_params, input.data(), input.size());
|
zcull_params = params;
|
||||||
LOG_DEBUG(Service_NVDRV, "called, gpu_va={:X}, mode={:X}", zcull_params.gpu_va,
|
LOG_DEBUG(Service_NVDRV, "called, gpu_va={:X}, mode={:X}", zcull_params.gpu_va,
|
||||||
zcull_params.mode);
|
zcull_params.mode);
|
||||||
|
|
||||||
std::memcpy(output.data(), &zcull_params, output.size());
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::SetErrorNotifier(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::SetErrorNotifier(IoctlSetErrorNotifier& params) {
|
||||||
IoctlSetErrorNotifier params{};
|
|
||||||
std::memcpy(¶ms, input.data(), input.size());
|
|
||||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset={:X}, size={:X}, mem={:X}", params.offset,
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset={:X}, size={:X}, mem={:X}", params.offset,
|
||||||
params.size, params.mem);
|
params.size, params.mem);
|
||||||
|
|
||||||
std::memcpy(output.data(), ¶ms, output.size());
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::SetChannelPriority(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::SetChannelPriority(IoctlChannelSetPriority& params) {
|
||||||
std::memcpy(&channel_priority, input.data(), input.size());
|
channel_priority = params.priority;
|
||||||
LOG_DEBUG(Service_NVDRV, "(STUBBED) called, priority={:X}", channel_priority);
|
LOG_DEBUG(Service_NVDRV, "(STUBBED) called, priority={:X}", channel_priority);
|
||||||
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::AllocGPFIFOEx2(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params) {
|
||||||
IoctlAllocGpfifoEx2 params{};
|
|
||||||
std::memcpy(¶ms, input.data(), input.size());
|
|
||||||
LOG_WARNING(Service_NVDRV,
|
LOG_WARNING(Service_NVDRV,
|
||||||
"(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, "
|
"(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, "
|
||||||
"unk1={:X}, unk2={:X}, unk3={:X}",
|
"unk1={:X}, unk2={:X}, unk3={:X}",
|
||||||
|
@ -193,18 +176,14 @@ NvResult nvhost_gpu::AllocGPFIFOEx2(std::span<const u8> input, std::span<u8> out
|
||||||
|
|
||||||
params.fence_out = syncpoint_manager.GetSyncpointFence(channel_syncpoint);
|
params.fence_out = syncpoint_manager.GetSyncpointFence(channel_syncpoint);
|
||||||
|
|
||||||
std::memcpy(output.data(), ¶ms, output.size());
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::AllocateObjectContext(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::AllocateObjectContext(IoctlAllocObjCtx& params) {
|
||||||
IoctlAllocObjCtx params{};
|
|
||||||
std::memcpy(¶ms, input.data(), input.size());
|
|
||||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num={:X}, flags={:X}", params.class_num,
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num={:X}, flags={:X}", params.class_num,
|
||||||
params.flags);
|
params.flags);
|
||||||
|
|
||||||
params.obj_id = 0x0;
|
params.obj_id = 0x0;
|
||||||
std::memcpy(output.data(), ¶ms, output.size());
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,11 +269,10 @@ NvResult nvhost_gpu::SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, std::span<u8> o
|
||||||
|
|
||||||
flags.raw = 0;
|
flags.raw = 0;
|
||||||
|
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(IoctlSubmitGpfifo));
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::SubmitGPFIFOBase(std::span<const u8> input, std::span<u8> output,
|
NvResult nvhost_gpu::SubmitGPFIFOBase1(std::span<const u8> input, std::span<u8> output,
|
||||||
bool kickoff) {
|
bool kickoff) {
|
||||||
if (input.size() < sizeof(IoctlSubmitGpfifo)) {
|
if (input.size() < sizeof(IoctlSubmitGpfifo)) {
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
|
@ -315,7 +293,7 @@ NvResult nvhost_gpu::SubmitGPFIFOBase(std::span<const u8> input, std::span<u8> o
|
||||||
return SubmitGPFIFOImpl(params, output, std::move(entries));
|
return SubmitGPFIFOImpl(params, output, std::move(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::SubmitGPFIFOBase(std::span<const u8> input, std::span<const u8> input_inline,
|
NvResult nvhost_gpu::SubmitGPFIFOBase2(std::span<const u8> input, std::span<const u8> input_inline,
|
||||||
std::span<u8> output) {
|
std::span<u8> output) {
|
||||||
if (input.size() < sizeof(IoctlSubmitGpfifo)) {
|
if (input.size() < sizeof(IoctlSubmitGpfifo)) {
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
|
@ -328,27 +306,20 @@ NvResult nvhost_gpu::SubmitGPFIFOBase(std::span<const u8> input, std::span<const
|
||||||
return SubmitGPFIFOImpl(params, output, std::move(entries));
|
return SubmitGPFIFOImpl(params, output, std::move(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::GetWaitbase(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::GetWaitbase(IoctlGetWaitbase& params) {
|
||||||
IoctlGetWaitbase params{};
|
|
||||||
std::memcpy(¶ms, input.data(), sizeof(IoctlGetWaitbase));
|
|
||||||
LOG_INFO(Service_NVDRV, "called, unknown=0x{:X}", params.unknown);
|
LOG_INFO(Service_NVDRV, "called, unknown=0x{:X}", params.unknown);
|
||||||
|
|
||||||
params.value = 0; // Seems to be hard coded at 0
|
params.value = 0; // Seems to be hard coded at 0
|
||||||
std::memcpy(output.data(), ¶ms, output.size());
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::ChannelSetTimeout(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::ChannelSetTimeout(IoctlChannelSetTimeout& params) {
|
||||||
IoctlChannelSetTimeout params{};
|
|
||||||
std::memcpy(¶ms, input.data(), sizeof(IoctlChannelSetTimeout));
|
|
||||||
LOG_INFO(Service_NVDRV, "called, timeout=0x{:X}", params.timeout);
|
LOG_INFO(Service_NVDRV, "called, timeout=0x{:X}", params.timeout);
|
||||||
|
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvResult nvhost_gpu::ChannelSetTimeslice(std::span<const u8> input, std::span<u8> output) {
|
NvResult nvhost_gpu::ChannelSetTimeslice(IoctlSetTimeslice& params) {
|
||||||
IoctlSetTimeslice params{};
|
|
||||||
std::memcpy(¶ms, input.data(), sizeof(IoctlSetTimeslice));
|
|
||||||
LOG_INFO(Service_NVDRV, "called, timeslice=0x{:X}", params.timeslice);
|
LOG_INFO(Service_NVDRV, "called, timeslice=0x{:X}", params.timeslice);
|
||||||
|
|
||||||
channel_timeslice = params.timeslice;
|
channel_timeslice = params.timeslice;
|
||||||
|
|
|
@ -186,23 +186,25 @@ private:
|
||||||
u32_le channel_priority{};
|
u32_le channel_priority{};
|
||||||
u32_le channel_timeslice{};
|
u32_le channel_timeslice{};
|
||||||
|
|
||||||
NvResult SetNVMAPfd(std::span<const u8> input, std::span<u8> output);
|
NvResult SetNVMAPfd(IoctlSetNvmapFD& params);
|
||||||
NvResult SetClientData(std::span<const u8> input, std::span<u8> output);
|
NvResult SetClientData(IoctlClientData& params);
|
||||||
NvResult GetClientData(std::span<const u8> input, std::span<u8> output);
|
NvResult GetClientData(IoctlClientData& params);
|
||||||
NvResult ZCullBind(std::span<const u8> input, std::span<u8> output);
|
NvResult ZCullBind(IoctlZCullBind& params);
|
||||||
NvResult SetErrorNotifier(std::span<const u8> input, std::span<u8> output);
|
NvResult SetErrorNotifier(IoctlSetErrorNotifier& params);
|
||||||
NvResult SetChannelPriority(std::span<const u8> input, std::span<u8> output);
|
NvResult SetChannelPriority(IoctlChannelSetPriority& params);
|
||||||
NvResult AllocGPFIFOEx2(std::span<const u8> input, std::span<u8> output);
|
NvResult AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params);
|
||||||
NvResult AllocateObjectContext(std::span<const u8> input, std::span<u8> output);
|
NvResult AllocateObjectContext(IoctlAllocObjCtx& params);
|
||||||
|
|
||||||
NvResult SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, std::span<u8> output,
|
NvResult SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, std::span<u8> output,
|
||||||
Tegra::CommandList&& entries);
|
Tegra::CommandList&& entries);
|
||||||
NvResult SubmitGPFIFOBase(std::span<const u8> input, std::span<u8> output,
|
NvResult SubmitGPFIFOBase1(std::span<const u8> input, std::span<u8> output,
|
||||||
bool kickoff = false);
|
bool kickoff = false);
|
||||||
NvResult SubmitGPFIFOBase(std::span<const u8> input, std::span<const u8> input_inline,
|
NvResult SubmitGPFIFOBase2(std::span<const u8> input, std::span<const u8> input_inline,
|
||||||
std::span<u8> output);
|
std::span<u8> output);
|
||||||
NvResult GetWaitbase(std::span<const u8> input, std::span<u8> output);
|
|
||||||
NvResult ChannelSetTimeout(std::span<const u8> input, std::span<u8> output);
|
NvResult GetWaitbase(IoctlGetWaitbase& params);
|
||||||
NvResult ChannelSetTimeslice(std::span<const u8> input, std::span<u8> output);
|
NvResult ChannelSetTimeout(IoctlChannelSetTimeout& params);
|
||||||
|
NvResult ChannelSetTimeslice(IoctlSetTimeslice& params);
|
||||||
|
|
||||||
EventInterface& events_interface;
|
EventInterface& events_interface;
|
||||||
NvCore::Container& core;
|
NvCore::Container& core;
|
||||||
|
|
Loading…
Reference in a new issue