vi: rewrite IHOSBinderDriver
This commit is contained in:
parent
c448001d47
commit
59011a04a1
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <span>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
@ -38,7 +40,8 @@ enum class TransactionId {
|
||||||
class IBinder {
|
class IBinder {
|
||||||
public:
|
public:
|
||||||
virtual ~IBinder() = default;
|
virtual ~IBinder() = default;
|
||||||
virtual void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) = 0;
|
virtual void Transact(android::TransactionId code, u32 flags, std::span<const u8> parcel_data,
|
||||||
|
std::span<u8> parcel_reply) = 0;
|
||||||
virtual Kernel::KReadableEvent& GetNativeHandle() = 0;
|
virtual Kernel::KReadableEvent& GetNativeHandle() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -807,9 +807,10 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot,
|
||||||
return Status::NoError;
|
return Status::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u32 flags) {
|
void BufferQueueProducer::Transact(TransactionId code, u32 flags, std::span<const u8> parcel_data,
|
||||||
|
std::span<u8> parcel_reply) {
|
||||||
Status status{Status::NoError};
|
Status status{Status::NoError};
|
||||||
InputParcel parcel_in{ctx.ReadBuffer()};
|
InputParcel parcel_in{parcel_data};
|
||||||
OutputParcel parcel_out{};
|
OutputParcel parcel_out{};
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
@ -917,7 +918,9 @@ void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u
|
||||||
|
|
||||||
parcel_out.Write(status);
|
parcel_out.Write(status);
|
||||||
|
|
||||||
ctx.WriteBuffer(parcel_out.Serialize());
|
const auto serialized = parcel_out.Serialize();
|
||||||
|
std::memcpy(parcel_reply.data(), serialized.data(),
|
||||||
|
std::min(parcel_reply.size(), serialized.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent& BufferQueueProducer::GetNativeHandle() {
|
Kernel::KReadableEvent& BufferQueueProducer::GetNativeHandle() {
|
||||||
|
|
|
@ -47,7 +47,8 @@ public:
|
||||||
Service::Nvidia::NvCore::NvMap& nvmap_);
|
Service::Nvidia::NvCore::NvMap& nvmap_);
|
||||||
~BufferQueueProducer();
|
~BufferQueueProducer();
|
||||||
|
|
||||||
void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) override;
|
void Transact(android::TransactionId code, u32 flags, std::span<const u8> parcel_data,
|
||||||
|
std::span<u8> parcel_reply) override;
|
||||||
|
|
||||||
Kernel::KReadableEvent& GetNativeHandle() override;
|
Kernel::KReadableEvent& GetNativeHandle() override;
|
||||||
|
|
||||||
|
|
|
@ -1,64 +1,53 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
#include "core/hle/service/nvnflinger/binder.h"
|
#include "core/hle/service/nvnflinger/binder.h"
|
||||||
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
|
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
|
||||||
#include "core/hle/service/vi/hos_binder_driver.h"
|
#include "core/hle/service/vi/hos_binder_driver.h"
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
IHOSBinderDriver::IHOSBinderDriver(Core::System& system_,
|
IHOSBinderDriver::IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server)
|
||||||
Nvnflinger::HosBinderDriverServer& server_)
|
: ServiceFramework{system_, "IHOSBinderDriver"}, m_server(server) {
|
||||||
: ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) {
|
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
|
{0, C<&IHOSBinderDriver::TransactParcel>, "TransactParcel"},
|
||||||
{1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
|
{1, C<&IHOSBinderDriver::AdjustRefcount>, "AdjustRefcount"},
|
||||||
{2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
|
{2, C<&IHOSBinderDriver::GetNativeHandle>, "GetNativeHandle"},
|
||||||
{3, &IHOSBinderDriver::TransactParcel, "TransactParcelAuto"},
|
{3, C<&IHOSBinderDriver::TransactParcelAuto>, "TransactParcelAuto"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
IHOSBinderDriver::~IHOSBinderDriver() = default;
|
IHOSBinderDriver::~IHOSBinderDriver() = default;
|
||||||
|
|
||||||
void IHOSBinderDriver::TransactParcel(HLERequestContext& ctx) {
|
Result IHOSBinderDriver::TransactParcel(s32 binder_id, android::TransactionId transaction_id,
|
||||||
IPC::RequestParser rp{ctx};
|
InBuffer<BufferAttr_HipcMapAlias> parcel_data,
|
||||||
const u32 id = rp.Pop<u32>();
|
OutBuffer<BufferAttr_HipcMapAlias> parcel_reply,
|
||||||
const auto transaction = static_cast<android::TransactionId>(rp.Pop<u32>());
|
u32 flags) {
|
||||||
const u32 flags = rp.Pop<u32>();
|
LOG_DEBUG(Service_VI, "called. id={} transaction={}, flags={}", binder_id, transaction_id,
|
||||||
|
|
||||||
LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, transaction,
|
|
||||||
flags);
|
flags);
|
||||||
|
m_server.TryGetProducer(binder_id)->Transact(transaction_id, flags, parcel_data, parcel_reply);
|
||||||
server.TryGetProducer(id)->Transact(ctx, transaction, flags);
|
R_SUCCEED();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IHOSBinderDriver::AdjustRefcount(HLERequestContext& ctx) {
|
Result IHOSBinderDriver::AdjustRefcount(s32 binder_id, s32 addval, s32 type) {
|
||||||
IPC::RequestParser rp{ctx};
|
LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={}, type={}", binder_id, addval, type);
|
||||||
const u32 id = rp.Pop<u32>();
|
R_SUCCEED();
|
||||||
const s32 addval = rp.PopRaw<s32>();
|
|
||||||
const u32 type = rp.Pop<u32>();
|
|
||||||
|
|
||||||
LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={:08X}, type={:08X}", id, addval, type);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IHOSBinderDriver::GetNativeHandle(HLERequestContext& ctx) {
|
Result IHOSBinderDriver::GetNativeHandle(s32 binder_id, u32 type_id,
|
||||||
IPC::RequestParser rp{ctx};
|
OutCopyHandle<Kernel::KReadableEvent> out_handle) {
|
||||||
const u32 id = rp.Pop<u32>();
|
LOG_WARNING(Service_VI, "(STUBBED) called id={}, type_id={}", binder_id, type_id);
|
||||||
const u32 unknown = rp.Pop<u32>();
|
*out_handle = &m_server.TryGetProducer(binder_id)->GetNativeHandle();
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
|
Result IHOSBinderDriver::TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id,
|
||||||
|
InBuffer<BufferAttr_HipcAutoSelect> parcel_data,
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply,
|
||||||
rb.Push(ResultSuccess);
|
u32 flags) {
|
||||||
rb.PushCopyObjects(server.TryGetProducer(id)->GetNativeHandle());
|
R_RETURN(this->TransactParcel(binder_id, transaction_id, parcel_data, parcel_reply, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "core/hle/service/cmif_types.h"
|
||||||
|
#include "core/hle/service/nvnflinger/binder.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
|
class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
|
||||||
public:
|
public:
|
||||||
explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server_);
|
explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server);
|
||||||
~IHOSBinderDriver() override;
|
~IHOSBinderDriver() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TransactParcel(HLERequestContext& ctx);
|
Result TransactParcel(s32 binder_id, android::TransactionId transaction_id,
|
||||||
void AdjustRefcount(HLERequestContext& ctx);
|
InBuffer<BufferAttr_HipcMapAlias> parcel_data,
|
||||||
void GetNativeHandle(HLERequestContext& ctx);
|
OutBuffer<BufferAttr_HipcMapAlias> parcel_reply, u32 flags);
|
||||||
|
Result AdjustRefcount(s32 binder_id, s32 addval, s32 type);
|
||||||
|
Result GetNativeHandle(s32 binder_id, u32 type_id,
|
||||||
|
OutCopyHandle<Kernel::KReadableEvent> out_handle);
|
||||||
|
Result TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id,
|
||||||
|
InBuffer<BufferAttr_HipcAutoSelect> parcel_data,
|
||||||
|
OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply, u32 flags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Nvnflinger::HosBinderDriverServer& server;
|
Nvnflinger::HosBinderDriverServer& m_server;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
Loading…
Reference in New Issue