From f58c45b2c3199a0675c32dde9433de0b201e4ec6 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 21 Nov 2019 00:28:32 -0800 Subject: [PATCH] strat: update for latest libnx. --- include/stratosphere/ncm/ncm_types.hpp | 18 +++++++++-------- source/boot2/boot2_api.cpp | 8 ++++---- source/updater/updater_api.cpp | 10 +++++----- source/updater/updater_bis_management.hpp | 24 +++++++++++------------ 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/include/stratosphere/ncm/ncm_types.hpp b/include/stratosphere/ncm/ncm_types.hpp index 6860404e..0c13966b 100644 --- a/include/stratosphere/ncm/ncm_types.hpp +++ b/include/stratosphere/ncm/ncm_types.hpp @@ -15,19 +15,21 @@ */ #pragma once - -#include +#include namespace ams::ncm { /* Storage IDs. */ enum class StorageId : u8 { - None = 0, - Host = 1, - GameCard = 2, - NandSystem = 3, - NandUser = 4, - SdCard = 5, + #define DEFINE_ENUM_MEMBER(nm) nm = NcmStorageId_##nm + DEFINE_ENUM_MEMBER(None), + DEFINE_ENUM_MEMBER(Host), + DEFINE_ENUM_MEMBER(GameCard), + DEFINE_ENUM_MEMBER(BuiltInSystem), + DEFINE_ENUM_MEMBER(BuiltInUser), + DEFINE_ENUM_MEMBER(SdCard), + DEFINE_ENUM_MEMBER(Any), + #undef DEFINE_ENUM_MEMBER }; /* Program IDs (Formerly: Title IDs). */ diff --git a/source/boot2/boot2_api.cpp b/source/boot2/boot2_api.cpp index 83cb69bc..63e57b84 100644 --- a/source/boot2/boot2_api.cpp +++ b/source/boot2/boot2_api.cpp @@ -152,7 +152,7 @@ namespace ams::boot2 { void LaunchList(const ncm::ProgramId *launch_list, size_t num_entries) { for (size_t i = 0; i < num_entries; i++) { - LaunchProgram(nullptr, ncm::ProgramLocation::Make(launch_list[i], ncm::StorageId::NandSystem), 0); + LaunchProgram(nullptr, ncm::ProgramLocation::Make(launch_list[i], ncm::StorageId::BuiltInSystem), 0); } } @@ -313,7 +313,7 @@ namespace ams::boot2 { R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc:c"))); } - /* Launch Atmosphere boot2, using FsStorageId_None to force SD card boot. */ + /* Launch Atmosphere boot2, using NcmStorageId_None to force SD card boot. */ LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Boot2, ncm::StorageId::None), 0); } @@ -326,7 +326,7 @@ namespace ams::boot2 { pm::bm::SetMaintenanceBoot(); } - /* Launch Atmosphere dmnt, using FsStorageId_None to force SD card boot. */ + /* Launch Atmosphere dmnt, using NcmStorageId_None to force SD card boot. */ LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Dmnt, ncm::StorageId::None), 0); /* Check for and forward declare non-atmosphere mitm modules. */ @@ -337,7 +337,7 @@ namespace ams::boot2 { LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms); /* Starting in 7.0.0, npns is launched during maintenance boot. */ if (hos::GetVersion() >= hos::Version_700) { - LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Npns, ncm::StorageId::NandSystem), 0); + LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Npns, ncm::StorageId::BuiltInSystem), 0); } } else { LaunchList(AdditionalLaunchPrograms, NumAdditionalLaunchPrograms); diff --git a/source/updater/updater_api.cpp b/source/updater/updater_api.cpp index 2af61ee3..cb7a7ddb 100644 --- a/source/updater/updater_api.cpp +++ b/source/updater/updater_api.cpp @@ -143,7 +143,7 @@ namespace ams::updater { /* Open NAND System meta database, list contents. */ NcmContentMetaDatabase meta_db; - R_TRY(ncmOpenContentMetaDatabase(&meta_db, FsStorageId_NandSystem)); + R_TRY(ncmOpenContentMetaDatabase(&meta_db, NcmStorageId_BuiltInSystem)); ON_SCOPE_EXIT { serviceClose(&meta_db.s); }; NcmContentMetaKey *records = reinterpret_cast(work_buffer); @@ -190,7 +190,7 @@ namespace ams::updater { /* Ensure work buffer is big enough for us to do what we want to do. */ R_TRY(ValidateWorkBuffer(work_buffer, work_buffer_size)); - R_TRY_CATCH(romfsMountFromDataArchive(data_id, FsStorageId_NandSystem, GetBootImagePackageMountPath())) { + R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) { R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound()) } R_END_TRY_CATCH; ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; @@ -243,7 +243,7 @@ namespace ams::updater { /* Ensure work buffer is big enough for us to do what we want to do. */ R_TRY(ValidateWorkBuffer(work_buffer, work_buffer_size)); - R_TRY_CATCH(romfsMountFromDataArchive(data_id, FsStorageId_NandSystem, GetBootImagePackageMountPath())) { + R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) { R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound()) } R_END_TRY_CATCH; ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; @@ -311,7 +311,7 @@ namespace ams::updater { /* Ensure work buffer is big enough for us to do what we want to do. */ R_TRY(ValidateWorkBuffer(work_buffer, work_buffer_size)); - R_TRY_CATCH(romfsMountFromDataArchive(data_id, FsStorageId_NandSystem, GetBootImagePackageMountPath())) { + R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) { R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound()) } R_END_TRY_CATCH; ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; @@ -366,7 +366,7 @@ namespace ams::updater { /* Ensure work buffer is big enough for us to do what we want to do. */ R_TRY(ValidateWorkBuffer(work_buffer, work_buffer_size)); - R_TRY_CATCH(romfsMountFromDataArchive(data_id, FsStorageId_NandSystem, GetBootImagePackageMountPath())) { + R_TRY_CATCH(romfsMountFromDataArchive(data_id, NcmStorageId_BuiltInSystem, GetBootImagePackageMountPath())) { R_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound()) } R_END_TRY_CATCH; ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; diff --git a/source/updater/updater_bis_management.hpp b/source/updater/updater_bis_management.hpp index 73ae1e7d..cb60d441 100644 --- a/source/updater/updater_bis_management.hpp +++ b/source/updater/updater_bis_management.hpp @@ -24,10 +24,10 @@ namespace ams::updater { static constexpr size_t SectorAlignment = 0x200; private: FsStorage storage = {}; - FsBisStorageId partition_id; + FsBisPartitionId partition_id; bool active; public: - BisAccessor(FsBisStorageId id) : partition_id(id), active(false) { } + BisAccessor(FsBisPartitionId id) : partition_id(id), active(false) { } ~BisAccessor() { if (this->active) { fsStorageClose(&storage); @@ -125,7 +125,7 @@ namespace ams::updater { using EnumType = typename Meta::EnumType; using OffsetSizeType = typename Meta::OffsetSizeType; public: - PartitionAccessor(FsBisStorageId id) : BisAccessor(id) { } + PartitionAccessor(FsBisPartitionId id) : BisAccessor(id) { } private: constexpr const OffsetSizeType *FindEntry(EnumType which) { const OffsetSizeType *entry = nullptr; @@ -182,27 +182,27 @@ namespace ams::updater { RepairSub, }; - static constexpr FsBisStorageId GetPackage2StorageId(Package2Type which) { + static constexpr FsBisPartitionId GetPackage2StorageId(Package2Type which) { switch (which) { case Package2Type::NormalMain: - return FsBisStorageId_BootConfigAndPackage2NormalMain; + return FsBisPartitionId_BootConfigAndPackage2Part1; case Package2Type::NormalSub: - return FsBisStorageId_BootConfigAndPackage2NormalSub; + return FsBisPartitionId_BootConfigAndPackage2Part2; case Package2Type::SafeMain: - return FsBisStorageId_BootConfigAndPackage2SafeMain; + return FsBisPartitionId_BootConfigAndPackage2Part3; case Package2Type::SafeSub: - return FsBisStorageId_BootConfigAndPackage2SafeSub; + return FsBisPartitionId_BootConfigAndPackage2Part4; case Package2Type::RepairMain: - return FsBisStorageId_BootConfigAndPackage2RepairMain; + return FsBisPartitionId_BootConfigAndPackage2Part5; case Package2Type::RepairSub: - return FsBisStorageId_BootConfigAndPackage2RepairSub; + return FsBisPartitionId_BootConfigAndPackage2Part6; AMS_UNREACHABLE_DEFAULT_CASE(); } } class Boot0Accessor : public PartitionAccessor { public: - static constexpr FsBisStorageId PartitionId = FsBisStorageId_Boot0; + static constexpr FsBisPartitionId PartitionId = FsBisPartitionId_BootPartition1Root; static constexpr size_t BctPubkOffset = 0x210; static constexpr size_t BctPubkSize = 0x100; static constexpr size_t BctEksOffset = 0x450; @@ -222,7 +222,7 @@ namespace ams::updater { class Boot1Accessor : public PartitionAccessor { public: - static constexpr FsBisStorageId PartitionId = FsBisStorageId_Boot1; + static constexpr FsBisPartitionId PartitionId = FsBisPartitionId_BootPartition2Root; public: Boot1Accessor() : PartitionAccessor(PartitionId) { } };