mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-28 14:02:40 +02:00
exo2: implement rest of main other than SetupSocProtections
This commit is contained in:
parent
91bcead046
commit
f47147653e
@ -19,9 +19,9 @@
|
||||
namespace ams::pkg2 {
|
||||
|
||||
constexpr inline size_t Package2SizeMax = 8_MB - 16_KB;
|
||||
constexpr inline size_t SegmentAlignment = 4;
|
||||
constexpr inline size_t PayloadAlignment = 4;
|
||||
|
||||
constexpr inline int SegmentCount = 3;
|
||||
constexpr inline int PayloadCount = 3;
|
||||
|
||||
constexpr inline int MinimumValidDataVersion = 0; /* We allow older package2 to load; this value is currently 0x10 in Nintendo's code. */
|
||||
constexpr inline int CurrentBootloaderVersion = 0xD;
|
||||
@ -32,7 +32,7 @@ namespace ams::pkg2 {
|
||||
u32 package2_size;
|
||||
u8 key_generation;
|
||||
u8 header_iv_remainder[11];
|
||||
u8 segment_iv[SegmentCount][0x10];
|
||||
u8 payload_ivs[PayloadCount][0x10];
|
||||
u8 padding_40[0x10];
|
||||
u8 magic[4];
|
||||
u32 entrypoint;
|
||||
@ -40,11 +40,11 @@ namespace ams::pkg2 {
|
||||
u8 package2_version;
|
||||
u8 bootloader_version;
|
||||
u8 padding_5E[2];
|
||||
u32 segment_sizes[SegmentCount];
|
||||
u32 payload_sizes[PayloadCount];
|
||||
u8 padding_6C[4];
|
||||
u32 segment_offsets[SegmentCount];
|
||||
u32 payload_offsets[PayloadCount];
|
||||
u8 padding_7C[4];
|
||||
u8 segment_hashes[SegmentCount][crypto::Sha256Generator::HashSize];
|
||||
u8 payload_hashes[PayloadCount][crypto::Sha256Generator::HashSize];
|
||||
u8 padding_E0[0x20];
|
||||
|
||||
private:
|
||||
@ -53,7 +53,7 @@ namespace ams::pkg2 {
|
||||
}
|
||||
public:
|
||||
ALWAYS_INLINE u8 GetKeyGeneration() const {
|
||||
return std::min<u8>(0, (this->key_generation ^ this->header_iv_remainder[1] ^ this->header_iv_remainder[2]) - 1);
|
||||
return static_cast<u8>(std::max<s32>(0, static_cast<s32>(this->key_generation ^ this->header_iv_remainder[1] ^ this->header_iv_remainder[2]) - 1));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u32 GetSize() const {
|
||||
|
@ -80,6 +80,9 @@ namespace ams::secmon {
|
||||
constexpr inline const MemoryRegion MemoryRegionDramDefaultKernelCarveout = MemoryRegion(UINT64_C(0x80060000), UINT64_C(0x1FFE0000));
|
||||
static_assert(MemoryRegionDram.Contains(MemoryRegionDramDefaultKernelCarveout));
|
||||
|
||||
constexpr inline const MemoryRegion MemoryRegionDramPackage2Payloads = MemoryRegion(MemoryRegionDram.GetAddress(), 8_MB);
|
||||
static_assert(MemoryRegionDram.Contains(MemoryRegionDramPackage2Payloads));
|
||||
|
||||
constexpr inline const MemoryRegion MemoryRegionDramPackage2 = MemoryRegion(UINT64_C(0xA9800000), UINT64_C(0x07FC0000));
|
||||
static_assert(MemoryRegionDram.Contains(MemoryRegionDramPackage2));
|
||||
|
||||
|
@ -36,5 +36,6 @@
|
||||
#include <vapours/util/util_tinymt.hpp>
|
||||
#include <vapours/util/util_uuid.hpp>
|
||||
#include <vapours/util/util_bounded_map.hpp>
|
||||
#include <vapours/util/util_overlap.hpp>
|
||||
#include <vapours/util/util_string_util.hpp>
|
||||
#include <vapours/util/util_variadic.hpp>
|
||||
|
35
libvapours/include/vapours/util/util_overlap.hpp
Normal file
35
libvapours/include/vapours/util/util_overlap.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
constexpr inline bool HasOverlap(uintptr_t addr0, size_t size0, uintptr_t addr1, size_t size1) {
|
||||
if (addr0 <= addr1) {
|
||||
return addr1 < addr0 + size0;
|
||||
} else {
|
||||
return addr0 < addr1 + size1;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr inline bool Contains(uintptr_t addr, size_t size, uintptr_t ptr) {
|
||||
return (addr <= ptr) && (ptr < addr + size);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user