mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 14:58:22 -04:00
exo2: implement through boot config load/validate
This commit is contained in:
parent
cbcd1d87fb
commit
e11fad6598
26 changed files with 688 additions and 49 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <exosphere/hw.hpp>
|
||||
#include <exosphere/util.hpp>
|
||||
#include <exosphere/mmu.hpp>
|
||||
#include <exosphere/br.hpp>
|
||||
#include <exosphere/gic.hpp>
|
||||
#include <exosphere/wdt.hpp>
|
||||
#include <exosphere/pkg1.hpp>
|
||||
|
|
19
libraries/libexosphere/include/exosphere/br.hpp
Normal file
19
libraries/libexosphere/include/exosphere/br.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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>
|
||||
|
||||
#include <exosphere/br/br_types.hpp>
|
30
libraries/libexosphere/include/exosphere/br/br_types.hpp
Normal file
30
libraries/libexosphere/include/exosphere/br/br_types.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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>
|
||||
|
||||
#include <exosphere/br/impl/br_erista_types.hpp>
|
||||
#include <exosphere/br/impl/br_mariko_types.hpp>
|
||||
|
||||
namespace ams::br {
|
||||
|
||||
struct BootEcid {
|
||||
u32 ecid[4];
|
||||
};
|
||||
static_assert(util::is_pod<BootEcid>::value);
|
||||
static_assert(sizeof(BootEcid) == 0x10);
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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::br::erista {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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::br::mariko {
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <exosphere/br.hpp>
|
||||
#include <exosphere/pmic.hpp>
|
||||
|
||||
namespace ams::fuse {
|
||||
|
@ -45,5 +46,6 @@ namespace ams::fuse {
|
|||
HardwareType GetHardwareType();
|
||||
HardwareState GetHardwareState();
|
||||
pmic::Regulator GetRegulator();
|
||||
void GetEcid(br::BootEcid *out);
|
||||
|
||||
}
|
|
@ -20,3 +20,4 @@
|
|||
#include <exosphere/pkg1/pkg1_error_types.hpp>
|
||||
#include <exosphere/pkg1/pkg1_key_generation.hpp>
|
||||
#include <exosphere/pkg1/pkg1_se_key_slots.hpp>
|
||||
#include <exosphere/pkg1/pkg1_api.hpp>
|
||||
|
|
25
libraries/libexosphere/include/exosphere/pkg1/pkg1_api.hpp
Normal file
25
libraries/libexosphere/include/exosphere/pkg1/pkg1_api.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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();
|
||||
|
||||
}
|
|
@ -90,9 +90,13 @@ namespace ams::pkg1 {
|
|||
return static_cast<MemoryMode>(this->flags0[3]);
|
||||
}
|
||||
|
||||
bool IsTscInitialValueValid() const {
|
||||
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);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <exosphere/se/se_common.hpp>
|
||||
#include <exosphere/se/se_management.hpp>
|
||||
#include <exosphere/se/se_aes.hpp>
|
||||
#include <exosphere/se/se_hash.hpp>
|
||||
#include <exosphere/se/se_rsa.hpp>
|
||||
#include <exosphere/se/se_rng.hpp>
|
||||
#include <exosphere/se/se_suspend.hpp>
|
||||
|
|
30
libraries/libexosphere/include/exosphere/se/se_hash.hpp
Normal file
30
libraries/libexosphere/include/exosphere/se/se_hash.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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::se {
|
||||
|
||||
constexpr inline int Sha256HashSize = crypto::Sha256Generator::HashSize;
|
||||
|
||||
union Sha256Hash {
|
||||
u8 bytes[Sha256HashSize / sizeof( u8)];
|
||||
u32 words[Sha256HashSize / sizeof(u32)];
|
||||
};
|
||||
|
||||
void CalculateSha256(Sha256Hash *dst, const void *src, size_t src_size);
|
||||
|
||||
}
|
|
@ -26,4 +26,6 @@ namespace ams::se {
|
|||
|
||||
void SetRsaKey(int slot, const void *mod, size_t mod_size, const void *exp, size_t exp_size);
|
||||
|
||||
void ModularExponentiate(void *dst, size_t dst_size, int slot, const void *src, size_t src_size);
|
||||
|
||||
}
|
||||
|
|
|
@ -70,6 +70,10 @@ namespace ams::secmon {
|
|||
GetConfigurationContext().secmon_cfg.key_generation = generation;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE pkg1::BootConfig *GetBootConfigStorage() {
|
||||
return std::addressof(GetConfigurationContext().boot_config);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const ConfigurationContext &GetConfigurationContext() {
|
||||
|
|
|
@ -271,7 +271,9 @@ namespace ams::secmon {
|
|||
static_assert(MemoryRegionVirtual.Contains(MemoryRegionVirtualTzramL2L3PageTable));
|
||||
static_assert(MemoryRegionPhysicalTzramNonVolatile.Contains(MemoryRegionPhysicalTzramL2L3PageTable));
|
||||
|
||||
constexpr inline const MemoryRegion MemoryRegionPhysicalTzramFullProgramImage = MemoryRegion(0x7C010800, 0xD800);
|
||||
constexpr inline const MemoryRegion MemoryRegionPhysicalIramBootCodeImage = MemoryRegion(0x40032000, 0xC000);
|
||||
constexpr inline const MemoryRegion MemoryRegionPhysicalTzramFullProgramImage = MemoryRegion(UINT64_C(0x7C010800), 0xD800);
|
||||
constexpr inline const MemoryRegion MemoryRegionPhysicalIramBootCodeImage = MemoryRegion(UINT64_C(0x40032000), 0xC000);
|
||||
|
||||
}
|
||||
constexpr inline const MemoryRegion MemoryRegionPhysicalIramBootConfig = MemoryRegion(UINT64_C(0x4003F800), 0x400);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
|
||||
#define SYSCTR0_CNTCR (0x00C)
|
||||
#define SYSCTR0_CNTCV0 (0x008)
|
||||
#define SYSCTR0_CNTCV1 (0x00C)
|
||||
#define SYSCTR0_CNTFID0 (0x020)
|
||||
#define SYSCTR0_CNTFID1 (0x024)
|
||||
|
||||
|
@ -33,4 +36,18 @@
|
|||
#define SYSCTR0_COUNTERID10 (0xFF8)
|
||||
#define SYSCTR0_COUNTERID11 (0xFFC)
|
||||
|
||||
#define SYSCTR0_COUNTERID(n) SYSCTR0_COUNTERID##n
|
||||
#define SYSCTR0_COUNTERID(n) SYSCTR0_COUNTERID##n
|
||||
|
||||
#define SYSCTR0_REG_BITS_MASK(NAME) REG_NAMED_BITS_MASK (SYSCTR0, NAME)
|
||||
#define SYSCTR0_REG_BITS_VALUE(NAME, VALUE) REG_NAMED_BITS_VALUE (SYSCTR0, NAME, VALUE)
|
||||
#define SYSCTR0_REG_BITS_ENUM(NAME, ENUM) REG_NAMED_BITS_ENUM (SYSCTR0, NAME, ENUM)
|
||||
#define SYSCTR0_REG_BITS_ENUM_SEL(NAME, __COND__, TRUE_ENUM, FALSE_ENUM) REG_NAMED_BITS_ENUM_SEL(SYSCTR0, NAME, __COND__, TRUE_ENUM, FALSE_ENUM)
|
||||
|
||||
#define DEFINE_SYSCTR0_REG(NAME, __OFFSET__, __WIDTH__) REG_DEFINE_NAMED_REG (SYSCTR0, NAME, __OFFSET__, __WIDTH__)
|
||||
#define DEFINE_SYSCTR0_REG_BIT_ENUM(NAME, __OFFSET__, ZERO, ONE) REG_DEFINE_NAMED_BIT_ENUM (SYSCTR0, NAME, __OFFSET__, ZERO, ONE)
|
||||
#define DEFINE_SYSCTR0_REG_TWO_BIT_ENUM(NAME, __OFFSET__, ZERO, ONE, TWO, THREE) REG_DEFINE_NAMED_TWO_BIT_ENUM (SYSCTR0, NAME, __OFFSET__, ZERO, ONE, TWO, THREE)
|
||||
#define DEFINE_SYSCTR0_REG_THREE_BIT_ENUM(NAME, __OFFSET__, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN) REG_DEFINE_NAMED_THREE_BIT_ENUM(SYSCTR0, NAME, __OFFSET__, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN)
|
||||
#define DEFINE_SYSCTR0_REG_FOUR_BIT_ENUM(NAME, __OFFSET__, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN) REG_DEFINE_NAMED_FOUR_BIT_ENUM (SYSCTR0, NAME, __OFFSET__, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN)
|
||||
|
||||
DEFINE_SYSCTR0_REG_BIT_ENUM(CNTCR_EN, 0, DISABLE, ENABLE);
|
||||
DEFINE_SYSCTR0_REG_BIT_ENUM(CNTCR_HDBG, 1, DISABLE, ENABLE);
|
Loading…
Add table
Add a link
Reference in a new issue