mirror of https://git.suyu.dev/suyu/suyu
hle: nvflinger: Add implementation for HosBinderDriverServer service.
parent
56284bff6c
commit
a87812c6a1
@ -0,0 +1,36 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
// Copyright 2021 yuzu Emulator Project
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/service/nvflinger/hos_binder_driver_server.h"
|
||||||
|
|
||||||
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
|
HosBinderDriverServer::HosBinderDriverServer(Core::System& system_)
|
||||||
|
: service_context(system_, "HosBinderDriverServer") {}
|
||||||
|
|
||||||
|
HosBinderDriverServer::~HosBinderDriverServer() {}
|
||||||
|
|
||||||
|
u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) {
|
||||||
|
std::lock_guard lk{lock};
|
||||||
|
|
||||||
|
last_id++;
|
||||||
|
|
||||||
|
producers[last_id] = std::move(binder);
|
||||||
|
|
||||||
|
return last_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) {
|
||||||
|
std::lock_guard lk{lock};
|
||||||
|
|
||||||
|
if (auto search = producers.find(id); search != producers.end()) {
|
||||||
|
return search->second.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Service::NVFlinger
|
@ -0,0 +1,37 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
// Copyright 2021 yuzu Emulator Project
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
|
#include "core/hle/service/nvflinger/binder.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
|
class HosBinderDriverServer final {
|
||||||
|
public:
|
||||||
|
explicit HosBinderDriverServer(Core::System& system_);
|
||||||
|
~HosBinderDriverServer();
|
||||||
|
|
||||||
|
u64 RegisterProducer(std::unique_ptr<android::IBinder>&& binder);
|
||||||
|
|
||||||
|
android::IBinder* TryGetProducer(u64 id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
KernelHelpers::ServiceContext service_context;
|
||||||
|
|
||||||
|
std::unordered_map<u64, std::unique_ptr<android::IBinder>> producers;
|
||||||
|
std::mutex lock;
|
||||||
|
u64 last_id{};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Service::NVFlinger
|
Loading…
Reference in New Issue