diff options
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/vi/vi.cpp | 63 |
1 files changed, 19 insertions, 44 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 55f196ab0..1f00a6cca 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -453,86 +453,61 @@ private: SetPreallocatedBuffer = 14 }; - void TransactParcel(u32 id, TransactionId transaction, const std::vector<u8>& input_data, - VAddr output_addr, u64 output_size) { + void TransactParcel(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + u32 id = rp.Pop<u32>(); + auto transaction = static_cast<TransactionId>(rp.Pop<u32>()); + u32 flags = rp.Pop<u32>(); auto buffer_queue = nv_flinger->GetBufferQueue(id); + LOG_DEBUG(Service_VI, "called, transaction=%x", transaction); + if (transaction == TransactionId::Connect) { - IGBPConnectRequestParcel request{input_data}; + IGBPConnectRequestParcel request{ctx.ReadBuffer()}; IGBPConnectResponseParcel response{1280, 720}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::SetPreallocatedBuffer) { - IGBPSetPreallocatedBufferRequestParcel request{input_data}; + IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer); IGBPSetPreallocatedBufferResponseParcel response{}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::DequeueBuffer) { - IGBPDequeueBufferRequestParcel request{input_data}; + IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; u32 slot = buffer_queue->DequeueBuffer(request.data.pixel_format, request.data.width, request.data.height); IGBPDequeueBufferResponseParcel response{slot}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::RequestBuffer) { - IGBPRequestBufferRequestParcel request{input_data}; + IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; auto& buffer = buffer_queue->RequestBuffer(request.slot); IGBPRequestBufferResponseParcel response{buffer}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::QueueBuffer) { - IGBPQueueBufferRequestParcel request{input_data}; + IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; buffer_queue->QueueBuffer(request.data.slot, request.data.transform); IGBPQueueBufferResponseParcel response{1280, 720}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::Query) { - IGBPQueryRequestParcel request{input_data}; + IGBPQueryRequestParcel request{ctx.ReadBuffer()}; u32 value = buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type)); IGBPQueryResponseParcel response{value}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::CancelBuffer) { LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer"); } else { ASSERT_MSG(false, "Unimplemented"); } - } - - void TransactParcel(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - u32 id = rp.Pop<u32>(); - auto transaction = static_cast<TransactionId>(rp.Pop<u32>()); - u32 flags = rp.Pop<u32>(); - LOG_DEBUG(Service_VI, "called, transaction=%x", transaction); - - if (ctx.BufferDescriptorA()[0].Size() != 0) { - auto& input_buffer = ctx.BufferDescriptorA()[0]; - auto& output_buffer = ctx.BufferDescriptorB()[0]; - std::vector<u8> input_data(input_buffer.Size()); - Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size()); - TransactParcel(id, transaction, input_data, output_buffer.Address(), - output_buffer.Size()); - } else { - auto& input_buffer = ctx.BufferDescriptorX()[0]; - auto& output_buffer = ctx.BufferDescriptorC()[0]; - std::vector<u8> input_data(input_buffer.size); - Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.size); - TransactParcel(id, transaction, input_data, output_buffer.Address(), - output_buffer.Size()); - } IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); |