2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2018-01-08 02:25:57 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/hle/ipc_helpers.h"
|
2018-01-15 23:30:49 +00:00
|
|
|
#include "core/hle/service/nvdrv/interface.h"
|
2018-01-08 02:25:57 +00:00
|
|
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
|
|
|
|
|
|
|
namespace Service {
|
2018-01-15 22:39:00 +00:00
|
|
|
namespace Nvidia {
|
2018-01-08 02:25:57 +00:00
|
|
|
|
2018-01-15 23:30:49 +00:00
|
|
|
void NVDRV::Open(Kernel::HLERequestContext& ctx) {
|
2018-02-04 22:00:33 +00:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-01-08 02:25:57 +00:00
|
|
|
|
|
|
|
auto buffer = ctx.BufferDescriptorA()[0];
|
|
|
|
|
|
|
|
std::string device_name = Memory::ReadCString(buffer.Address(), buffer.Size());
|
|
|
|
|
2018-01-15 22:39:00 +00:00
|
|
|
u32 fd = nvdrv->Open(device_name);
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-01-08 02:25:57 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(fd);
|
|
|
|
rb.Push<u32>(0);
|
|
|
|
}
|
|
|
|
|
2018-01-15 23:30:49 +00:00
|
|
|
void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
|
2018-02-04 22:00:33 +00:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-01-08 02:25:57 +00:00
|
|
|
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
u32 fd = rp.Pop<u32>();
|
|
|
|
u32 command = rp.Pop<u32>();
|
|
|
|
|
|
|
|
auto input_buffer = ctx.BufferDescriptorA()[0];
|
|
|
|
auto output_buffer = ctx.BufferDescriptorB()[0];
|
|
|
|
|
|
|
|
std::vector<u8> input(input_buffer.Size());
|
|
|
|
std::vector<u8> output(output_buffer.Size());
|
|
|
|
|
|
|
|
Memory::ReadBlock(input_buffer.Address(), input.data(), input_buffer.Size());
|
|
|
|
|
2018-01-15 22:39:00 +00:00
|
|
|
u32 nv_result = nvdrv->Ioctl(fd, command, input, output);
|
2018-01-08 02:25:57 +00:00
|
|
|
|
|
|
|
Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.Size());
|
|
|
|
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-01-08 02:25:57 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(nv_result);
|
|
|
|
}
|
|
|
|
|
2018-01-17 16:08:46 +00:00
|
|
|
void NVDRV::Close(Kernel::HLERequestContext& ctx) {
|
2018-02-04 22:00:33 +00:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-01-17 16:08:46 +00:00
|
|
|
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
u32 fd = rp.Pop<u32>();
|
|
|
|
|
|
|
|
auto result = nvdrv->Close(fd);
|
|
|
|
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-01-17 16:08:46 +00:00
|
|
|
rb.Push(result);
|
|
|
|
}
|
|
|
|
|
2018-01-15 23:30:49 +00:00
|
|
|
void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
|
2018-02-04 22:00:33 +00:00
|
|
|
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-01-08 02:25:57 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0);
|
|
|
|
}
|
|
|
|
|
2018-01-19 04:50:18 +00:00
|
|
|
void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2018-01-21 22:59:50 +00:00
|
|
|
pid = rp.Pop<u64>();
|
2018-01-19 04:50:18 +00:00
|
|
|
|
2018-02-04 22:00:33 +00:00
|
|
|
LOG_INFO(Service_NVDRV, "called, pid=0x%lx", pid);
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-01-19 04:50:18 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-01-21 22:59:50 +00:00
|
|
|
rb.Push<u32>(0);
|
2018-01-19 04:50:18 +00:00
|
|
|
}
|
|
|
|
|
2018-01-15 23:30:49 +00:00
|
|
|
NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name)
|
|
|
|
: ServiceFramework(name), nvdrv(std::move(nvdrv)) {
|
2018-01-08 02:25:57 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-01-15 23:30:49 +00:00
|
|
|
{0, &NVDRV::Open, "Open"},
|
|
|
|
{1, &NVDRV::Ioctl, "Ioctl"},
|
2018-01-17 16:08:46 +00:00
|
|
|
{2, &NVDRV::Close, "Close"},
|
2018-01-15 23:30:49 +00:00
|
|
|
{3, &NVDRV::Initialize, "Initialize"},
|
2018-01-19 04:50:18 +00:00
|
|
|
{8, &NVDRV::SetClientPID, "SetClientPID"},
|
2018-01-08 02:25:57 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2018-01-15 22:39:00 +00:00
|
|
|
} // namespace Nvidia
|
2018-01-08 02:25:57 +00:00
|
|
|
} // namespace Service
|