rewrite everything
This commit is contained in:
26
Source/sys-clk/common/include/sysclk.h
Normal file
26
Source/sys-clk/common/include/sysclk.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sysclk/ipc.h"
|
||||
#include "sysclk/board.h"
|
||||
#include "sysclk/clock_manager.h"
|
||||
#include "sysclk/apm.h"
|
||||
#include "sysclk/config.h"
|
||||
#include "sysclk/errors.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
22
Source/sys-clk/common/include/sysclk/apm.h
Normal file
22
Source/sys-clk/common/include/sysclk/apm.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "board.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
uint32_t cpu_hz;
|
||||
uint32_t gpu_hz;
|
||||
uint32_t mem_hz;
|
||||
} SysClkApmConfiguration;
|
||||
|
||||
extern SysClkApmConfiguration sysclk_g_apm_configurations[];
|
||||
126
Source/sys-clk/common/include/sysclk/board.h
Normal file
126
Source/sys-clk/common/include/sysclk/board.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkSocType_Erista = 0,
|
||||
SysClkSocType_Mariko,
|
||||
SysClkSocType_EnumMax
|
||||
} SysClkSocType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkProfile_Handheld = 0,
|
||||
SysClkProfile_HandheldCharging,
|
||||
SysClkProfile_HandheldChargingUSB,
|
||||
SysClkProfile_HandheldChargingOfficial,
|
||||
SysClkProfile_Docked,
|
||||
SysClkProfile_EnumMax
|
||||
} SysClkProfile;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkModule_CPU = 0,
|
||||
SysClkModule_GPU,
|
||||
SysClkModule_MEM,
|
||||
SysClkModule_EnumMax
|
||||
} SysClkModule;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkThermalSensor_SOC = 0,
|
||||
SysClkThermalSensor_PCB,
|
||||
SysClkThermalSensor_Skin,
|
||||
SysClkThermalSensor_EnumMax
|
||||
} SysClkThermalSensor;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkPowerSensor_Now = 0,
|
||||
SysClkPowerSensor_Avg,
|
||||
SysClkPowerSensor_EnumMax
|
||||
} SysClkPowerSensor;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkRamLoad_All = 0,
|
||||
SysClkRamLoad_Cpu,
|
||||
SysClkRamLoad_EnumMax
|
||||
} SysClkRamLoad;
|
||||
|
||||
#define SYSCLK_ENUM_VALID(n, v) ((v) < n##_EnumMax)
|
||||
|
||||
static inline const char* sysclkFormatModule(SysClkModule module, bool pretty)
|
||||
{
|
||||
switch(module)
|
||||
{
|
||||
case SysClkModule_CPU:
|
||||
return pretty ? "CPU" : "cpu";
|
||||
case SysClkModule_GPU:
|
||||
return pretty ? "GPU" : "gpu";
|
||||
case SysClkModule_MEM:
|
||||
return pretty ? "Memory" : "mem";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const char* sysclkFormatThermalSensor(SysClkThermalSensor thermSensor, bool pretty)
|
||||
{
|
||||
switch(thermSensor)
|
||||
{
|
||||
case SysClkThermalSensor_SOC:
|
||||
return pretty ? "SOC" : "soc";
|
||||
case SysClkThermalSensor_PCB:
|
||||
return pretty ? "PCB" : "pcb";
|
||||
case SysClkThermalSensor_Skin:
|
||||
return pretty ? "Skin" : "skin";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const char* sysclkFormatPowerSensor(SysClkPowerSensor powSensor, bool pretty)
|
||||
{
|
||||
switch(powSensor)
|
||||
{
|
||||
case SysClkPowerSensor_Now:
|
||||
return pretty ? "Now" : "now";
|
||||
case SysClkPowerSensor_Avg:
|
||||
return pretty ? "Avg" : "avg";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const char* sysclkFormatProfile(SysClkProfile profile, bool pretty)
|
||||
{
|
||||
switch(profile)
|
||||
{
|
||||
case SysClkProfile_Docked:
|
||||
return pretty ? "Docked" : "docked";
|
||||
case SysClkProfile_Handheld:
|
||||
return pretty ? "Handheld" : "handheld";
|
||||
case SysClkProfile_HandheldCharging:
|
||||
return pretty ? "Charging" : "handheld_charging";
|
||||
case SysClkProfile_HandheldChargingUSB:
|
||||
return pretty ? "USB Charger" : "handheld_charging_usb";
|
||||
case SysClkProfile_HandheldChargingOfficial:
|
||||
return pretty ? "Official Charger" : "handheld_charging_official";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
38
Source/sys-clk/common/include/sysclk/client/ipc.h
Normal file
38
Source/sys-clk/common/include/sysclk/client/ipc.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "../config.h"
|
||||
#include "../board.h"
|
||||
#include "../ipc.h"
|
||||
|
||||
bool sysclkIpcRunning();
|
||||
Result sysclkIpcInitialize(void);
|
||||
void sysclkIpcExit(void);
|
||||
|
||||
Result sysclkIpcGetAPIVersion(u32* out_ver);
|
||||
Result sysclkIpcGetVersionString(char* out, size_t len);
|
||||
Result sysclkIpcGetCurrentContext(SysClkContext* out_context);
|
||||
Result sysclkIpcGetProfileCount(u64 tid, u8* out_count);
|
||||
Result sysclkIpcSetEnabled(bool enabled);
|
||||
Result sysclkIpcExitCmd();
|
||||
Result sysclkIpcSetOverride(SysClkModule module, u32 hz);
|
||||
Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles);
|
||||
Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles);
|
||||
Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues);
|
||||
Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues);
|
||||
Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* outCount);
|
||||
|
||||
static inline Result sysclkIpcRemoveOverride(SysClkModule module)
|
||||
{
|
||||
return sysclkIpcSetOverride(module, 0);
|
||||
}
|
||||
29
Source/sys-clk/common/include/sysclk/client/types.h
Normal file
29
Source/sys-clk/common/include/sysclk/client/types.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __SWITCH__
|
||||
|
||||
#include <switch/types.h>
|
||||
#include <switch/result.h>
|
||||
|
||||
#else
|
||||
|
||||
#define R_FAILED(res) ((res) != 0)
|
||||
#define R_SUCCEEDED(res) ((res) == 0)
|
||||
|
||||
typedef std::uint32_t Result;
|
||||
typedef std::uint32_t u32;
|
||||
typedef std::int32_t s32;
|
||||
typedef std::uint64_t u64;
|
||||
typedef std::uint8_t u8;
|
||||
|
||||
#endif
|
||||
37
Source/sys-clk/common/include/sysclk/clock_manager.h
Normal file
37
Source/sys-clk/common/include/sysclk/clock_manager.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "board.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enabled;
|
||||
uint64_t applicationId;
|
||||
SysClkProfile profile;
|
||||
uint32_t freqs[SysClkModule_EnumMax];
|
||||
uint32_t realFreqs[SysClkModule_EnumMax];
|
||||
uint32_t overrideFreqs[SysClkModule_EnumMax];
|
||||
uint32_t temps[SysClkThermalSensor_EnumMax];
|
||||
int32_t power[SysClkPowerSensor_EnumMax];
|
||||
uint32_t ramLoad[SysClkRamLoad_EnumMax];
|
||||
} SysClkContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
uint32_t mhz[SysClkProfile_EnumMax * SysClkModule_EnumMax];
|
||||
uint32_t mhzMap[SysClkProfile_EnumMax][SysClkModule_EnumMax];
|
||||
};
|
||||
} SysClkTitleProfileList;
|
||||
|
||||
#define SYSCLK_FREQ_LIST_MAX 32
|
||||
79
Source/sys-clk/common/include/sysclk/config.h
Normal file
79
Source/sys-clk/common/include/sysclk/config.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef enum {
|
||||
SysClkConfigValue_PollingIntervalMs = 0,
|
||||
SysClkConfigValue_TempLogIntervalMs,
|
||||
SysClkConfigValue_FreqLogIntervalMs,
|
||||
SysClkConfigValue_PowerLogIntervalMs,
|
||||
SysClkConfigValue_CsvWriteIntervalMs,
|
||||
SysClkConfigValue_EnumMax,
|
||||
SysClkConfigValue_UncappedClocks,
|
||||
} SysClkConfigValue;
|
||||
|
||||
typedef struct {
|
||||
uint64_t values[SysClkConfigValue_UncappedClocks];
|
||||
} SysClkConfigValueList;
|
||||
|
||||
static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pretty)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return pretty ? "Polling Interval (ms)" : "poll_interval_ms";
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
return pretty ? "Temperature logging interval (ms)" : "temp_log_interval_ms";
|
||||
case SysClkConfigValue_FreqLogIntervalMs:
|
||||
return pretty ? "Frequency logging interval (ms)" : "freq_log_interval_ms";
|
||||
case SysClkConfigValue_PowerLogIntervalMs:
|
||||
return pretty ? "Power logging interval (ms)" : "power_log_interval_ms";
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
return pretty ? "CSV write interval (ms)" : "csv_write_interval_ms";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return 300ULL;
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
case SysClkConfigValue_FreqLogIntervalMs:
|
||||
case SysClkConfigValue_PowerLogIntervalMs:
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
return 0ULL;
|
||||
default:
|
||||
return 0ULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t input)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return input > 0;
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
case SysClkConfigValue_FreqLogIntervalMs:
|
||||
case SysClkConfigValue_PowerLogIntervalMs:
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
return input >= 0;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
21
Source/sys-clk/common/include/sysclk/errors.h
Normal file
21
Source/sys-clk/common/include/sysclk/errors.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SYSCLK_ERROR_MODULE 388
|
||||
#define SYSCLK_ERROR(desc) ((SYSCLK_ERROR_MODULE & 0x1FF) | (SysClkError_##desc & 0x1FFF)<<9)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkError_Generic = 0,
|
||||
SysClkError_ConfigNotLoaded = 1,
|
||||
SysClkError_ConfigSaveFailed = 2,
|
||||
} SysClkError;
|
||||
54
Source/sys-clk/common/include/sysclk/ipc.h
Normal file
54
Source/sys-clk/common/include/sysclk/ipc.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "board.h"
|
||||
#include "clock_manager.h"
|
||||
|
||||
#define SYSCLK_IPC_API_VERSION 4
|
||||
#define SYSCLK_IPC_SERVICE_NAME "sys:clk"
|
||||
|
||||
enum SysClkIpcCmd
|
||||
{
|
||||
SysClkIpcCmd_GetApiVersion = 0,
|
||||
SysClkIpcCmd_GetVersionString = 1,
|
||||
SysClkIpcCmd_GetCurrentContext = 2,
|
||||
SysClkIpcCmd_Exit = 3,
|
||||
SysClkIpcCmd_GetProfileCount = 4,
|
||||
SysClkIpcCmd_GetProfiles = 5,
|
||||
SysClkIpcCmd_SetProfiles = 6,
|
||||
SysClkIpcCmd_SetEnabled = 7,
|
||||
SysClkIpcCmd_SetOverride = 8,
|
||||
SysClkIpcCmd_GetConfigValues = 9,
|
||||
SysClkIpcCmd_SetConfigValues = 10,
|
||||
SysClkIpcCmd_ToggleUncappedClocks = 11,
|
||||
SysClkIpcCmd_GetFreqList = 12,
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t tid;
|
||||
SysClkTitleProfileList profiles;
|
||||
} SysClkIpc_SetProfiles_Args;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SysClkModule module;
|
||||
uint32_t hz;
|
||||
} SysClkIpc_SetOverride_Args;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SysClkModule module;
|
||||
uint32_t maxCount;
|
||||
} SysClkIpc_GetFreqList_Args;
|
||||
32
Source/sys-clk/common/src/apm_profile_table.c
Normal file
32
Source/sys-clk/common/src/apm_profile_table.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <sysclk/apm.h>
|
||||
|
||||
SysClkApmConfiguration sysclk_g_apm_configurations[] = {
|
||||
{0x00010000, 1020000000, 384000000, 1600000000},
|
||||
{0x00010001, 1020000000, 768000000, 1600000000},
|
||||
{0x00010002, 1224000000, 691200000, 1600000000},
|
||||
{0x00020000, 1020000000, 230400000, 1600000000},
|
||||
{0x00020001, 1020000000, 307200000, 1600000000},
|
||||
{0x00020002, 1224000000, 230400000, 1600000000},
|
||||
{0x00020003, 1020000000, 307200000, 1331200000},
|
||||
{0x00020004, 1020000000, 384000000, 1331200000},
|
||||
{0x00020005, 1020000000, 307200000, 1065600000},
|
||||
{0x00020006, 1020000000, 384000000, 1065600000},
|
||||
{0x92220007, 1020000000, 460800000, 1600000000},
|
||||
{0x92220008, 1020000000, 460800000, 1331200000},
|
||||
{0x92220009, 1785000000, 76800000, 1600000000},
|
||||
{0x9222000A, 1785000000, 76800000, 1331200000},
|
||||
{0x9222000B, 1020000000, 76800000, 1600000000},
|
||||
{0x9222000C, 1020000000, 76800000, 1331200000},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
133
Source/sys-clk/common/src/client/ipc.c
Normal file
133
Source/sys-clk/common/src/client/ipc.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include <sysclk/client/ipc.h>
|
||||
#include <switch.h>
|
||||
#include <string.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
static Service g_sysclkSrv;
|
||||
static atomic_size_t g_refCnt;
|
||||
|
||||
bool sysclkIpcRunning()
|
||||
{
|
||||
Handle handle;
|
||||
bool running = R_FAILED(smRegisterService(&handle, smEncodeName(SYSCLK_IPC_SERVICE_NAME), false, 1));
|
||||
|
||||
if (!running)
|
||||
{
|
||||
smUnregisterService(smEncodeName(SYSCLK_IPC_SERVICE_NAME));
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
Result sysclkIpcInitialize(void)
|
||||
{
|
||||
Result rc = 0;
|
||||
|
||||
g_refCnt++;
|
||||
|
||||
if (serviceIsActive(&g_sysclkSrv))
|
||||
return 0;
|
||||
|
||||
rc = smGetService(&g_sysclkSrv, SYSCLK_IPC_SERVICE_NAME);
|
||||
|
||||
if (R_FAILED(rc)) sysclkIpcExit();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void sysclkIpcExit(void)
|
||||
{
|
||||
if (--g_refCnt == 0)
|
||||
{
|
||||
serviceClose(&g_sysclkSrv);
|
||||
}
|
||||
}
|
||||
|
||||
Result sysclkIpcGetAPIVersion(u32* out_ver)
|
||||
{
|
||||
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetApiVersion, *out_ver);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetVersionString(char* out, size_t len)
|
||||
{
|
||||
return serviceDispatch(&g_sysclkSrv, SysClkIpcCmd_GetVersionString,
|
||||
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||
.buffers = {{out, len}},
|
||||
);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetCurrentContext(SysClkContext* out_context)
|
||||
{
|
||||
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetCurrentContext, *out_context);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetProfileCount(u64 tid, u8* out_count)
|
||||
{
|
||||
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetProfileCount, tid, *out_count);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetEnabled(bool enabled)
|
||||
{
|
||||
u8 enabledRaw = (u8)enabled;
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetEnabled, enabledRaw);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetOverride(SysClkModule module, u32 hz)
|
||||
{
|
||||
SysClkIpc_SetOverride_Args args = {
|
||||
.module = module,
|
||||
.hz = hz
|
||||
};
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetOverride, args);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles)
|
||||
{
|
||||
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetProfiles, tid, *out_profiles);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles)
|
||||
{
|
||||
SysClkIpc_SetProfiles_Args args;
|
||||
args.tid = tid;
|
||||
memcpy(&args.profiles, profiles, sizeof(SysClkTitleProfileList));
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetProfiles, args);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues)
|
||||
{
|
||||
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues, *out_configValues);
|
||||
}
|
||||
|
||||
Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues)
|
||||
{
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetConfigValues, *configValues);
|
||||
}
|
||||
|
||||
Result SysClkIpcToggleUncappedClocks(bool toggled)
|
||||
{
|
||||
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_ToggleUncappedClocks, *toggled);
|
||||
}
|
||||
|
||||
Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* outCount)
|
||||
{
|
||||
SysClkIpc_GetFreqList_Args args = {
|
||||
.module = module,
|
||||
.maxCount = maxCount
|
||||
};
|
||||
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetFreqList, args, *outCount,
|
||||
.buffer_attrs = { SfBufferAttr_HipcAutoSelect | SfBufferAttr_Out },
|
||||
.buffers = {{list, maxCount * sizeof(u32)}},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user