Atmosphere/libraries/libexosphere/include/exosphere/pkg1/pkg1_boot_config.hpp
Michael Scire f66b41c027 exo2: Initial work on the exosphere rewrite.
exo2: Implement uncompressor stub and boot code up to Main().

exo2: implement some more init (uart/gic)

exo2: implement more of init

exo2: improve reg api, add keyslot flag setters

exo2: implement se aes decryption/enc

exo2: fix bugs in loader stub/mmu mappings

exo2: start skeletoning bootconfig/global context types

arch: fix makefile flags

exo2: implement through master key derivation

exo2: implement device master keygen

exo2: more init through start of SetupSocSecurity

exo2: implement pmc secure scratch management

se: implement sticky bit validation

libexosphere: fix building for arm32

libexo: fix makefile flags

libexo: support building for arm64/arm

sc7fw: skeleton binary

sc7fw: skeleton a little more

sc7fw: implement all non-dram functionality

exo2: fix DivideUp error

sc7fw: implement more dram code, fix reg library errors

sc7fw: complete sc7fw impl.

exo2: skeleton the rest of SetupSocSecurity

exo2: implement fiq interrupt handler

exo2: implement all exception handlers

exo2: skeleton the entire smc api, implement the svc invoker

exo2: implement rest of SetupSocSecurity

exo2: correct slave security errors

exo2: fix register definition

exo2: minor fixes
2020-06-14 22:07:45 -07:00

133 lines
4.2 KiB
C++

/*
* 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 {
enum MemorySize {
MemorySize_4GB = 0,
MemorySize_6GB = 1,
MemorySize_8GB = 2,
};
enum MemoryArrange {
MemoryArrange_Normal = 1,
MemoryArrange_AppletDev = 2,
MemoryArrange_SystemDev = 2,
};
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]);
}
bool IsTscInitialValueValid() const {
return (this->flags0[4] & (1 << 0)) != 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;
}
};
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);
}