aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/service/psc/psc.cpp
blob: 31fb9f011730c2f9b82b52413688052773faf690 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// 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/psc/ovln/receiver_service.h"
#include "core/hle/service/psc/ovln/sender_service.h"
#include "core/hle/service/psc/pm_control.h"
#include "core/hle/service/psc/pm_service.h"
#include "core/hle/service/psc/psc.h"
#include "core/hle/service/psc/time/manager.h"
#include "core/hle/service/psc/time/power_state_service.h"
#include "core/hle/service/psc/time/service_manager.h"
#include "core/hle/service/psc/time/static.h"
#include "core/hle/service/service.h"

namespace Service::PSC {

class PSC_L final : public ServiceFramework<PSC_L> {
public:
    explicit PSC_L(Core::System& system_) : ServiceFramework{system_, "psc:l"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "Initialize_3"},
            {1, nullptr, "Lock"},
            {2, nullptr, "Unlock"},
            {3, nullptr, "IsLocked"},
            {4, nullptr, "GetRelatedState"},
        };
        // clang-format on
        RegisterHandlers(functions);
    }
};

class INS_R final : public ServiceFramework<INS_R> {
public:
    explicit INS_R(Core::System& system_) : ServiceFramework{system_, "ins:r"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "GetInputSourceState"},
            {1, nullptr, "GetTriggerTargetEvent"},
        };
        // clang-format on
        RegisterHandlers(functions);
    }
};

class INS_S final : public ServiceFramework<INS_S> {
public:
    explicit INS_S(Core::System& system_) : ServiceFramework{system_, "ins:s"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "GetNotifyEvent"},
        };
        // clang-format on
        RegisterHandlers(functions);
    }
};

class HSHL_SYS final : public ServiceFramework<HSHL_SYS> {
public:
    explicit HSHL_SYS(Core::System& system_) : ServiceFramework{system_, "hshl:sys"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "GetBatteryPercentage"},
            {1, nullptr, "GetChargerType"},
            {2, nullptr, "OpenChargeSession"},
            {3, nullptr, "GetRawBatteryPercentage"},
            {4, nullptr, "GetBatteryVoltageLevel"},
            {5, nullptr, "OpenThermalSession"},
            {6, nullptr, "GetAbnormalTemperatureSet"},
            {7, nullptr, "OpenClockSession"},
            {8, nullptr, "GetClockRate"},
            {9, nullptr, "OpenBridgeSession"},
            {10, nullptr, "GetBridgePowerSupply"},
            {11, nullptr, "OpenVsysVoltageSession"},
            {12, nullptr, "GetIsBatteryEnoughForFullAwake"},
            {13, nullptr, "GetIsCharging"},
            {14, nullptr, "Cmd14"},
            {15, nullptr, "Cmd15"},
        };
        // clang-format on
        RegisterHandlers(functions);
    }
};

class HSHL_SET final : public ServiceFramework<HSHL_SET> {
public:
    explicit HSHL_SET(Core::System& system_) : ServiceFramework{system_, "hshl:set"} {
        // clang-format off
        static const FunctionInfo functions[] = {
            {0, nullptr, "OpenChargeSession_2"},
            {1, nullptr, "OpenThermalSession_2"},
            {2, nullptr, "SetClockRate"},
            {3, nullptr, "SetBridgePowerSupply"},
            {4, nullptr, "Cmd4"},
            {5, nullptr, "Cmd5"},
        };
        // clang-format on
        RegisterHandlers(functions);
    }
};

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

    server_manager->RegisterNamedService("psc:c", std::make_shared<IPmControl>(system));
    server_manager->RegisterNamedService("psc:m", std::make_shared<IPmService>(system));
    server_manager->RegisterNamedService("psc:l", std::make_shared<PSC_L>(system));
    server_manager->RegisterNamedService("ins:r", std::make_shared<INS_R>(system));
    server_manager->RegisterNamedService("ins:s", std::make_shared<INS_S>(system));
    server_manager->RegisterNamedService("hshl:sys", std::make_shared<HSHL_SYS>(system));
    server_manager->RegisterNamedService("hshl:set", std::make_shared<HSHL_SET>(system));
    server_manager->RegisterNamedService("ovln:rcv", std::make_shared<IReceiverService>(system));
    server_manager->RegisterNamedService("ovln:snd", std::make_shared<ISenderService>(system));

    auto time = std::make_shared<Time::TimeManager>(system);

    server_manager->RegisterNamedService("time:m", std::make_shared<Time::ServiceManager>(system, time, server_manager.get()));
    server_manager->RegisterNamedService("time:su", std::make_shared<Time::StaticService>(system, Time::StaticServiceSetupInfo{0, 0, 0, 0, 0, 1}, time, "time:su"));
    server_manager->RegisterNamedService("time:al", std::make_shared<Time::IAlarmService>(system, time));

    ServerManager::RunServer(std::move(server_manager));
}

} // namespace Service::PSC