summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/vi/hos_binder_driver.cpp
blob: e04acc297b7ebe6aa7559d504b6dc629249b3e2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "core/hle/service/ipc_helpers.h"
#include "core/hle/service/nvnflinger/binder.h"
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
#include "core/hle/service/vi/hos_binder_driver.h"

namespace Service::VI {

IHOSBinderDriver::IHOSBinderDriver(Core::System& system_,
                                   Nvnflinger::HosBinderDriverServer& server_)
    : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) {
    static const FunctionInfo functions[] = {
        {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
        {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
        {2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
        {3, &IHOSBinderDriver::TransactParcel, "TransactParcelAuto"},
    };
    RegisterHandlers(functions);
}

IHOSBinderDriver::~IHOSBinderDriver() = default;

void IHOSBinderDriver::TransactParcel(HLERequestContext& ctx) {
    IPC::RequestParser rp{ctx};
    const u32 id = rp.Pop<u32>();
    const auto transaction = static_cast<android::TransactionId>(rp.Pop<u32>());
    const u32 flags = rp.Pop<u32>();

    LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, transaction,
              flags);

    server.TryGetProducer(id)->Transact(ctx, transaction, flags);

    IPC::ResponseBuilder rb{ctx, 2};
    rb.Push(ResultSuccess);
}

void IHOSBinderDriver::AdjustRefcount(HLERequestContext& ctx) {
    IPC::RequestParser rp{ctx};
    const u32 id = rp.Pop<u32>();
    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) {
    IPC::RequestParser rp{ctx};
    const u32 id = rp.Pop<u32>();
    const u32 unknown = rp.Pop<u32>();

    LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);

    IPC::ResponseBuilder rb{ctx, 2, 1};
    rb.Push(ResultSuccess);
    rb.PushCopyObjects(server.TryGetProducer(id)->GetNativeHandle());
}

} // namespace Service::VI