// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging.h" #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfp/nfp.h" #include "core/hle/service/nfp/nfp_interface.h" #include "core/hle/service/server_manager.h" namespace Service::NFP { class IUser final : public Interface { public: explicit IUser(Core::System& system_) : Interface(system_, "NFP:IUser") {} FunctionInfoBase const* FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMapWithClass( FunctionInfoTyped{0, &IUser::Initialize, "Initialize"}, FunctionInfoTyped{1, &IUser::Finalize, "Finalize"}, FunctionInfoTyped{2, &IUser::ListDevices, "ListDevices"}, FunctionInfoTyped{3, &IUser::StartDetection, "StartDetection"}, FunctionInfoTyped{4, &IUser::StopDetection, "StopDetection"}, FunctionInfoTyped{5, &IUser::Mount, "Mount"}, FunctionInfoTyped{6, &IUser::Unmount, "Unmount"}, FunctionInfoTyped{7, &IUser::OpenApplicationArea, "OpenApplicationArea"}, FunctionInfoTyped{8, &IUser::GetApplicationArea, "GetApplicationArea"}, FunctionInfoTyped{9, &IUser::SetApplicationArea, "SetApplicationArea"}, FunctionInfoTyped{10, &IUser::Flush, "Flush"}, FunctionInfoTyped{11, &IUser::Restore, "Restore"}, FunctionInfoTyped{12, &IUser::CreateApplicationArea, "CreateApplicationArea"}, FunctionInfoTyped{13, &IUser::GetTagInfo, "GetTagInfo"}, FunctionInfoTyped{14, &IUser::GetRegisterInfo, "GetRegisterInfo"}, FunctionInfoTyped{15, &IUser::GetCommonInfo, "GetCommonInfo"}, FunctionInfoTyped{16, &IUser::GetModelInfo, "GetModelInfo"}, FunctionInfoTyped{17, &IUser::AttachActivateEvent, "AttachActivateEvent"}, FunctionInfoTyped{18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"}, FunctionInfoTyped{19, &IUser::GetState, "GetState"}, FunctionInfoTyped{20, &IUser::GetDeviceState, "GetDeviceState"}, FunctionInfoTyped{21, &IUser::GetNpadId, "GetNpadId"}, FunctionInfoTyped{22, &IUser::GetApplicationAreaSize, "GetApplicationAreaSize"}, FunctionInfoTyped{23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, FunctionInfoTyped{24, &IUser::RecreateApplicationArea, "RecreateApplicationArea"}, FunctionInfoTyped{25, &IUser::StartDetection, "StartDetectionWithFilter"} ); }; class ISystem final : public Interface { public: explicit ISystem(Core::System& system_) : Interface(system_, "NFP:ISystem") {} FunctionInfoBase const* FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMapWithClass( FunctionInfoTyped{0, &ISystem::InitializeSystem, "InitializeSystem"}, FunctionInfoTyped{1, &ISystem::FinalizeSystem, "FinalizeSystem"}, FunctionInfoTyped{2, &ISystem::ListDevices, "ListDevices"}, FunctionInfoTyped{3, &ISystem::StartDetection, "StartDetection"}, FunctionInfoTyped{4, &ISystem::StopDetection, "StopDetection"}, FunctionInfoTyped{5, &ISystem::Mount, "Mount"}, FunctionInfoTyped{6, &ISystem::Unmount, "Unmount"}, FunctionInfoTyped{10, &ISystem::Flush, "Flush"}, FunctionInfoTyped{11, &ISystem::Restore, "Restore"}, FunctionInfoTyped{12, &ISystem::CreateApplicationArea, "CreateApplicationArea"}, FunctionInfoTyped{13, &ISystem::GetTagInfo, "GetTagInfo"}, FunctionInfoTyped{14, &ISystem::GetRegisterInfo, "GetRegisterInfo"}, FunctionInfoTyped{15, &ISystem::GetCommonInfo, "GetCommonInfo"}, FunctionInfoTyped{16, &ISystem::GetModelInfo, "GetModelInfo"}, FunctionInfoTyped{17, &ISystem::AttachActivateEvent, "AttachActivateEvent"}, FunctionInfoTyped{18, &ISystem::AttachDeactivateEvent, "AttachDeactivateEvent"}, FunctionInfoTyped{19, &ISystem::GetState, "GetState"}, FunctionInfoTyped{20, &ISystem::GetDeviceState, "GetDeviceState"}, FunctionInfoTyped{21, &ISystem::GetNpadId, "GetNpadId"}, FunctionInfoTyped{23, &ISystem::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, FunctionInfoTyped{25, &ISystem::StartDetection, "StartDetectionWithFilter"}, FunctionInfoTyped{100, &ISystem::Format, "Format"}, FunctionInfoTyped{101, &ISystem::GetAdminInfo, "GetAdminInfo"}, FunctionInfoTyped{102, &ISystem::GetRegisterInfoPrivate, "GetRegisterInfoPrivate"}, FunctionInfoTyped{103, &ISystem::SetRegisterInfoPrivate, "SetRegisterInfoPrivate"}, FunctionInfoTyped{104, &ISystem::DeleteRegisterInfo, "DeleteRegisterInfo"}, FunctionInfoTyped{105, &ISystem::DeleteApplicationArea, "DeleteApplicationArea"}, FunctionInfoTyped{106, &ISystem::ExistsApplicationArea, "ExistsApplicationArea"} ); }; class IDebug final : public Interface { public: explicit IDebug(Core::System& system_) : Interface(system_, "NFP:IDebug") {} FunctionInfoBase const* FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMapWithClass( FunctionInfoTyped{0, &IDebug::InitializeDebug, "InitializeDebug"}, FunctionInfoTyped{1, &IDebug::FinalizeDebug, "FinalizeDebug"}, FunctionInfoTyped{2, &IDebug::ListDevices, "ListDevices"}, FunctionInfoTyped{3, &IDebug::StartDetection, "StartDetection"}, FunctionInfoTyped{4, &IDebug::StopDetection, "StopDetection"}, FunctionInfoTyped{5, &IDebug::Mount, "Mount"}, FunctionInfoTyped{6, &IDebug::Unmount, "Unmount"}, FunctionInfoTyped{7, &IDebug::OpenApplicationArea, "OpenApplicationArea"}, FunctionInfoTyped{8, &IDebug::GetApplicationArea, "GetApplicationArea"}, FunctionInfoTyped{9, &IDebug::SetApplicationArea, "SetApplicationArea"}, FunctionInfoTyped{10, &IDebug::Flush, "Flush"}, FunctionInfoTyped{11, &IDebug::Restore, "Restore"}, FunctionInfoTyped{12, &IDebug::CreateApplicationArea, "CreateApplicationArea"}, FunctionInfoTyped{13, &IDebug::GetTagInfo, "GetTagInfo"}, FunctionInfoTyped{14, &IDebug::GetRegisterInfo, "GetRegisterInfo"}, FunctionInfoTyped{15, &IDebug::GetCommonInfo, "GetCommonInfo"}, FunctionInfoTyped{16, &IDebug::GetModelInfo, "GetModelInfo"}, FunctionInfoTyped{17, &IDebug::AttachActivateEvent, "AttachActivateEvent"}, FunctionInfoTyped{18, &IDebug::AttachDeactivateEvent, "AttachDeactivateEvent"}, FunctionInfoTyped{19, &IDebug::GetState, "GetState"}, FunctionInfoTyped{20, &IDebug::GetDeviceState, "GetDeviceState"}, FunctionInfoTyped{21, &IDebug::GetNpadId, "GetNpadId"}, FunctionInfoTyped{22, &IDebug::GetApplicationAreaSize, "GetApplicationAreaSize"}, FunctionInfoTyped{23, &IDebug::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, FunctionInfoTyped{24, &IDebug::RecreateApplicationArea, "RecreateApplicationArea"}, FunctionInfoTyped{25, &IDebug::StartDetection, "StartDetectionWithFilter"}, FunctionInfoTyped{100, &IDebug::Format, "Format"}, FunctionInfoTyped{101, &IDebug::GetAdminInfo, "GetAdminInfo"}, FunctionInfoTyped{102, &IDebug::GetRegisterInfoPrivate, "GetRegisterInfoPrivate"}, FunctionInfoTyped{103, &IDebug::SetRegisterInfoPrivate, "SetRegisterInfoPrivate"}, FunctionInfoTyped{104, &IDebug::DeleteRegisterInfo, "DeleteRegisterInfo"}, FunctionInfoTyped{105, &IDebug::DeleteApplicationArea, "DeleteApplicationArea"}, FunctionInfoTyped{106, &IDebug::ExistsApplicationArea, "ExistsApplicationArea"}, FunctionInfoTyped{200, &IDebug::GetAll, "GetAll"}, FunctionInfoTyped{201, &IDebug::SetAll, "SetAll"}, FunctionInfoTyped{202, &IDebug::FlushDebug, "FlushDebug"}, FunctionInfoTyped{203, &IDebug::BreakTag, "BreakTag"}, FunctionInfoTyped{204, &IDebug::ReadBackupData, "ReadBackupData"}, FunctionInfoTyped{205, &IDebug::WriteBackupData, "WriteBackupData"}, FunctionInfoTyped{206, &IDebug::WriteNtf, "WriteNtf"} ); }; class IUserManager final : public ServiceFramework { public: explicit IUserManager(Core::System& system_) : ServiceFramework{system_, "nfp:user"} {} private: void CreateUserInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface(ctx, system); } FunctionInfoBase const* FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } static constexpr auto functions = CreateStaticMap( FunctionInfo{0, &IUserManager::CreateUserInterface, "CreateUserInterface"} ); }; class ISystemManager final : public ServiceFramework { public: explicit ISystemManager(Core::System& system_) : ServiceFramework{system_, "nfp:sys"} {} FunctionInfoBase const* FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } private: void CreateSystemInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface(ctx, system); } static constexpr auto functions = CreateStaticMap( FunctionInfo{0, &ISystemManager::CreateSystemInterface, "CreateSystemInterface"} ); }; class IDebugManager final : public ServiceFramework { public: explicit IDebugManager(Core::System& system_) : ServiceFramework{system_, "nfp:dbg"} {} FunctionInfoBase const* FindRequest(u32 key) override { return HandlerTableGenerateWithFind(key, functions); } private: void CreateDebugInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface(ctx, system); } static constexpr auto functions = CreateStaticMap( FunctionInfo{0, &IDebugManager::CreateDebugInterface, "CreateDebugInterface"} ); }; void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); server_manager->RegisterNamedService("nfp:user", std::make_shared(system)); server_manager->RegisterNamedService("nfp:sys", std::make_shared(system)); server_manager->RegisterNamedService("nfp:dbg", std::make_shared(system)); ServerManager::RunServer(std::move(server_manager)); } } // namespace Service::NFP