mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 04:22:50 +02:00
add hosversionIsAtmosphere (#525)
This commit is contained in:
parent
076657fd31
commit
e48f1c339f
@ -25,6 +25,9 @@ u32 hosversionGet(void);
|
|||||||
/// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup with the version info obtained with \ref setsysGetFirmwareVersion.
|
/// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup with the version info obtained with \ref setsysGetFirmwareVersion.
|
||||||
void hosversionSet(u32 version);
|
void hosversionSet(u32 version);
|
||||||
|
|
||||||
|
/// Returns whether the current HOS version is augmented by running the Atmosphère custom firmware.
|
||||||
|
bool hosversionIsAtmosphere(void);
|
||||||
|
|
||||||
/// Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
|
/// Returns true if the current HOS version is equal to or above the specified major/minor/micro version.
|
||||||
static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) {
|
static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) {
|
||||||
return hosversionGet() >= MAKEHOSVERSION(major,minor,micro);
|
return hosversionGet() >= MAKEHOSVERSION(major,minor,micro);
|
||||||
|
@ -4,10 +4,15 @@ static u32 g_hosVersion;
|
|||||||
|
|
||||||
u32 hosversionGet(void)
|
u32 hosversionGet(void)
|
||||||
{
|
{
|
||||||
return __atomic_load_n(&g_hosVersion, __ATOMIC_SEQ_CST);
|
return __atomic_load_n(&g_hosVersion, __ATOMIC_SEQ_CST) & ~(BIT(31));
|
||||||
}
|
}
|
||||||
|
|
||||||
void hosversionSet(u32 version)
|
void hosversionSet(u32 version)
|
||||||
{
|
{
|
||||||
__atomic_store_n(&g_hosVersion, version, __ATOMIC_SEQ_CST);
|
__atomic_store_n(&g_hosVersion, version, __ATOMIC_SEQ_CST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hosversionIsAtmosphere(void)
|
||||||
|
{
|
||||||
|
return __atomic_load_n(&g_hosVersion, __ATOMIC_SEQ_CST) & (BIT(31));
|
||||||
|
}
|
||||||
|
@ -49,7 +49,7 @@ Service* ro1GetServiceSession(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result _roDmntInitialize(void) {
|
Result _roDmntInitialize(void) {
|
||||||
if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
if (!hosversionIsAtmosphere() && hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
return smGetService(&g_dmntSrv, "ro:dmnt");
|
return smGetService(&g_dmntSrv, "ro:dmnt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,6 @@ Result smUnregisterService(SmServiceName name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result smDetachClient(void) {
|
Result smDetachClient(void) {
|
||||||
if (hosversionBefore(11,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
if (!hosversionIsAtmosphere() && hosversionBefore(11,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
return _smCmdInPid(4);
|
return _smCmdInPid(4);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user