Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"
This reverts commit 15b7df8ef1.
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
#include "../os/impl/os_rng_manager.hpp"
|
||||
|
||||
namespace ams::os {
|
||||
|
||||
void Initialize();
|
||||
|
||||
}
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
extern "C" {
|
||||
|
||||
/* Provide libnx address space allocation shim. */
|
||||
uintptr_t __libnx_virtmem_rng(void) {
|
||||
return static_cast<uintptr_t>(::ams::os::impl::GetRngManager().GenerateRandomU64());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace ams::hos {
|
||||
|
||||
namespace {
|
||||
|
||||
bool CanAllowTemporaryApproximateVersion() {
|
||||
/* Check if we're a program that can use a temporary approximate version. */
|
||||
const auto program_id = os::GetCurrentProgramId();
|
||||
|
||||
return program_id == ncm::SystemProgramId::Pm || /* Needed so that boot has permissions to use fsp-srv. */
|
||||
program_id == ncm::SystemProgramId::Sm || /* Needed so that boot can acquire fsp-srv. */
|
||||
program_id == ncm::SystemProgramId::Boot || /* Needed so that boot can set the true target firmware. */
|
||||
program_id == ncm::SystemProgramId::Spl || /* Needed so that FS can complete initialization. */
|
||||
program_id == ncm::SystemProgramId::Ncm; /* Needed so that FS can determine where SystemVersion is located. */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool IsUnitTestProgramForSetVersion();
|
||||
void InitializeVersionInternal(bool allow_approximate);
|
||||
|
||||
void InitializeForStratosphere() {
|
||||
/* Initialize the global os resource managers. This *must* be done before anything else in stratosphere. */
|
||||
os::Initialize();
|
||||
|
||||
/* Initialize hos::Version API. */
|
||||
hos::InitializeVersionInternal(CanAllowTemporaryApproximateVersion());
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
/* Check that we're running under mesosphere. */
|
||||
AMS_ABORT_UNLESS(IsUnitTestProgramForSetVersion() || svc::IsKernelMesosphere());
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
|
||||
namespace ams::hos {
|
||||
|
||||
namespace {
|
||||
|
||||
constinit os::SdkMutex g_hos_init_lock;
|
||||
constinit hos::Version g_hos_version;
|
||||
constinit bool g_set_hos_version;
|
||||
|
||||
Result GetExosphereApiInfo(exosphere::ApiInfo *out) {
|
||||
u64 exosphere_cfg;
|
||||
R_TRY_CATCH(spl::impl::GetConfig(std::addressof(exosphere_cfg), spl::ConfigItem::ExosphereApiVersion)) {
|
||||
R_CATCH_RETHROW(spl::ResultSecureMonitorNotInitialized)
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
|
||||
*out = { exosphere_cfg };
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
Result GetApproximateExosphereApiInfo(exosphere::ApiInfo *out) {
|
||||
u64 exosphere_cfg;
|
||||
|
||||
R_TRY_CATCH(spl::impl::GetConfig(std::addressof(exosphere_cfg), spl::ConfigItem::ExosphereApproximateApiVersion)) {
|
||||
R_CATCH_RETHROW(spl::ResultSecureMonitorBusy)
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
|
||||
*out = { exosphere_cfg };
|
||||
R_SUCCEED();
|
||||
}
|
||||
#endif
|
||||
|
||||
exosphere::ApiInfo GetExosphereApiInfo(bool allow_approximate) {
|
||||
exosphere::ApiInfo info;
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
while (true) {
|
||||
if (R_SUCCEEDED(GetExosphereApiInfo(std::addressof(info)))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (allow_approximate && R_SUCCEEDED(GetApproximateExosphereApiInfo(std::addressof(info)))) {
|
||||
break;
|
||||
}
|
||||
|
||||
svc::SleepThread(TimeSpan::FromMilliSeconds(25).GetNanoSeconds());
|
||||
}
|
||||
#else
|
||||
AMS_UNUSED(allow_approximate);
|
||||
R_ABORT_UNLESS(GetExosphereApiInfo(std::addressof(info)));
|
||||
#endif
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool IsUnitTestProgramForSetVersion();
|
||||
|
||||
void InitializeVersionInternal(bool allow_approximate) {
|
||||
hos::Version current = hos::Version_Current;
|
||||
|
||||
/* If we're unit testing, just set the version and move on. */
|
||||
if (IsUnitTestProgramForSetVersion()) {
|
||||
g_hos_version = hos::Version_Current;
|
||||
g_set_hos_version = true;
|
||||
} else {
|
||||
/* Get the current (and previous approximation of) target firmware. */
|
||||
hos::Version prev;
|
||||
bool has_prev = false;
|
||||
{
|
||||
/* Acquire exclusive access to set hos version. */
|
||||
std::scoped_lock lk(g_hos_init_lock);
|
||||
|
||||
/* Save the previous value of g_hos_version. */
|
||||
prev = g_hos_version;
|
||||
has_prev = g_set_hos_version;
|
||||
|
||||
/* Set hos version = exosphere api version target firmware. */
|
||||
g_hos_version = static_cast<hos::Version>(GetExosphereApiInfo(allow_approximate).GetTargetFirmware());
|
||||
|
||||
/* Save the current value of g_hos_version. */
|
||||
current = g_hos_version;
|
||||
|
||||
/* Note that we've set a previous hos version. */
|
||||
g_set_hos_version = true;
|
||||
}
|
||||
|
||||
/* Ensure that this is a hos version we can sanely *try* to run. */
|
||||
/* To be friendly, we will only require that we recognize the major and minor versions. */
|
||||
/* We can consider only recognizing major in the future, but micro seems safe to ignore as */
|
||||
/* there are no breaking IPC changes in minor updates. */
|
||||
{
|
||||
constexpr u32 MaxMajor = (static_cast<u32>(hos::Version_Max) >> 24) & 0xFF;
|
||||
constexpr u32 MaxMinor = (static_cast<u32>(hos::Version_Max) >> 16) & 0xFF;
|
||||
|
||||
const u32 major = (static_cast<u32>(current) >> 24) & 0xFF;
|
||||
const u32 minor = (static_cast<u32>(current) >> 16) & 0xFF;
|
||||
|
||||
const bool is_safely_tryable_version = (current <= hos::Version_Max) || (major == MaxMajor && minor <= MaxMinor);
|
||||
AMS_ABORT_UNLESS(is_safely_tryable_version);
|
||||
}
|
||||
|
||||
/* Ensure that this is a hos version compatible with previous approximations. */
|
||||
if (has_prev) {
|
||||
AMS_ABORT_UNLESS(current >= prev);
|
||||
|
||||
const u32 current_major = (static_cast<u32>(current) >> 24) & 0xFF;
|
||||
const u32 prev_major = (static_cast<u32>(prev) >> 24) & 0xFF;
|
||||
|
||||
AMS_ABORT_UNLESS(current_major == prev_major);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
/* Set the version for libnx. */
|
||||
{
|
||||
const u32 major = (static_cast<u32>(current) >> 24) & 0xFF;
|
||||
const u32 minor = (static_cast<u32>(current) >> 16) & 0xFF;
|
||||
const u32 micro = (static_cast<u32>(current) >> 8) & 0xFF;
|
||||
hosversionSet((BIT(31)) | (MAKEHOSVERSION(major, minor, micro)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
::ams::hos::Version GetVersion() {
|
||||
return g_hos_version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
|
||||
namespace ams::hos {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
settings::FirmwareVersion GetSettingsFirmwareVersion() {
|
||||
/* Mount the system version title. */
|
||||
R_ABORT_UNLESS(ams::fs::MountSystemData("sysver", ncm::SystemDataId::SystemVersion));
|
||||
ON_SCOPE_EXIT { ams::fs::Unmount("sysver"); };
|
||||
|
||||
/* Read the firmware version file. */
|
||||
ams::fs::FileHandle file;
|
||||
R_ABORT_UNLESS(ams::fs::OpenFile(std::addressof(file), "sysver:/file", fs::OpenMode_Read));
|
||||
ON_SCOPE_EXIT { ams::fs::CloseFile(file); };
|
||||
|
||||
/* Must be possible to read firmware version from file. */
|
||||
settings::FirmwareVersion firmware_version;
|
||||
R_ABORT_UNLESS(ams::fs::ReadFile(file, 0, std::addressof(firmware_version), sizeof(firmware_version)));
|
||||
|
||||
return firmware_version;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void InitializeVersionInternal(bool allow_approximate);
|
||||
|
||||
void SetNonApproximateVersionInternal() {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
/* Get the settings . */
|
||||
const auto firmware_version = GetSettingsFirmwareVersion();
|
||||
|
||||
/* Set the exosphere api version. */
|
||||
R_ABORT_UNLESS(spl::SetConfig(spl::ConfigItem::ExosphereApiVersion, (static_cast<u32>(firmware_version.major) << 24) | (static_cast<u32>(firmware_version.minor) << 16) | (static_cast<u32>(firmware_version.micro) << 8)));
|
||||
|
||||
/* Update our own version value. */
|
||||
InitializeVersionInternal(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
|
||||
namespace ams::hos {
|
||||
|
||||
WEAK_SYMBOL bool IsUnitTestProgramForSetVersion() {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user