nvdrv: Get rid of global std::weak_ptr

Rather than use global state, we can simply pass the instance into the
NVFlinger instance directly.
This commit is contained in:
Lioncash 2018-08-07 09:17:09 -04:00
parent 825e8cb925
commit d378d98e26
5 changed files with 22 additions and 11 deletions

View file

@ -16,19 +16,18 @@
#include "core/hle/service/nvdrv/interface.h"
#include "core/hle/service/nvdrv/nvdrv.h"
#include "core/hle/service/nvdrv/nvmemp.h"
#include "core/hle/service/nvflinger/nvflinger.h"
namespace Service::Nvidia {
std::weak_ptr<Module> nvdrv;
void InstallInterfaces(SM::ServiceManager& service_manager) {
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger) {
auto module_ = std::make_shared<Module>();
std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager);
std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager);
std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager);
std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager);
std::make_shared<NVMEMP>()->InstallAsService(service_manager);
nvdrv = module_;
nvflinger.SetNVDrvInstance(module_);
}
Module::Module() {

View file

@ -10,6 +10,10 @@
#include "common/common_types.h"
#include "core/hle/service/service.h"
namespace Service::NVFlinger {
class NVFlinger;
}
namespace Service::Nvidia {
namespace Devices {
@ -56,8 +60,6 @@ private:
};
/// Registers all NVDRV services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& service_manager);
extern std::weak_ptr<Module> nvdrv;
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger);
} // namespace Service::Nvidia