From 4aef24ba32df2364ce428f93e7e5504faf2061b3 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 31 Aug 2022 15:16:41 +0100 Subject: [PATCH] Implement NVGPU_GPU_IOCTL_GET_GPU_TIME in nvdrv --- .../skyline/services/nvdrv/devices/nvhost/ctrl_gpu.cpp | 8 ++++++++ .../cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.cpp index bce3b770..193f3af0 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT OR MPL-2.0 // Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) +#include #include #include "ctrl_gpu.h" @@ -55,6 +56,11 @@ namespace skyline::service::nvdrv::device::nvhost { return PosixResult::Success; } + PosixResult CtrlGpu::GetGpuTime(Out time) { + time = static_cast(util::GetTimeNs()); + return PosixResult::Success; + } + std::shared_ptr CtrlGpu::QueryEvent(u32 eventId) { switch (eventId) { case 1: @@ -82,6 +88,8 @@ namespace skyline::service::nvdrv::device::nvhost { GetTpcMasks, ARGS(In, Pad, Out)) IOCTL_CASE_ARGS(OUT, SIZE(0x8), MAGIC(CtrlGpuMagic), FUNC(0x14), GetActiveSlotMask, ARGS(Out, Out)) + IOCTL_CASE_ARGS(INOUT, SIZE(0x10), MAGIC(CtrlGpuMagic), FUNC(0x1C), + GetGpuTime, ARGS(Out, Pad)) })) INLINE_IOCTL_HANDLER_FUNC(Ioctl3, CtrlGpu, ({ diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.h index 127046fd..52a4f4e2 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl_gpu.h @@ -123,6 +123,11 @@ namespace skyline::service::nvdrv::device::nvhost { */ PosixResult GetActiveSlotMask(Out slot, Out mask); + /** + * @url https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_GET_GPU_TIME + */ + PosixResult GetGpuTime(Out time); + std::shared_ptr QueryEvent(u32 eventId) override; PosixResult Ioctl(IoctlDescriptor cmd, span buffer) override;