diff options
| author | bunnei <bunneidev@gmail.com> | 2018-02-14 18:31:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-14 18:31:53 -0500 |
| commit | db873a232ca92191df89e7e5a13f254f3d58b966 (patch) | |
| tree | 0b0c4a1116f6ef1af1a3144781c149ebd4429577 /src/core/hle/service/nvdrv/interface.cpp | |
| parent | 756e9f14848ce19b774de10de9891fd27ec333a7 (diff) | |
| parent | 88bfec37ce445db30fe36bb2d00b115df6a24838 (diff) | |
Merge pull request #188 from bunnei/refactor-buffer-descriptor
Refactor IPC buffer descriptor interface
Diffstat (limited to 'src/core/hle/service/nvdrv/interface.cpp')
| -rw-r--r-- | src/core/hle/service/nvdrv/interface.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 1a5efaeaf..c70370f1f 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -15,9 +15,8 @@ namespace Nvidia { void NVDRV::Open(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_NVDRV, "called"); - auto buffer = ctx.BufferDescriptorA()[0]; - - std::string device_name = Memory::ReadCString(buffer.Address(), buffer.Size()); + const auto& buffer = ctx.ReadBuffer(); + std::string device_name(buffer.begin(), buffer.end()); u32 fd = nvdrv->Open(device_name); IPC::ResponseBuilder rb{ctx, 4}; @@ -33,25 +32,13 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) { u32 fd = rp.Pop<u32>(); u32 command = rp.Pop<u32>(); + std::vector<u8> output(ctx.GetWriteBufferSize()); + IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - if (ctx.BufferDescriptorA()[0].Size() != 0) { - 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()); - rb.Push(nvdrv->Ioctl(fd, command, input, output)); - Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.Size()); - } else { - auto input_buffer = ctx.BufferDescriptorX()[0]; - auto output_buffer = ctx.BufferDescriptorC()[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); - rb.Push(nvdrv->Ioctl(fd, command, input, output)); - Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.size); - } + rb.Push(nvdrv->Ioctl(fd, command, ctx.ReadBuffer(), output)); + + ctx.WriteBuffer(output); } void NVDRV::Close(Kernel::HLERequestContext& ctx) { |
