From fc4d692c503ca11a9339f0464520caf88d8474de Mon Sep 17 00:00:00 2001 From: Chloe Marcec Date: Tue, 10 Nov 2020 15:56:41 +1100 Subject: Addressed issues --- src/core/hle/service/nvdrv/devices/nvdevice.h | 25 ++++++++++++++++++++++ .../hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 7 ++++++ .../service/nvdrv/devices/nvhost_nvdec_common.h | 25 ++++++++++++++++++++++ .../hle/service/nvdrv/devices/nvhost_nvjpg.cpp | 3 ++- src/core/hle/service/nvdrv/devices/nvhost_vic.cpp | 7 ++++++ src/core/hle/service/nvdrv/devices/nvmap.cpp | 5 +++++ src/core/hle/service/nvdrv/interface.cpp | 17 +++++++-------- src/core/hle/service/nvdrv/interface.h | 2 +- src/core/hle/service/nvdrv/nvdrv.cpp | 10 ++++----- src/core/hle/service/nvdrv/nvdrv.h | 2 +- 10 files changed, 86 insertions(+), 17 deletions(-) diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index b86805d26..5681599ba 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h @@ -24,10 +24,35 @@ public: explicit nvdevice(Core::System& system) : system{system} {} virtual ~nvdevice() = default; + /** + * Handles an ioctl1 request. + * @param command The ioctl command id. + * @param input A buffer containing the input data for the ioctl. + * @param output A buffer where the output data will be written to. + * @returns The result code of the ioctl. + */ virtual NvResult Ioctl1(Ioctl command, const std::vector& input, std::vector& output) = 0; + + /** + * Handles an ioctl2 request. + * @param command The ioctl command id. + * @param input A buffer containing the input data for the ioctl. + * @param inline_input A buffer containing the input data for the ioctl which has been inlined. + * @param output A buffer where the output data will be written to. + * @returns The result code of the ioctl. + */ virtual NvResult Ioctl2(Ioctl command, const std::vector& input, const std::vector& inline_input, std::vector& output) = 0; + + /** + * Handles an ioctl3 request. + * @param command The ioctl command id. + * @param input A buffer containing the input data for the ioctl. + * @param output A buffer where the output data will be written to. + * @param inline_output A buffer where the inlined output data will be written to. + * @returns The result code of the ioctl. + */ virtual NvResult Ioctl3(Ioctl command, const std::vector& input, std::vector& output, std::vector& inline_output) = 0; 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 725cb7b55..6b062e10e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -42,6 +42,8 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector& input, return InitalizeEx(input, output); case 0x14: return Remap(input, output); + default: + break; } break; default: @@ -65,7 +67,12 @@ NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector& input, std: switch (command.cmd) { case 0x8: return GetVARegions(input, output, inline_output); + default: + break; } + break; + default: + break; } UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); return NvResult::NotImplemented; 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 e07d4d280..86ba3a4d1 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -18,10 +18,35 @@ public: explicit nvhost_nvdec_common(Core::System& system, std::shared_ptr nvmap_dev); ~nvhost_nvdec_common() override; + /** + * Handles an ioctl1 request. + * @param command The ioctl command id. + * @param input A buffer containing the input data for the ioctl. + * @param output A buffer where the output data will be written to. + * @returns The result code of the ioctl. + */ virtual NvResult Ioctl1(Ioctl command, const std::vector& input, std::vector& output) = 0; + + /** + * Handles an ioctl2 request. + * @param command The ioctl command id. + * @param input A buffer containing the input data for the ioctl. + * @param inline_input A buffer containing the input data for the ioctl which has been inlined. + * @param output A buffer where the output data will be written to. + * @returns The result code of the ioctl. + */ virtual NvResult Ioctl2(Ioctl command, const std::vector& input, const std::vector& inline_input, std::vector& output) = 0; + + /** + * Handles an ioctl3 request. + * @param command The ioctl command id. + * @param input A buffer containing the input data for the ioctl. + * @param output A buffer where the output data will be written to. + * @param inline_output A buffer where the inlined output data will be written to. + * @returns The result code of the ioctl. + */ virtual NvResult Ioctl3(Ioctl command, const std::vector& input, std::vector& output, std::vector& inline_output) = 0; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp index 5bd2958cd..2d06955c0 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp @@ -15,7 +15,6 @@ nvhost_nvjpg::~nvhost_nvjpg() = default; NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector& input, std::vector& output) { - switch (command.group) { case 'H': switch (command.cmd) { @@ -25,6 +24,8 @@ NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector& input, break; } break; + default: + break; } UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp index 347638490..805fe86ae 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp @@ -29,13 +29,20 @@ NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector& input, std::ve return MapBuffer(input, output); case 0xa: return UnmapBuffer(input, output); + default: + break; } + break; case 'H': switch (command.cmd) { case 0x1: return SetNVMAPfd(input); + default: + break; } break; + default: + break; } UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index c3d324788..4015a2740 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp @@ -35,7 +35,12 @@ NvResult nvmap::Ioctl1(Ioctl command, const std::vector& input, std::vector< return IocParam(input, output); case 0xe: return IocGetId(input, output); + default: + break; } + break; + default: + break; } UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index e01ef676a..f6c38e853 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -23,7 +23,7 @@ void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) { void NVDRV::Open(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_NVDRV, "called"); - if (!initialized) { + if (!is_initialized) { ServiceError(ctx, NvResult::NotInitialized); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; @@ -51,7 +51,7 @@ void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) { const auto command = rp.PopRaw(); LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); - if (!initialized) { + if (!is_initialized) { ServiceError(ctx, NvResult::NotInitialized); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; @@ -78,7 +78,7 @@ void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) { const auto command = rp.PopRaw(); LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); - if (!initialized) { + if (!is_initialized) { ServiceError(ctx, NvResult::NotInitialized); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; @@ -106,7 +106,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) { const auto command = rp.PopRaw(); LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw); - if (!initialized) { + if (!is_initialized) { ServiceError(ctx, NvResult::NotInitialized); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; @@ -132,7 +132,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) { void NVDRV::Close(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_NVDRV, "called"); - if (!initialized) { + if (!is_initialized) { ServiceError(ctx, NvResult::NotInitialized); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; @@ -150,7 +150,7 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) { void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); - initialized = true; + is_initialized = true; IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); @@ -163,14 +163,13 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) { const auto event_id = rp.Pop() & 0x00FF; LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id); - if (!initialized) { + if (!is_initialized) { ServiceError(ctx, NvResult::NotInitialized); LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; } - auto nv_result = nvdrv->VerifyFd(fd); - + const auto nv_result = nvdrv->VerifyFD(fd); if (nv_result != NvResult::Success) { LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd); ServiceError(ctx, nv_result); diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h index d7bcf2b7e..e05f905ae 100644 --- a/src/core/hle/service/nvdrv/interface.h +++ b/src/core/hle/service/nvdrv/interface.h @@ -39,7 +39,7 @@ private: std::shared_ptr nvdrv; u64 pid{}; - bool initialized{}; + bool is_initialized{}; }; } // namespace Service::Nvidia diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 69a4b07ba..bdbbedd0d 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -62,7 +62,7 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { Module::~Module() = default; -NvResult Module::VerifyFd(DeviceFD fd) const { +NvResult Module::VerifyFD(DeviceFD fd) const { if (fd < 0) { LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); return NvResult::InvalidState; @@ -97,7 +97,7 @@ NvResult Module::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input return NvResult::InvalidState; } - auto itr = open_files.find(fd); + const auto itr = open_files.find(fd); if (itr == open_files.end()) { LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); @@ -114,7 +114,7 @@ NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector& input return NvResult::InvalidState; } - auto itr = open_files.find(fd); + const auto itr = open_files.find(fd); if (itr == open_files.end()) { LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); @@ -131,7 +131,7 @@ NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector& input return NvResult::InvalidState; } - auto itr = open_files.find(fd); + const auto itr = open_files.find(fd); if (itr == open_files.end()) { LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); @@ -147,7 +147,7 @@ NvResult Module::Close(DeviceFD fd) { return NvResult::InvalidState; } - auto itr = open_files.find(fd); + const auto itr = open_files.find(fd); if (itr == open_files.end()) { LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 3ccc62a76..7654bb026 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -112,7 +112,7 @@ public: return std::static_pointer_cast(itr->second); } - NvResult VerifyFd(DeviceFD fd) const; + NvResult VerifyFD(DeviceFD fd) const; /// Opens a device node and returns a file descriptor to it. DeviceFD Open(const std::string& device_name); -- cgit v1.2.3