2019-12-09 12:57:37 +01:00
|
|
|
/*
|
2021-10-04 21:59:10 +02:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2019-12-09 12:57:37 +01: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>
|
|
|
|
|
|
|
|
namespace ams::exosphere {
|
|
|
|
|
|
|
|
ApiInfo GetApiInfo() {
|
|
|
|
u64 exosphere_cfg;
|
2021-10-10 21:57:24 +02:00
|
|
|
if (R_FAILED(spl::impl::GetConfig(std::addressof(exosphere_cfg), spl::ConfigItem::ExosphereApiVersion))) {
|
|
|
|
R_ABORT_UNLESS(exosphere::ResultNotPresent());
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
|
|
|
|
2020-04-14 02:07:06 +02:00
|
|
|
return ApiInfo{ util::BitPack64{exosphere_cfg} };
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
|
|
|
|
2022-03-06 21:08:20 +01:00
|
|
|
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
|
2019-12-09 12:57:37 +01:00
|
|
|
void ForceRebootToRcm() {
|
2021-10-10 21:57:24 +02:00
|
|
|
R_ABORT_UNLESS(spl::impl::SetConfig(spl::ConfigItem::ExosphereNeedsReboot, 1));
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ForceRebootToIramPayload() {
|
2021-10-10 21:57:24 +02:00
|
|
|
R_ABORT_UNLESS(spl::impl::SetConfig(spl::ConfigItem::ExosphereNeedsReboot, 2));
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
|
|
|
|
2020-11-15 21:58:13 +01:00
|
|
|
void ForceRebootToFatalError() {
|
2021-10-10 21:57:24 +02:00
|
|
|
R_ABORT_UNLESS(spl::impl::SetConfig(spl::ConfigItem::ExosphereNeedsReboot, 3));
|
2020-11-15 21:58:13 +01:00
|
|
|
}
|
|
|
|
|
2019-12-09 12:57:37 +01:00
|
|
|
void ForceShutdown() {
|
2021-10-10 21:57:24 +02:00
|
|
|
R_ABORT_UNLESS(spl::impl::SetConfig(spl::ConfigItem::ExosphereNeedsShutdown, 1));
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CopyToIram(uintptr_t iram_dst, const void *dram_src, size_t size) {
|
|
|
|
spl::smc::AtmosphereCopyToIram(iram_dst, dram_src, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyFromIram(void *dram_dst, uintptr_t iram_src, size_t size) {
|
|
|
|
spl::smc::AtmosphereCopyFromIram(dram_dst, iram_src, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2020-04-23 01:22:14 +02:00
|
|
|
inline u64 GetU64ConfigItem(spl::ConfigItem cfg) {
|
|
|
|
u64 tmp;
|
2020-07-08 02:07:23 +02:00
|
|
|
R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::GetConfig(std::addressof(tmp), 1, cfg)));
|
2020-04-23 01:22:14 +02:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool GetBooleanConfigItem(spl::ConfigItem cfg) {
|
|
|
|
return GetU64ConfigItem(cfg) != 0;
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsRcmBugPatched() {
|
2021-10-10 21:57:24 +02:00
|
|
|
return spl::impl::GetConfigBool(spl::ConfigItem::ExosphereHasRcmBugPatch);
|
2020-04-23 01:22:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShouldBlankProdInfo() {
|
2021-10-10 21:57:24 +02:00
|
|
|
return spl::impl::GetConfigBool(spl::ConfigItem::ExosphereBlankProdInfo);
|
2020-04-23 01:22:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShouldAllowWritesToProdInfo() {
|
2021-10-10 21:57:24 +02:00
|
|
|
return spl::impl::GetConfigBool(spl::ConfigItem::ExosphereAllowCalWrites);
|
2020-04-23 01:22:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u64 GetDeviceId() {
|
2021-10-10 21:57:24 +02:00
|
|
|
u64 device_id;
|
|
|
|
R_ABORT_UNLESS(spl::impl::GetConfig(std::addressof(device_id), spl::ConfigItem::DeviceId));
|
|
|
|
return device_id;
|
2019-12-09 12:57:37 +01:00
|
|
|
}
|
2022-03-06 21:08:20 +01:00
|
|
|
#endif
|
2019-12-09 12:57:37 +01:00
|
|
|
|
|
|
|
}
|