Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"
This reverts commit 15b7df8ef1.
This commit is contained in:
@@ -1,253 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
#include <stratosphere/ncm/ncm_ids.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
#include <stratosphere/fssrv/impl/fssrv_access_control_bits.hpp>
|
||||
|
||||
namespace ams::fssrv {
|
||||
|
||||
bool IsDebugFlagEnabled();
|
||||
void SetDebugFlagEnabled(bool en);
|
||||
|
||||
}
|
||||
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
struct Accessibility {
|
||||
u8 value;
|
||||
|
||||
constexpr bool CanRead() const { return value & (1 << 0); }
|
||||
constexpr bool CanWrite() const { return value & (1 << 1); }
|
||||
|
||||
static constexpr Accessibility MakeAccessibility(bool read, bool write) {
|
||||
return { static_cast<u8>(read * (1 << 0) + write * (1 << 1)) };
|
||||
}
|
||||
};
|
||||
static_assert(std::is_trivial<Accessibility>::value);
|
||||
|
||||
class ContentOwnerInfo : public util::IntrusiveListBaseNode<ContentOwnerInfo>, public ::ams::fs::impl::Newable {
|
||||
private:
|
||||
u64 m_id;
|
||||
public:
|
||||
ContentOwnerInfo(u64 id) : m_id(id) { /* ... */ }
|
||||
|
||||
u64 GetId() const { return m_id; }
|
||||
};
|
||||
|
||||
class SaveDataOwnerInfo : public util::IntrusiveListBaseNode<SaveDataOwnerInfo>, public ::ams::fs::impl::Newable {
|
||||
private:
|
||||
u64 m_id;
|
||||
Accessibility m_accessibility;
|
||||
public:
|
||||
SaveDataOwnerInfo(u64 id, Accessibility access) : m_id(id), m_accessibility(access) { /* ... */ }
|
||||
|
||||
u64 GetId() const { return m_id; }
|
||||
Accessibility GetAccessibility() const { return m_accessibility; }
|
||||
};
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
class AccessControl {
|
||||
public:
|
||||
enum class AccessibilityType : u32 {
|
||||
MountLogo,
|
||||
MountContentMeta,
|
||||
MountContentControl,
|
||||
MountContentManual,
|
||||
MountContentData,
|
||||
MountApplicationPackage,
|
||||
MountSaveDataStorage,
|
||||
MountContentStorage,
|
||||
MountImageAndVideoStorage,
|
||||
MountCloudBackupWorkStorage,
|
||||
MountCustomStorage,
|
||||
MountBisCalibrationFile,
|
||||
MountBisSafeMode,
|
||||
MountBisUser,
|
||||
MountBisSystem,
|
||||
MountBisSystemProperEncryption,
|
||||
MountBisSystemProperPartition,
|
||||
MountSdCard,
|
||||
MountGameCard,
|
||||
MountDeviceSaveData,
|
||||
MountSystemSaveData,
|
||||
MountOthersSaveData,
|
||||
MountOthersSystemSaveData,
|
||||
OpenBisPartitionBootPartition1Root,
|
||||
OpenBisPartitionBootPartition2Root,
|
||||
OpenBisPartitionUserDataRoot,
|
||||
OpenBisPartitionBootConfigAndPackage2Part1,
|
||||
OpenBisPartitionBootConfigAndPackage2Part2,
|
||||
OpenBisPartitionBootConfigAndPackage2Part3,
|
||||
OpenBisPartitionBootConfigAndPackage2Part4,
|
||||
OpenBisPartitionBootConfigAndPackage2Part5,
|
||||
OpenBisPartitionBootConfigAndPackage2Part6,
|
||||
OpenBisPartitionCalibrationBinary,
|
||||
OpenBisPartitionCalibrationFile,
|
||||
OpenBisPartitionSafeMode,
|
||||
OpenBisPartitionUser,
|
||||
OpenBisPartitionSystem,
|
||||
OpenBisPartitionSystemProperEncryption,
|
||||
OpenBisPartitionSystemProperPartition,
|
||||
OpenSdCardStorage,
|
||||
OpenGameCardStorage,
|
||||
MountSystemDataPrivate,
|
||||
MountHost,
|
||||
MountRegisteredUpdatePartition,
|
||||
MountSaveDataInternalStorage,
|
||||
MountTemporaryDirectory,
|
||||
MountAllBaseFileSystem,
|
||||
NotMount,
|
||||
|
||||
Count,
|
||||
};
|
||||
|
||||
enum class OperationType : u32 {
|
||||
InvalidateBisCache,
|
||||
EraseMmc,
|
||||
GetGameCardDeviceCertificate,
|
||||
GetGameCardIdSet,
|
||||
FinalizeGameCardDriver,
|
||||
GetGameCardAsicInfo,
|
||||
CreateSaveData,
|
||||
DeleteSaveData,
|
||||
CreateSystemSaveData,
|
||||
CreateOthersSystemSaveData,
|
||||
DeleteSystemSaveData,
|
||||
OpenSaveDataInfoReader,
|
||||
OpenSaveDataInfoReaderForSystem,
|
||||
OpenSaveDataInfoReaderForInternal,
|
||||
OpenSaveDataMetaFile,
|
||||
SetCurrentPosixTime,
|
||||
ReadSaveDataFileSystemExtraData,
|
||||
SetGlobalAccessLogMode,
|
||||
SetSpeedEmulationMode,
|
||||
Debug,
|
||||
FillBis,
|
||||
CorruptSaveData,
|
||||
CorruptSystemSaveData,
|
||||
VerifySaveData,
|
||||
DebugSaveData,
|
||||
FormatSdCard,
|
||||
GetRightsId,
|
||||
RegisterExternalKey,
|
||||
SetEncryptionSeed,
|
||||
WriteSaveDataFileSystemExtraDataTimeStamp,
|
||||
WriteSaveDataFileSystemExtraDataFlags,
|
||||
WriteSaveDataFileSystemExtraDataCommitId,
|
||||
WriteSaveDataFileSystemExtraDataAll,
|
||||
ExtendSaveData,
|
||||
ExtendSystemSaveData,
|
||||
ExtendOthersSystemSaveData,
|
||||
RegisterUpdatePartition,
|
||||
OpenSaveDataTransferManager,
|
||||
OpenSaveDataTransferManagerVersion2,
|
||||
OpenSaveDataTransferManagerForSaveDataRepair,
|
||||
OpenSaveDataTransferManagerForSaveDataRepairTool,
|
||||
OpenSaveDataTransferProhibiter,
|
||||
OpenSaveDataMover,
|
||||
OpenBisWiper,
|
||||
ListAccessibleSaveDataOwnerId,
|
||||
ControlMmcPatrol,
|
||||
OverrideSaveDataTransferTokenSignVerificationKey,
|
||||
OpenSdCardDetectionEventNotifier,
|
||||
OpenGameCardDetectionEventNotifier,
|
||||
OpenSystemDataUpdateEventNotifier,
|
||||
NotifySystemDataUpdateEvent,
|
||||
OpenAccessFailureDetectionEventNotifier,
|
||||
GetAccessFailureDetectionEvent,
|
||||
IsAccessFailureDetected,
|
||||
ResolveAccessFailure,
|
||||
AbandonAccessFailure,
|
||||
QuerySaveDataInternalStorageTotalSize,
|
||||
GetSaveDataCommitId,
|
||||
SetSdCardAccessibility,
|
||||
SimulateDevice,
|
||||
CreateSaveDataWithHashSalt,
|
||||
RegisterProgramIndexMapInfo,
|
||||
ChallengeCardExistence,
|
||||
CreateOwnSaveData,
|
||||
DeleteOwnSaveData,
|
||||
ReadOwnSaveDataFileSystemExtraData,
|
||||
ExtendOwnSaveData,
|
||||
OpenOwnSaveDataTransferProhibiter,
|
||||
FindOwnSaveDataWithFilter,
|
||||
OpenSaveDataTransferManagerForRepair,
|
||||
SetDebugConfiguration,
|
||||
OpenDataStorageByPath,
|
||||
|
||||
Count,
|
||||
};
|
||||
|
||||
AMS_PRAGMA_BEGIN_PACK(4)
|
||||
struct AccessControlDataHeader {
|
||||
u8 version;
|
||||
u8 reserved[3];
|
||||
u64 flag_bits;
|
||||
u32 content_owner_infos_offset;
|
||||
u32 content_owner_infos_size;
|
||||
u32 save_data_owner_infos_offset;
|
||||
u32 save_data_owner_infos_size;
|
||||
};
|
||||
|
||||
struct AccessControlDescriptor {
|
||||
u8 version;
|
||||
u8 content_owner_id_count;
|
||||
u8 save_data_owner_id_count;
|
||||
u8 reserved;
|
||||
u64 flag_bits;
|
||||
u64 content_owner_id_min;
|
||||
u64 content_owner_id_max;
|
||||
u64 save_data_owner_id_min;
|
||||
u64 save_data_owner_id_max;
|
||||
/* ... */
|
||||
};
|
||||
AMS_PRAGMA_END_PACK()
|
||||
|
||||
static_assert(util::is_pod<AccessControlDataHeader>::value);
|
||||
static_assert(util::is_pod<AccessControlDescriptor>::value);
|
||||
|
||||
static constexpr u64 AllFlagBitsMask = ~static_cast<u64>(0);
|
||||
static constexpr u64 DebugFlagDisableMask = AllFlagBitsMask & ~util::ToUnderlying(AccessControlBits::Bits::Debug);
|
||||
private:
|
||||
using ContentOwnerInfoList = util::IntrusiveListBaseTraits<ContentOwnerInfo>::ListType;
|
||||
using SaveDataOwnerInfoList = util::IntrusiveListBaseTraits<SaveDataOwnerInfo>::ListType;
|
||||
private:
|
||||
util::optional<AccessControlBits> m_flag_bits;
|
||||
ContentOwnerInfoList m_content_owner_infos;
|
||||
SaveDataOwnerInfoList m_save_data_owner_infos;
|
||||
public:
|
||||
AccessControl(const void *data, s64 data_size, const void *desc, s64 desc_size);
|
||||
AccessControl(const void *data, s64 data_size, const void *desc, s64 desc_size, u64 flag_mask);
|
||||
~AccessControl();
|
||||
public:
|
||||
bool HasContentOwnerId(u64 owner_id) const;
|
||||
Accessibility GetAccessibilitySaveDataOwnedBy(u64 owner_id) const;
|
||||
|
||||
void ListContentOwnerId(s32 *out_count, u64 *out_owner_ids, s32 offset, s32 count) const;
|
||||
void ListSaveDataOwnedId(s32 *out_count, ncm::ApplicationId *out_owner_ids, s32 offset, s32 count) const;
|
||||
|
||||
Accessibility GetAccessibilityFor(AccessibilityType type) const;
|
||||
bool CanCall(OperationType type) const;
|
||||
public:
|
||||
u64 GetRawFlagBits() const {
|
||||
return m_flag_bits.value().GetValue();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
#include <stratosphere/ncm/ncm_ids.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
#include <stratosphere/fssrv/impl/fssrv_access_control_bits.hpp>
|
||||
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
#define AMS_FSSRV_FOR_EACH_ACCESS_CONTROL_CAPABILITY(HANDLER, _NS_) \
|
||||
HANDLER(CanAbandonAccessFailure, _NS_::AccessFailureResolution) \
|
||||
HANDLER(CanChallengeCardExistence, _NS_::GameCard) \
|
||||
HANDLER(CanControlMmcPatrol, _NS_::None) \
|
||||
HANDLER(CanCorruptSaveData, _NS_::Debug, _NS_::CorruptSaveData) \
|
||||
HANDLER(CanCorruptSystemSaveData, _NS_::CorruptSaveData, _NS_::SaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanCreateOthersSystemSaveData, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanCreateOwnSaveData, _NS_::CreateOwnSaveData) \
|
||||
HANDLER(CanCreateSaveData, _NS_::CreateSaveData, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanCreateSaveDataWithHashSalt, _NS_::None) \
|
||||
HANDLER(CanCreateSystemSaveData, _NS_::SaveDataBackUp, _NS_::SystemSaveData) \
|
||||
HANDLER(CanDebugSaveData, _NS_::Debug, _NS_::SaveDataForDebug) \
|
||||
HANDLER(CanDeleteOwnSaveData, _NS_::CreateOwnSaveData) \
|
||||
HANDLER(CanDeleteSaveData, _NS_::SaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanDeleteSystemSaveData, _NS_::SystemSaveDataManagement, _NS_::SaveDataBackUp, _NS_::SystemSaveData) \
|
||||
HANDLER(CanEraseMmc, _NS_::BisAllRaw) \
|
||||
HANDLER(CanExtendOthersSystemSaveData, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanExtendOwnSaveData, _NS_::CreateOwnSaveData) \
|
||||
HANDLER(CanExtendSaveData, _NS_::CreateSaveData, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanExtendSystemSaveData, _NS_::SaveDataBackUp, _NS_::SystemSaveData) \
|
||||
HANDLER(CanFillBis, _NS_::Debug, _NS_::FillBis) \
|
||||
HANDLER(CanFinalizeGameCardDriver, _NS_::GameCardPrivate) \
|
||||
HANDLER(CanFindOwnSaveDataWithFilter, _NS_::CreateOwnSaveData) \
|
||||
HANDLER(CanFormatSdCard, _NS_::FormatSdCard) \
|
||||
HANDLER(CanGetAccessFailureDetectionEvent, _NS_::AccessFailureResolution) \
|
||||
HANDLER(CanGetGameCardAsicInfo, _NS_::GameCardPrivate) \
|
||||
HANDLER(CanGetGameCardDeviceCertificate, _NS_::GameCard) \
|
||||
HANDLER(CanGetGameCardIdSet, _NS_::GameCard) \
|
||||
HANDLER(CanGetRightsId, _NS_::GetRightsId) \
|
||||
HANDLER(CanGetSaveDataCommitId, _NS_::SaveDataTransferVersion2, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanInvalidateBisCache, _NS_::BisAllRaw) \
|
||||
HANDLER(CanIsAccessFailureDetected, _NS_::AccessFailureResolution) \
|
||||
HANDLER(CanListAccessibleSaveDataOwnerId, _NS_::SaveDataTransferVersion2, _NS_::SaveDataTransfer, _NS_::CreateSaveData) \
|
||||
HANDLER(CanMountAllBaseFileSystemRead, _NS_::None) \
|
||||
HANDLER(CanMountAllBaseFileSystemWrite, _NS_::None) \
|
||||
HANDLER(CanMountApplicationPackageRead, _NS_::ContentManager, _NS_::ApplicationInfo) \
|
||||
HANDLER(CanMountBisCalibrationFileRead, _NS_::BisAllRaw, _NS_::Calibration) \
|
||||
HANDLER(CanMountBisCalibrationFileWrite, _NS_::BisAllRaw, _NS_::Calibration) \
|
||||
HANDLER(CanMountBisSafeModeRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSafeModeWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSystemProperEncryptionRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSystemProperEncryptionWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSystemProperPartitionRead, _NS_::BisFileSystem, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSystemProperPartitionWrite, _NS_::BisFileSystem, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSystemRead, _NS_::BisFileSystem, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisSystemWrite, _NS_::BisFileSystem, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisUserRead, _NS_::BisFileSystem, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountBisUserWrite, _NS_::BisFileSystem, _NS_::BisAllRaw) \
|
||||
HANDLER(CanMountCloudBackupWorkStorageRead, _NS_::SaveDataTransferVersion2) \
|
||||
HANDLER(CanMountCloudBackupWorkStorageWrite, _NS_::SaveDataTransferVersion2) \
|
||||
HANDLER(CanMountContentControlRead, _NS_::ContentManager, _NS_::ApplicationInfo) \
|
||||
HANDLER(CanMountContentDataRead, _NS_::ContentManager, _NS_::ApplicationInfo) \
|
||||
HANDLER(CanMountContentManualRead, _NS_::ContentManager, _NS_::ApplicationInfo) \
|
||||
HANDLER(CanMountContentMetaRead, _NS_::ContentManager, _NS_::ApplicationInfo) \
|
||||
HANDLER(CanMountContentStorageRead, _NS_::ContentManager) \
|
||||
HANDLER(CanMountContentStorageWrite, _NS_::ContentManager) \
|
||||
HANDLER(CanMountCustomStorage0Read, _NS_::None) \
|
||||
HANDLER(CanMountCustomStorage0Write, _NS_::None) \
|
||||
HANDLER(CanMountDeviceSaveDataRead, _NS_::DeviceSaveData, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanMountDeviceSaveDataWrite, _NS_::DeviceSaveData, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanMountGameCardRead, _NS_::GameCard) \
|
||||
HANDLER(CanMountHostRead, _NS_::Debug, _NS_::Host) \
|
||||
HANDLER(CanMountHostWrite, _NS_::Debug, _NS_::Host) \
|
||||
HANDLER(CanMountImageAndVideoStorageRead, _NS_::ImageManager) \
|
||||
HANDLER(CanMountImageAndVideoStorageWrite, _NS_::ImageManager) \
|
||||
HANDLER(CanMountLogoRead, _NS_::ContentManager, _NS_::ApplicationInfo) \
|
||||
HANDLER(CanMountOthersSaveDataRead, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanMountOthersSaveDataWrite, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanMountOthersSystemSaveDataRead, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanMountOthersSystemSaveDataWrite, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanMountRegisteredUpdatePartitionRead, _NS_::SystemUpdate) \
|
||||
HANDLER(CanMountSaveDataStorageRead, _NS_::None) \
|
||||
HANDLER(CanMountSaveDataStorageWrite, _NS_::None) \
|
||||
HANDLER(CanMountSdCardRead, _NS_::Debug, _NS_::SdCard) \
|
||||
HANDLER(CanMountSdCardWrite, _NS_::Debug, _NS_::SdCard) \
|
||||
HANDLER(CanMountSystemDataPrivateRead, _NS_::SystemData, _NS_::SystemSaveData) \
|
||||
HANDLER(CanMountSystemSaveDataRead, _NS_::SaveDataBackUp, _NS_::SystemSaveData) \
|
||||
HANDLER(CanMountSystemSaveDataWrite, _NS_::SaveDataBackUp, _NS_::SystemSaveData) \
|
||||
HANDLER(CanMountTemporaryDirectoryRead, _NS_::Debug) \
|
||||
HANDLER(CanMountTemporaryDirectoryWrite, _NS_::Debug) \
|
||||
HANDLER(CanNotifySystemDataUpdateEvent, _NS_::SystemUpdate) \
|
||||
HANDLER(CanOpenAccessFailureDetectionEventNotifier, _NS_::AccessFailureResolution) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part1Read, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part1Write, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part2Read, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part2Write, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part3Read, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part3Write, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part4Read, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part4Write, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part5Read, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part5Write, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part6Read, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootConfigAndPackage2Part6Write, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootPartition1RootRead, _NS_::SystemUpdate, _NS_::BisAllRaw, _NS_::BootModeControl) \
|
||||
HANDLER(CanOpenBisPartitionBootPartition1RootWrite, _NS_::SystemUpdate, _NS_::BisAllRaw, _NS_::BootModeControl) \
|
||||
HANDLER(CanOpenBisPartitionBootPartition2RootRead, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionBootPartition2RootWrite, _NS_::SystemUpdate, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionCalibrationBinaryRead, _NS_::BisAllRaw, _NS_::Calibration) \
|
||||
HANDLER(CanOpenBisPartitionCalibrationBinaryWrite, _NS_::BisAllRaw, _NS_::Calibration) \
|
||||
HANDLER(CanOpenBisPartitionCalibrationFileRead, _NS_::BisAllRaw, _NS_::Calibration) \
|
||||
HANDLER(CanOpenBisPartitionCalibrationFileWrite, _NS_::BisAllRaw, _NS_::Calibration) \
|
||||
HANDLER(CanOpenBisPartitionSafeModeRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSafeModeWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSystemProperEncryptionRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSystemProperEncryptionWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSystemProperPartitionRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSystemProperPartitionWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSystemRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionSystemWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionUserDataRootRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionUserDataRootWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionUserRead, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisPartitionUserWrite, _NS_::BisAllRaw) \
|
||||
HANDLER(CanOpenBisWiper, _NS_::ContentManager) \
|
||||
HANDLER(CanOpenDataStorageByPath, _NS_::None) \
|
||||
HANDLER(CanOpenGameCardDetectionEventNotifier, _NS_::DeviceDetection, _NS_::GameCardRaw, _NS_::GameCard) \
|
||||
HANDLER(CanOpenGameCardStorageRead, _NS_::GameCardRaw) \
|
||||
HANDLER(CanOpenGameCardStorageWrite, _NS_::GameCardRaw) \
|
||||
HANDLER(CanOpenOwnSaveDataTransferProhibiter, _NS_::CreateOwnSaveData) \
|
||||
HANDLER(CanOpenSaveDataInfoReader, _NS_::SaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanOpenSaveDataInfoReaderForInternal, _NS_::SaveDataManagement) \
|
||||
HANDLER(CanOpenSaveDataInfoReaderForSystem, _NS_::SystemSaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanOpenSaveDataInternalStorageRead, _NS_::None) \
|
||||
HANDLER(CanOpenSaveDataInternalStorageWrite, _NS_::None) \
|
||||
HANDLER(CanOpenSaveDataMetaFile, _NS_::SaveDataMeta) \
|
||||
HANDLER(CanOpenSaveDataMover, _NS_::MoveCacheStorage) \
|
||||
HANDLER(CanOpenSaveDataTransferManager, _NS_::SaveDataTransfer) \
|
||||
HANDLER(CanOpenSaveDataTransferManagerForRepair, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanOpenSaveDataTransferManagerForSaveDataRepair, _NS_::SaveDataTransferVersion2) \
|
||||
HANDLER(CanOpenSaveDataTransferManagerForSaveDataRepairTool, _NS_::None) \
|
||||
HANDLER(CanOpenSaveDataTransferManagerVersion2, _NS_::SaveDataTransferVersion2) \
|
||||
HANDLER(CanOpenSaveDataTransferProhibiter, _NS_::SaveDataTransferVersion2, _NS_::CreateSaveData) \
|
||||
HANDLER(CanOpenSdCardDetectionEventNotifier, _NS_::DeviceDetection, _NS_::SdCard) \
|
||||
HANDLER(CanOpenSdCardStorageRead, _NS_::Debug, _NS_::SdCard) \
|
||||
HANDLER(CanOpenSdCardStorageWrite, _NS_::Debug, _NS_::SdCard) \
|
||||
HANDLER(CanOpenSystemDataUpdateEventNotifier, _NS_::SystemData, _NS_::SystemSaveData) \
|
||||
HANDLER(CanOverrideSaveDataTransferTokenSignVerificationKey, _NS_::None) \
|
||||
HANDLER(CanQuerySaveDataInternalStorageTotalSize, _NS_::SaveDataTransfer) \
|
||||
HANDLER(CanReadOwnSaveDataFileSystemExtraData, _NS_::CreateOwnSaveData) \
|
||||
HANDLER(CanReadSaveDataFileSystemExtraData, _NS_::SystemSaveDataManagement, _NS_::SaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanRegisterExternalKey, _NS_::RegisterExternalKey) \
|
||||
HANDLER(CanRegisterProgramIndexMapInfo, _NS_::RegisterProgramIndexMapInfo) \
|
||||
HANDLER(CanRegisterUpdatePartition, _NS_::RegisterUpdatePartition) \
|
||||
HANDLER(CanResolveAccessFailure, _NS_::AccessFailureResolution) \
|
||||
HANDLER(CanSetCurrentPosixTime, _NS_::SetTime) \
|
||||
HANDLER(CanSetDebugConfiguration, _NS_::None) \
|
||||
HANDLER(CanSetEncryptionSeed, _NS_::ContentManager) \
|
||||
HANDLER(CanSetGlobalAccessLogMode, _NS_::SettingsControl) \
|
||||
HANDLER(CanSetSdCardAccessibility, _NS_::SdCard) \
|
||||
HANDLER(CanSetSpeedEmulationMode, _NS_::SettingsControl) \
|
||||
HANDLER(CanSimulateDevice, _NS_::Debug) \
|
||||
HANDLER(CanVerifySaveData, _NS_::SaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanWriteSaveDataFileSystemExtraDataAll, _NS_::None) \
|
||||
HANDLER(CanWriteSaveDataFileSystemExtraDataCommitId, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanWriteSaveDataFileSystemExtraDataFlags, _NS_::SaveDataTransferVersion2, _NS_::SystemSaveDataManagement, _NS_::SaveDataBackUp) \
|
||||
HANDLER(CanWriteSaveDataFileSystemExtraDataTimeStamp, _NS_::SaveDataBackUp)
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
class AccessControlBits {
|
||||
public:
|
||||
enum class Bits : u64 {
|
||||
None = 0,
|
||||
|
||||
ApplicationInfo = UINT64_C(1) << 0,
|
||||
BootModeControl = UINT64_C(1) << 1,
|
||||
Calibration = UINT64_C(1) << 2,
|
||||
SystemSaveData = UINT64_C(1) << 3,
|
||||
GameCard = UINT64_C(1) << 4,
|
||||
SaveDataBackUp = UINT64_C(1) << 5,
|
||||
SaveDataManagement = UINT64_C(1) << 6,
|
||||
BisAllRaw = UINT64_C(1) << 7,
|
||||
GameCardRaw = UINT64_C(1) << 8,
|
||||
GameCardPrivate = UINT64_C(1) << 9,
|
||||
SetTime = UINT64_C(1) << 10,
|
||||
ContentManager = UINT64_C(1) << 11,
|
||||
ImageManager = UINT64_C(1) << 12,
|
||||
CreateSaveData = UINT64_C(1) << 13,
|
||||
SystemSaveDataManagement = UINT64_C(1) << 14,
|
||||
BisFileSystem = UINT64_C(1) << 15,
|
||||
SystemUpdate = UINT64_C(1) << 16,
|
||||
SaveDataMeta = UINT64_C(1) << 17,
|
||||
DeviceSaveData = UINT64_C(1) << 18,
|
||||
SettingsControl = UINT64_C(1) << 19,
|
||||
SystemData = UINT64_C(1) << 20,
|
||||
SdCard = UINT64_C(1) << 21,
|
||||
Host = UINT64_C(1) << 22,
|
||||
FillBis = UINT64_C(1) << 23,
|
||||
CorruptSaveData = UINT64_C(1) << 24,
|
||||
SaveDataForDebug = UINT64_C(1) << 25,
|
||||
FormatSdCard = UINT64_C(1) << 26,
|
||||
GetRightsId = UINT64_C(1) << 27,
|
||||
RegisterExternalKey = UINT64_C(1) << 28,
|
||||
RegisterUpdatePartition = UINT64_C(1) << 29,
|
||||
SaveDataTransfer = UINT64_C(1) << 30,
|
||||
DeviceDetection = UINT64_C(1) << 31,
|
||||
AccessFailureResolution = UINT64_C(1) << 32,
|
||||
SaveDataTransferVersion2 = UINT64_C(1) << 33,
|
||||
RegisterProgramIndexMapInfo = UINT64_C(1) << 34,
|
||||
CreateOwnSaveData = UINT64_C(1) << 35,
|
||||
MoveCacheStorage = UINT64_C(1) << 36,
|
||||
|
||||
Debug = UINT64_C(1) << 62,
|
||||
FullPermission = UINT64_C(1) << 63
|
||||
};
|
||||
private:
|
||||
static constexpr u64 CombineBits(Bits b) {
|
||||
return util::ToUnderlying(b);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
static constexpr u64 CombineBits(Bits b, Args... args) {
|
||||
return CombineBits(b) | CombineBits(args...);
|
||||
}
|
||||
private:
|
||||
const u64 m_value;
|
||||
public:
|
||||
constexpr AccessControlBits(u64 v) : m_value(v) { /* ... */ }
|
||||
|
||||
constexpr u64 GetValue() const { return m_value; }
|
||||
|
||||
#define DEFINE_ACCESS_GETTER(name, ...) \
|
||||
constexpr bool name() const { constexpr u64 Mask = CombineBits(Bits::FullPermission, ## __VA_ARGS__); return (m_value & Mask); }
|
||||
|
||||
AMS_FSSRV_FOR_EACH_ACCESS_CONTROL_CAPABILITY(DEFINE_ACCESS_GETTER, Bits)
|
||||
|
||||
#undef DEFINE_ACCESS_GETTER
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
#include <stratosphere/ncm/ncm_ids.hpp>
|
||||
#include <stratosphere/fs/fs_rights_id.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
#include <stratosphere/spl/spl_types.hpp>
|
||||
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
class ExternalKeyEntry : public util::IntrusiveListBaseNode<ExternalKeyEntry>, public ::ams::fs::impl::Newable {
|
||||
private:
|
||||
fs::RightsId m_rights_id;
|
||||
spl::AccessKey m_access_key;
|
||||
public:
|
||||
ExternalKeyEntry(const fs::RightsId &rights_id, const spl::AccessKey &access_key) : m_rights_id(rights_id), m_access_key(access_key) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
bool Contains(const fs::RightsId &rights_id) const {
|
||||
return crypto::IsSameBytes(std::addressof(m_rights_id), std::addressof(rights_id), sizeof(m_rights_id));
|
||||
}
|
||||
|
||||
bool Contains(const void *key, size_t key_size) const {
|
||||
AMS_ASSERT(key_size == sizeof(spl::AccessKey));
|
||||
AMS_UNUSED(key_size);
|
||||
|
||||
return crypto::IsSameBytes(std::addressof(m_access_key), key, sizeof(m_access_key));
|
||||
}
|
||||
|
||||
void CopyAccessKey(spl::AccessKey *out) const {
|
||||
AMS_ASSERT(out != nullptr);
|
||||
std::memcpy(out, std::addressof(m_access_key), sizeof(m_access_key));
|
||||
}
|
||||
};
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
class ExternalKeyManager {
|
||||
NON_COPYABLE(ExternalKeyManager);
|
||||
NON_MOVEABLE(ExternalKeyManager);
|
||||
private:
|
||||
using ExternalKeyList = util::IntrusiveListBaseTraits<ExternalKeyEntry>::ListType;
|
||||
private:
|
||||
ExternalKeyList m_key_list;
|
||||
os::SdkMutex m_mutex;
|
||||
public:
|
||||
constexpr ExternalKeyManager() : m_key_list(), m_mutex() { /* ... */ }
|
||||
|
||||
Result Register(const fs::RightsId &rights_id, const spl::AccessKey &access_key) {
|
||||
/* Acquire exclusive access to the key list */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Try to find an existing entry. */
|
||||
spl::AccessKey existing;
|
||||
if (R_SUCCEEDED(this->FindCore(std::addressof(existing), rights_id))) {
|
||||
/* Check the key matches what was previously registered. */
|
||||
R_UNLESS(crypto::IsSameBytes(std::addressof(existing), std::addressof(access_key), sizeof(access_key)), fs::ResultNcaExternalKeyInconsistent());
|
||||
} else {
|
||||
/* Make a new entry. */
|
||||
auto *entry = new ExternalKeyEntry(rights_id, access_key);
|
||||
R_UNLESS(entry != nullptr, fs::ResultAllocationMemoryFailed());
|
||||
|
||||
/* Add the entry to our list. */
|
||||
m_key_list.push_back(*entry);
|
||||
}
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Unregister(const fs::RightsId &rights_id) {
|
||||
/* Acquire exclusive access to the key list */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Find a matching entry. */
|
||||
for (auto it = m_key_list.begin(); it != m_key_list.end(); ++it) {
|
||||
if (it->Contains(rights_id)) {
|
||||
auto *entry = std::addressof(*it);
|
||||
m_key_list.erase(it);
|
||||
delete entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Always succeed. */
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result UnregisterAll() {
|
||||
/* Acquire exclusive access to the key list */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Remove all entries until our list is empty. */
|
||||
while (!m_key_list.empty()) {
|
||||
auto *entry = std::addressof(*m_key_list.begin());
|
||||
m_key_list.erase(m_key_list.iterator_to(*entry));
|
||||
delete entry;
|
||||
}
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
bool IsAvailableAccessKey(const void *key, size_t key_size) {
|
||||
/* Acquire exclusive access to the key list */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Check if any entry contains the key. */
|
||||
for (const auto &entry : m_key_list) {
|
||||
if (entry.Contains(key, key_size)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Result Find(spl::AccessKey *out, const fs::RightsId &rights_id) {
|
||||
/* Acquire exclusive access to the key list */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Try to find an entry with the desired rights id. */
|
||||
R_RETURN(this->FindCore(out, rights_id));
|
||||
}
|
||||
private:
|
||||
Result FindCore(spl::AccessKey *out, const fs::RightsId &rights_id) {
|
||||
for (const auto &entry : m_key_list) {
|
||||
if (entry.Contains(rights_id)) {
|
||||
entry.CopyAccessKey(out);
|
||||
R_SUCCEED();
|
||||
}
|
||||
}
|
||||
|
||||
R_THROW(fs::ResultNcaExternalKeyUnregistered());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
#include <stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy.hpp>
|
||||
#include <stratosphere/fssrv/sf/fssrv_sf_i_program_registry.hpp>
|
||||
#include <stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy_for_loader.hpp>
|
||||
#include <stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp>
|
||||
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
ams::sf::EmplacedRef<fssrv::sf::IFileSystemProxy, fssrv::FileSystemProxyImpl> GetFileSystemProxyServiceObject();
|
||||
|
||||
ams::sf::SharedPointer<fssrv::sf::IProgramRegistry> GetProgramRegistryServiceObject();
|
||||
ams::sf::SharedPointer<fssrv::sf::IProgramRegistry> GetInvalidProgramRegistryServiceObject();
|
||||
|
||||
ams::sf::SharedPointer<fssrv::sf::IFileSystemProxyForLoader> GetFileSystemProxyForLoaderServiceObject();
|
||||
ams::sf::SharedPointer<fssrv::sf::IFileSystemProxyForLoader> GetInvalidFileSystemProxyForLoaderServiceObject();
|
||||
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
#include <stratosphere/ncm/ncm_ids.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
#include <stratosphere/fs/fs_program_index_map_info.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_pimpl.hpp>
|
||||
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
struct ProgramIndexMapInfoEntry : public ::ams::util::IntrusiveListBaseNode<ProgramIndexMapInfoEntry>, public ::ams::fs::impl::Newable {
|
||||
ncm::ProgramId program_id;
|
||||
ncm::ProgramId base_program_id;
|
||||
u8 program_index;
|
||||
};
|
||||
|
||||
/* ACCURATE_TO_VERSION: 13.4.0.0 */
|
||||
class ProgramIndexMapInfoManager {
|
||||
NON_COPYABLE(ProgramIndexMapInfoManager);
|
||||
NON_MOVEABLE(ProgramIndexMapInfoManager);
|
||||
private:
|
||||
using ProgramIndexMapInfoList = util::IntrusiveListBaseTraits<ProgramIndexMapInfoEntry>::ListType;
|
||||
private:
|
||||
ProgramIndexMapInfoList m_list;
|
||||
mutable os::SdkMutex m_mutex;
|
||||
public:
|
||||
constexpr ProgramIndexMapInfoManager() : m_list(), m_mutex() { /* ... */ }
|
||||
|
||||
void Clear() {
|
||||
/* Acquire exclusive access to the map. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Actually clear. */
|
||||
this->ClearImpl();
|
||||
}
|
||||
|
||||
size_t GetProgramCount() const {
|
||||
/* Acquire exclusive access to the map. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Get the size. */
|
||||
return m_list.size();
|
||||
}
|
||||
|
||||
util::optional<fs::ProgramIndexMapInfo> Get(const ncm::ProgramId &program_id) const {
|
||||
/* Acquire exclusive access to the map. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Get the entry from the map. */
|
||||
return this->GetImpl([&] (const ProgramIndexMapInfoEntry &entry) {
|
||||
return entry.program_id == program_id;
|
||||
});
|
||||
}
|
||||
|
||||
ncm::ProgramId GetProgramId(const ncm::ProgramId &program_id, u8 program_index) const {
|
||||
/* Acquire exclusive access to the map. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Get the program info for the desired program id. */
|
||||
const auto base_info = this->GetImpl([&] (const ProgramIndexMapInfoEntry &entry) {
|
||||
return entry.program_id == program_id;
|
||||
});
|
||||
|
||||
/* Check that an entry exists for the program id. */
|
||||
if (!base_info.has_value()) {
|
||||
return ncm::InvalidProgramId;
|
||||
}
|
||||
|
||||
/* Get a program info which matches the same base program with the desired index. */
|
||||
const auto target_info = this->GetImpl([&] (const ProgramIndexMapInfoEntry &entry) {
|
||||
return entry.base_program_id == base_info->base_program_id && entry.program_index == program_index;
|
||||
});
|
||||
|
||||
/* Return the desired program id. */
|
||||
if (target_info.has_value()) {
|
||||
return target_info->program_id;
|
||||
} else {
|
||||
return ncm::InvalidProgramId;
|
||||
}
|
||||
}
|
||||
|
||||
Result Reset(const fs::ProgramIndexMapInfo *infos, int count) {
|
||||
/* Acquire exclusive access to the map. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Clear the map, and ensure we remain clear if we fail after this point. */
|
||||
this->ClearImpl();
|
||||
ON_RESULT_FAILURE { this->ClearImpl(); };
|
||||
|
||||
/* Add each info to the list. */
|
||||
for (int i = 0; i < count; ++i) {
|
||||
/* Allocate new entry. */
|
||||
auto *entry = new ProgramIndexMapInfoEntry;
|
||||
R_UNLESS(entry != nullptr, fs::ResultAllocationMemoryFailedNew());
|
||||
|
||||
/* Copy over the info. */
|
||||
entry->program_id = infos[i].program_id;
|
||||
entry->base_program_id = infos[i].base_program_id;
|
||||
entry->program_index = infos[i].program_index;
|
||||
|
||||
/* Add to the list. */
|
||||
m_list.push_back(*entry);
|
||||
}
|
||||
|
||||
/* We successfully imported the map. */
|
||||
R_SUCCEED();
|
||||
}
|
||||
private:
|
||||
void ClearImpl() {
|
||||
/* Delete all entries. */
|
||||
while (!m_list.empty()) {
|
||||
/* Get the first entry. */
|
||||
ProgramIndexMapInfoEntry *front = std::addressof(*m_list.begin());
|
||||
|
||||
/* Erase it from the list. */
|
||||
m_list.erase(m_list.iterator_to(*front));
|
||||
|
||||
/* Delete the entry. */
|
||||
delete front;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
util::optional<fs::ProgramIndexMapInfo> GetImpl(F f) const {
|
||||
/* Try to find an entry matching the predicate. */
|
||||
util::optional<fs::ProgramIndexMapInfo> match = util::nullopt;
|
||||
|
||||
for (const auto &entry : m_list) {
|
||||
/* If the predicate matches, we want to return the relevant info. */
|
||||
if (f(entry)) {
|
||||
match.emplace();
|
||||
|
||||
match->program_id = entry.program_id;
|
||||
match->base_program_id = entry.base_program_id;
|
||||
match->program_index = entry.program_index;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
AMS_FSSYSTEM_ENABLE_PIMPL(::ams::fssrv::impl::ProgramIndexMapInfoManager)
|
||||
Reference in New Issue
Block a user