2019-09-30 10:52:32 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
2019-10-24 10:30:10 +01:00
|
|
|
namespace ams::hos {
|
2019-09-30 10:52:32 +01:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2019-10-11 07:49:28 +01:00
|
|
|
hos::Version g_hos_version;
|
2019-09-30 10:52:32 +01:00
|
|
|
bool g_has_cached;
|
|
|
|
os::Mutex g_mutex;
|
|
|
|
|
|
|
|
void CacheValues() {
|
|
|
|
if (__atomic_load_n(&g_has_cached, __ATOMIC_SEQ_CST)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::scoped_lock lk(g_mutex);
|
|
|
|
|
|
|
|
if (g_has_cached) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-24 10:30:10 +01:00
|
|
|
switch (exosphere::GetApiInfo().GetTargetFirmware()) {
|
|
|
|
case exosphere::TargetFirmware_100:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_100;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_200:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_200;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_300:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_300;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_400:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_400;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_500:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_500;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_600:
|
|
|
|
case exosphere::TargetFirmware_620:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_600;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_700:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_700;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_800:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_800;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_810:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_810;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
case exosphere::TargetFirmware_900:
|
2019-10-11 07:49:28 +01:00
|
|
|
g_hos_version = hos::Version_900;
|
2019-12-07 21:44:08 +00:00
|
|
|
case exosphere::TargetFirmware_910:
|
|
|
|
g_hos_version = hos::Version_910;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
2019-09-30 10:52:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
__atomic_store_n(&g_has_cached, true, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-24 10:30:10 +01:00
|
|
|
::ams::hos::Version GetVersion() {
|
2019-09-30 10:52:32 +01:00
|
|
|
CacheValues();
|
2019-10-11 07:49:28 +01:00
|
|
|
return g_hos_version;
|
2019-09-30 10:52:32 +01:00
|
|
|
}
|
|
|
|
|
2019-10-11 07:49:28 +01:00
|
|
|
void SetVersionForLibnx() {
|
2019-09-30 10:52:32 +01:00
|
|
|
u32 major = 0, minor = 0, micro = 0;
|
2019-10-11 07:49:28 +01:00
|
|
|
switch (hos::GetVersion()) {
|
|
|
|
case hos::Version_100:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 1;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_200:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 2;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_300:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 3;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_400:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 4;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_500:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 5;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_600:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 6;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_700:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 7;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_800:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 8;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_810:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 8;
|
|
|
|
minor = 1;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-10-11 07:49:28 +01:00
|
|
|
case hos::Version_900:
|
2019-09-30 10:52:32 +01:00
|
|
|
major = 9;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
2019-12-07 21:44:08 +00:00
|
|
|
case hos::Version_910:
|
|
|
|
major = 9;
|
|
|
|
minor = 1;
|
|
|
|
micro = 0;
|
2019-09-30 10:52:32 +01:00
|
|
|
break;
|
2019-10-24 10:30:10 +01:00
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
2019-09-30 10:52:32 +01:00
|
|
|
}
|
|
|
|
hosversionSet(MAKEHOSVERSION(major, minor, micro));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|