service/nifm: Deduplicate interface code
Rather than having the same code for each nifm service variant, we can centralize it on one class and get rid of a bit of extra code.
This commit is contained in:
parent
1e4935c3a0
commit
85ed42a1d2
|
@ -162,12 +162,6 @@ add_library(core STATIC
|
||||||
hle/service/nfp/nfp_user.h
|
hle/service/nfp/nfp_user.h
|
||||||
hle/service/nifm/nifm.cpp
|
hle/service/nifm/nifm.cpp
|
||||||
hle/service/nifm/nifm.h
|
hle/service/nifm/nifm.h
|
||||||
hle/service/nifm/nifm_a.cpp
|
|
||||||
hle/service/nifm/nifm_a.h
|
|
||||||
hle/service/nifm/nifm_s.cpp
|
|
||||||
hle/service/nifm/nifm_s.h
|
|
||||||
hle/service/nifm/nifm_u.cpp
|
|
||||||
hle/service/nifm/nifm_u.h
|
|
||||||
hle/service/ns/ns.cpp
|
hle/service/ns/ns.cpp
|
||||||
hle/service/ns/ns.h
|
hle/service/ns/ns.h
|
||||||
hle/service/ns/pl_u.cpp
|
hle/service/ns/pl_u.cpp
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/kernel/event.h"
|
#include "core/hle/kernel/event.h"
|
||||||
#include "core/hle/service/nifm/nifm.h"
|
#include "core/hle/service/nifm/nifm.h"
|
||||||
#include "core/hle/service/nifm/nifm_a.h"
|
#include "core/hle/service/service.h"
|
||||||
#include "core/hle/service/nifm/nifm_s.h"
|
|
||||||
#include "core/hle/service/nifm/nifm_u.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
namespace Service::NIFM {
|
||||||
|
|
||||||
|
@ -210,28 +208,35 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") {
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) {
|
class NetworkInterface final : public ServiceFramework<NetworkInterface> {
|
||||||
|
public:
|
||||||
|
explicit NetworkInterface(const char* name) : ServiceFramework{name} {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"},
|
||||||
|
{5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<IGeneralService>();
|
rb.PushIpcInterface<IGeneralService>();
|
||||||
LOG_DEBUG(Service_NIFM, "called");
|
LOG_DEBUG(Service_NIFM, "called");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::CreateGeneralService(Kernel::HLERequestContext& ctx) {
|
void CreateGeneralService(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<IGeneralService>();
|
rb.PushIpcInterface<IGeneralService>();
|
||||||
LOG_DEBUG(Service_NIFM, "called");
|
LOG_DEBUG(Service_NIFM, "called");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
|
||||||
: ServiceFramework(name), module(std::move(module)) {}
|
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||||
auto module = std::make_shared<Module>();
|
std::make_shared<NetworkInterface>("nifm:a")->InstallAsService(service_manager);
|
||||||
std::make_shared<NIFM_A>(module)->InstallAsService(service_manager);
|
std::make_shared<NetworkInterface>("nifm:s")->InstallAsService(service_manager);
|
||||||
std::make_shared<NIFM_S>(module)->InstallAsService(service_manager);
|
std::make_shared<NetworkInterface>("nifm:u")->InstallAsService(service_manager);
|
||||||
std::make_shared<NIFM_U>(module)->InstallAsService(service_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
} // namespace Service::NIFM
|
||||||
|
|
|
@ -4,24 +4,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/hle/service/service.h"
|
namespace Service::SM {
|
||||||
|
class ServiceManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::NIFM {
|
namespace Service::NIFM {
|
||||||
|
|
||||||
class Module final {
|
/// Registers all NIFM services with the specified service manager.
|
||||||
public:
|
|
||||||
class Interface : public ServiceFramework<Interface> {
|
|
||||||
public:
|
|
||||||
explicit Interface(std::shared_ptr<Module> module, const char* name);
|
|
||||||
|
|
||||||
void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx);
|
|
||||||
void CreateGeneralService(Kernel::HLERequestContext& ctx);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::shared_ptr<Module> module;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
} // namespace Service::NIFM
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "core/hle/service/nifm/nifm_a.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
|
||||||
|
|
||||||
NIFM_A::NIFM_A(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "nifm:a") {
|
|
||||||
static const FunctionInfo functions[] = {
|
|
||||||
{4, &NIFM_A::CreateGeneralServiceOld, "CreateGeneralServiceOld"},
|
|
||||||
{5, &NIFM_A::CreateGeneralService, "CreateGeneralService"},
|
|
||||||
};
|
|
||||||
RegisterHandlers(functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
|
|
@ -1,16 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "core/hle/service/nifm/nifm.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
|
||||||
|
|
||||||
class NIFM_A final : public Module::Interface {
|
|
||||||
public:
|
|
||||||
explicit NIFM_A(std::shared_ptr<Module> module);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "core/hle/service/nifm/nifm_s.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
|
||||||
|
|
||||||
NIFM_S::NIFM_S(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "nifm:s") {
|
|
||||||
static const FunctionInfo functions[] = {
|
|
||||||
{4, &NIFM_S::CreateGeneralServiceOld, "CreateGeneralServiceOld"},
|
|
||||||
{5, &NIFM_S::CreateGeneralService, "CreateGeneralService"},
|
|
||||||
};
|
|
||||||
RegisterHandlers(functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
|
|
@ -1,16 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "core/hle/service/nifm/nifm.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
|
||||||
|
|
||||||
class NIFM_S final : public Module::Interface {
|
|
||||||
public:
|
|
||||||
explicit NIFM_S(std::shared_ptr<Module> module);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "core/hle/service/nifm/nifm_u.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
|
||||||
|
|
||||||
NIFM_U::NIFM_U(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "nifm:u") {
|
|
||||||
static const FunctionInfo functions[] = {
|
|
||||||
{4, &NIFM_U::CreateGeneralServiceOld, "CreateGeneralServiceOld"},
|
|
||||||
{5, &NIFM_U::CreateGeneralService, "CreateGeneralService"},
|
|
||||||
};
|
|
||||||
RegisterHandlers(functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
|
|
@ -1,16 +0,0 @@
|
||||||
// Copyright 2018 yuzu emulator team
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "core/hle/service/nifm/nifm.h"
|
|
||||||
|
|
||||||
namespace Service::NIFM {
|
|
||||||
|
|
||||||
class NIFM_U final : public Module::Interface {
|
|
||||||
public:
|
|
||||||
explicit NIFM_U(std::shared_ptr<Module> module);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Service::NIFM
|
|
Reference in New Issue