aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/service/ns/ns.cpp
blob: fe057422cec1be6b6c1395405ec76c6edd5dbf4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// 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 "core/hle/service/ns/develop_interface.h"
#include "core/hle/service/ns/ns.h"
#include "core/hle/service/ns/platform_service_manager.h"
#include "core/hle/service/ns/query_service.h"
#include "core/hle/service/ns/service_getter_interface.h"
#include "core/hle/service/ns/system_update_interface.h"
#include "core/hle/service/ipc_helpers.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/server_manager.h"

namespace Service::NS {

class INotifyService final : public ServiceFramework<INotifyService> {
public:
    explicit INotifyService(Core::System& system_) : ServiceFramework{system_, "pdm:ntfy"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            { 0, nullptr, "NotifyAppletEvent" },
            { 2, nullptr, "NotifyOperationModeChangeEvent" },
            { 3, nullptr, "NotifyPowerStateChangeEvent" },
            { 4, nullptr, "NotifyClearAllEvent" },
            { 5, nullptr, "NotifyEventForDebug" },
            { 6, nullptr, "SuspendUserAccountEventService" },
            { 7, nullptr, "ResumeUserAccountEventService" },
            { 8, nullptr, "NotifyLibraryAppletEvent" },
            { 9, nullptr, "Cmd9" },
            { 20, nullptr, "Cmd20" },
            { 30, nullptr, "Cmd30" },
            { 100, nullptr, "Cmd100" },
            { 101, nullptr, "Cmd101" },
        };
        // clang-format on
        RegisterHandlers(functions);
    }
};

class IVulnerabilityManagerInterface final
    : public ServiceFramework<IVulnerabilityManagerInterface> {
public:
    explicit IVulnerabilityManagerInterface(Core::System& system_)
        : ServiceFramework{system_, "ns:vm"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {1200, D<&IVulnerabilityManagerInterface::NeedsUpdateVulnerability>, "NeedsUpdateVulnerability"},
            {1201, nullptr, "UpdateSafeSystemVersionForDebug"},
            {1202, nullptr, "GetSafeSystemVersion"},
            {3100, D<&IVulnerabilityManagerInterface::GetSafeSystemVersionCheckInfo>, "GetSafeSystemVersionCheckInfo"},
            {3101, nullptr, "RequestUpdateSafeSystemVersionCheckInfo"},
            {3102, D<&IVulnerabilityManagerInterface::ResetSafeSystemVersionCheckInfo>, "ResetSafeSystemVersionCheckInfo"},
        };
        // clang-format on
        RegisterHandlers(functions);
    }
    ~IVulnerabilityManagerInterface() override = default;

    Result NeedsUpdateVulnerability(Out<bool> out_needs_update_vulnerability) {
        LOG_WARNING(Service_NS, "(STUBBED)");
        *out_needs_update_vulnerability = false;
        R_SUCCEED();
    }

    Result GetSafeSystemVersionCheckInfo(Out<std::array<u8, 0x20>> out_system_version_check_info) {
        LOG_WARNING(Service_NS, "(STUBBED)");
        *out_system_version_check_info = {};
        R_SUCCEED();
    }

    Result ResetSafeSystemVersionCheckInfo() {
        LOG_WARNING(Service_NS, "(STUBBED)");
        R_SUCCEED();
    }
};

void LoopProcess(Core::System& system) {
    auto server_manager = std::make_unique<ServerManager>(system);

    server_manager->RegisterNamedService("ns:am2", std::make_shared<IServiceGetterInterface>(system, "ns:am2"), 5);
    server_manager->RegisterNamedService("ns:ec", std::make_shared<IServiceGetterInterface>(system, "ns:ec"), 5);
    server_manager->RegisterNamedService("ns:rid", std::make_shared<IServiceGetterInterface>(system, "ns:rid"), 5);
    server_manager->RegisterNamedService("ns:rt", std::make_shared<IServiceGetterInterface>(system, "ns:rt"), 5);
    server_manager->RegisterNamedService("ns:web", std::make_shared<IServiceGetterInterface>(system, "ns:web"), 5);
    server_manager->RegisterNamedService("ns:ro", std::make_shared<IServiceGetterInterface>(system, "ns:ro"), 5);

    server_manager->RegisterNamedService("ns:dev", std::make_shared<IDevelopInterface>(system), 5);
    server_manager->RegisterNamedService("ns:su", std::make_shared<ISystemUpdateInterface>(system), 5);
    server_manager->RegisterNamedService("ns:vm", std::make_shared<IVulnerabilityManagerInterface>(system), 5);
    server_manager->RegisterNamedService("pdm:ntfy", std::make_shared<INotifyService>(system));
    server_manager->RegisterNamedService("pdm:qry", std::make_shared<IQueryService>(system));

    server_manager->RegisterNamedService("pl:s", std::make_shared<IPlatformServiceManager>(system, "pl:s"));
    server_manager->RegisterNamedService("pl:u", std::make_shared<IPlatformServiceManager>(system, "pl:u"));
    ServerManager::RunServer(std::move(server_manager));
}

} // namespace Service::NS