VERY experimental Nintendo Switch 2 emulator
C++
service: Add ldn services
Lioncash6116b53dfb9f
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cppindex 59b999935b..ad9edbcdf0 100644--- a/src/common/logging/backend.cpp+++ b/src/common/logging/backend.cpp@@ -173,6 +173,7 @@ void FileBackend::Write(const Entry& entry) {SUB(Service, Friend) \SUB(Service, FS) \SUB(Service, HID) \+ SUB(Service, LDN) \SUB(Service, LM) \SUB(Service, MM) \SUB(Service, NFP) \diff --git a/src/common/logging/log.h b/src/common/logging/log.hindex e7115933f3..ad3cbf5d15 100644--- a/src/common/logging/log.h+++ b/src/common/logging/log.h@@ -60,6 +60,7 @@ enum class Class : ClassType {Service_Friend, ///< The friend serviceService_FS, ///< The FS (Filesystem) serviceService_HID, ///< The HID (Human interface device) service+ Service_LDN, ///< The LDN (Local domain network) serviceService_LM, ///< The LM (Logger) serviceService_MM, ///< The MM (Multimedia) serviceService_NFP, ///< The NFP servicediff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex 2e2de59b12..2602174427 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -158,6 +158,8 @@ add_library(core STATIChle/service/friend/interface.hhle/service/hid/hid.cpphle/service/hid/hid.h+ hle/service/ldn/ldn.cpp+ hle/service/ldn/ldn.hhle/service/ldr/ldr.cpphle/service/ldr/ldr.hhle/service/lm/lm.cppdiff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cppnew file mode 100644index 0000000000..167f2c66a9--- /dev/null+++ b/src/core/hle/service/ldn/ldn.cpp@@ -0,0 +1,142 @@+// Copyright 2018 yuzu emulator team+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#include <memory>++#include "core/hle/ipc_helpers.h"+#include "core/hle/result.h"+#include "core/hle/service/ldn/ldn.h"+#include "core/hle/service/sm/sm.h"++namespace Service::LDN {++class IMonitorService final : public ServiceFramework<IMonitorService> {+public:+ explicit IMonitorService() : ServiceFramework{"IMonitorService"} {+ // clang-format off+ static const FunctionInfo functions[] = {+ {0, nullptr, "GetStateForMonitor"},+ {1, nullptr, "GetNetworkInfoForMonitor"},+ {2, nullptr, "GetIpv4AddressForMonitor"},+ {3, nullptr, "GetDisconnectReasonForMonitor"},+ {4, nullptr, "GetSecurityParameterForMonitor"},+ {5, nullptr, "GetNetworkConfigForMonitor"},+ {100, nullptr, "InitializeMonitor"},+ {101, nullptr, "FinalizeMonitor"},+ };+ // clang-format on++ RegisterHandlers(functions);+ }+};++class LDNM final : public ServiceFramework<LDNM> {+public:+ explicit LDNM() : ServiceFramework{"ldn:m"} {+ // clang-format off+ static const FunctionInfo functions[] = {+ {0, &LDNM::CreateMonitorService, "CreateMonitorService"}+ };+ // clang-format on++ RegisterHandlers(functions);+ }++ void CreateMonitorService(Kernel::HLERequestContext& ctx) {+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};+ rb.Push(RESULT_SUCCESS);+ rb.PushIpcInterface<IMonitorService>();++ LOG_DEBUG(Service_LDN, "called");+ }+};++class ILocalCommunicationService final : public ServiceFramework<ILocalCommunicationService> {+public:+ explicit ILocalCommunicationService(const char* name) : ServiceFramework{name} {+ // clang-format off+ static const FunctionInfo functions[] = {+ {0, nullptr, "GetState"},+ {1, nullptr, "GetNetworkInfo"},+ {2, nullptr, "GetIpv4Address"},+ {3, nullptr, "GetDisconnectReason"},+ {4, nullptr, "GetSecurityParameter"},+ {5, nullptr, "GetNetworkConfig"},+ {100, nullptr, "AttachStateChangeEvent"},+ {101, nullptr, "GetNetworkInfoLatestUpdate"},+ {102, nullptr, "Scan"},+ {103, nullptr, "ScanPrivate"},+ {200, nullptr, "OpenAccessPoint"},+ {201, nullptr, "CloseAccessPoint"},+ {202, nullptr, "CreateNetwork"},+ {203, nullptr, "CreateNetworkPrivate"},+ {204, nullptr, "DestroyNetwork"},+ {205, nullptr, "Reject"},+ {206, nullptr, "SetAdvertiseData"},+ {207, nullptr, "SetStationAcceptPolicy"},+ {208, nullptr, "AddAcceptFilterEntry"},+ {209, nullptr, "ClearAcceptFilter"},+ {300, nullptr, "OpenStation"},+ {301, nullptr, "CloseStation"},+ {302, nullptr, "Connect"},+ {303, nullptr, "ConnectPrivate"},+ {304, nullptr, "Disconnect"},+ {400, nullptr, "InitializeSystem"},+ {401, nullptr, "FinalizeSystem"},+ };+ // clang-format on++ RegisterHandlers(functions);+ }+};++class LDNS final : public ServiceFramework<LDNS> {+public:+ explicit LDNS() : ServiceFramework{"ldn:s"} {+ // clang-format off+ static const FunctionInfo functions[] = {+ {0, &LDNS::CreateSystemLocalCommunicationService, "CreateSystemLocalCommunicationService"},+ };+ // clang-format on++ RegisterHandlers(functions);+ }++ void CreateSystemLocalCommunicationService(Kernel::HLERequestContext& ctx) {+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};+ rb.Push(RESULT_SUCCESS);+ rb.PushIpcInterface<ILocalCommunicationService>("ISystemLocalCommunicationService");++ LOG_DEBUG(Service_LDN, "called");+ }+};++class LDNU final : public ServiceFramework<LDNU> {+public:+ explicit LDNU() : ServiceFramework{"ldn:u"} {+ // clang-format off+ static const FunctionInfo functions[] = {+ {0, &LDNU::CreateUserLocalCommunicationService, "CreateUserLocalCommunicationService"},+ };+ // clang-format on++ RegisterHandlers(functions);+ }++ void CreateUserLocalCommunicationService(Kernel::HLERequestContext& ctx) {+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};+ rb.Push(RESULT_SUCCESS);+ rb.PushIpcInterface<ILocalCommunicationService>("IUserLocalCommunicationService");++ LOG_DEBUG(Service_LDN, "called");+ }+};++void InstallInterfaces(SM::ServiceManager& sm) {+ std::make_shared<LDNM>()->InstallAsService(sm);+ std::make_shared<LDNS>()->InstallAsService(sm);+ std::make_shared<LDNU>()->InstallAsService(sm);+}++} // namespace Service::LDNdiff --git a/src/core/hle/service/ldn/ldn.h b/src/core/hle/service/ldn/ldn.hnew file mode 100644index 0000000000..6b2a3c2b2a--- /dev/null+++ b/src/core/hle/service/ldn/ldn.h@@ -0,0 +1,16 @@+// Copyright 2018 yuzu emulator team+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#pragma once++namespace Service::SM {+class ServiceManager;+}++namespace Service::LDN {++/// Registers all LDN services with the specified service manager.+void InstallInterfaces(SM::ServiceManager& sm);++} // namespace Service::LDNdiff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cppindex 482989ea72..1e24d33e2d 100644--- a/src/core/hle/service/service.cpp+++ b/src/core/hle/service/service.cpp@@ -28,6 +28,7 @@#include "core/hle/service/filesystem/filesystem.h"#include "core/hle/service/friend/friend.h"#include "core/hle/service/hid/hid.h"+#include "core/hle/service/ldn/ldn.h"#include "core/hle/service/ldr/ldr.h"#include "core/hle/service/lm/lm.h"#include "core/hle/service/mm/mm_u.h"@@ -199,6 +200,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {FileSystem::InstallInterfaces(*sm);Friend::InstallInterfaces(*sm);HID::InstallInterfaces(*sm);+ LDN::InstallInterfaces(*sm);LDR::InstallInterfaces(*sm);LM::InstallInterfaces(*sm);MM::InstallInterfaces(*sm);