Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"

This reverts commit 15b7df8ef1.
This commit is contained in:
souldbminersmwc
2025-11-09 16:14:52 -05:00
parent 22ec140738
commit 21a3f953d7
3804 changed files with 435 additions and 570162 deletions

View File

@@ -1,25 +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/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pkg1 {
bool IsProduction();
bool IsProductionForVersionCheck();
bool IsProductionForPublicKey();
}

View File

@@ -1,145 +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/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pkg1 {
enum MemorySize {
MemorySize_4GB = 0,
MemorySize_6GB = 1,
MemorySize_8GB = 2,
};
enum MemoryArrange {
MemoryArrange_Normal = 1,
MemoryArrange_AppletDev = 2,
MemoryArrange_SystemDev = 3,
};
enum MemoryMode {
MemoryMode_SizeShift = 4,
MemoryMode_SizeMask = 0x30,
MemoryMode_ArrangeMask = 0x0F,
MemoryMode_Auto = 0x00,
MemoryMode_4GB = ((MemorySize_4GB << MemoryMode_SizeShift) | (MemoryArrange_Normal)),
MemoryMode_4GBAppletDev = ((MemorySize_4GB << MemoryMode_SizeShift) | (MemoryArrange_AppletDev)),
MemoryMode_4GBSystemDev = ((MemorySize_4GB << MemoryMode_SizeShift) | (MemoryArrange_SystemDev)),
MemoryMode_6GB = ((MemorySize_6GB << MemoryMode_SizeShift) | (MemoryArrange_Normal)),
MemoryMode_6GBAppletDev = ((MemorySize_6GB << MemoryMode_SizeShift) | (MemoryArrange_AppletDev)),
MemoryMode_8GB = ((MemorySize_8GB << MemoryMode_SizeShift) | (MemoryArrange_Normal)),
};
constexpr ALWAYS_INLINE MemorySize GetMemorySize(MemoryMode mode) {
return static_cast<MemorySize>(mode >> MemoryMode_SizeShift);
}
constexpr ALWAYS_INLINE MemoryArrange GetMemoryArrange(MemoryMode mode) {
return static_cast<MemoryArrange>(mode & MemoryMode_ArrangeMask);
}
constexpr ALWAYS_INLINE MemoryMode MakeMemoryMode(MemorySize size, MemoryArrange arrange) {
return static_cast<MemoryMode>((size << MemoryMode_SizeShift) | (arrange));
}
struct BootConfigData {
u32 version;
u32 reserved_04;
u32 reserved_08;
u32 reserved_0C;
u8 flags1[0x10];
u8 flags0[0x10];
u64 initial_tsc_value;
u8 padding_38[0x200 - 0x38];
constexpr bool IsDevelopmentFunctionEnabled() const {
return (this->flags1[0] & (1 << 1)) != 0;
}
constexpr bool IsSErrorDebugEnabled() const {
return (this->flags1[0] & (1 << 2)) != 0;
}
constexpr u8 GetKernelFlags0() const {
return this->flags0[1];
}
constexpr u8 GetKernelFlags1() const {
return this->flags1[0];
}
constexpr MemoryMode GetMemoryMode() const {
return static_cast<MemoryMode>(this->flags0[3]);
}
constexpr bool IsInitialTscValueValid() const {
return (this->flags0[4] & (1 << 0)) != 0;
}
constexpr u64 GetInitialTscValue() const {
return this->IsInitialTscValueValid() ? this->initial_tsc_value : 0;
}
};
static_assert(util::is_pod<BootConfigData>::value);
static_assert(sizeof(BootConfigData) == 0x200);
struct BootConfigSignedData {
u32 version;
u32 reserved_04;
u8 flags;
u8 reserved_09[0x10 - 9];
u8 ecid[0x10];
u8 flags1[0x10];
u8 flags0[0x10];
u8 padding_40[0x100 - 0x40];
constexpr bool IsPackage2EncryptionDisabled() const {
return (this->flags & (1 << 0)) != 0;
}
constexpr bool IsPackage2SignatureVerificationDisabled() const {
return (this->flags & (1 << 1)) != 0;
}
constexpr bool IsProgramVerificationDisabled() const {
return (this->flags1[0] & (1 << 0)) != 0;
}
constexpr void SetPackage2SignatureVerificationDisabled(bool decrypted) {
this->flags |= decrypted ? (1 << 1) : (0 << 0);
}
constexpr void SetPackage2EncryptionDisabled(bool decrypted) {
this->flags |= decrypted ? (1 << 0) : (0 << 0);
}
};
static_assert(util::is_pod<BootConfigSignedData>::value);
static_assert(sizeof(BootConfigSignedData) == 0x100);
struct BootConfig {
BootConfigData data;
u8 signature[0x100];
BootConfigSignedData signed_data;
};
static_assert(util::is_pod<BootConfig>::value);
static_assert(sizeof(BootConfig) == 0x400);
}

View File

@@ -1,70 +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/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pkg1 {
enum BootloaderState {
BootloaderState_Start = 0,
BootloaderState_LoadedBootConfig = 1,
BootloaderState_InitializedDram = 2,
BootloaderState_LoadedPackage2 = 3,
BootloaderState_Done = 4,
};
enum SecureMonitorState {
SecureMonitorState_Start = 0,
SecureMonitorState_Initialized = 1,
};
struct BctParameters {
u32 bootloader_version;
u32 bootloader_start_block;
u32 bootloader_start_page;
u32 bootloader_attributes;
};
static_assert(util::is_pod<BctParameters>::value && sizeof(BctParameters) == 0x10);
struct SecureMonitorParameters {
u32 bootloader_start_time;
u32 bootloader_end_time;
u32 secmon_start_time;
u32 secmon_end_time;
BctParameters bct_params;
u32 deprecated_boot_reason_value;
u8 deprecated_boot_reason_state;
u8 reserved[0xD3];
u32 bootloader_state;
u32 secmon_state;
u8 reserved2[0x100];
};
static_assert(util::is_pod<SecureMonitorParameters>::value);
static_assert(sizeof(SecureMonitorParameters) == 0x200);
static_assert(AMS_OFFSETOF(SecureMonitorParameters, bct_params) == 0x10);
static_assert(AMS_OFFSETOF(SecureMonitorParameters, bootloader_state) == 0xF8);
static_assert(AMS_OFFSETOF(SecureMonitorParameters, secmon_state) == 0xFC);
enum BootloaderAttribute {
BootloaderAttribute_None = (0u << 0),
BootloaderAttribute_RecoveryBoot = (1u << 0),
BootloaderAttribute_RestrictedSmcShift = 1,
BootloaderAttribute_RestrictedSmcMask = (0xFu << BootloaderAttribute_RestrictedSmcShift),
};
}

View File

@@ -1,108 +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/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pkg1 {
enum ErrorReason {
ErrorReason_None = 0,
ErrorReason_InvalidPackage2Signature = 1,
ErrorReason_InvalidPackage2Meta = 2,
ErrorReason_InvalidPackage2Version = 3,
ErrorReason_InvalidPackage2Payload = 4,
ErrorReason_UnknownSmc = 5,
ErrorReason_UnknownAbort = 6,
ErrorReason_InvalidCoreContext = 7,
ErrorReason_InvalidSecurityEngineStickyBits = 8,
ErrorReason_UnexpectedReset = 9,
ErrorReason_Exception = 0x10,
ErrorReason_TransitionToSafeMode = 0x20,
ErrorReason_SecureInitializerReboot = 0x21,
ErrorReason_SdmmcError = 0x30,
ErrorReason_InvalidDramId = 0x31,
ErrorReason_InvalidPackage2 = 0x32,
ErrorReason_InvalidBct = 0x33,
ErrorReason_InvalidGpt = 0x34,
ErrorReason_FailedToTransitionToSafeMode = 0x35,
ErrorReason_ActivityMonitorInterrupt = 0x36,
ErrorReason_KernelPanic = 0x40,
};
enum ErrorColor {
ErrorColor_Black = 0x000,
ErrorColor_Red = 0x00F,
ErrorColor_Yellow = 0x0FF,
ErrorColor_Orange = 0x07F,
ErrorColor_Blue = 0xF00,
ErrorColor_LightBlue = 0xFF0,
ErrorColor_Pink = 0xF7F,
ErrorColor_Purple = 0xF0A,
};
enum ErrorInfo {
ErrorInfo_ReasonMask = 0xFF,
ErrorInfo_ColorShift = 20,
#define MAKE_ERROR_INFO(_COLOR_, _DESC_) ((static_cast<u32>(ErrorColor_##_COLOR_) << ErrorInfo_ColorShift) | (ErrorReason_##_DESC_))
ErrorInfo_None = MAKE_ERROR_INFO(Black, None),
ErrorInfo_InvalidPackage2Signature = MAKE_ERROR_INFO(Blue, InvalidPackage2Signature),
ErrorInfo_InvalidPackage2Meta = MAKE_ERROR_INFO(Blue, InvalidPackage2Meta),
ErrorInfo_InvalidPackage2Version = MAKE_ERROR_INFO(Blue, InvalidPackage2Version),
ErrorInfo_InvalidPackage2Payload = MAKE_ERROR_INFO(Blue, InvalidPackage2Payload),
ErrorInfo_UnknownSmc = MAKE_ERROR_INFO(LightBlue, UnknownSmc),
ErrorInfo_UnknownAbort = MAKE_ERROR_INFO(Yellow, UnknownAbort),
ErrorInfo_InvalidCoreContext = MAKE_ERROR_INFO(Pink, InvalidCoreContext),
ErrorInfo_InvalidSecurityEngineStickyBits = MAKE_ERROR_INFO(Pink, InvalidSecurityEngineStickyBits),
ErrorInfo_UnexpectedReset = MAKE_ERROR_INFO(Pink, UnexpectedReset),
ErrorInfo_Exception = MAKE_ERROR_INFO(Orange, Exception),
ErrorInfo_TransitionToSafeMode = MAKE_ERROR_INFO(Black, TransitionToSafeMode),
ErrorInfo_SecureInitializerReboot = MAKE_ERROR_INFO(Black, SecureInitializerReboot),
ErrorInfo_SdmmcError = MAKE_ERROR_INFO(Purple, SdmmcError),
ErrorInfo_InvalidDramId = MAKE_ERROR_INFO(Purple, InvalidDramId),
ErrorInfo_InvalidPackage2 = MAKE_ERROR_INFO(Purple, InvalidPackage2),
ErrorInfo_InvalidBct = MAKE_ERROR_INFO(Purple, InvalidBct),
ErrorInfo_InvalidGpt = MAKE_ERROR_INFO(Purple, InvalidGpt),
ErrorInfo_FailedToTransitionToSafeMode = MAKE_ERROR_INFO(Purple, FailedToTransitionToSafeMode),
ErrorInfo_ActivityMonitorInterrupt = MAKE_ERROR_INFO(Purple, ActivityMonitorInterrupt),
#undef MAKE_ERROR_INFO
};
constexpr inline ErrorReason GetErrorReason(u32 info) {
return static_cast<ErrorReason>(info & ErrorInfo_ReasonMask);
}
constexpr inline ErrorInfo MakeKernelPanicResetInfo(u32 color) {
return static_cast<ErrorInfo>((color << ErrorInfo_ColorShift) | (ErrorReason_KernelPanic));
}
#define PKG1_SECURE_MONITOR_PMC_ERROR_SCRATCH (0x840)
}

View File

@@ -1,64 +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/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pkg1 {
enum KeyGeneration : int {
KeyGeneration_1_0_0 = 0x00,
KeyGeneration_3_0_0 = 0x01,
KeyGeneration_3_0_1 = 0x02,
KeyGeneration_4_0_0 = 0x03,
KeyGeneration_5_0_0 = 0x04,
KeyGeneration_6_0_0 = 0x05,
KeyGeneration_6_2_0 = 0x06,
KeyGeneration_7_0_0 = 0x07,
KeyGeneration_8_1_0 = 0x08,
KeyGeneration_9_0_0 = 0x09,
KeyGeneration_9_1_0 = 0x0A,
KeyGeneration_12_1_0 = 0x0B,
KeyGeneration_13_0_0 = 0x0C,
KeyGeneration_14_0_0 = 0x0D,
KeyGeneration_15_0_0 = 0x0E,
KeyGeneration_16_0_0 = 0x0F,
KeyGeneration_17_0_0 = 0x10,
KeyGeneration_18_0_0 = 0x11,
KeyGeneration_19_0_0 = 0x12,
KeyGeneration_20_0_0 = 0x13,
KeyGeneration_Count,
KeyGeneration_Current = KeyGeneration_Count - 1,
KeyGeneration_Min = 0x00,
KeyGeneration_Max = 0x20,
};
static_assert(KeyGeneration_Count <= KeyGeneration_Max);
constexpr inline const int OldMasterKeyCount = KeyGeneration_Count - 1;
constexpr inline const int OldDeviceMasterKeyCount = KeyGeneration_Count - KeyGeneration_4_0_0;
constexpr bool IsValidDeviceUniqueKeyGeneration(int generation) {
return generation == KeyGeneration_1_0_0 || (KeyGeneration_4_0_0 <= generation && generation <= KeyGeneration_Current);
}
constexpr bool IsValidKeyGeneration(int generation) {
return KeyGeneration_Min <= generation && generation <= KeyGeneration_Current;
}
}

View File

@@ -1,75 +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/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pkg1 {
enum AesKeySlot {
AesKeySlot_UserStart = 0,
AesKeySlot_TzramSaveKek = 2,
AesKeySlot_TzramSaveKey = 3,
AesKeySlot_UserLast = 5,
AesKeySlot_UserEnd = AesKeySlot_UserLast + 1,
AesKeySlot_SecmonStart = 8,
AesKeySlot_Temporary = 8,
AesKeySlot_Smc = 9,
AesKeySlot_RandomForUserWrap = 10,
AesKeySlot_RandomForKeyStorageWrap = 11,
AesKeySlot_DeviceMaster = 12,
AesKeySlot_Master = 13,
AesKeySlot_Device = 15,
AesKeySlot_Count = 16,
AesKeySlot_SecmonEnd = AesKeySlot_Count,
/* Used only during boot. */
AesKeySlot_TsecRootDev = 11,
AesKeySlot_Tsec = 12,
AesKeySlot_TsecRoot = 13,
AesKeySlot_SecureBoot = 14,
AesKeySlot_SecureStorage = 15,
AesKeySlot_DeviceMasterKeySourceKekErista = 10,
AesKeySlot_MasterKek = 13,
AesKeySlot_DeviceMasterKeySourceKekMariko = 14,
/* Mariko only keyslots, used during boot. */
AesKeySlot_MarikoKek = 12,
AesKeySlot_MarikoBek = 13,
/* Bootloader keyslots, for fusee only. */
AesKeySlot_BootloaderSystem0 = 2,
AesKeySlot_BootloaderSystem1 = 3,
AesKeySlot_BootloaderDeviceMaster = 6,
AesKeySlot_BootloaderMaster = 7,
AesKeySlot_BootloaderTemporary = 8,
};
enum RsaKeySlot {
RsaKeySlot_Temporary = 0,
RsaKeySlot_PrivateKey = 1,
};
constexpr bool IsUserAesKeySlot(int slot) {
return AesKeySlot_UserStart <= slot && slot < AesKeySlot_UserEnd;
}
}