Deglobalize System: Nim

master
David Marcec 2019-09-21 19:11:52 +07:00
parent ad53dc0106
commit 8d3ff2b127
2 changed files with 12 additions and 7 deletions

@ -126,7 +126,7 @@ public:
class IEnsureNetworkClockAvailabilityService final class IEnsureNetworkClockAvailabilityService final
: public ServiceFramework<IEnsureNetworkClockAvailabilityService> { : public ServiceFramework<IEnsureNetworkClockAvailabilityService> {
public: public:
IEnsureNetworkClockAvailabilityService() IEnsureNetworkClockAvailabilityService(Core::System& system)
: ServiceFramework("IEnsureNetworkClockAvailabilityService") { : ServiceFramework("IEnsureNetworkClockAvailabilityService") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"},
@ -139,7 +139,7 @@ public:
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
auto& kernel = Core::System::GetInstance().Kernel(); auto& kernel = system.Kernel();
finished_event = Kernel::WritableEvent::CreateEventPair( finished_event = Kernel::WritableEvent::CreateEventPair(
kernel, Kernel::ResetType::Automatic, kernel, Kernel::ResetType::Automatic,
"IEnsureNetworkClockAvailabilityService:FinishEvent"); "IEnsureNetworkClockAvailabilityService:FinishEvent");
@ -200,7 +200,7 @@ private:
class NTC final : public ServiceFramework<NTC> { class NTC final : public ServiceFramework<NTC> {
public: public:
explicit NTC() : ServiceFramework{"ntc"} { explicit NTC(Core::System& system) : ServiceFramework{"ntc"}, system(system) {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"}, {0, &NTC::OpenEnsureNetworkClockAvailabilityService, "OpenEnsureNetworkClockAvailabilityService"},
@ -218,7 +218,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>(); rb.PushIpcInterface<IEnsureNetworkClockAvailabilityService>(system);
} }
// TODO(ogniK): Do we need these? // TODO(ogniK): Do we need these?
@ -235,13 +235,14 @@ private:
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
Core::System& system;
}; };
void InstallInterfaces(SM::ServiceManager& sm) { void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
std::make_shared<NIM>()->InstallAsService(sm); std::make_shared<NIM>()->InstallAsService(sm);
std::make_shared<NIM_ECA>()->InstallAsService(sm); std::make_shared<NIM_ECA>()->InstallAsService(sm);
std::make_shared<NIM_SHP>()->InstallAsService(sm); std::make_shared<NIM_SHP>()->InstallAsService(sm);
std::make_shared<NTC>()->InstallAsService(sm); std::make_shared<NTC>(system)->InstallAsService(sm);
} }
} // namespace Service::NIM } // namespace Service::NIM

@ -8,8 +8,12 @@ namespace Service::SM {
class ServiceManager; class ServiceManager;
} }
namespace Core {
class System;
}
namespace Service::NIM { namespace Service::NIM {
void InstallInterfaces(SM::ServiceManager& sm); void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
} // namespace Service::NIM } // namespace Service::NIM