2021-08-21 23:49:36 +01:00
|
|
|
/*
|
|
|
|
* 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
|
2021-08-23 22:18:59 +01:00
|
|
|
#include <exosphere.hpp>
|
|
|
|
#include "fusee_display.hpp"
|
2021-08-21 23:49:36 +01:00
|
|
|
|
|
|
|
namespace ams::nxboot {
|
|
|
|
|
2021-09-03 07:45:51 +01:00
|
|
|
constexpr inline const size_t SecondaryArchiveSize = 8_MB;
|
2021-08-23 22:18:59 +01:00
|
|
|
|
|
|
|
constexpr inline const size_t InitialProcessStorageSizeMax = 3_MB / 8;
|
|
|
|
|
2021-08-24 05:15:51 +01:00
|
|
|
struct SecondaryArchiveContentMeta {
|
|
|
|
u32 offset;
|
|
|
|
u32 size;
|
|
|
|
u8 type;
|
|
|
|
u8 flags[3];
|
|
|
|
u32 pad;
|
|
|
|
char name[0x10];
|
|
|
|
};
|
|
|
|
static_assert(sizeof(SecondaryArchiveContentMeta) == 0x20);
|
|
|
|
|
|
|
|
struct SecondaryArchiveKipMeta {
|
|
|
|
u64 program_id;
|
|
|
|
u32 offset;
|
|
|
|
u32 size;
|
2021-09-03 04:40:15 +01:00
|
|
|
se::Sha256Hash hash;
|
2021-08-24 05:15:51 +01:00
|
|
|
};
|
2021-09-03 04:40:15 +01:00
|
|
|
static_assert(sizeof(SecondaryArchiveKipMeta) == 0x30);
|
2021-08-24 05:15:51 +01:00
|
|
|
|
2021-08-23 22:18:59 +01:00
|
|
|
struct SecondaryArchiveHeader {
|
2021-08-24 05:15:51 +01:00
|
|
|
static constexpr u32 Magic = util::FourCC<'F','S','S','0'>::Code;
|
|
|
|
|
|
|
|
u32 reserved0; /* Previously entrypoint. */
|
|
|
|
u32 metadata_offset;
|
2021-09-03 07:45:51 +01:00
|
|
|
u32 flags;
|
2021-08-24 05:15:51 +01:00
|
|
|
u32 num_kips;
|
2021-09-03 07:45:51 +01:00
|
|
|
u32 reserved1[4];
|
2021-08-24 05:15:51 +01:00
|
|
|
u32 magic;
|
|
|
|
u32 total_size;
|
2021-09-03 07:45:51 +01:00
|
|
|
u32 reserved2; /* Previously crt0 offset. */
|
2021-08-24 05:15:51 +01:00
|
|
|
u32 content_header_offset;
|
|
|
|
u32 num_content_headers;
|
|
|
|
u32 supported_hos_version;
|
|
|
|
u32 release_version;
|
|
|
|
u32 git_revision;
|
|
|
|
SecondaryArchiveContentMeta content_metas[(0x400 - 0x40) / sizeof(SecondaryArchiveContentMeta)];
|
|
|
|
SecondaryArchiveKipMeta emummc_meta;
|
|
|
|
SecondaryArchiveKipMeta kip_metas[8];
|
2021-09-03 07:45:51 +01:00
|
|
|
u8 reserved3[0x800 - (0x400 + 9 * sizeof(SecondaryArchiveKipMeta))];
|
2021-08-23 22:18:59 +01:00
|
|
|
};
|
2021-08-24 05:15:51 +01:00
|
|
|
static_assert(sizeof(SecondaryArchiveHeader) == 0x800);
|
2021-08-23 22:18:59 +01:00
|
|
|
|
|
|
|
struct SecondaryArchive {
|
2021-08-24 05:15:51 +01:00
|
|
|
SecondaryArchiveHeader header; /* 0x000000-0x000800 */
|
|
|
|
u8 warmboot[0x1800]; /* 0x000800-0x002000 */
|
|
|
|
u8 tsec_keygen[0x2000]; /* 0x002000-0x004000 */
|
|
|
|
u8 mariko_fatal[0x1C000]; /* 0x004000-0x020000 */
|
|
|
|
u8 ovl_mtc_erista[0x14000]; /* 0x020000-0x034000 */
|
|
|
|
u8 ovl_mtc_mariko[0x14000]; /* 0x034000-0x048000 */
|
2021-09-01 22:05:39 +01:00
|
|
|
u8 exosphere[0xE000]; /* 0x048000-0x056000 */
|
|
|
|
u8 mesosphere[0xAA000]; /* 0x056000-0x100000 */
|
2021-08-24 05:15:51 +01:00
|
|
|
u8 kips[3_MB]; /* 0x100000-0x400000 */
|
|
|
|
u8 splash_screen_fb[FrameBufferSize]; /* 0x400000-0x7C0000 */
|
2021-09-03 07:45:51 +01:00
|
|
|
u8 fusee[0x20000]; /* 0x7C0000-0x7E0000 */
|
|
|
|
u8 reboot_stub[0x1000]; /* 0x7E0000-0x7E1000 */
|
|
|
|
u8 reserved[0x1F000]; /* 0x7E1000-0x800000 */
|
2021-08-23 22:18:59 +01:00
|
|
|
};
|
|
|
|
static_assert(sizeof(SecondaryArchive) == SecondaryArchiveSize);
|
|
|
|
|
|
|
|
ALWAYS_INLINE const SecondaryArchive &GetSecondaryArchive() { return *reinterpret_cast<const SecondaryArchive *>(0xC0000000); }
|
2021-08-21 23:49:36 +01:00
|
|
|
|
2021-08-23 22:18:59 +01:00
|
|
|
}
|