SwitchIdent/source/kernel.cpp

167 lines
4.7 KiB
C++
Raw Permalink Normal View History

2021-11-05 04:59:45 +00:00
#include <cstdio>
#include "common.hpp"
namespace SwitchIdent {
const char *GetDramDesc(void) {
Result ret = 0;
u64 id = 0;
const char *dram_desc[] = {
"EristaIcosaSamsung4gb",
"EristaIcosaHynix4gb",
"EristaIcosaMicron4gb",
"MarikoIowaHynix1y4gb",
"EristaIcosaSamsung6gb",
"MarikoHoagHynix1y4gb",
"MarikoAulaHynix1y4gb",
"MarikoIowax1x2Samsung4gb",
"MarikoIowaSamsung4gb",
"MarikoIowaSamsung8gb",
"MarikoIowaHynix4gb",
"MarikoIowaMicron4gb",
"MarikoHoagSamsung4gb",
"MarikoHoagSamsung8gb",
"MarikoHoagSamsung8gb",
"MarikoHoagHynix4gb",
"MarikoHoagMicron4gb",
"MarikoIowaSamsung4gbY",
"MarikoIowaSamsung1y4gbX",
"MarikoIowaSamsung1y8gbX",
"MarikoHoagSamsung1y4gbX",
"MarikoIowaSamsung1y4gbY",
"MarikoIowaSamsung1y8gbY",
"MarikoAulaSamsung1y4gb",
"MarikoHoagSamsung1y8gbX",
"MarikoAulaSamsung1y4gbX",
"MarikoIowaMicron1y4gb",
"MarikoHoagMicron1y4gb",
"MarikoAulaMicron1y4gb",
"MarikoAulaSamsung1y8gbX",
"Unknown"
};
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = splGetConfig(SplConfigItem_DramId, &id))) {
2021-11-05 04:59:45 +00:00
std::printf("splGetConfig(SplConfigItem_DramId) failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
2023-06-18 19:17:59 +00:00
if (id >= 30) {
2021-11-05 04:59:45 +00:00
return dram_desc[30];
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
return dram_desc[id];
}
SetSysFirmwareVersion GetFirmwareVersion(void) {
Result ret = 0;
SetSysFirmwareVersion version;
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = setsysGetFirmwareVersion(&version))) {
2021-11-05 04:59:45 +00:00
std::printf("setsysGetFirmwareVersion() failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
return version;
}
const char *GetHardwareType(void) {
Result ret = 0;
u64 hardware_type;
const char *hardware_string[] = {
"Icosa",
"Copper",
"Hoag",
"Iowa",
"Calcio",
"Aula",
"Unknown"
};
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = splGetConfig(SplConfigItem_HardwareType, &hardware_type))) {
2021-11-05 04:59:45 +00:00
std::printf("splGetConfig(SplConfigItem_HardwareType) failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
2023-06-18 19:17:59 +00:00
if (hardware_type >= 6) {
2021-11-05 04:59:45 +00:00
return hardware_string[6];
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
return hardware_string[hardware_type];
}
// [4.0.0+] Kiosk mode (0 = retail; 1 = kiosk)
bool IsKiosk(void) {
u64 is_kiosk_mode = 0;
Result ret = 0;
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = splGetConfig(SplConfigItem_IsKiosk , &is_kiosk_mode))) {
2021-11-05 04:59:45 +00:00
std::printf("splGetConfig(SplConfigItem_IsKiosk) failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
return is_kiosk_mode? true : false;
}
const char *GetUnit(void) {
Result ret = 0;
u64 is_retail_mode = 0;
const char *unit[] = {
"Debug",
"Retail",
"Unknown"
};
if (R_FAILED(ret = splGetConfig(SplConfigItem_IsRetail, &is_retail_mode))) {
std::printf("splGetConfig(SplConfigItem_IsRetail) failed: 0x%x.\n\n", ret);
return unit[2];
}
return unit[is_retail_mode];
}
bool IsSafeMode(void) {
Result ret = 0;
u64 safemode = 0;
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = splGetConfig(SplConfigItem_IsRecoveryBoot, &safemode))) {
2021-11-05 04:59:45 +00:00
std::printf("splGetConfig(SplConfigItem_IsRecoveryBoot) failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
2023-06-18 19:17:59 +00:00
return safemode? true : false;
2021-11-05 04:59:45 +00:00
}
u64 GetDeviceID(void) {
Result ret = 0;
u64 id = 0;
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = splGetConfig(SplConfigItem_DeviceId, &id))) {
2021-11-05 04:59:45 +00:00
std::printf("splGetConfig(SplConfigItem_DeviceId) failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
return id;
}
SetSysSerialNumber GetSerialNumber(void) {
Result ret = 0;
SetSysSerialNumber serial;
2023-06-18 19:17:59 +00:00
if (R_FAILED(ret = setsysGetSerialNumber(&serial))) {
2021-11-05 04:59:45 +00:00
std::printf("setsysGetSerialNumber() failed: 0x%x.\n\n", ret);
2023-06-18 19:17:59 +00:00
}
2021-11-05 04:59:45 +00:00
return serial;
}
DockFirmwareVersion GetDockFirmware(void) {
Result ret = 0;
DockFirmwareVersion version;
if (R_FAILED(ret = appletGetCradleFwVersion(&version.major, &version.minor, &version.micro, &version.rev))) {
std::printf("appletGetCradleFwVersion() failed: 0x%x.\n\n", ret);
}
return version;
}
2021-11-05 04:59:45 +00:00
}