vers: use svcCallSecMon instead of spl

This commit is contained in:
Michael Scire 2019-03-24 14:39:04 -07:00
parent 37c41f6324
commit 31c1dc1a82
2 changed files with 20 additions and 7 deletions

View File

@ -61,6 +61,25 @@ static inline void CopyFromIram(void *dst_addr, uintptr_t iram_addr, size_t size
svcCallSecureMonitor(&args); svcCallSecureMonitor(&args);
} }
static inline Result SmcGetConfig(SplConfigItem config_item, u64 *out_config) {
SecmonArgs args = {0};
args.X[0] = 0xC3000002; /* smcGetConfig */
args.X[1] = (u64)config_item; /* config item */
Result rc = svcCallSecureMonitor(&args);
if (R_SUCCEEDED(rc)) {
if (args.X[0] == 0) {
if (out_config) {
*out_config = args.X[1];
}
} else {
/* SPL result n = SMC result n */
rc = MAKERESULT(26, args.X[0]);
}
}
return rc;
}
static inline bool IsApplicationTid(u64 title_id) { static inline bool IsApplicationTid(u64 title_id) {
constexpr u64 application_tid_min = 0x0100000000010000ul; constexpr u64 application_tid_min = 0x0100000000010000ul;
constexpr u64 application_tid_max = 0x01FFFFFFFFFFFFFFul; constexpr u64 application_tid_max = 0x01FFFFFFFFFFFFFFul;

View File

@ -18,13 +18,9 @@
#include <switch.h> #include <switch.h>
static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u32 *target_fw, u32 *mkey_rev) { static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u32 *target_fw, u32 *mkey_rev) {
if (R_FAILED(splInitialize())) {
fatalSimple(0xCAFE << 4 | 0xD);
}
/* Check for exosphere API compatibility. */ /* Check for exosphere API compatibility. */
u64 exosphere_cfg; u64 exosphere_cfg;
if (R_FAILED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) { if (R_FAILED(SmcGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
fatalSimple(0xCAFE << 4 | 0xE); fatalSimple(0xCAFE << 4 | 0xE);
} }
@ -47,8 +43,6 @@ static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u
if (major) { if (major) {
*major = (u32)((exosphere_cfg >> 0x20) & 0xFF); *major = (u32)((exosphere_cfg >> 0x20) & 0xFF);
} }
splExit();
} }
static inline u32 MakeAtmosphereVersion(u32 major, u32 minor, u32 micro) { static inline u32 MakeAtmosphereVersion(u32 major, u32 minor, u32 micro) {