Add pcvSetVoltageEnabled and pcvGetVoltageEnabled

This commit is contained in:
dark-samus 2018-11-17 01:25:19 -05:00
parent e7117a7903
commit 7f2c3f7d3c
2 changed files with 82 additions and 0 deletions

View File

@ -18,3 +18,6 @@ void pcvExit(void);
Result pcvGetClockRate(PcvModule module, u32 *out_hz);
Result pcvSetClockRate(PcvModule module, u32 hz);
Result pcvSetVoltageEnabled(bool state, u32 voltage);
Result pcvGetVoltageEnabled(bool *isEnabled, u32 voltage);

View File

@ -104,3 +104,82 @@ Result pcvGetClockRate(PcvModule module, u32 *out_hz) {
return rc;
}
Result pcvSetVoltageEnabled(bool state, u32 voltage)
{
IpcCommand c;
ipcInitialize(&c);
struct
{
u64 magic;
u64 cmd_id;
bool state;
u32 voltage;
} *raw;
raw = serviceIpcPrepareHeader(&g_pcvSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 8;
raw->state = state;
raw->voltage = voltage;
Result rc = serviceIpcDispatch(&g_pcvSrv);
if (R_SUCCEEDED(rc))
{
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(&g_pcvSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result pcvGetVoltageEnabled(bool *isEnabled, u32 voltage)
{
IpcCommand c;
ipcInitialize(&c);
struct
{
u64 magic;
u64 cmd_id;
u32 voltage;
} *raw;
raw = serviceIpcPrepareHeader(&g_pcvSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 9;
raw->voltage = voltage;
Result rc = serviceIpcDispatch(&g_pcvSrv);
if (R_SUCCEEDED(rc))
{
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
bool isEnabled;
} *resp;
serviceIpcParse(&g_pcvSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
*isEnabled = resp->isEnabled;
}
return rc;
}