2018-01-13 22:22:39 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2018-01-08 03:25:57 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-02-14 06:51:42 +01:00
|
|
|
#include <cinttypes>
|
2018-01-08 03:25:57 +01:00
|
|
|
#include "common/logging/log.h"
|
2018-08-28 18:30:33 +02:00
|
|
|
#include "core/core.h"
|
2018-01-08 03:25:57 +01:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2020-12-31 08:01:08 +01:00
|
|
|
#include "core/hle/kernel/k_thread.h"
|
2018-11-27 00:34:07 +01:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
|
|
|
#include "core/hle/kernel/readable_event.h"
|
|
|
|
#include "core/hle/kernel/writable_event.h"
|
2018-01-16 00:30:49 +01:00
|
|
|
#include "core/hle/service/nvdrv/interface.h"
|
2019-06-08 00:41:55 +02:00
|
|
|
#include "core/hle/service/nvdrv/nvdata.h"
|
2018-01-08 03:25:57 +01:00
|
|
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
|
|
|
|
2018-04-20 03:41:44 +02:00
|
|
|
namespace Service::Nvidia {
|
2018-01-08 03:25:57 +01:00
|
|
|
|
2019-06-12 13:52:49 +02:00
|
|
|
void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
|
|
|
|
nvdrv->SignalSyncpt(syncpoint_id, value);
|
2019-06-08 00:41:55 +02:00
|
|
|
}
|
|
|
|
|
2018-01-16 00:30:49 +01:00
|
|
|
void NVDRV::Open(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_DEBUG(Service_NVDRV, "called");
|
2018-01-08 03:25:57 +01:00
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
if (!is_initialized) {
|
2020-11-08 09:11:34 +01:00
|
|
|
ServiceError(ctx, NvResult::NotInitialized);
|
|
|
|
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-14 05:16:19 +01:00
|
|
|
const auto& buffer = ctx.ReadBuffer();
|
2020-11-08 09:11:34 +01:00
|
|
|
const std::string device_name(buffer.begin(), buffer.end());
|
|
|
|
DeviceFD fd = nvdrv->Open(device_name);
|
2018-01-08 03:25:57 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-01-08 03:25:57 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-08 09:11:34 +01:00
|
|
|
rb.Push<DeviceFD>(fd);
|
|
|
|
rb.PushEnum(fd != INVALID_NVDRV_FD ? NvResult::Success : NvResult::FileOperationFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NVDRV::ServiceError(Kernel::HLERequestContext& ctx, NvResult result) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(result);
|
2018-01-08 03:25:57 +01:00
|
|
|
}
|
|
|
|
|
2020-11-08 09:11:34 +01:00
|
|
|
void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) {
|
2018-01-08 03:25:57 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
2020-11-08 09:11:34 +01:00
|
|
|
const auto fd = rp.Pop<DeviceFD>();
|
|
|
|
const auto command = rp.PopRaw<Ioctl>();
|
|
|
|
LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
|
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
if (!is_initialized) {
|
2020-11-08 09:11:34 +01:00
|
|
|
ServiceError(ctx, NvResult::NotInitialized);
|
|
|
|
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
|
|
|
|
return;
|
2019-09-19 07:37:25 +02:00
|
|
|
}
|
|
|
|
|
2020-11-08 09:11:34 +01:00
|
|
|
// Check device
|
|
|
|
std::vector<u8> output_buffer(ctx.GetWriteBufferSize(0));
|
|
|
|
const auto input_buffer = ctx.ReadBuffer(0);
|
2019-09-19 07:37:25 +02:00
|
|
|
|
2020-12-12 01:04:46 +01:00
|
|
|
const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, output_buffer);
|
|
|
|
if (command.is_out != 0) {
|
|
|
|
ctx.WriteBuffer(output_buffer);
|
2019-06-16 17:43:41 +02:00
|
|
|
}
|
2020-11-08 09:11:34 +01:00
|
|
|
|
2019-07-04 16:19:25 +02:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-08 09:11:34 +01:00
|
|
|
rb.PushEnum(nv_result);
|
2019-09-19 07:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) {
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto fd = rp.Pop<DeviceFD>();
|
|
|
|
const auto command = rp.PopRaw<Ioctl>();
|
|
|
|
LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
|
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
if (!is_initialized) {
|
2020-11-08 09:11:34 +01:00
|
|
|
ServiceError(ctx, NvResult::NotInitialized);
|
|
|
|
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto input_buffer = ctx.ReadBuffer(0);
|
|
|
|
const auto input_inlined_buffer = ctx.ReadBuffer(1);
|
|
|
|
std::vector<u8> output_buffer(ctx.GetWriteBufferSize(0));
|
|
|
|
|
|
|
|
const auto nv_result =
|
2020-12-12 01:04:46 +01:00
|
|
|
nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, output_buffer);
|
2020-11-08 09:11:34 +01:00
|
|
|
if (command.is_out != 0) {
|
|
|
|
ctx.WriteBuffer(output_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(nv_result);
|
2019-09-19 07:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) {
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto fd = rp.Pop<DeviceFD>();
|
|
|
|
const auto command = rp.PopRaw<Ioctl>();
|
|
|
|
LOG_DEBUG(Service_NVDRV, "called fd={}, ioctl=0x{:08X}", fd, command.raw);
|
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
if (!is_initialized) {
|
2020-11-08 09:11:34 +01:00
|
|
|
ServiceError(ctx, NvResult::NotInitialized);
|
|
|
|
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto input_buffer = ctx.ReadBuffer(0);
|
|
|
|
std::vector<u8> output_buffer(ctx.GetWriteBufferSize(0));
|
|
|
|
std::vector<u8> output_buffer_inline(ctx.GetWriteBufferSize(1));
|
|
|
|
|
|
|
|
const auto nv_result =
|
2020-12-12 01:04:46 +01:00
|
|
|
nvdrv->Ioctl3(fd, command, input_buffer, output_buffer, output_buffer_inline);
|
|
|
|
if (command.is_out != 0) {
|
|
|
|
ctx.WriteBuffer(output_buffer, 0);
|
|
|
|
ctx.WriteBuffer(output_buffer_inline, 1);
|
2020-11-08 09:11:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(nv_result);
|
2019-09-19 07:37:25 +02:00
|
|
|
}
|
|
|
|
|
2018-01-17 17:08:46 +01:00
|
|
|
void NVDRV::Close(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_DEBUG(Service_NVDRV, "called");
|
2018-01-17 17:08:46 +01:00
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
if (!is_initialized) {
|
2020-11-08 09:11:34 +01:00
|
|
|
ServiceError(ctx, NvResult::NotInitialized);
|
|
|
|
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
|
|
|
|
return;
|
|
|
|
}
|
2018-01-17 17:08:46 +01:00
|
|
|
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto fd = rp.Pop<DeviceFD>();
|
|
|
|
const auto result = nvdrv->Close(fd);
|
2018-01-17 17:08:46 +01:00
|
|
|
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(result);
|
2018-01-17 17:08:46 +01:00
|
|
|
}
|
|
|
|
|
2018-01-16 00:30:49 +01:00
|
|
|
void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-11-26 07:06:13 +01:00
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
is_initialized = true;
|
2020-11-08 09:11:34 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-01-08 03:25:57 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-08 09:11:34 +01:00
|
|
|
rb.PushEnum(NvResult::Success);
|
2018-01-08 03:25:57 +01:00
|
|
|
}
|
|
|
|
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2020-11-08 09:11:34 +01:00
|
|
|
const auto fd = rp.Pop<DeviceFD>();
|
|
|
|
const auto event_id = rp.Pop<u32>() & 0x00FF;
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd={:X}, event_id={:X}", fd, event_id);
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
if (!is_initialized) {
|
2020-11-08 09:11:34 +01:00
|
|
|
ServiceError(ctx, NvResult::NotInitialized);
|
|
|
|
LOG_ERROR(Service_NVDRV, "NvServices is not initalized!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-10 05:56:41 +01:00
|
|
|
const auto nv_result = nvdrv->VerifyFD(fd);
|
2020-11-08 09:11:34 +01:00
|
|
|
if (nv_result != NvResult::Success) {
|
|
|
|
LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd);
|
|
|
|
ServiceError(ctx, nv_result);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-01 17:10:27 +02:00
|
|
|
if (event_id < MaxNvEvents) {
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-09-27 00:11:27 +02:00
|
|
|
auto event = nvdrv->GetEvent(event_id);
|
|
|
|
event->Clear();
|
|
|
|
rb.PushCopyObjects(event);
|
2020-11-08 09:11:34 +01:00
|
|
|
rb.PushEnum(NvResult::Success);
|
2019-06-08 00:41:55 +02:00
|
|
|
} else {
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(NvResult::BadParameter);
|
2019-06-08 00:41:55 +02:00
|
|
|
}
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
}
|
|
|
|
|
2020-06-29 04:01:34 +02:00
|
|
|
void NVDRV::SetAruid(Kernel::HLERequestContext& ctx) {
|
2018-01-19 05:50:18 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
2018-01-21 23:59:50 +01:00
|
|
|
pid = rp.Pop<u64>();
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called, pid=0x{:X}", pid);
|
2018-11-26 07:06:13 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-01-19 05:50:18 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-08 09:11:34 +01:00
|
|
|
rb.PushEnum(NvResult::Success);
|
2018-01-19 05:50:18 +01:00
|
|
|
}
|
|
|
|
|
2020-06-29 04:01:34 +02:00
|
|
|
void NVDRV::SetGraphicsFirmwareMemoryMarginEnabled(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-11-26 07:06:13 +01:00
|
|
|
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-11-23 20:55:41 +01:00
|
|
|
void NVDRV::GetStatus(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-11-26 07:06:13 +01:00
|
|
|
|
2020-11-08 09:11:34 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-11-23 20:55:41 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-08 09:11:34 +01:00
|
|
|
rb.PushEnum(NvResult::Success);
|
2018-11-23 20:55:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NVDRV::DumpGraphicsMemoryInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
// According to SwitchBrew, this has no inputs and no outputs, so effectively does nothing on
|
|
|
|
// retail hardware.
|
|
|
|
LOG_DEBUG(Service_NVDRV, "called");
|
2018-11-26 07:06:13 +01:00
|
|
|
|
2018-11-23 20:55:41 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-11-26 21:19:08 +01:00
|
|
|
NVDRV::NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name)
|
|
|
|
: ServiceFramework{system_, name}, nvdrv{std::move(nvdrv_)} {
|
2018-01-08 03:25:57 +01:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-01-16 00:30:49 +01:00
|
|
|
{0, &NVDRV::Open, "Open"},
|
2020-11-08 09:11:34 +01:00
|
|
|
{1, &NVDRV::Ioctl1, "Ioctl"},
|
2018-01-17 17:08:46 +01:00
|
|
|
{2, &NVDRV::Close, "Close"},
|
2018-01-16 00:30:49 +01:00
|
|
|
{3, &NVDRV::Initialize, "Initialize"},
|
Extra nvdrv support (#162)
* FinishInitalize needed for 3.0.1+ games
* nvdrv:s and nvdrv:t both use NVDRV
* Most settings return 0 on hardware, disabled NV_MEMORY_PROFILER for now.
NVN_THROUGH_OPENGL & NVRM_GPU_PREVENT_USE are a few interesting settings to look at. Carefully choosing settings can help with drawing graphics later on
* Initial /dev/nvhost-gpu support
* ZCullBind
* Stubbed SetErrorNotifier
* Fixed SetErrorNotifier log, Added SetChannelPriority
* Allocate GPFIFO Ex2, Allocate Obj Ctx, Submit GPFIFO
* oops
* Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry"
* Added missing fixes
* /dev/nvhost-ctrl-gpu
* unneeded struct
* Forgot u32 in enum class
* Automatic descriptor swapping for ioctls, fixed nvgpu_gpu_get_tpc_masks_args being incorrect size
* nvdrv#QueryEvent
* Renamed logs for nvdrv
* Refactor ioctl so nv_result isn't needed
* /dev/nvhost-as-gpu
* Fixed Log service naming, CtxObjects now u32, renamed all structs, added static_asserts to structs, used INSERT_PADDING_WORDS instead of u32s
* nvdevices now uses "Ioctl" union,
* IoctlGpfifoEntry now uses bit field
* final changes
2018-02-06 03:19:31 +01:00
|
|
|
{4, &NVDRV::QueryEvent, "QueryEvent"},
|
2018-04-10 19:26:49 +02:00
|
|
|
{5, nullptr, "MapSharedMem"},
|
2018-11-23 20:55:41 +01:00
|
|
|
{6, &NVDRV::GetStatus, "GetStatus"},
|
2020-06-29 04:01:34 +02:00
|
|
|
{7, nullptr, "SetAruidForTest"},
|
|
|
|
{8, &NVDRV::SetAruid, "SetAruid"},
|
2018-11-23 20:55:41 +01:00
|
|
|
{9, &NVDRV::DumpGraphicsMemoryInfo, "DumpGraphicsMemoryInfo"},
|
2018-04-10 19:26:49 +02:00
|
|
|
{10, nullptr, "InitializeDevtools"},
|
2019-09-19 07:37:25 +02:00
|
|
|
{11, &NVDRV::Ioctl2, "Ioctl2"},
|
|
|
|
{12, &NVDRV::Ioctl3, "Ioctl3"},
|
2020-06-29 04:01:34 +02:00
|
|
|
{13, &NVDRV::SetGraphicsFirmwareMemoryMarginEnabled,
|
|
|
|
"SetGraphicsFirmwareMemoryMarginEnabled"},
|
2018-01-08 03:25:57 +01:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 03:20:52 +02:00
|
|
|
NVDRV::~NVDRV() = default;
|
|
|
|
|
2018-04-20 03:41:44 +02:00
|
|
|
} // namespace Service::Nvidia
|