strat: update for latest libnx.

This commit is contained in:
Michael Scire 2019-11-21 00:28:32 -08:00 committed by SciresM
parent 393596ef9a
commit b758e3fc55
9 changed files with 39 additions and 37 deletions

View file

@ -55,7 +55,7 @@ namespace ams::boot {
Result GetBatteryVendorImpl(u32 *vendor) { Result GetBatteryVendorImpl(u32 *vendor) {
FsStorage s; FsStorage s;
R_TRY(fsOpenBisStorage(&s, FsBisStorageId_CalibrationBinary)); R_TRY(fsOpenBisStorage(&s, FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(&s); }; ON_SCOPE_EXIT { fsStorageClose(&s); };
u8 battery_lot[BatteryLotSize]; u8 battery_lot[BatteryLotSize];
@ -69,7 +69,7 @@ namespace ams::boot {
Result GetBatteryVersionImpl(u32 *version) { Result GetBatteryVersionImpl(u32 *version) {
FsStorage s; FsStorage s;
R_TRY(fsOpenBisStorage(&s, FsBisStorageId_CalibrationBinary)); R_TRY(fsOpenBisStorage(&s, FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(&s); }; ON_SCOPE_EXIT { fsStorageClose(&s); };
u8 battery_version[BatteryVersionSize]; u8 battery_version[BatteryVersionSize];

View file

@ -94,7 +94,7 @@ namespace ams::fatal::srv {
} }
/* Check that the gamecard is a repair tool. */ /* Check that the gamecard is a repair tool. */
return (gc_attr & FsGameCardAttribute_Repair) == FsGameCardAttribute_Repair; return (gc_attr & FsGameCardAttribute_RepairToolFlag);
} }
bool IsInRepairWithoutTimeReviserCartridge() { bool IsInRepairWithoutTimeReviserCartridge() {

View file

@ -15,19 +15,21 @@
*/ */
#pragma once #pragma once
#include <atmosphere/common.hpp>
#include <type_traits>
namespace ams::ncm { namespace ams::ncm {
/* Storage IDs. */ /* Storage IDs. */
enum class StorageId : u8 { enum class StorageId : u8 {
None = 0, #define DEFINE_ENUM_MEMBER(nm) nm = NcmStorageId_##nm
Host = 1, DEFINE_ENUM_MEMBER(None),
GameCard = 2, DEFINE_ENUM_MEMBER(Host),
NandSystem = 3, DEFINE_ENUM_MEMBER(GameCard),
NandUser = 4, DEFINE_ENUM_MEMBER(BuiltInSystem),
SdCard = 5, DEFINE_ENUM_MEMBER(BuiltInUser),
DEFINE_ENUM_MEMBER(SdCard),
DEFINE_ENUM_MEMBER(Any),
#undef DEFINE_ENUM_MEMBER
}; };
/* Program IDs (Formerly: Title IDs). */ /* Program IDs (Formerly: Title IDs). */

View file

@ -152,7 +152,7 @@ namespace ams::boot2 {
void LaunchList(const ncm::ProgramId *launch_list, size_t num_entries) { void LaunchList(const ncm::ProgramId *launch_list, size_t num_entries) {
for (size_t i = 0; i < num_entries; i++) { 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"))); 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); LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Boot2, ncm::StorageId::None), 0);
} }
@ -326,7 +326,7 @@ namespace ams::boot2 {
pm::bm::SetMaintenanceBoot(); 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); LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Dmnt, ncm::StorageId::None), 0);
/* Check for and forward declare non-atmosphere mitm modules. */ /* Check for and forward declare non-atmosphere mitm modules. */
@ -337,7 +337,7 @@ namespace ams::boot2 {
LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms); LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms);
/* Starting in 7.0.0, npns is launched during maintenance boot. */ /* Starting in 7.0.0, npns is launched during maintenance boot. */
if (hos::GetVersion() >= hos::Version_700) { 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 { } else {
LaunchList(AdditionalLaunchPrograms, NumAdditionalLaunchPrograms); LaunchList(AdditionalLaunchPrograms, NumAdditionalLaunchPrograms);

View file

@ -143,7 +143,7 @@ namespace ams::updater {
/* Open NAND System meta database, list contents. */ /* Open NAND System meta database, list contents. */
NcmContentMetaDatabase meta_db; NcmContentMetaDatabase meta_db;
R_TRY(ncmOpenContentMetaDatabase(&meta_db, FsStorageId_NandSystem)); R_TRY(ncmOpenContentMetaDatabase(&meta_db, NcmStorageId_BuiltInSystem));
ON_SCOPE_EXIT { serviceClose(&meta_db.s); }; ON_SCOPE_EXIT { serviceClose(&meta_db.s); };
NcmContentMetaKey *records = reinterpret_cast<NcmContentMetaKey *>(work_buffer); NcmContentMetaKey *records = reinterpret_cast<NcmContentMetaKey *>(work_buffer);
@ -190,7 +190,7 @@ namespace ams::updater {
/* Ensure work buffer is big enough for us to do what we want to do. */ /* 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(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_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
} R_END_TRY_CATCH; } R_END_TRY_CATCH;
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; 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. */ /* 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(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_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
} R_END_TRY_CATCH; } R_END_TRY_CATCH;
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; 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. */ /* 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(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_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
} R_END_TRY_CATCH; } R_END_TRY_CATCH;
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; 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. */ /* 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(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_CONVERT(fs::ResultTargetNotFound, ResultBootImagePackageNotFound())
} R_END_TRY_CATCH; } R_END_TRY_CATCH;
ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); }; ON_SCOPE_EXIT { R_ASSERT(romfsUnmount(GetBootImagePackageMountPath())); };

View file

@ -24,10 +24,10 @@ namespace ams::updater {
static constexpr size_t SectorAlignment = 0x200; static constexpr size_t SectorAlignment = 0x200;
private: private:
FsStorage storage = {}; FsStorage storage = {};
FsBisStorageId partition_id; FsBisPartitionId partition_id;
bool active; bool active;
public: public:
BisAccessor(FsBisStorageId id) : partition_id(id), active(false) { } BisAccessor(FsBisPartitionId id) : partition_id(id), active(false) { }
~BisAccessor() { ~BisAccessor() {
if (this->active) { if (this->active) {
fsStorageClose(&storage); fsStorageClose(&storage);
@ -125,7 +125,7 @@ namespace ams::updater {
using EnumType = typename Meta::EnumType; using EnumType = typename Meta::EnumType;
using OffsetSizeType = typename Meta::OffsetSizeType; using OffsetSizeType = typename Meta::OffsetSizeType;
public: public:
PartitionAccessor(FsBisStorageId id) : BisAccessor(id) { } PartitionAccessor(FsBisPartitionId id) : BisAccessor(id) { }
private: private:
constexpr const OffsetSizeType *FindEntry(EnumType which) { constexpr const OffsetSizeType *FindEntry(EnumType which) {
const OffsetSizeType *entry = nullptr; const OffsetSizeType *entry = nullptr;
@ -182,27 +182,27 @@ namespace ams::updater {
RepairSub, RepairSub,
}; };
static constexpr FsBisStorageId GetPackage2StorageId(Package2Type which) { static constexpr FsBisPartitionId GetPackage2StorageId(Package2Type which) {
switch (which) { switch (which) {
case Package2Type::NormalMain: case Package2Type::NormalMain:
return FsBisStorageId_BootConfigAndPackage2NormalMain; return FsBisPartitionId_BootConfigAndPackage2Part1;
case Package2Type::NormalSub: case Package2Type::NormalSub:
return FsBisStorageId_BootConfigAndPackage2NormalSub; return FsBisPartitionId_BootConfigAndPackage2Part2;
case Package2Type::SafeMain: case Package2Type::SafeMain:
return FsBisStorageId_BootConfigAndPackage2SafeMain; return FsBisPartitionId_BootConfigAndPackage2Part3;
case Package2Type::SafeSub: case Package2Type::SafeSub:
return FsBisStorageId_BootConfigAndPackage2SafeSub; return FsBisPartitionId_BootConfigAndPackage2Part4;
case Package2Type::RepairMain: case Package2Type::RepairMain:
return FsBisStorageId_BootConfigAndPackage2RepairMain; return FsBisPartitionId_BootConfigAndPackage2Part5;
case Package2Type::RepairSub: case Package2Type::RepairSub:
return FsBisStorageId_BootConfigAndPackage2RepairSub; return FsBisPartitionId_BootConfigAndPackage2Part6;
AMS_UNREACHABLE_DEFAULT_CASE(); AMS_UNREACHABLE_DEFAULT_CASE();
} }
} }
class Boot0Accessor : public PartitionAccessor<Boot0Meta> { class Boot0Accessor : public PartitionAccessor<Boot0Meta> {
public: public:
static constexpr FsBisStorageId PartitionId = FsBisStorageId_Boot0; static constexpr FsBisPartitionId PartitionId = FsBisPartitionId_BootPartition1Root;
static constexpr size_t BctPubkOffset = 0x210; static constexpr size_t BctPubkOffset = 0x210;
static constexpr size_t BctPubkSize = 0x100; static constexpr size_t BctPubkSize = 0x100;
static constexpr size_t BctEksOffset = 0x450; static constexpr size_t BctEksOffset = 0x450;
@ -222,7 +222,7 @@ namespace ams::updater {
class Boot1Accessor : public PartitionAccessor<Boot1Meta> { class Boot1Accessor : public PartitionAccessor<Boot1Meta> {
public: public:
static constexpr FsBisStorageId PartitionId = FsBisStorageId_Boot1; static constexpr FsBisPartitionId PartitionId = FsBisPartitionId_BootPartition2Root;
public: public:
Boot1Accessor() : PartitionAccessor<Boot1Meta>(PartitionId) { } Boot1Accessor() : PartitionAccessor<Boot1Meta>(PartitionId) { }
}; };

View file

@ -288,7 +288,7 @@ namespace ams::ldr {
R_CATCH(lr::ResultProgramNotFound) { R_CATCH(lr::ResultProgramNotFound) {
/* Program wasn't found via registered resolver, fall back to the normal resolver. */ /* Program wasn't found via registered resolver, fall back to the normal resolver. */
LrLocationResolver lr; LrLocationResolver lr;
R_TRY(lrOpenLocationResolver(static_cast<FsStorageId>(loc.storage_id), &lr)); R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(loc.storage_id), &lr));
ON_SCOPE_EXIT { serviceClose(&lr.s); }; ON_SCOPE_EXIT { serviceClose(&lr.s); };
R_TRY(lrLrResolveProgramPath(&lr, static_cast<u64>(loc.program_id), path)); R_TRY(lrLrResolveProgramPath(&lr, static_cast<u64>(loc.program_id), path));
@ -303,7 +303,7 @@ namespace ams::ldr {
Result RedirectContentPath(const char *path, const ncm::ProgramLocation &loc) { Result RedirectContentPath(const char *path, const ncm::ProgramLocation &loc) {
LrLocationResolver lr; LrLocationResolver lr;
R_TRY(lrOpenLocationResolver(static_cast<FsStorageId>(loc.storage_id), &lr)); R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(loc.storage_id), &lr));
ON_SCOPE_EXIT { serviceClose(&lr.s); }; ON_SCOPE_EXIT { serviceClose(&lr.s); };
return lrLrRedirectProgramPath(&lr, static_cast<u64>(loc.program_id), path); return lrLrRedirectProgramPath(&lr, static_cast<u64>(loc.program_id), path);
@ -314,7 +314,7 @@ namespace ams::ldr {
/* Open a location resolver. */ /* Open a location resolver. */
LrLocationResolver lr; LrLocationResolver lr;
R_TRY(lrOpenLocationResolver(static_cast<FsStorageId>(loc.storage_id), &lr)); R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(loc.storage_id), &lr));
ON_SCOPE_EXIT { serviceClose(&lr.s); }; ON_SCOPE_EXIT { serviceClose(&lr.s); };
/* If there's already a Html Document path, we don't need to set one. */ /* If there's already a Html Document path, we don't need to set one. */

View file

@ -331,7 +331,7 @@ namespace ams::pm::impl {
const u8 *aci_fah = acid_fac + program_info.acid_fac_size; const u8 *aci_fah = acid_fac + program_info.acid_fac_size;
/* Register with FS and SM. */ /* Register with FS and SM. */
R_TRY(fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(location.program_id), static_cast<FsStorageId>(location.storage_id), aci_fah, program_info.aci_fah_size, acid_fac, program_info.acid_fac_size)); R_TRY(fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(location.program_id), static_cast<NcmStorageId>(location.storage_id), aci_fah, program_info.aci_fah_size, acid_fac, program_info.acid_fac_size));
R_TRY(sm::manager::RegisterProcess(process_id, location.program_id, acid_sac, program_info.acid_sac_size, aci_sac, program_info.aci_sac_size)); R_TRY(sm::manager::RegisterProcess(process_id, location.program_id, acid_sac, program_info.acid_sac_size, aci_sac, program_info.aci_sac_size));
/* Set flags. */ /* Set flags. */

View file

@ -104,7 +104,7 @@ namespace {
/* It also registers privileged processes with SM, so that their program ids can be known. */ /* It also registers privileged processes with SM, so that their program ids can be known. */
void RegisterPrivilegedProcess(os::ProcessId process_id) { void RegisterPrivilegedProcess(os::ProcessId process_id) {
fsprUnregisterProgram(static_cast<u64>(process_id)); fsprUnregisterProgram(static_cast<u64>(process_id));
fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(process_id), FsStorageId_NandSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl)); fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(process_id), NcmStorageId_BuiltInSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl));
sm::manager::UnregisterProcess(process_id); sm::manager::UnregisterProcess(process_id);
sm::manager::RegisterProcess(process_id, GetProcessProgramId(process_id), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl)); sm::manager::RegisterProcess(process_id, GetProcessProgramId(process_id), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl));
} }