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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/pcv/pcv.h"
#include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"
namespace Service::PCV {
class PCV final : public ServiceFramework<PCV> {
public:
explicit PCV(Core::System& system_) : ServiceFramework{system_, "pcv"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "SetPowerEnabled"},
{1, nullptr, "SetClockEnabled"},
{2, nullptr, "SetClockRate"},
{3, nullptr, "GetClockRate"},
{4, nullptr, "GetState"},
{5, nullptr, "GetPossibleClockRates"},
{6, nullptr, "SetMinVClockRate"},
{7, nullptr, "SetReset"},
{8, nullptr, "SetVoltageEnabled"},
{9, nullptr, "GetVoltageEnabled"},
{10, nullptr, "GetVoltageRange"},
{11, nullptr, "SetVoltageValue"},
{12, nullptr, "GetVoltageValue"},
{13, nullptr, "GetTemperatureThresholds"},
{14, nullptr, "SetTemperature"},
{15, nullptr, "Initialize"},
{16, nullptr, "IsInitialized"},
{17, nullptr, "Finalize"},
{18, nullptr, "PowerOn"},
{19, nullptr, "PowerOff"},
{20, nullptr, "ChangeVoltage"},
{21, nullptr, "GetPowerClockInfoEvent"},
{22, nullptr, "GetOscillatorClock"},
{23, nullptr, "GetDvfsTable"},
{24, nullptr, "GetModuleStateTable"},
{25, nullptr, "GetPowerDomainStateTable"},
{26, nullptr, "GetFuseInfo"},
{27, nullptr, "GetDramId"},
{28, nullptr, "IsPoweredOn"},
{29, nullptr, "GetVoltage"},
};
// clang-format on
RegisterHandlers(functions);
}
};
class IClkrstSession final : public ServiceFramework<IClkrstSession> {
public:
explicit IClkrstSession(Core::System& system_, DeviceCode deivce_code_)
: ServiceFramework{system_, "IClkrstSession"}, deivce_code(deivce_code_) {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "SetClockEnabled"},
{1, nullptr, "SetClockDisabled"},
{2, nullptr, "SetResetAsserted"},
{3, nullptr, "SetResetDeasserted"},
{4, nullptr, "SetPowerEnabled"},
{5, nullptr, "SetPowerDisabled"},
{6, nullptr, "GetState"},
{7, &IClkrstSession::SetClockRate, "SetClockRate"},
{8, &IClkrstSession::GetClockRate, "GetClockRate"},
{9, nullptr, "SetMinVClockRate"},
{10, nullptr, "GetPossibleClockRates"},
{11, nullptr, "GetDvfsTable"},
};
// clang-format on
RegisterHandlers(functions);
}
private:
void SetClockRate(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
clock_rate = rp.Pop<u32>();
LOG_DEBUG(Service_PCV, "(STUBBED) called, clock_rate={}", clock_rate);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void GetClockRate(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_PCV, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u32>(clock_rate);
}
DeviceCode deivce_code;
u32 clock_rate{};
};
class CLKRST final : public ServiceFramework<CLKRST> {
public:
explicit CLKRST(Core::System& system_, const char* name) : ServiceFramework{system_, name} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &CLKRST::OpenSession, "OpenSession"},
{1, nullptr, "GetTemperatureThresholds"},
{2, nullptr, "SetTemperature"},
{3, nullptr, "GetModuleStateTable"},
{4, nullptr, "GetModuleStateTableEvent"},
{5, nullptr, "GetModuleStateTableMaxCount"},
};
// clang-format on
RegisterHandlers(functions);
}
private:
void OpenSession(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto device_code = static_cast<DeviceCode>(rp.Pop<u32>());
const auto unkonwn_input = rp.Pop<u32>();
LOG_DEBUG(Service_PCV, "called, device_code={}, input={}", device_code, unkonwn_input);
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<IClkrstSession>(system, device_code);
}
};
class CLKRST_A final : public ServiceFramework<CLKRST_A> {
public:
explicit CLKRST_A(Core::System& system_) : ServiceFramework{system_, "clkrst:a"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "ReleaseControl"},
};
// clang-format on
RegisterHandlers(functions);
}
};
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
std::make_shared<PCV>(system)->InstallAsService(sm);
std::make_shared<CLKRST>(system, "clkrst")->InstallAsService(sm);
std::make_shared<CLKRST>(system, "clkrst:i")->InstallAsService(sm);
std::make_shared<CLKRST_A>(system)->InstallAsService(sm);
}
} // namespace Service::PCV
|