diff options
| author | 2024-02-14 00:09:29 -0500 | |
|---|---|---|
| committer | 2024-02-14 12:03:32 -0500 | |
| commit | 59011a04a10d20804eb1eb4c8164b64d0f0ca824 (patch) | |
| tree | 23d4943c7c49b7d16434231d441d2934fe06193f /src | |
| parent | vi: rewrite IApplicationRootService, IManagerRootService, ISystemRootService (diff) | |
| download | yuzu-59011a04a10d20804eb1eb4c8164b64d0f0ca824.tar.gz yuzu-59011a04a10d20804eb1eb4c8164b64d0f0ca824.tar.xz yuzu-59011a04a10d20804eb1eb4c8164b64d0f0ca824.zip | |
vi: rewrite IHOSBinderDriver
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/nvnflinger/binder.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_producer.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_producer.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/vi/hos_binder_driver.cpp | 67 | ||||
| -rw-r--r-- | src/core/hle/service/vi/hos_binder_driver.h | 18 |
5 files changed, 53 insertions, 49 deletions
diff --git a/src/core/hle/service/nvnflinger/binder.h b/src/core/hle/service/nvnflinger/binder.h index aef1477e3..179938192 100644 --- a/src/core/hle/service/nvnflinger/binder.h +++ b/src/core/hle/service/nvnflinger/binder.h | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | #pragma once | 7 | #pragma once |
| 8 | 8 | ||
| 9 | #include <span> | ||
| 10 | |||
| 9 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 10 | 12 | ||
| 11 | namespace Kernel { | 13 | namespace Kernel { |
| @@ -38,7 +40,8 @@ enum class TransactionId { | |||
| 38 | class IBinder { | 40 | class IBinder { |
| 39 | public: | 41 | public: |
| 40 | virtual ~IBinder() = default; | 42 | virtual ~IBinder() = default; |
| 41 | virtual void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) = 0; | 43 | virtual void Transact(android::TransactionId code, u32 flags, std::span<const u8> parcel_data, |
| 44 | std::span<u8> parcel_reply) = 0; | ||
| 42 | virtual Kernel::KReadableEvent& GetNativeHandle() = 0; | 45 | virtual Kernel::KReadableEvent& GetNativeHandle() = 0; |
| 43 | }; | 46 | }; |
| 44 | 47 | ||
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 5d8762d25..ec83beb9b 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp | |||
| @@ -807,9 +807,10 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot, | |||
| 807 | return Status::NoError; | 807 | return Status::NoError; |
| 808 | } | 808 | } |
| 809 | 809 | ||
| 810 | void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u32 flags) { | 810 | void BufferQueueProducer::Transact(TransactionId code, u32 flags, std::span<const u8> parcel_data, |
| 811 | std::span<u8> parcel_reply) { | ||
| 811 | Status status{Status::NoError}; | 812 | Status status{Status::NoError}; |
| 812 | InputParcel parcel_in{ctx.ReadBuffer()}; | 813 | InputParcel parcel_in{parcel_data}; |
| 813 | OutputParcel parcel_out{}; | 814 | OutputParcel parcel_out{}; |
| 814 | 815 | ||
| 815 | switch (code) { | 816 | switch (code) { |
| @@ -917,7 +918,9 @@ void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u | |||
| 917 | 918 | ||
| 918 | parcel_out.Write(status); | 919 | parcel_out.Write(status); |
| 919 | 920 | ||
| 920 | ctx.WriteBuffer(parcel_out.Serialize()); | 921 | const auto serialized = parcel_out.Serialize(); |
| 922 | std::memcpy(parcel_reply.data(), serialized.data(), | ||
| 923 | std::min(parcel_reply.size(), serialized.size())); | ||
| 921 | } | 924 | } |
| 922 | 925 | ||
| 923 | Kernel::KReadableEvent& BufferQueueProducer::GetNativeHandle() { | 926 | Kernel::KReadableEvent& BufferQueueProducer::GetNativeHandle() { |
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.h b/src/core/hle/service/nvnflinger/buffer_queue_producer.h index 64c17d56c..4682b0f84 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.h +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.h | |||
| @@ -47,7 +47,8 @@ public: | |||
| 47 | Service::Nvidia::NvCore::NvMap& nvmap_); | 47 | Service::Nvidia::NvCore::NvMap& nvmap_); |
| 48 | ~BufferQueueProducer(); | 48 | ~BufferQueueProducer(); |
| 49 | 49 | ||
| 50 | void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) override; | 50 | void Transact(android::TransactionId code, u32 flags, std::span<const u8> parcel_data, |
| 51 | std::span<u8> parcel_reply) override; | ||
| 51 | 52 | ||
| 52 | Kernel::KReadableEvent& GetNativeHandle() override; | 53 | Kernel::KReadableEvent& GetNativeHandle() override; |
| 53 | 54 | ||
diff --git a/src/core/hle/service/vi/hos_binder_driver.cpp b/src/core/hle/service/vi/hos_binder_driver.cpp index e04acc297..ba0317245 100644 --- a/src/core/hle/service/vi/hos_binder_driver.cpp +++ b/src/core/hle/service/vi/hos_binder_driver.cpp | |||
| @@ -1,64 +1,53 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/ipc_helpers.h" | 4 | #include "core/hle/service/cmif_serialization.h" |
| 5 | #include "core/hle/service/nvnflinger/binder.h" | 5 | #include "core/hle/service/nvnflinger/binder.h" |
| 6 | #include "core/hle/service/nvnflinger/hos_binder_driver_server.h" | 6 | #include "core/hle/service/nvnflinger/hos_binder_driver_server.h" |
| 7 | #include "core/hle/service/vi/hos_binder_driver.h" | 7 | #include "core/hle/service/vi/hos_binder_driver.h" |
| 8 | 8 | ||
| 9 | namespace Service::VI { | 9 | namespace Service::VI { |
| 10 | 10 | ||
| 11 | IHOSBinderDriver::IHOSBinderDriver(Core::System& system_, | 11 | IHOSBinderDriver::IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server) |
| 12 | Nvnflinger::HosBinderDriverServer& server_) | 12 | : ServiceFramework{system_, "IHOSBinderDriver"}, m_server(server) { |
| 13 | : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) { | ||
| 14 | static const FunctionInfo functions[] = { | 13 | static const FunctionInfo functions[] = { |
| 15 | {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, | 14 | {0, C<&IHOSBinderDriver::TransactParcel>, "TransactParcel"}, |
| 16 | {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, | 15 | {1, C<&IHOSBinderDriver::AdjustRefcount>, "AdjustRefcount"}, |
| 17 | {2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"}, | 16 | {2, C<&IHOSBinderDriver::GetNativeHandle>, "GetNativeHandle"}, |
| 18 | {3, &IHOSBinderDriver::TransactParcel, "TransactParcelAuto"}, | 17 | {3, C<&IHOSBinderDriver::TransactParcelAuto>, "TransactParcelAuto"}, |
| 19 | }; | 18 | }; |
| 20 | RegisterHandlers(functions); | 19 | RegisterHandlers(functions); |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | IHOSBinderDriver::~IHOSBinderDriver() = default; | 22 | IHOSBinderDriver::~IHOSBinderDriver() = default; |
| 24 | 23 | ||
| 25 | void IHOSBinderDriver::TransactParcel(HLERequestContext& ctx) { | 24 | Result IHOSBinderDriver::TransactParcel(s32 binder_id, android::TransactionId transaction_id, |
| 26 | IPC::RequestParser rp{ctx}; | 25 | InBuffer<BufferAttr_HipcMapAlias> parcel_data, |
| 27 | const u32 id = rp.Pop<u32>(); | 26 | OutBuffer<BufferAttr_HipcMapAlias> parcel_reply, |
| 28 | const auto transaction = static_cast<android::TransactionId>(rp.Pop<u32>()); | 27 | u32 flags) { |
| 29 | const u32 flags = rp.Pop<u32>(); | 28 | LOG_DEBUG(Service_VI, "called. id={} transaction={}, flags={}", binder_id, transaction_id, |
| 30 | |||
| 31 | LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, transaction, | ||
| 32 | flags); | 29 | flags); |
| 33 | 30 | m_server.TryGetProducer(binder_id)->Transact(transaction_id, flags, parcel_data, parcel_reply); | |
| 34 | server.TryGetProducer(id)->Transact(ctx, transaction, flags); | 31 | R_SUCCEED(); |
| 35 | |||
| 36 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 37 | rb.Push(ResultSuccess); | ||
| 38 | } | 32 | } |
| 39 | 33 | ||
| 40 | void IHOSBinderDriver::AdjustRefcount(HLERequestContext& ctx) { | 34 | Result IHOSBinderDriver::AdjustRefcount(s32 binder_id, s32 addval, s32 type) { |
| 41 | IPC::RequestParser rp{ctx}; | 35 | LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={}, type={}", binder_id, addval, type); |
| 42 | const u32 id = rp.Pop<u32>(); | 36 | R_SUCCEED(); |
| 43 | const s32 addval = rp.PopRaw<s32>(); | ||
| 44 | const u32 type = rp.Pop<u32>(); | ||
| 45 | |||
| 46 | LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={:08X}, type={:08X}", id, addval, type); | ||
| 47 | |||
| 48 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 49 | rb.Push(ResultSuccess); | ||
| 50 | } | 37 | } |
| 51 | 38 | ||
| 52 | void IHOSBinderDriver::GetNativeHandle(HLERequestContext& ctx) { | 39 | Result IHOSBinderDriver::GetNativeHandle(s32 binder_id, u32 type_id, |
| 53 | IPC::RequestParser rp{ctx}; | 40 | OutCopyHandle<Kernel::KReadableEvent> out_handle) { |
| 54 | const u32 id = rp.Pop<u32>(); | 41 | LOG_WARNING(Service_VI, "(STUBBED) called id={}, type_id={}", binder_id, type_id); |
| 55 | const u32 unknown = rp.Pop<u32>(); | 42 | *out_handle = &m_server.TryGetProducer(binder_id)->GetNativeHandle(); |
| 56 | 43 | R_SUCCEED(); | |
| 57 | LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); | 44 | } |
| 58 | 45 | ||
| 59 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 46 | Result IHOSBinderDriver::TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id, |
| 60 | rb.Push(ResultSuccess); | 47 | InBuffer<BufferAttr_HipcAutoSelect> parcel_data, |
| 61 | rb.PushCopyObjects(server.TryGetProducer(id)->GetNativeHandle()); | 48 | OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply, |
| 49 | u32 flags) { | ||
| 50 | R_RETURN(this->TransactParcel(binder_id, transaction_id, parcel_data, parcel_reply, flags)); | ||
| 62 | } | 51 | } |
| 63 | 52 | ||
| 64 | } // namespace Service::VI | 53 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/hos_binder_driver.h b/src/core/hle/service/vi/hos_binder_driver.h index 24780c7d8..ed6e8cdbe 100644 --- a/src/core/hle/service/vi/hos_binder_driver.h +++ b/src/core/hle/service/vi/hos_binder_driver.h | |||
| @@ -1,22 +1,30 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/cmif_types.h" | ||
| 5 | #include "core/hle/service/nvnflinger/binder.h" | ||
| 4 | #include "core/hle/service/service.h" | 6 | #include "core/hle/service/service.h" |
| 5 | 7 | ||
| 6 | namespace Service::VI { | 8 | namespace Service::VI { |
| 7 | 9 | ||
| 8 | class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { | 10 | class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { |
| 9 | public: | 11 | public: |
| 10 | explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server_); | 12 | explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server); |
| 11 | ~IHOSBinderDriver() override; | 13 | ~IHOSBinderDriver() override; |
| 12 | 14 | ||
| 13 | private: | 15 | private: |
| 14 | void TransactParcel(HLERequestContext& ctx); | 16 | Result TransactParcel(s32 binder_id, android::TransactionId transaction_id, |
| 15 | void AdjustRefcount(HLERequestContext& ctx); | 17 | InBuffer<BufferAttr_HipcMapAlias> parcel_data, |
| 16 | void GetNativeHandle(HLERequestContext& ctx); | 18 | OutBuffer<BufferAttr_HipcMapAlias> parcel_reply, u32 flags); |
| 19 | Result AdjustRefcount(s32 binder_id, s32 addval, s32 type); | ||
| 20 | Result GetNativeHandle(s32 binder_id, u32 type_id, | ||
| 21 | OutCopyHandle<Kernel::KReadableEvent> out_handle); | ||
| 22 | Result TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id, | ||
| 23 | InBuffer<BufferAttr_HipcAutoSelect> parcel_data, | ||
| 24 | OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply, u32 flags); | ||
| 17 | 25 | ||
| 18 | private: | 26 | private: |
| 19 | Nvnflinger::HosBinderDriverServer& server; | 27 | Nvnflinger::HosBinderDriverServer& m_server; |
| 20 | }; | 28 | }; |
| 21 | 29 | ||
| 22 | } // namespace Service::VI | 30 | } // namespace Service::VI |