2019-12-09 11:57:37 +00:00
|
|
|
/*
|
2020-01-24 10:10:40 +00:00
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
2019-12-09 11:57:37 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2020-04-17 06:57:01 +01:00
|
|
|
#include "hos_version_api_private.hpp"
|
2019-12-09 11:57:37 +00:00
|
|
|
|
|
|
|
namespace ams::hos {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
hos::Version g_hos_version;
|
|
|
|
bool g_has_cached;
|
2020-04-08 10:21:35 +01:00
|
|
|
os::Mutex g_mutex(false);
|
2019-12-09 11:57:37 +00:00
|
|
|
|
|
|
|
void CacheValues() {
|
|
|
|
if (__atomic_load_n(&g_has_cached, __ATOMIC_SEQ_CST)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::scoped_lock lk(g_mutex);
|
|
|
|
|
|
|
|
if (g_has_cached) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (exosphere::GetApiInfo().GetTargetFirmware()) {
|
|
|
|
case exosphere::TargetFirmware_100:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_1_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_200:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_2_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_300:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_3_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_400:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_4_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_500:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_5_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_600:
|
|
|
|
case exosphere::TargetFirmware_620:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_6_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_700:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_7_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_800:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_8_0_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_810:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_8_1_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
|
|
|
case exosphere::TargetFirmware_900:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_9_0_0;
|
2020-04-14 07:30:54 +01:00
|
|
|
break;
|
2019-12-09 11:57:37 +00:00
|
|
|
case exosphere::TargetFirmware_910:
|
2020-04-14 06:19:44 +01:00
|
|
|
g_hos_version = hos::Version_9_1_0;
|
2019-12-09 11:57:37 +00:00
|
|
|
break;
|
2020-04-14 07:30:54 +01:00
|
|
|
case exosphere::TargetFirmware_1000:
|
|
|
|
g_hos_version = hos::Version_10_0_0;
|
|
|
|
break;
|
2019-12-09 11:57:37 +00:00
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
|
|
|
}
|
|
|
|
|
|
|
|
__atomic_store_n(&g_has_cached, true, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
::ams::hos::Version GetVersion() {
|
|
|
|
CacheValues();
|
|
|
|
return g_hos_version;
|
|
|
|
}
|
|
|
|
|
2020-04-17 06:57:01 +01:00
|
|
|
void SetVersionForLibnxInternal() {
|
2019-12-09 11:57:37 +00:00
|
|
|
u32 major = 0, minor = 0, micro = 0;
|
|
|
|
switch (hos::GetVersion()) {
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_1_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 1;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_2_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 2;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_3_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 3;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_4_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 4;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_5_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 5;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_6_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 6;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_7_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 7;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_8_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 8;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_8_1_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 8;
|
|
|
|
minor = 1;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_9_0_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 9;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
2020-04-14 06:19:44 +01:00
|
|
|
case hos::Version_9_1_0:
|
2019-12-09 11:57:37 +00:00
|
|
|
major = 9;
|
|
|
|
minor = 1;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2020-04-14 07:30:54 +01:00
|
|
|
case hos::Version_10_0_0:
|
|
|
|
major = 10;
|
|
|
|
minor = 0;
|
|
|
|
micro = 0;
|
|
|
|
break;
|
2019-12-09 11:57:37 +00:00
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
|
|
|
}
|
|
|
|
hosversionSet(MAKEHOSVERSION(major, minor, micro));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|