mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-14 17:16:36 +00:00
fs: move bitmap classes out of save::
This commit is contained in:
parent
d76e678da2
commit
d6dbfd356d
14 changed files with 52 additions and 85 deletions
|
@ -13,10 +13,10 @@
|
|||
* 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 <stratosphere/fssystem/fssystem_allocator_utility.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_utility.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_bitmap_utils.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_speed_emulation_configuration.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_external_code.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_forwarding_file_system.hpp>
|
||||
|
@ -46,8 +46,8 @@
|
|||
#include <stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_alignment_matching_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_compressed_storage.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_buffered_storage.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_buffered_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_sha256_hash_generator.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_local_file_system.hpp>
|
||||
|
|
|
@ -1,43 +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>
|
||||
|
||||
namespace ams::fssystem::dbm {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr inline s32 CountLeadingZeros(u32 val) {
|
||||
return util::CountLeadingZeros(val);
|
||||
}
|
||||
|
||||
constexpr inline s32 CountLeadingOnes(u32 val) {
|
||||
return CountLeadingZeros(~val);
|
||||
}
|
||||
|
||||
inline u32 ReadU32(const u8 *buf, size_t index) {
|
||||
u32 val;
|
||||
std::memcpy(std::addressof(val), buf + index, sizeof(u32));
|
||||
return val;
|
||||
}
|
||||
|
||||
inline void WriteU32(u8 *buf, size_t index, u32 val) {
|
||||
std::memcpy(buf + index, std::addressof(val), sizeof(u32));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -15,12 +15,26 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/lmem.hpp>
|
||||
#include <stratosphere/fs/fs_directory.hpp>
|
||||
#include <stratosphere/fs/fs_filesystem.hpp>
|
||||
#include <stratosphere/fssystem/dbm/fssystem_dbm_utils.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
constexpr inline s32 CountLeadingZeros(u32 val) {
|
||||
return util::CountLeadingZeros(val);
|
||||
}
|
||||
|
||||
constexpr inline s32 CountLeadingOnes(u32 val) {
|
||||
return CountLeadingZeros(~val);
|
||||
}
|
||||
|
||||
inline u32 ReadU32(const u8 *buf, size_t index) {
|
||||
u32 val;
|
||||
std::memcpy(std::addressof(val), buf + index, sizeof(u32));
|
||||
return val;
|
||||
}
|
||||
|
||||
inline void WriteU32(u8 *buf, size_t index, u32 val) {
|
||||
std::memcpy(buf + index, std::addressof(val), sizeof(u32));
|
||||
}
|
||||
|
||||
constexpr inline bool IsPowerOfTwo(s32 val) {
|
||||
return util::IsPowerOfTwo(val);
|
||||
|
@ -28,14 +42,15 @@ namespace ams::fssystem::save {
|
|||
|
||||
constexpr inline u32 ILog2(u32 val) {
|
||||
AMS_ASSERT(val > 0);
|
||||
return (BITSIZEOF(u32) - 1 - dbm::CountLeadingZeros(val));
|
||||
return (BITSIZEOF(u32) - 1 - util::CountLeadingZeros<u32>(val));
|
||||
}
|
||||
|
||||
constexpr inline u32 CeilPowerOfTwo(u32 val) {
|
||||
constexpr inline u32 CeilingPowerOfTwo(u32 val) {
|
||||
if (val == 0) {
|
||||
return 1;
|
||||
}
|
||||
return ((1u << (BITSIZEOF(u32) - 1)) >> (dbm::CountLeadingZeros(val - 1) - 1));
|
||||
|
||||
return util::CeilingPowerOfTwo<u32>(val);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,11 +19,10 @@
|
|||
#include <stratosphere/fs/fs_storage_type.hpp>
|
||||
#include <stratosphere/fs/fs_istorage.hpp>
|
||||
#include <stratosphere/fs/fs_memory_management.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_i_save_file_system_driver.hpp>
|
||||
#include <stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp>
|
||||
#include <stratosphere/fssystem/impl/fssystem_block_cache_manager.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
constexpr inline size_t IntegrityMinLayerCount = 2;
|
||||
constexpr inline size_t IntegrityMaxLayerCount = 7;
|
|
@ -20,7 +20,7 @@
|
|||
#include <stratosphere/fs/fs_substorage.hpp>
|
||||
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
class BufferedStorage : public ::ams::fs::IStorage {
|
||||
NON_COPYABLE(BufferedStorage);
|
|
@ -19,11 +19,10 @@
|
|||
#include <stratosphere/fs/fs_istorage.hpp>
|
||||
#include <stratosphere/fs/fs_substorage.hpp>
|
||||
#include <stratosphere/fs/fs_storage_type.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_i_save_file.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_integrity_verification_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
struct HierarchicalIntegrityVerificationLevelInformation {
|
||||
fs::Int64 offset;
|
|
@ -19,7 +19,7 @@
|
|||
#include <stratosphere/fs/fs_memory_storage.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_nca_header.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
|
@ -28,8 +28,8 @@ namespace ams::fssystem {
|
|||
|
||||
class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
|
||||
private:
|
||||
save::HierarchicalIntegrityVerificationStorage m_integrity_storage;
|
||||
save::FileSystemBufferManagerSet m_buffers;
|
||||
HierarchicalIntegrityVerificationStorage m_integrity_storage;
|
||||
FileSystemBufferManagerSet m_buffers;
|
||||
os::SdkRecursiveMutex m_mutex;
|
||||
Hash m_master_hash;
|
||||
std::unique_ptr<fs::MemoryStorage> m_master_hash_storage;
|
||||
|
@ -37,7 +37,7 @@ namespace ams::fssystem {
|
|||
IntegrityRomFsStorage() : m_mutex() { /* ... */ }
|
||||
virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
|
||||
|
||||
Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf);
|
||||
Result Initialize(HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf);
|
||||
void Finalize();
|
||||
|
||||
virtual Result Read(s64 offset, void *buffer, size_t size) override {
|
||||
|
@ -66,7 +66,7 @@ namespace ams::fssystem {
|
|||
return m_integrity_storage.Commit();
|
||||
}
|
||||
|
||||
save::FileSystemBufferManagerSet *GetBuffers() {
|
||||
FileSystemBufferManagerSet *GetBuffers() {
|
||||
return m_integrity_storage.GetBuffers();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
#include <stratosphere/fs/fs_istorage.hpp>
|
||||
#include <stratosphere/fs/fs_substorage.hpp>
|
||||
#include <stratosphere/fs/fs_storage_type.hpp>
|
||||
#include <stratosphere/fs/fs_save_data_types.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_save_types.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_i_save_file_system_driver.hpp>
|
||||
#include <stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp>
|
||||
#include <stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
class IntegrityVerificationStorage : public ::ams::fs::IStorage {
|
||||
NON_COPYABLE(IntegrityVerificationStorage);
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
BlockCacheBufferedStorage::BlockCacheBufferedStorage() : m_mutex(), m_data_storage(), m_last_result(ResultSuccess()), m_data_size(), m_verification_block_size(), m_verification_block_shift(), m_flags(), m_buffer_level(-1), m_block_cache_manager()
|
||||
{
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
namespace {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
namespace {
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace ams::fssystem {
|
||||
|
||||
Result IntegrityRomFsStorage::Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf) {
|
||||
Result IntegrityRomFsStorage::Initialize(HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf) {
|
||||
/* Validate preconditions. */
|
||||
AMS_ASSERT(bm != nullptr);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::fssystem::save {
|
||||
namespace ams::fssystem {
|
||||
|
||||
Result IntegrityVerificationStorage::Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, fs::IBufferManager *bm, fssystem::IHash256GeneratorFactory *hgf, const fs::HashSalt &salt, bool is_real_data, fs::StorageType storage_type) {
|
||||
/* Validate preconditions. */
|
|
@ -549,7 +549,7 @@ namespace ams::fssystem {
|
|||
R_TRY(base_storage->GetSize(std::addressof(base_size)));
|
||||
|
||||
/* Create buffered storage. */
|
||||
auto buffered_storage = fssystem::AllocateShared<save::BufferedStorage>();
|
||||
auto buffered_storage = fssystem::AllocateShared<BufferedStorage>();
|
||||
R_UNLESS(buffered_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
|
||||
|
||||
/* Initialize the buffered storage. */
|
||||
|
@ -655,7 +655,7 @@ namespace ams::fssystem {
|
|||
R_TRY(this->CreateAesCtrStorage(std::addressof(decrypted_storage), std::move(enc_storage), offset + meta_offset, sparse_info.MakeAesCtrUpperIv(upper_iv), AlignmentStorageRequirement_None));
|
||||
|
||||
/* Create meta storage. */
|
||||
auto meta_storage = fssystem::AllocateShared<save::BufferedStorage>();
|
||||
auto meta_storage = fssystem::AllocateShared<BufferedStorage>();
|
||||
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
|
||||
|
||||
/* Initialize the meta storage. */
|
||||
|
@ -789,7 +789,7 @@ namespace ams::fssystem {
|
|||
R_TRY(this->CreateAesCtrStorage(std::addressof(decrypted_storage), std::move(enc_storage), offset + meta_offset, upper_iv, AlignmentStorageRequirement_None));
|
||||
|
||||
/* Create meta storage. */
|
||||
auto meta_storage = fssystem::AllocateShared<save::BufferedStorage>();
|
||||
auto meta_storage = fssystem::AllocateShared<BufferedStorage>();
|
||||
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
|
||||
|
||||
/* Initialize the meta storage. */
|
||||
|
@ -921,7 +921,7 @@ namespace ams::fssystem {
|
|||
R_UNLESS(patch_info.indirect_offset + patch_info.indirect_size <= base_size, fs::ResultNcaBaseStorageOutOfRangeE());
|
||||
|
||||
/* Allocate the meta storage. */
|
||||
auto meta_storage = fssystem::AllocateShared<save::BufferedStorage>();
|
||||
auto meta_storage = fssystem::AllocateShared<BufferedStorage>();
|
||||
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
|
||||
|
||||
/* Initialize the meta storage. */
|
||||
|
@ -954,7 +954,7 @@ namespace ams::fssystem {
|
|||
AMS_ASSERT(util::IsAligned(indirect_data_size, NcaHeader::XtsBlockSize));
|
||||
|
||||
/* Create the indirect data storage. */
|
||||
auto indirect_data_storage = fssystem::AllocateShared<save::BufferedStorage>();
|
||||
auto indirect_data_storage = fssystem::AllocateShared<BufferedStorage>();
|
||||
R_UNLESS(indirect_data_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
|
||||
|
||||
/* Initialize the indirect data storage. */
|
||||
|
@ -1061,15 +1061,15 @@ namespace ams::fssystem {
|
|||
AMS_ASSERT(base_storage != nullptr);
|
||||
|
||||
/* Define storage types. */
|
||||
using VerificationStorage = save::HierarchicalIntegrityVerificationStorage;
|
||||
using VerificationStorage = HierarchicalIntegrityVerificationStorage;
|
||||
using StorageInfo = VerificationStorage::HierarchicalStorageInformation;
|
||||
|
||||
/* Validate the meta info. */
|
||||
save::HierarchicalIntegrityVerificationInformation level_hash_info;
|
||||
HierarchicalIntegrityVerificationInformation level_hash_info;
|
||||
std::memcpy(std::addressof(level_hash_info), std::addressof(meta_info.level_hash_info), sizeof(level_hash_info));
|
||||
|
||||
R_UNLESS(save::IntegrityMinLayerCount <= level_hash_info.max_layers, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
|
||||
R_UNLESS(level_hash_info.max_layers <= save::IntegrityMaxLayerCount, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
|
||||
R_UNLESS(IntegrityMinLayerCount <= level_hash_info.max_layers, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
|
||||
R_UNLESS(level_hash_info.max_layers <= IntegrityMaxLayerCount, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
|
||||
|
||||
/* Get the base storage size. */
|
||||
s64 base_storage_size;
|
||||
|
|
Loading…
Reference in a new issue